@ndla/ui 56.0.172-alpha.0 → 56.0.174-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/es/AnchorHeading/AnchorHeading.mjs +1 -1
- package/es/AnchorHeading/AnchorHeading.mjs.map +1 -1
- package/es/Article/Article.mjs +1 -8
- package/es/Article/Article.mjs.map +1 -1
- package/es/Article/ArticleByline.mjs +1 -1
- package/es/Article/ArticleByline.mjs.map +1 -1
- package/es/AudioPlayer/AudioPlayer.mjs +1 -1
- package/es/AudioPlayer/AudioPlayer.mjs.map +1 -1
- package/es/AudioPlayer/Controls.mjs +1 -1
- package/es/AudioPlayer/Controls.mjs.map +1 -1
- package/es/AudioPlayer/SpeechControl.mjs +1 -1
- package/es/AudioPlayer/SpeechControl.mjs.map +1 -1
- package/es/Breadcrumb/Breadcrumb.mjs +8 -1
- package/es/Breadcrumb/Breadcrumb.mjs.map +1 -1
- package/es/Breadcrumb/BreadcrumbItem.mjs +8 -1
- package/es/Breadcrumb/BreadcrumbItem.mjs.map +1 -1
- package/es/Breadcrumb/HomeBreadcrumb.mjs.map +1 -1
- package/es/CampaignBlock/CampaignBlock.mjs +1 -8
- package/es/CampaignBlock/CampaignBlock.mjs.map +1 -1
- package/es/CodeBlock/CodeBlock.mjs +1 -8
- package/es/CodeBlock/CodeBlock.mjs.map +1 -1
- package/es/Concept/Concept.mjs +1 -8
- package/es/Concept/Concept.mjs.map +1 -1
- package/es/ContactBlock/ContactBlock.mjs +0 -7
- package/es/ContactBlock/ContactBlock.mjs.map +1 -1
- package/es/Embed/AudioEmbed.mjs +1 -8
- package/es/Embed/AudioEmbed.mjs.map +1 -1
- package/es/Embed/BrightcoveEmbed.mjs +2 -9
- package/es/Embed/BrightcoveEmbed.mjs.map +1 -1
- package/es/Embed/CodeEmbed.mjs +1 -8
- package/es/Embed/CodeEmbed.mjs.map +1 -1
- package/es/Embed/ConceptEmbed.mjs +1 -8
- package/es/Embed/ConceptEmbed.mjs.map +1 -1
- package/es/Embed/ContentLinkEmbed.mjs.map +1 -1
- package/es/Embed/CopyrightEmbed.mjs.map +1 -1
- package/es/Embed/EmbedErrorPlaceholder.mjs +8 -1
- package/es/Embed/EmbedErrorPlaceholder.mjs.map +1 -1
- package/es/Embed/EmbedWrapper.mjs +1 -8
- package/es/Embed/EmbedWrapper.mjs.map +1 -1
- package/es/Embed/ExternalEmbed.mjs +1 -8
- package/es/Embed/ExternalEmbed.mjs.map +1 -1
- package/es/Embed/FootnoteEmbed.mjs +0 -7
- package/es/Embed/FootnoteEmbed.mjs.map +1 -1
- package/es/Embed/GlossEmbed.mjs +1 -8
- package/es/Embed/GlossEmbed.mjs.map +1 -1
- package/es/Embed/H5pEmbed.mjs +0 -7
- package/es/Embed/H5pEmbed.mjs.map +1 -1
- package/es/Embed/IframeEmbed.mjs +2 -9
- package/es/Embed/IframeEmbed.mjs.map +1 -1
- package/es/Embed/ImageEmbed.mjs +2 -9
- package/es/Embed/ImageEmbed.mjs.map +1 -1
- package/es/Embed/InlineTriggerButton.mjs +1 -1
- package/es/Embed/InlineTriggerButton.mjs.map +1 -1
- package/es/Embed/RelatedContentEmbed.mjs +0 -7
- package/es/Embed/RelatedContentEmbed.mjs.map +1 -1
- package/es/Embed/UnknownEmbed.mjs +0 -7
- package/es/Embed/UnknownEmbed.mjs.map +1 -1
- package/es/Embed/UuDisclaimerEmbed.mjs +1 -1
- package/es/Embed/UuDisclaimerEmbed.mjs.map +1 -1
- package/es/FactBox/FactBox.mjs +1 -1
- package/es/FactBox/FactBox.mjs.map +1 -1
- package/es/FileList/File.mjs +1 -1
- package/es/FileList/File.mjs.map +1 -1
- package/es/FileList/FileList.mjs +8 -1
- package/es/FileList/FileList.mjs.map +1 -1
- package/es/Gloss/Gloss.mjs +1 -8
- package/es/Gloss/Gloss.mjs.map +1 -1
- package/es/Gloss/GlossExample.mjs +1 -8
- package/es/Gloss/GlossExample.mjs.map +1 -1
- package/es/Grid/Grid.mjs +1 -1
- package/es/Grid/Grid.mjs.map +1 -1
- package/es/KeyFigure/KeyFigure.mjs.map +1 -1
- package/es/LicenseByline/EmbedByline.mjs +1 -8
- package/es/LicenseByline/EmbedByline.mjs.map +1 -1
- package/es/LicenseByline/LicenseLink.mjs +1 -8
- package/es/LicenseByline/LicenseLink.mjs.map +1 -1
- package/es/LinkBlock/LinkBlock.mjs +1 -8
- package/es/LinkBlock/LinkBlock.mjs.map +1 -1
- package/es/LinkBlock/LinkBlockSection.mjs +1 -1
- package/es/LinkBlock/LinkBlockSection.mjs.map +1 -1
- package/es/Pitch/Pitch.mjs.map +1 -1
- package/es/RelatedArticleList/RelatedArticleList.mjs +1 -1
- package/es/RelatedArticleList/RelatedArticleList.mjs.map +1 -1
- package/es/TagSelector/TagSelector.mjs +1 -1
- package/es/TagSelector/TagSelector.mjs.map +1 -1
- package/es/ZendeskButton/ZendeskButton.mjs +1 -1
- package/es/ZendeskButton/ZendeskButton.mjs.map +1 -1
- package/es/i18n/useComponentTranslations.mjs +0 -7
- package/es/i18n/useComponentTranslations.mjs.map +1 -1
- package/es/model/ContentType.mjs +8 -1
- package/es/model/ContentType.mjs.map +1 -1
- package/lib/AnchorHeading/AnchorHeading.js +1 -1
- package/lib/AnchorHeading/AnchorHeading.js.map +1 -1
- package/lib/Article/Article.d.ts +1 -1
- package/lib/Article/Article.js +1 -8
- package/lib/Article/Article.js.map +1 -1
- package/lib/Article/ArticleByline.d.ts +1 -1
- package/lib/Article/ArticleByline.js +1 -1
- package/lib/Article/ArticleByline.js.map +1 -1
- package/lib/AudioPlayer/AudioPlayer.js +1 -1
- package/lib/AudioPlayer/AudioPlayer.js.map +1 -1
- package/lib/AudioPlayer/Controls.js +1 -1
- package/lib/AudioPlayer/Controls.js.map +1 -1
- package/lib/AudioPlayer/SpeechControl.js +1 -1
- package/lib/AudioPlayer/SpeechControl.js.map +1 -1
- package/lib/Breadcrumb/Breadcrumb.js +1 -1
- package/lib/Breadcrumb/Breadcrumb.js.map +1 -1
- package/lib/Breadcrumb/BreadcrumbItem.js +1 -1
- package/lib/Breadcrumb/BreadcrumbItem.js.map +1 -1
- package/lib/Breadcrumb/HomeBreadcrumb.js.map +1 -1
- package/lib/CampaignBlock/CampaignBlock.js +1 -8
- package/lib/CampaignBlock/CampaignBlock.js.map +1 -1
- package/lib/CodeBlock/CodeBlock.d.ts +1 -1
- package/lib/CodeBlock/CodeBlock.js +1 -8
- package/lib/CodeBlock/CodeBlock.js.map +1 -1
- package/lib/Concept/Concept.d.ts +1 -1
- package/lib/Concept/Concept.js +1 -8
- package/lib/Concept/Concept.js.map +1 -1
- package/lib/ContactBlock/ContactBlock.js +0 -7
- package/lib/ContactBlock/ContactBlock.js.map +1 -1
- package/lib/Embed/AudioEmbed.js +1 -8
- package/lib/Embed/AudioEmbed.js.map +1 -1
- package/lib/Embed/BrightcoveEmbed.js +2 -9
- package/lib/Embed/BrightcoveEmbed.js.map +1 -1
- package/lib/Embed/CodeEmbed.js +1 -8
- package/lib/Embed/CodeEmbed.js.map +1 -1
- package/lib/Embed/ConceptEmbed.d.ts +1 -1
- package/lib/Embed/ConceptEmbed.js +1 -8
- package/lib/Embed/ConceptEmbed.js.map +1 -1
- package/lib/Embed/ContentLinkEmbed.d.ts +1 -1
- package/lib/Embed/ContentLinkEmbed.js.map +1 -1
- package/lib/Embed/CopyrightEmbed.d.ts +1 -1
- package/lib/Embed/CopyrightEmbed.js.map +1 -1
- package/lib/Embed/EmbedErrorPlaceholder.d.ts +1 -1
- package/lib/Embed/EmbedErrorPlaceholder.js +1 -1
- package/lib/Embed/EmbedErrorPlaceholder.js.map +1 -1
- package/lib/Embed/EmbedWrapper.d.ts +1 -1
- package/lib/Embed/EmbedWrapper.js +1 -8
- package/lib/Embed/EmbedWrapper.js.map +1 -1
- package/lib/Embed/ExternalEmbed.js +1 -8
- package/lib/Embed/ExternalEmbed.js.map +1 -1
- package/lib/Embed/FootnoteEmbed.js +0 -7
- package/lib/Embed/FootnoteEmbed.js.map +1 -1
- package/lib/Embed/GlossEmbed.d.ts +1 -1
- package/lib/Embed/GlossEmbed.js +1 -8
- package/lib/Embed/GlossEmbed.js.map +1 -1
- package/lib/Embed/H5pEmbed.js +0 -7
- package/lib/Embed/H5pEmbed.js.map +1 -1
- package/lib/Embed/IframeEmbed.js +2 -9
- package/lib/Embed/IframeEmbed.js.map +1 -1
- package/lib/Embed/ImageEmbed.d.ts +1 -1
- package/lib/Embed/ImageEmbed.js +2 -9
- package/lib/Embed/ImageEmbed.js.map +1 -1
- package/lib/Embed/InlineTriggerButton.js +1 -1
- package/lib/Embed/InlineTriggerButton.js.map +1 -1
- package/lib/Embed/RelatedContentEmbed.js +0 -7
- package/lib/Embed/RelatedContentEmbed.js.map +1 -1
- package/lib/Embed/UnknownEmbed.js +0 -7
- package/lib/Embed/UnknownEmbed.js.map +1 -1
- package/lib/Embed/UuDisclaimerEmbed.d.ts +1 -1
- package/lib/Embed/UuDisclaimerEmbed.js +1 -8
- package/lib/Embed/UuDisclaimerEmbed.js.map +1 -1
- package/lib/Embed/types.d.ts +1 -1
- package/lib/FactBox/FactBox.js +2 -2
- package/lib/FactBox/FactBox.js.map +1 -1
- package/lib/FileList/File.js +1 -1
- package/lib/FileList/File.js.map +1 -1
- package/lib/FileList/FileList.js +1 -1
- package/lib/FileList/FileList.js.map +1 -1
- package/lib/Gloss/Gloss.js +1 -8
- package/lib/Gloss/Gloss.js.map +1 -1
- package/lib/Gloss/GlossExample.js +1 -8
- package/lib/Gloss/GlossExample.js.map +1 -1
- package/lib/Grid/Grid.d.ts +1 -1
- package/lib/Grid/Grid.js +1 -8
- package/lib/Grid/Grid.js.map +1 -1
- package/lib/KeyFigure/KeyFigure.js.map +1 -1
- package/lib/LicenseByline/EmbedByline.d.ts +1 -1
- package/lib/LicenseByline/EmbedByline.js +1 -8
- package/lib/LicenseByline/EmbedByline.js.map +1 -1
- package/lib/LicenseByline/LicenseLink.js +1 -8
- package/lib/LicenseByline/LicenseLink.js.map +1 -1
- package/lib/LinkBlock/LinkBlock.js +1 -8
- package/lib/LinkBlock/LinkBlock.js.map +1 -1
- package/lib/LinkBlock/LinkBlockSection.js +1 -1
- package/lib/LinkBlock/LinkBlockSection.js.map +1 -1
- package/lib/Pitch/Pitch.js.map +1 -1
- package/lib/RelatedArticleList/RelatedArticleList.js +1 -1
- package/lib/RelatedArticleList/RelatedArticleList.js.map +1 -1
- package/lib/TagSelector/TagSelector.js +1 -1
- package/lib/TagSelector/TagSelector.js.map +1 -1
- package/lib/ZendeskButton/ZendeskButton.js +1 -1
- package/lib/ZendeskButton/ZendeskButton.js.map +1 -1
- package/lib/i18n/useComponentTranslations.js +0 -7
- package/lib/i18n/useComponentTranslations.js.map +1 -1
- package/lib/model/ContentType.d.ts +5 -0
- package/lib/model/ContentType.js +8 -1
- package/lib/model/ContentType.js.map +1 -1
- package/lib/model/index.d.ts +2 -0
- package/package.json +9 -9
- package/src/AnchorHeading/AnchorHeading.tsx +1 -1
- package/src/Article/Article.tsx +2 -2
- package/src/Article/ArticleByline.stories.tsx +0 -1
- package/src/Article/ArticleByline.tsx +3 -3
- package/src/AudioPlayer/AudioPlayer.tsx +2 -2
- package/src/AudioPlayer/Controls.tsx +2 -2
- package/src/AudioPlayer/SpeechControl.tsx +2 -2
- package/src/Breadcrumb/Breadcrumb.tsx +1 -1
- package/src/Breadcrumb/BreadcrumbItem.tsx +1 -1
- package/src/Breadcrumb/HomeBreadcrumb.tsx +1 -1
- package/src/CampaignBlock/CampaignBlock.tsx +3 -3
- package/src/CodeBlock/CodeBlock.tsx +2 -2
- package/src/Concept/Concept.stories.tsx +1 -1
- package/src/Concept/Concept.tsx +3 -3
- package/src/ContactBlock/ContactBlock.tsx +3 -3
- package/src/Embed/AudioEmbed.stories.tsx +2 -2
- package/src/Embed/AudioEmbed.tsx +2 -2
- package/src/Embed/BrightcoveEmbed.stories.tsx +2 -2
- package/src/Embed/BrightcoveEmbed.tsx +4 -4
- package/src/Embed/CodeEmbed.stories.tsx +1 -1
- package/src/Embed/CodeEmbed.tsx +4 -4
- package/src/Embed/ConceptEmbed.stories.tsx +2 -2
- package/src/Embed/ConceptEmbed.tsx +5 -5
- package/src/Embed/ContentLinkEmbed.tsx +2 -2
- package/src/Embed/CopyrightEmbed.tsx +1 -1
- package/src/Embed/EmbedErrorPlaceholder.tsx +1 -1
- package/src/Embed/EmbedWrapper.tsx +2 -2
- package/src/Embed/ExternalEmbed.stories.tsx +2 -2
- package/src/Embed/ExternalEmbed.tsx +4 -4
- package/src/Embed/FootnoteEmbed.stories.tsx +2 -2
- package/src/Embed/FootnoteEmbed.tsx +2 -2
- package/src/Embed/GlossEmbed.stories.tsx +2 -2
- package/src/Embed/GlossEmbed.tsx +3 -3
- package/src/Embed/H5pEmbed.stories.tsx +2 -2
- package/src/Embed/H5pEmbed.tsx +2 -2
- package/src/Embed/IframeEmbed.stories.tsx +2 -2
- package/src/Embed/IframeEmbed.tsx +5 -5
- package/src/Embed/ImageEmbed.stories.tsx +4 -4
- package/src/Embed/ImageEmbed.tsx +5 -5
- package/src/Embed/InlineTriggerButton.tsx +1 -1
- package/src/Embed/RelatedContentEmbed.stories.tsx +2 -2
- package/src/Embed/RelatedContentEmbed.tsx +1 -1
- package/src/Embed/UnknownEmbed.tsx +2 -2
- package/src/Embed/UuDisclaimerEmbed.stories.tsx +4 -4
- package/src/Embed/UuDisclaimerEmbed.tsx +3 -3
- package/src/Embed/types.ts +1 -1
- package/src/FactBox/FactBox.tsx +3 -3
- package/src/FileList/File.tsx +2 -2
- package/src/FileList/FileList.tsx +1 -1
- package/src/Gloss/Gloss.stories.tsx +1 -1
- package/src/Gloss/Gloss.tsx +6 -6
- package/src/Gloss/GlossExample.tsx +2 -2
- package/src/Grid/Grid.stories.tsx +1 -1
- package/src/Grid/Grid.tsx +2 -2
- package/src/KeyFigure/KeyFigure.tsx +1 -1
- package/src/LicenseByline/EmbedByline.tsx +6 -6
- package/src/LicenseByline/LicenseLink.tsx +1 -1
- package/src/LinkBlock/LinkBlock.tsx +3 -3
- package/src/LinkBlock/LinkBlockSection.tsx +1 -1
- package/src/Pitch/Pitch.stories.tsx +1 -1
- package/src/Pitch/Pitch.tsx +1 -1
- package/src/RelatedArticleList/RelatedArticleList.tsx +2 -2
- package/src/TagSelector/TagSelector.stories.tsx +3 -4
- package/src/TagSelector/TagSelector.tsx +1 -1
- package/src/ZendeskButton/ZendeskButton.tsx +1 -1
- package/src/i18n/useComponentTranslations.ts +2 -2
- package/src/model/ContentType.ts +7 -0
|
@@ -1 +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 {
|
|
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 { ErrorWarningLine } from \"@ndla/icons\";\nimport { Figure, type FigureFloat, type FigureSize } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { type ReactNode } from \"react\";\nimport { EmbedByline, 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\nexport const 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"],"mappings":";;;;;;;;;;;;;;;;AAqBA,MAAM,uDAA0B,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;EACP;CACF,EACF,CAAC;AAEF,MAAM,mDAAsBA,yBAAQ,EAClC,MAAM,EACJ,2BAA2B,EACzB,kBAAkB,WACnB,EACF,EACF,CAAC;AAEF,MAAa,yBAAyB,EAAE,MAAM,UAAU,YAAY,YAAmB;AACrF,QACE,4CAAC;EAAa,MAAM;EAAmB;EAAO,mBAAiB;aAC5D,YACC,2CAAC;GAAiB,mBAAiB;aACjC,2CAACC,iCAAmB;IACH,EAErB,2CAACC;GAAY;GAAY;IAAQ;GACpB"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { type HTMLArkProps } from "@ark-ui/react";
|
|
9
8
|
import type { StyledProps, RecipeVariantProps } from "@ndla/styled-system/types";
|
|
9
|
+
import { type HTMLArkProps } from "@ark-ui/react";
|
|
10
10
|
declare const embedWrapperRecipe: import("@ndla/styled-system/types").RecipeRuntimeFn<{
|
|
11
11
|
noClear: {
|
|
12
12
|
true: {
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
let react = require("react");
|
|
3
2
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
3
|
+
let react = require("react");
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
let _ark_ui_react = require("@ark-ui/react");
|
|
6
6
|
let _ndla_styled_system_css = require("@ndla/styled-system/css");
|
|
7
7
|
|
|
8
8
|
//#region src/Embed/EmbedWrapper.tsx
|
|
9
|
-
/**
|
|
10
|
-
* Copyright (c) 2024-present, NDLA.
|
|
11
|
-
*
|
|
12
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
13
|
-
* LICENSE file in the root directory of this source tree.
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
9
|
const embedWrapperRecipe = (0, _ndla_styled_system_css.cva)({
|
|
17
10
|
base: { position: "relative" },
|
|
18
11
|
defaultVariants: { noClear: false },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbedWrapper.js","names":["ark","css"],"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 {
|
|
1
|
+
{"version":3,"file":"EmbedWrapper.js","names":["ark","css"],"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 type { StyledProps, RecipeVariantProps } from \"@ndla/styled-system/types\";\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\";\nimport { css, cva } from \"@ndla/styled-system/css\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { forwardRef } from \"react\";\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 = NonNullable<RecipeVariantProps<typeof embedWrapperRecipe>>;\n\nexport interface EmbedWrapperProps extends HTMLArkProps<\"div\">, StyledProps, 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,sDAAyB;CAC7B,MAAM,EACJ,UAAU,YACX;CACD,iBAAiB,EACf,SAAS,OACV;CACD,UAAU,EACR,SAAS;EACP,MAAM,EACJ,4BAA4B,EAC1B,OAAO,QACR,EACF;EACD,OAAO,EACL,OAAO,QACR;EACF,EACF;CACF,CAAC;AAMF,MAAM,yDAA4BA,kBAAI,KAAK,EAAE,EAAE,EAAE,eAAe,MAAM,CAAC;AAEvE,MAAa,sCACV,EAAE,SAAS,KAAK,SAAS,GAAG,SAAS,QACpC,2CAAC;CACC,KAAKC,4BAAI,IAAI,mBAAmB,IAAI,EAAE,SAAS,CAAC,EAAE,QAAQ;CAC1D,sBAAmB;CACnB,GAAI;CACC;EACL,CAEL"}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
2
|
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
3
|
const require_ResourceBox = require('../ResourceBox/ResourceBox.js');
|
|
4
|
-
let react = require("react");
|
|
5
4
|
let _ndla_primitives = require("@ndla/primitives");
|
|
6
5
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
6
|
+
let react = require("react");
|
|
7
7
|
let react_i18next = require("react-i18next");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
|
|
10
10
|
//#region src/Embed/ExternalEmbed.tsx
|
|
11
|
-
/**
|
|
12
|
-
* Copyright (c) 2023-present, NDLA.
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
15
|
-
* LICENSE file in the root directory of this source tree.
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
11
|
const StyledFigure = (0, _ndla_styled_system_jsx.styled)(_ndla_primitives.Figure, { base: { "& iframe": {
|
|
19
12
|
height: "auto",
|
|
20
13
|
width: "100%"
|
|
@@ -1 +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
|
|
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 type { OembedMetaData } from \"@ndla/types-embed\";\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { ResourceBox } from \"../ResourceBox/ResourceBox\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\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\nexport const 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};\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,mDAAsBA,yBAAQ,EAClC,MAAM,EACJ,YAAY;CACV,QAAQ;CACR,OAAO;CACR,EACF,EACF,CAAC;AAEF,MAAa,iBAAiB,EAAE,YAAmB;CACjD,MAAM,EAAE,yCAAsB;CAC9B,MAAM,2BAA6B,KAAK;AAExC,4BAAgB;EACd,MAAM,SAAS,OAAO,SAAS,cAAc,SAAS;AACtD,MAAI,QAAQ;GACV,MAAM,CAAC,OAAO,UAAU,CAAC,OAAO,SAAS,OAAO,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,CAAC;AACvF,UAAO,MAAM,cAAc,GAAG,QAAQ,QAAQ,GAAG,GAAG,SAAS,SAAS;AACtE,UAAO,QAAQ;AACf,UAAO,SAAS;;IAEjB,EAAE,CAAC;AAEN,KAAI,MAAM,WAAW,QACnB,QAAO,2CAACC,uDAAsB,MAAK,aAAa;CAGlD,MAAM,EAAE,WAAW,SAAS;AAE5B,KAAI,UAAU,SAAS,cAAc;EACnC,MAAM,QAAQ;GACZ,KAAK,KAAK,aAAa,MAAM;GAC7B,KAAK,UAAU,QAAQ,SAAY,UAAU,MAAO,KAAK,aAAa,SAAS,WAAW;GAC3F;AACD,SACE,2CAACD;GAAO,mBAAgB;aACtB,2CAACE;IACQ;IACP,OAAO,UAAU,SAAS;IAC1B,KAAK,UAAU;IACf,SAAS,UAAU,WAAW;IAC9B,YAAY,EAAE,oCAAoC;KAClD;IACK;;AAIb,QACE,2CAAC;EACC,mBAAgB;EAChB,KAAK;EACL,yBAAyB,EAAE,QAAQ,MAAM,QAAQ,QAAQ,IAAI;GAC7D"}
|
|
@@ -4,13 +4,6 @@ let react_i18next = require("react-i18next");
|
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
|
|
6
6
|
//#region src/Embed/FootnoteEmbed.tsx
|
|
7
|
-
/**
|
|
8
|
-
* Copyright (c) 2023-present, NDLA.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
7
|
const StyledSup = (0, _ndla_styled_system_jsx.styled)("sup", { base: { "& a": {
|
|
15
8
|
textStyle: "label.xsmall",
|
|
16
9
|
marginInlineStart: "1"
|
|
@@ -1 +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 {
|
|
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 type { FootnoteMetaData } from \"@ndla/types-embed\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { useTranslation } from \"react-i18next\";\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\nexport const 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"],"mappings":";;;;;;AAgBA,MAAM,gDAAmB,OAAO,EAC9B,MAAM,EACJ,OAAO;CACL,WAAW;CACX,mBAAmB;CACpB,EACF,EACF,CAAC;AAEF,MAAa,iBAAiB,EAAE,YAAmB;CACjD,MAAM,EAAE,yCAAsB;AAC9B,KAAI,MAAM,WAAW,QACnB,QAAO,2CAAC,mBAAK,EAAE,QAAQ,GAAO;AAGhC,QACE,2CAAC;EAAK,IAAI,MAAM,MAAM,KAAK;EAAY,mBAAgB;YACrD,2CAAC,uBACC,2CAAC;GAAE,MAAM,QAAQ,MAAM,KAAK;GAAY,QAAO;aAAS,IAAI,MAAM,KAAK,SAAS;IAAO,GAC7E;GACP"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { type ReactNode } from "react";
|
|
9
8
|
import type { ConceptMetaData } from "@ndla/types-embed";
|
|
9
|
+
import { type ReactNode } from "react";
|
|
10
10
|
interface Props {
|
|
11
11
|
embed: ConceptMetaData;
|
|
12
12
|
children?: ReactNode;
|
package/lib/Embed/GlossEmbed.js
CHANGED
|
@@ -2,20 +2,13 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
|
2
2
|
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
3
|
const require_ConceptInlineTriggerButton = require('./ConceptInlineTriggerButton.js');
|
|
4
4
|
const require_Gloss = require('../Gloss/Gloss.js');
|
|
5
|
-
let react = require("react");
|
|
6
5
|
let _ndla_primitives = require("@ndla/primitives");
|
|
7
6
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
7
|
+
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
let _ark_ui_react = require("@ark-ui/react");
|
|
10
10
|
|
|
11
11
|
//#region src/Embed/GlossEmbed.tsx
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) 2024-present, NDLA.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
12
|
const StyledPopoverContent = (0, _ndla_styled_system_jsx.styled)(_ndla_primitives.PopoverContent, { base: { width: "surface.xlarge" } });
|
|
20
13
|
const GlossEmbed = ({ embed, children }) => {
|
|
21
14
|
const contentRef = (0, react.useRef)(null);
|
|
@@ -1 +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 {
|
|
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 type { ConceptMetaData } from \"@ndla/types-embed\";\nimport { Portal } from \"@ark-ui/react\";\nimport { Figure, PopoverContent, PopoverRoot, PopoverTrigger } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { useRef, type ReactNode } from \"react\";\nimport { Gloss } from \"../Gloss/Gloss\";\nimport { ConceptInlineTriggerButton } from \"./ConceptInlineTriggerButton\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\n\ninterface Props {\n embed: ConceptMetaData;\n children?: ReactNode;\n}\n\nconst StyledPopoverContent = styled(PopoverContent, {\n base: {\n width: \"surface.xlarge\",\n },\n});\n\nexport const GlossEmbed = ({ embed, children }: Props) => {\n const contentRef = useRef<HTMLDivElement>(null);\n if (embed.status === \"error\" && embed.embedData.type === \"inline\") {\n return <span>{children}</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>{children}</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":";;;;;;;;;;;AAsBA,MAAM,2DAA8BA,iCAAgB,EAClD,MAAM,EACJ,OAAO,kBACR,EACF,CAAC;AAEF,MAAa,cAAc,EAAE,OAAO,eAAsB;CACxD,MAAM,+BAAoC,KAAK;AAC/C,KAAI,MAAM,WAAW,WAAW,MAAM,UAAU,SAAS,SACvD,QAAO,2CAAC,UAAM,WAAgB;AAEhC,KAAI,MAAM,WAAW,WAAW,CAAC,MAAM,KAAK,QAAQ,UAClD,QAAO,2CAACC,uDAAsB,MAAK,UAAU;CAG/C,MAAM,EAAE,SAAS,kBAAkB,MAAM;CAEzC,MAAM,QACJ,eAAe,WAAW,aAAa,cAAc,aAAa,UAC9D;EACE,KAAK,cAAc,KAAK,UAAU;EAClC,OAAO,cAAc,KAAK,MAAM;EACjC,GACD;AAEN,KAAI,MAAM,UAAU,SAAS,SAC3B,QACE,4CAACC;EAAY,sBAAsB,WAAW;aAC5C,2CAACC;GAAe;aACd,2CAACC,iEAA4B,WAAsC;IACpD,EACjB,2CAACC,kCACC,2CAAC;GAAqB,KAAK;aACzB,2CAACC,qCACC,2CAACC;IACC,WAAW,QAAQ;IACnB,OAAO,QAAQ;IACR;IACP,YAAY,MAAM,UAAU;IAC5B,cAAc,MAAM,UAAU;KAC9B,GACK;IACY,GAChB;GACG;AAIlB,QACE,2CAACD;EAAO,mBAAgB;YACtB,2CAACC;GACC,WAAW,QAAQ;GACnB,OAAO,QAAQ;GACR;GACP,YAAY,MAAM,UAAU;GAC5B,cAAc,MAAM,UAAU;GAC9B,SAAQ;IACR;GACK"}
|
package/lib/Embed/H5pEmbed.js
CHANGED
|
@@ -6,13 +6,6 @@ let react_i18next = require("react-i18next");
|
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
|
|
8
8
|
//#region src/Embed/H5pEmbed.tsx
|
|
9
|
-
/**
|
|
10
|
-
* Copyright (c) 2023-present, NDLA.
|
|
11
|
-
*
|
|
12
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
13
|
-
* LICENSE file in the root directory of this source tree.
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
9
|
const StyledFigure = (0, _ndla_styled_system_jsx.styled)(_ndla_primitives.Figure, { base: { "& iframe": {
|
|
17
10
|
height: "auto",
|
|
18
11
|
width: "100%"
|
|
@@ -1 +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 {
|
|
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 type { H5pMetaData } from \"@ndla/types-embed\";\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { useTranslation } from \"react-i18next\";\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\nexport const 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"],"mappings":";;;;;;;;AAkBA,MAAM,mDAAsBA,yBAAQ,EAClC,MAAM,EACJ,YAAY;CACV,QAAQ;CACR,OAAO;CACR,EACF,EACF,CAAC;AAEF,MAAM,mDAAsBA,yBAAQ,EAClC,MAAM;CACJ,OAAO;CACP,YAAY,EACV,OAAO,QACR;CACF,EACF,CAAC;AAEF,MAAa,YAAY,EAAE,YAAmB;CAC5C,MAAM,EAAE,yCAAsB;AAC9B,KAAI,MAAM,WAAW,QACnB,QAAO,2CAACC,uDAAsB,MAAK,QAAQ;AAG7C,KAAI,MAAM,KAAK,OACb,QAAO,2CAAC;EAAa,mBAAgB;EAAM,yBAAyB,EAAE,QAAQ,MAAM,KAAK,OAAO,QAAQ,IAAI;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,kBAAkB,GAAG,EAAE,iBAAiB,CAAC,IAAI;AAEnD,QACE,2CAAC;EAAa,mBAAgB;YAC5B,2CAAC;GAAO,OAAO;GAAiB,cAAY;GAAiB,KAAK,MAAM,UAAU;IAAO;GAC5E"}
|
package/lib/Embed/IframeEmbed.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
2
|
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
3
|
const require_ResourceBox = require('../ResourceBox/ResourceBox.js');
|
|
4
|
-
let react = require("react");
|
|
5
4
|
let _ndla_primitives = require("@ndla/primitives");
|
|
6
5
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
6
|
+
let react = require("react");
|
|
7
7
|
let react_i18next = require("react-i18next");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
|
|
10
10
|
//#region src/Embed/IframeEmbed.tsx
|
|
11
|
-
/**
|
|
12
|
-
* Copyright (c) 2023-present, NDLA.
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
15
|
-
* LICENSE file in the root directory of this source tree.
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
11
|
const StyledIframe = (0, _ndla_styled_system_jsx.styled)("iframe", { base: {
|
|
19
12
|
width: "100%",
|
|
20
13
|
border: 0
|
|
@@ -65,7 +58,7 @@ const IframeEmbed = ({ embed }) => {
|
|
|
65
58
|
src: url,
|
|
66
59
|
width: strippedWidth,
|
|
67
60
|
height: strippedHeight,
|
|
68
|
-
allow: "
|
|
61
|
+
allow: "autoplay; encrypted-media; fullscreen",
|
|
69
62
|
loading: "lazy"
|
|
70
63
|
})
|
|
71
64
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IframeEmbed.js","names":["Figure","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
|
|
1
|
+
{"version":3,"file":"IframeEmbed.js","names":["Figure","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 type { IframeMetaData } from \"@ndla/types-embed\";\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { ResourceBox } from \"../ResourceBox/ResourceBox\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\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\nexport const 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=\"autoplay; encrypted-media; fullscreen\"\n loading=\"lazy\"\n />\n </StyledFigure>\n );\n};\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,mDAAsB,UAAU,EACpC,MAAM;CACJ,OAAO;CACP,QAAQ;CACT,EACF,CAAC;AAEF,MAAM,mDAAsBA,yBAAQ,EAClC,MAAM,EACJ,OAAO,QACR,EACF,CAAC;AAEF,MAAa,eAAe,EAAE,YAAmB;CAC/C,MAAM,EAAE,yCAAsB;CAC9B,MAAM,8BAAsC,KAAK;AAEjD,4BAAgB;EACd,MAAM,SAAS,UAAU;AACzB,MAAI,QAAQ;GACV,MAAM,CAAC,OAAO,UAAU,CAAC,OAAO,SAAS,OAAO,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,CAAC;AACvF,UAAO,MAAM,cAAc,GAAG,QAAQ,QAAQ,GAAG,GAAG,SAAS,SAAS;AACtE,UAAO,QAAQ;AACf,UAAO,SAAS;;IAEjB,EAAE,CAAC;AAEN,KAAI,MAAM,WAAW,QACnB,QAAO,2CAACC,uDAAsB,MAAK,aAAa;CAGlD,MAAM,EAAE,WAAW,SAAS;AAE5B,KAAI,UAAU,SAAS,cAAc;EACnC,MAAM,cAAc,MAAM,WAAW,YAAY,KAAK,cAAc;EACpE,MAAM,MAAM,UAAU,QAAQ,SAAY,UAAU,MAAM,aAAa,QAAQ;EAC/E,MAAM,QAAQ;GAAE,KAAK,aAAa,MAAM;GAAU,KAAK,OAAO;GAAI;AAClE,SACE,2CAAC;GAAa,mBAAgB;aAC5B,2CAACC;IACQ;IACP,OAAO,UAAU,SAAS;IAC1B,KAAK,UAAU;IACf,SAAS,UAAU,WAAW;IAC9B,YAAY,EAAE,oCAAoC;KAClD;IACW;;CAInB,MAAM,EAAE,OAAO,QAAQ,QAAQ;CAE/B,MAAM,gBAAgB,OAAO,UAAU,WAAW,QAAQ,OAAO,QAAQ,SAAS,GAAG;CACrF,MAAM,iBAAiB,OAAO,WAAW,WAAW,SAAS,QAAQ,QAAQ,SAAS,GAAG;CACzF,MAAM,QAAQ,GAAG,EAAE,sBAAsB,CAAC,IAAI,UAAU,OAAO,MAAM,GAAG,UAAU,QAAQ;AAE1F,QACE,2CAAC;EAAa,mBAAgB;YAC5B,2CAAC;GACC,KAAK;GACE;GACP,cAAY;GACZ,KAAK;GACL,OAAO;GACP,QAAQ;GACR,OAAM;GACN,SAAQ;IACR;GACW"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { type ReactNode } from "react";
|
|
9
8
|
import type { ImageEmbedData, ImageMetaData } from "@ndla/types-embed";
|
|
9
|
+
import { type ReactNode } from "react";
|
|
10
10
|
import type { RenderContext } from "./types";
|
|
11
11
|
interface Props {
|
|
12
12
|
embed: ImageMetaData;
|
package/lib/Embed/ImageEmbed.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
2
|
const require_EmbedByline = require('../LicenseByline/EmbedByline.js');
|
|
3
|
-
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
4
3
|
const require_licenseAttributes = require('../utils/licenseAttributes.js');
|
|
5
|
-
|
|
4
|
+
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
6
5
|
let _ndla_primitives = require("@ndla/primitives");
|
|
7
6
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
7
|
+
let react = require("react");
|
|
8
8
|
let html_react_parser = require("html-react-parser");
|
|
9
9
|
html_react_parser = require_rolldown_runtime.__toESM(html_react_parser);
|
|
10
10
|
let react_i18next = require("react-i18next");
|
|
@@ -12,13 +12,6 @@ let _ndla_icons = require("@ndla/icons");
|
|
|
12
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
13
|
|
|
14
14
|
//#region src/Embed/ImageEmbed.tsx
|
|
15
|
-
/**
|
|
16
|
-
* Copyright (c) 2023-present, NDLA.
|
|
17
|
-
*
|
|
18
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
19
|
-
* LICENSE file in the root directory of this source tree.
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
15
|
const getFigureProps = (size, float) => {
|
|
23
16
|
const actualFloat = float === "left" ? "left" : float === "right" ? "right" : void 0;
|
|
24
17
|
const replacedSize = size?.replace("-hide-byline", "") ?? "full";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageEmbed.js","names":["Figure","EmbedErrorPlaceholder","licenseAttributes","Image","AddLine","EmbedByline"],"sources":["../../src/Embed/ImageEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport parse from \"html-react-parser\";\nimport { type ReactNode, useMemo, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { AddLine } from \"@ndla/icons\";\nimport { Figure, type FigureSize, type FigureVariantProps, Image } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { ImageEmbedData, ImageMetaData } from \"@ndla/types-embed\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\nimport type { RenderContext } from \"./types\";\nimport { EmbedByline } from \"../LicenseByline/EmbedByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\n\ninterface Props {\n embed: ImageMetaData;\n previewAlt?: boolean;\n lang?: string;\n renderContext?: RenderContext;\n children?: ReactNode;\n}\n\nexport interface Author {\n name: string;\n type: string;\n}\n\nconst getFigureProps = (size?: string, float?: string): FigureVariantProps => {\n const actualFloat = float === \"left\" ? \"left\" : float === \"right\" ? \"right\" : undefined;\n const replacedSize = size?.replace(\"-hide-byline\", \"\") ?? \"full\";\n const actualSize: FigureSize = (replacedSize === \"fullwidth\" ? \"full\" : replacedSize) as FigureSize;\n return {\n float: actualFloat,\n // Figure expects you to set a size when floating. If you don't, the figure will simply take up the available width. Fallback to medium in those cases.\n size: actualSize === \"full\" && float ? \"medium\" : actualSize,\n };\n};\n\nconst getSizes = (size?: string, align?: string) => {\n if (align && size === \"full\") {\n return \"(min-width: 1024px) 512px, (min-width: 768px) 350px, 100vw\";\n }\n if (align && size === \"small\") {\n return \"(min-width: 1024px) 350px, (min-width: 768px) 180px, 100vw\";\n }\n if (align && size === \"xsmall\") {\n return \"(min-width: 1024px) 180px, (min-width: 768px) 180px, 100vw\";\n }\n return \"(min-width: 1024px) 1024px, 100vw\";\n};\n\nexport const getFocalPoint = (data: ImageEmbedData) => {\n const focalX = Number.parseFloat(data.focalX ?? \"\");\n const focalY = Number.parseFloat(data.focalY ?? \"\");\n if (!Number.isNaN(focalX) && !Number.isNaN(focalY)) {\n return { x: focalX, y: focalY };\n }\n return undefined;\n};\n\nexport const getCrop = (data: ImageEmbedData) => {\n const lowerRightX = Number.parseFloat(data.lowerRightX ?? \"\");\n const lowerRightY = Number.parseFloat(data.lowerRightY ?? \"\");\n const upperLeftX = Number.parseFloat(data.upperLeftX ?? \"\");\n const upperLeftY = Number.parseFloat(data.upperLeftY ?? \"\");\n if (\n !Number.isNaN(lowerRightX) &&\n !Number.isNaN(lowerRightY) &&\n !Number.isNaN(upperLeftX) &&\n !Number.isNaN(upperLeftY)\n ) {\n return {\n startX: lowerRightX,\n startY: lowerRightY,\n endX: upperLeftX,\n endY: upperLeftY,\n };\n }\n return undefined;\n};\n\nconst expandedSizes = \"(min-width: 1024px) 1024px, 100vw\";\n\nconst ImageWrapper = styled(\"div\", {\n base: {\n overflow: \"hidden\",\n position: \"relative\",\n width: \"100%\",\n \"& img\": {\n width: \"100%\",\n },\n },\n variants: {\n svg: {\n true: {\n display: \"flex\",\n justifyContent: \"center\",\n },\n false: {},\n },\n border: {\n true: {\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n borderRadius: \"xsmall\",\n \"& img\": {\n borderRadius: \"0\",\n },\n },\n false: {},\n },\n expandable: {\n true: {\n cursor: \"pointer\",\n },\n false: {},\n },\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n zIndex: \"docked\",\n _hover: {\n \"& [data-byline-button]\": {\n background: \"background.default\",\n },\n \"& button[data-expanded]\": {\n transform: \"scale(1.2)\",\n },\n },\n \"& button[data-expanded='true']\": {\n \"& svg\": {\n transform: \"rotate(-45deg)\",\n },\n },\n },\n});\n\nconst ExpandButton = styled(\n \"button\",\n {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n cursor: \"pointer\",\n position: \"absolute\",\n padding: \"0\",\n top: \"xsmall\",\n right: \"xsmall\",\n width: \"medium\",\n height: \"medium\",\n border: \"2px solid\",\n borderColor: \"background.default\",\n transitionProperty: \"transform, background-color, color\",\n transitionDuration: \"normal\",\n transitionTimingFunction: \"ease-out\",\n color: \"background.default\",\n backgroundColor: \"surface.action\",\n borderRadius: \"large\",\n \"& svg\": {\n transitionProperty: \"transform\",\n transitionDuration: \"normal\",\n transitionTimingFunction: \"ease-out\",\n },\n tabletDown: {\n display: \"none\",\n },\n _print: {\n display: \"none\",\n },\n },\n },\n { defaultProps: { type: \"button\" } },\n);\n\nexport const ImageEmbed = ({ embed, previewAlt, lang, renderContext = \"article\", children }: Props) => {\n const [expanded, setExpanded] = useState(false);\n const figureProps = getFigureProps(embed.embedData.size, embed.embedData.align);\n const { t } = useTranslation();\n\n const parsedDescription = useMemo(() => {\n if (embed.embedData.caption || renderContext === \"article\") {\n return embed.embedData.caption ? parse(embed.embedData.caption) : undefined;\n }\n if (embed.status === \"success\" && embed.data.caption.caption) {\n return parse(embed.data.caption.caption);\n }\n }, [embed, renderContext]);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type={\"image\"} figureType={figureProps?.size} float={figureProps?.float} />;\n }\n\n const { data, embedData } = embed;\n\n const altText = embedData.alt || \"\";\n\n const sizes = getSizes(embedData.size, embedData.align);\n\n const focalPoint = getFocalPoint(embedData);\n const crop = getCrop(embedData);\n\n const toggleImageSize = () => {\n setExpanded((prev) => !prev);\n };\n\n const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);\n\n const figureSize = figureProps?.float ? (figureProps?.size ?? \"medium\") : \"full\";\n\n return (\n <StyledFigure\n float={figureProps?.float}\n size={expanded ? \"full\" : figureSize}\n data-embed-type=\"image\"\n {...licenseProps}\n >\n {children}\n <ImageWrapper border={embedData.border === \"true\"} expandable={!!figureProps?.float}>\n <Image\n focalPoint={focalPoint}\n contentType={data.image.contentType}\n crop={crop}\n sizes={expanded ? expandedSizes : sizes}\n alt={altText}\n src={data.image.imageUrl}\n variants={data.image.variants}\n lang={lang}\n onClick={figureProps?.float ? toggleImageSize : undefined}\n variant=\"rounded\"\n {...data.image.dimensions}\n />\n {(embedData.align === \"right\" || embedData.align === \"left\") && (\n <ExpandButton\n aria-label={t(`license.images.itemImage.zoom${expanded ? \"Out\" : \"\"}ImageButtonLabel`)}\n onClick={toggleImageSize}\n data-expanded={expanded}\n >\n <AddLine />\n </ExpandButton>\n )}\n </ImageWrapper>\n <EmbedByline\n type=\"image\"\n copyright={data.copyright}\n description={parsedDescription}\n hideDescription={embedData.hideCaption === \"true\"}\n hideCopyright={embedData.hideByline === \"true\"}\n visibleAlt={previewAlt ? embed.embedData.alt : \"\"}\n />\n </StyledFigure>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,kBAAkB,MAAe,UAAuC;CAC5E,MAAM,cAAc,UAAU,SAAS,SAAS,UAAU,UAAU,UAAU;CAC9E,MAAM,eAAe,MAAM,QAAQ,gBAAgB,GAAG,IAAI;CAC1D,MAAM,aAA0B,iBAAiB,cAAc,SAAS;AACxE,QAAO;EACL,OAAO;EAEP,MAAM,eAAe,UAAU,QAAQ,WAAW;EACnD;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MAAM;CAEvD,MAAM,aAAa,cAAc,UAAU;CAC3C,MAAM,OAAO,QAAQ,UAAU;CAE/B,MAAM,wBAAwB;AAC5B,eAAa,SAAS,CAAC,KAAK;;CAG9B,MAAM,eAAeC,4CAAkB,KAAK,UAAU,QAAQ,SAAS,MAAM,UAAU,IAAI;CAE3F,MAAM,aAAa,aAAa,QAAS,aAAa,QAAQ,WAAY;AAE1E,QACE,4CAAC;EACC,OAAO,aAAa;EACpB,MAAM,WAAW,SAAS;EAC1B,mBAAgB;EAChB,GAAI;;GAEH;GACD,4CAAC;IAAa,QAAQ,UAAU,WAAW;IAAQ,YAAY,CAAC,CAAC,aAAa;eAC5E,2CAACC;KACa;KACZ,aAAa,KAAK,MAAM;KAClB;KACN,OAAO,WAAW,gBAAgB;KAClC,KAAK;KACL,KAAK,KAAK,MAAM;KAChB,UAAU,KAAK,MAAM;KACf;KACN,SAAS,aAAa,QAAQ,kBAAkB;KAChD,SAAQ;KACR,GAAI,KAAK,MAAM;MACf,GACA,UAAU,UAAU,WAAW,UAAU,UAAU,WACnD,2CAAC;KACC,cAAY,EAAE,gCAAgC,WAAW,QAAQ,GAAG,kBAAkB;KACtF,SAAS;KACT,iBAAe;eAEf,2CAACC,wBAAU;MACE;KAEJ;GACf,2CAACC;IACC,MAAK;IACL,WAAW,KAAK;IAChB,aAAa;IACb,iBAAiB,UAAU,gBAAgB;IAC3C,eAAe,UAAU,eAAe;IACxC,YAAY,aAAa,MAAM,UAAU,MAAM;KAC/C;;GACW"}
|
|
1
|
+
{"version":3,"file":"ImageEmbed.js","names":["Figure","EmbedErrorPlaceholder","licenseAttributes","Image","AddLine","EmbedByline"],"sources":["../../src/Embed/ImageEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ImageEmbedData, ImageMetaData } from \"@ndla/types-embed\";\nimport { AddLine } from \"@ndla/icons\";\nimport { Figure, type FigureSize, type FigureVariantProps, Image } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport parse from \"html-react-parser\";\nimport { type ReactNode, useMemo, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport type { RenderContext } from \"./types\";\nimport { EmbedByline } from \"../LicenseByline/EmbedByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\nimport { EmbedErrorPlaceholder } from \"./EmbedErrorPlaceholder\";\n\ninterface Props {\n embed: ImageMetaData;\n previewAlt?: boolean;\n lang?: string;\n renderContext?: RenderContext;\n children?: ReactNode;\n}\n\nexport interface Author {\n name: string;\n type: string;\n}\n\nconst getFigureProps = (size?: string, float?: string): FigureVariantProps => {\n const actualFloat = float === \"left\" ? \"left\" : float === \"right\" ? \"right\" : undefined;\n const replacedSize = size?.replace(\"-hide-byline\", \"\") ?? \"full\";\n const actualSize: FigureSize = (replacedSize === \"fullwidth\" ? \"full\" : replacedSize) as FigureSize;\n return {\n float: actualFloat,\n // Figure expects you to set a size when floating. If you don't, the figure will simply take up the available width. Fallback to medium in those cases.\n size: actualSize === \"full\" && float ? \"medium\" : actualSize,\n };\n};\n\nconst getSizes = (size?: string, align?: string) => {\n if (align && size === \"full\") {\n return \"(min-width: 1024px) 512px, (min-width: 768px) 350px, 100vw\";\n }\n if (align && size === \"small\") {\n return \"(min-width: 1024px) 350px, (min-width: 768px) 180px, 100vw\";\n }\n if (align && size === \"xsmall\") {\n return \"(min-width: 1024px) 180px, (min-width: 768px) 180px, 100vw\";\n }\n return \"(min-width: 1024px) 1024px, 100vw\";\n};\n\nexport const getFocalPoint = (data: ImageEmbedData) => {\n const focalX = Number.parseFloat(data.focalX ?? \"\");\n const focalY = Number.parseFloat(data.focalY ?? \"\");\n if (!Number.isNaN(focalX) && !Number.isNaN(focalY)) {\n return { x: focalX, y: focalY };\n }\n return undefined;\n};\n\nexport const getCrop = (data: ImageEmbedData) => {\n const lowerRightX = Number.parseFloat(data.lowerRightX ?? \"\");\n const lowerRightY = Number.parseFloat(data.lowerRightY ?? \"\");\n const upperLeftX = Number.parseFloat(data.upperLeftX ?? \"\");\n const upperLeftY = Number.parseFloat(data.upperLeftY ?? \"\");\n if (\n !Number.isNaN(lowerRightX) &&\n !Number.isNaN(lowerRightY) &&\n !Number.isNaN(upperLeftX) &&\n !Number.isNaN(upperLeftY)\n ) {\n return {\n startX: lowerRightX,\n startY: lowerRightY,\n endX: upperLeftX,\n endY: upperLeftY,\n };\n }\n return undefined;\n};\n\nconst expandedSizes = \"(min-width: 1024px) 1024px, 100vw\";\n\nconst ImageWrapper = styled(\"div\", {\n base: {\n overflow: \"hidden\",\n position: \"relative\",\n width: \"100%\",\n \"& img\": {\n width: \"100%\",\n },\n },\n variants: {\n svg: {\n true: {\n display: \"flex\",\n justifyContent: \"center\",\n },\n false: {},\n },\n border: {\n true: {\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n borderRadius: \"xsmall\",\n \"& img\": {\n borderRadius: \"0\",\n },\n },\n false: {},\n },\n expandable: {\n true: {\n cursor: \"pointer\",\n },\n false: {},\n },\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n zIndex: \"docked\",\n _hover: {\n \"& [data-byline-button]\": {\n background: \"background.default\",\n },\n \"& button[data-expanded]\": {\n transform: \"scale(1.2)\",\n },\n },\n \"& button[data-expanded='true']\": {\n \"& svg\": {\n transform: \"rotate(-45deg)\",\n },\n },\n },\n});\n\nconst ExpandButton = styled(\n \"button\",\n {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n cursor: \"pointer\",\n position: \"absolute\",\n padding: \"0\",\n top: \"xsmall\",\n right: \"xsmall\",\n width: \"medium\",\n height: \"medium\",\n border: \"2px solid\",\n borderColor: \"background.default\",\n transitionProperty: \"transform, background-color, color\",\n transitionDuration: \"normal\",\n transitionTimingFunction: \"ease-out\",\n color: \"background.default\",\n backgroundColor: \"surface.action\",\n borderRadius: \"large\",\n \"& svg\": {\n transitionProperty: \"transform\",\n transitionDuration: \"normal\",\n transitionTimingFunction: \"ease-out\",\n },\n tabletDown: {\n display: \"none\",\n },\n _print: {\n display: \"none\",\n },\n },\n },\n { defaultProps: { type: \"button\" } },\n);\n\nexport const ImageEmbed = ({ embed, previewAlt, lang, renderContext = \"article\", children }: Props) => {\n const [expanded, setExpanded] = useState(false);\n const figureProps = getFigureProps(embed.embedData.size, embed.embedData.align);\n const { t } = useTranslation();\n\n const parsedDescription = useMemo(() => {\n if (embed.embedData.caption || renderContext === \"article\") {\n return embed.embedData.caption ? parse(embed.embedData.caption) : undefined;\n }\n if (embed.status === \"success\" && embed.data.caption.caption) {\n return parse(embed.data.caption.caption);\n }\n }, [embed, renderContext]);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type={\"image\"} figureType={figureProps?.size} float={figureProps?.float} />;\n }\n\n const { data, embedData } = embed;\n\n const altText = embedData.alt || \"\";\n\n const sizes = getSizes(embedData.size, embedData.align);\n\n const focalPoint = getFocalPoint(embedData);\n const crop = getCrop(embedData);\n\n const toggleImageSize = () => {\n setExpanded((prev) => !prev);\n };\n\n const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);\n\n const figureSize = figureProps?.float ? (figureProps?.size ?? \"medium\") : \"full\";\n\n return (\n <StyledFigure\n float={figureProps?.float}\n size={expanded ? \"full\" : figureSize}\n data-embed-type=\"image\"\n {...licenseProps}\n >\n {children}\n <ImageWrapper border={embedData.border === \"true\"} expandable={!!figureProps?.float}>\n <Image\n focalPoint={focalPoint}\n contentType={data.image.contentType}\n crop={crop}\n sizes={expanded ? expandedSizes : sizes}\n alt={altText}\n src={data.image.imageUrl}\n variants={data.image.variants}\n lang={lang}\n onClick={figureProps?.float ? toggleImageSize : undefined}\n variant=\"rounded\"\n {...data.image.dimensions}\n />\n {(embedData.align === \"right\" || embedData.align === \"left\") && (\n <ExpandButton\n aria-label={t(`license.images.itemImage.zoom${expanded ? \"Out\" : \"\"}ImageButtonLabel`)}\n onClick={toggleImageSize}\n data-expanded={expanded}\n >\n <AddLine />\n </ExpandButton>\n )}\n </ImageWrapper>\n <EmbedByline\n type=\"image\"\n copyright={data.copyright}\n description={parsedDescription}\n hideDescription={embedData.hideCaption === \"true\"}\n hideCopyright={embedData.hideByline === \"true\"}\n visibleAlt={previewAlt ? embed.embedData.alt : \"\"}\n />\n </StyledFigure>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAiCA,MAAM,kBAAkB,MAAe,UAAuC;CAC5E,MAAM,cAAc,UAAU,SAAS,SAAS,UAAU,UAAU,UAAU;CAC9E,MAAM,eAAe,MAAM,QAAQ,gBAAgB,GAAG,IAAI;CAC1D,MAAM,aAA0B,iBAAiB,cAAc,SAAS;AACxE,QAAO;EACL,OAAO;EAEP,MAAM,eAAe,UAAU,QAAQ,WAAW;EACnD;;AAGH,MAAM,YAAY,MAAe,UAAmB;AAClD,KAAI,SAAS,SAAS,OACpB,QAAO;AAET,KAAI,SAAS,SAAS,QACpB,QAAO;AAET,KAAI,SAAS,SAAS,SACpB,QAAO;AAET,QAAO;;AAGT,MAAa,iBAAiB,SAAyB;CACrD,MAAM,SAAS,OAAO,WAAW,KAAK,UAAU,GAAG;CACnD,MAAM,SAAS,OAAO,WAAW,KAAK,UAAU,GAAG;AACnD,KAAI,CAAC,OAAO,MAAM,OAAO,IAAI,CAAC,OAAO,MAAM,OAAO,CAChD,QAAO;EAAE,GAAG;EAAQ,GAAG;EAAQ;;AAKnC,MAAa,WAAW,SAAyB;CAC/C,MAAM,cAAc,OAAO,WAAW,KAAK,eAAe,GAAG;CAC7D,MAAM,cAAc,OAAO,WAAW,KAAK,eAAe,GAAG;CAC7D,MAAM,aAAa,OAAO,WAAW,KAAK,cAAc,GAAG;CAC3D,MAAM,aAAa,OAAO,WAAW,KAAK,cAAc,GAAG;AAC3D,KACE,CAAC,OAAO,MAAM,YAAY,IAC1B,CAAC,OAAO,MAAM,YAAY,IAC1B,CAAC,OAAO,MAAM,WAA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,GAAG,kBAAkB;KACtF,SAAS;KACT,iBAAe;eAEf,2CAACC,wBAAU;MACE;KAEJ;GACf,2CAACC;IACC,MAAK;IACL,WAAW,KAAK;IAChB,aAAa;IACb,iBAAiB,UAAU,gBAAgB;IAC3C,eAAe,UAAU,eAAe;IACxC,YAAY,aAAa,MAAM,UAAU,MAAM;KAC/C;;GACW"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
let react = require("react");
|
|
3
2
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
3
|
+
let react = require("react");
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
let _ndla_util = require("@ndla/util");
|
|
6
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineTriggerButton.js","names":[],"sources":["../../src/Embed/InlineTriggerButton.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"InlineTriggerButton.js","names":[],"sources":["../../src/Embed/InlineTriggerButton.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { composeRefs } from \"@ndla/util\";\nimport { type ComponentPropsWithRef, type KeyboardEvent, forwardRef, useCallback, useRef } from \"react\";\n\nconst StyledSpan = styled(\"span\", { base: {} });\n\nexport const InlineTriggerButton = forwardRef<HTMLSpanElement, ComponentPropsWithRef<\"span\">>(\n ({ onClick, ...props }, ref) => {\n const spanRef = useRef<HTMLSpanElement>(null);\n\n // Emulate a button click when pressing Enter or Space\n const onKeyboardEvent = useCallback((event: KeyboardEvent<HTMLSpanElement>) => {\n if (event.key === \"Enter\" || event.key === \" \") {\n spanRef.current?.click();\n }\n }, []);\n\n return (\n <StyledSpan\n ref={composeRefs(spanRef, ref)}\n onKeyUp={onKeyboardEvent}\n onClick={onClick}\n role=\"button\"\n tabIndex={0}\n {...props}\n />\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,iDAAoB,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;AAE/C,MAAa,6CACV,EAAE,SAAS,GAAG,SAAS,QAAQ;CAC9B,MAAM,4BAAkC,KAAK;CAG7C,MAAM,0CAA+B,UAA0C;AAC7E,MAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,IACzC,SAAQ,SAAS,OAAO;IAEzB,EAAE,CAAC;AAEN,QACE,2CAAC;EACC,iCAAiB,SAAS,IAAI;EAC9B,SAAS;EACA;EACT,MAAK;EACL,UAAU;EACV,GAAI;GACJ;EAGP"}
|
|
@@ -4,13 +4,6 @@ let react_i18next = require("react-i18next");
|
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
|
|
6
6
|
//#region src/Embed/RelatedContentEmbed.tsx
|
|
7
|
-
/**
|
|
8
|
-
* Copyright (c) 2023-present, NDLA.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
7
|
const RelatedContentEmbed = ({ embed, isOembed, subject, ndlaFrontendDomain }) => {
|
|
15
8
|
const { t } = (0, react_i18next.useTranslation)();
|
|
16
9
|
if (embed.status === "error") return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelatedContentEmbed.js","names":["RelatedArticle"],"sources":["../../src/Embed/RelatedContentEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"RelatedContentEmbed.js","names":["RelatedArticle"],"sources":["../../src/Embed/RelatedContentEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { RelatedContentMetaData } from \"@ndla/types-embed\";\nimport { useTranslation } from \"react-i18next\";\nimport { RelatedArticle } from \"../RelatedArticleList/RelatedArticleList\";\n\ninterface Props {\n embed: RelatedContentMetaData;\n isOembed?: boolean;\n subject?: string;\n ndlaFrontendDomain?: string;\n}\n\nexport const RelatedContentEmbed = ({ embed, isOembed, subject, ndlaFrontendDomain }: Props) => {\n const { t } = useTranslation();\n if (embed.status === \"error\") {\n return null;\n }\n\n const { data, embedData } = embed;\n\n if (embedData.articleId && data) {\n const context = data.resource?.contexts.find((c) => c.rootId === subject);\n const url = context?.url ?? data.resource?.url ?? `/article/${embedData.articleId}`;\n return (\n <RelatedArticle\n title={data.article.title?.title ?? \"\"}\n introduction={data.article.metaDescription?.metaDescription ?? \"\"}\n target={isOembed ? \"_blank\" : undefined}\n to={`${ndlaFrontendDomain ?? \"\"}${url ?? \"\"}`}\n />\n );\n }\n if (typeof embedData.url === \"string\") {\n return (\n <RelatedArticle\n title={embedData.title ?? \"\"}\n to={embedData.url}\n target=\"_blank\"\n linkInfo={`${t(\"related.linkInfo\")} ${embedData.urlDomain}`}\n />\n );\n }\n return null;\n};\n"],"mappings":";;;;;;AAmBA,MAAa,uBAAuB,EAAE,OAAO,UAAU,SAAS,yBAAgC;CAC9F,MAAM,EAAE,yCAAsB;AAC9B,KAAI,MAAM,WAAW,QACnB,QAAO;CAGT,MAAM,EAAE,MAAM,cAAc;AAE5B,KAAI,UAAU,aAAa,MAAM;EAE/B,MAAM,OADU,KAAK,UAAU,SAAS,MAAM,MAAM,EAAE,WAAW,QAAQ,GACpD,OAAO,KAAK,UAAU,OAAO,YAAY,UAAU;AACxE,SACE,2CAACA;GACC,OAAO,KAAK,QAAQ,OAAO,SAAS;GACpC,cAAc,KAAK,QAAQ,iBAAiB,mBAAmB;GAC/D,QAAQ,WAAW,WAAW;GAC9B,IAAI,GAAG,sBAAsB,KAAK,OAAO;IACzC;;AAGN,KAAI,OAAO,UAAU,QAAQ,SAC3B,QACE,2CAACA;EACC,OAAO,UAAU,SAAS;EAC1B,IAAI,UAAU;EACd,QAAO;EACP,UAAU,GAAG,EAAE,mBAAmB,CAAC,GAAG,UAAU;GAChD;AAGN,QAAO"}
|
|
@@ -4,13 +4,6 @@ let react_i18next = require("react-i18next");
|
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
|
|
6
6
|
//#region src/Embed/UnknownEmbed.tsx
|
|
7
|
-
/**
|
|
8
|
-
* Copyright (c) 2023-present, NDLA.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
7
|
const UnknownEmbed = ({ embed }) => {
|
|
15
8
|
const { t } = (0, react_i18next.useTranslation)();
|
|
16
9
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ndla_primitives.Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnknownEmbed.js","names":["Text"],"sources":["../../src/Embed/UnknownEmbed.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 {
|
|
1
|
+
{"version":3,"file":"UnknownEmbed.js","names":["Text"],"sources":["../../src/Embed/UnknownEmbed.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 { MetaData } from \"@ndla/types-embed\";\nimport { Text } from \"@ndla/primitives\";\nimport { useTranslation } from \"react-i18next\";\n\ninterface Props {\n embed: MetaData<any, any>;\n}\n\nexport const UnknownEmbed = ({ embed }: Props) => {\n const { t } = useTranslation();\n return (\n <Text color=\"text.error\" asChild consumeCss data-embed-type=\"unknown\">\n <span>{t(\"embed.unsupported\", { type: embed.resource })}</span>\n </Text>\n );\n};\n"],"mappings":";;;;;;AAgBA,MAAa,gBAAgB,EAAE,YAAmB;CAChD,MAAM,EAAE,yCAAsB;AAC9B,QACE,2CAACA;EAAK,OAAM;EAAa;EAAQ;EAAW,mBAAgB;YAC1D,2CAAC,oBAAM,EAAE,qBAAqB,EAAE,MAAM,MAAM,UAAU,CAAC,GAAQ;GAC1D"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { type ReactNode } from "react";
|
|
9
8
|
import type { UuDisclaimerMetaData } from "@ndla/types-embed";
|
|
9
|
+
import { type ReactNode } from "react";
|
|
10
10
|
interface Props {
|
|
11
11
|
embed: UuDisclaimerMetaData;
|
|
12
12
|
transformedDisclaimer: ReactNode;
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
let react = require("react");
|
|
3
2
|
let _ndla_primitives = require("@ndla/primitives");
|
|
4
3
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
4
|
+
let react = require("react");
|
|
5
5
|
let react_i18next = require("react-i18next");
|
|
6
6
|
let _ndla_icons = require("@ndla/icons");
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
let _ark_ui_react = require("@ark-ui/react");
|
|
9
9
|
|
|
10
10
|
//#region src/Embed/UuDisclaimerEmbed.tsx
|
|
11
|
-
/**
|
|
12
|
-
* Copyright (c) 2024-present, NDLA.
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
15
|
-
* LICENSE file in the root directory of this source tree.
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
11
|
const DisclaimerWrapper = (0, _ndla_styled_system_jsx.styled)("div", { base: {
|
|
19
12
|
display: "flex",
|
|
20
13
|
flexDirection: "column",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UuDisclaimerEmbed.js","names":["IconButton","ErrorWarningFill","PopoverContent","PopoverRoot","PopoverTrigger","AccessibilityFill","Portal"],"sources":["../../src/Embed/UuDisclaimerEmbed.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
|
|
1
|
+
{"version":3,"file":"UuDisclaimerEmbed.js","names":["IconButton","ErrorWarningFill","PopoverContent","PopoverRoot","PopoverTrigger","AccessibilityFill","Portal"],"sources":["../../src/Embed/UuDisclaimerEmbed.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 { UuDisclaimerMetaData } from \"@ndla/types-embed\";\nimport { Portal } from \"@ark-ui/react\";\nimport { AccessibilityFill, ErrorWarningFill } from \"@ndla/icons\";\nimport { IconButton, PopoverContent, PopoverRoot, PopoverTrigger } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { type ReactNode } from \"react\";\nimport { useTranslation } from \"react-i18next\";\n\ninterface Props {\n embed: UuDisclaimerMetaData;\n transformedDisclaimer: ReactNode;\n children?: ReactNode;\n}\n\nconst DisclaimerWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"3xsmall\",\n clear: \"both\",\n },\n});\n\nconst StyledIconButton = styled(IconButton, {\n base: {\n alignSelf: \"flex-end\",\n },\n});\n\nconst StyledErrorWarningFill = styled(ErrorWarningFill, {\n base: {\n alignSelf: \"flex-end\",\n fill: \"icon.subtle\",\n },\n});\n\nconst StyledPopoverContent = styled(PopoverContent, {\n base: {\n width: \"surface.xlarge\",\n maxHeight: \"50vh\",\n overflowY: \"auto\",\n },\n});\n\nexport const UuDisclaimerEmbed = ({ embed, transformedDisclaimer, children }: Props) => {\n const { t } = useTranslation();\n if (embed.status === \"error\") {\n return (\n <DisclaimerWrapper>\n <StyledErrorWarningFill\n aria-label={t(\"embed.embedError\", { type: t(\"embed.type.disclaimer\") })}\n title={t(\"embed.embedError\", { type: t(\"embed.type.disclaimer\") })}\n />\n {children}\n </DisclaimerWrapper>\n );\n }\n\n return (\n <DisclaimerWrapper role=\"region\" data-embed-type=\"uu-disclaimer\">\n <PopoverRoot>\n <PopoverTrigger asChild>\n <StyledIconButton\n size=\"small\"\n variant=\"secondary\"\n aria-label={t(\"uuDisclaimer.title\")}\n title={t(\"uuDisclaimer.title\")}\n >\n <AccessibilityFill />\n </StyledIconButton>\n </PopoverTrigger>\n <Portal>\n <StyledPopoverContent>\n <div>{transformedDisclaimer}</div>\n </StyledPopoverContent>\n </Portal>\n </PopoverRoot>\n <div data-uu-content=\"\">{children}</div>\n </DisclaimerWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,wDAA2B,OAAO,EACtC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,OAAO;CACR,EACF,CAAC;AAEF,MAAM,uDAA0BA,6BAAY,EAC1C,MAAM,EACJ,WAAW,YACZ,EACF,CAAC;AAEF,MAAM,6DAAgCC,8BAAkB,EACtD,MAAM;CACJ,WAAW;CACX,MAAM;CACP,EACF,CAAC;AAEF,MAAM,2DAA8BC,iCAAgB,EAClD,MAAM;CACJ,OAAO;CACP,WAAW;CACX,WAAW;CACZ,EACF,CAAC;AAEF,MAAa,qBAAqB,EAAE,OAAO,uBAAuB,eAAsB;CACtF,MAAM,EAAE,yCAAsB;AAC9B,KAAI,MAAM,WAAW,QACnB,QACE,4CAAC,gCACC,2CAAC;EACC,cAAY,EAAE,oBAAoB,EAAE,MAAM,EAAE,wBAAwB,EAAE,CAAC;EACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,wBAAwB,EAAE,CAAC;GAClE,EACD,YACiB;AAIxB,QACE,4CAAC;EAAkB,MAAK;EAAS,mBAAgB;aAC/C,4CAACC,2CACC,2CAACC;GAAe;aACd,2CAAC;IACC,MAAK;IACL,SAAQ;IACR,cAAY,EAAE,qBAAqB;IACnC,OAAO,EAAE,qBAAqB;cAE9B,2CAACC,kCAAoB;KACJ;IACJ,EACjB,2CAACC,kCACC,2CAAC,kCACC,2CAAC,mBAAK,wBAA4B,GACb,GAChB,IACG,EACd,2CAAC;GAAI,mBAAgB;GAAI;IAAe;GACtB"}
|
package/lib/Embed/types.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { ElementType } from "react";
|
|
9
8
|
import type { ImageMetaInformationV3DTO } from "@ndla/types-backend/image-api";
|
|
10
9
|
import type { EmbedMetaData } from "@ndla/types-embed";
|
|
10
|
+
import type { ElementType } from "react";
|
|
11
11
|
export type HeartButtonType = ElementType<{
|
|
12
12
|
embed: Extract<EmbedMetaData, {
|
|
13
13
|
status: "success";
|
package/lib/FactBox/FactBox.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
let react = require("react");
|
|
3
|
-
react = require_rolldown_runtime.__toESM(react);
|
|
4
2
|
let _ndla_primitives = require("@ndla/primitives");
|
|
5
3
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
6
6
|
let react_i18next = require("react-i18next");
|
|
7
7
|
let _ndla_icons = require("@ndla/icons");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FactBox.js","names":["IconButton","React","ArrowDownShortLine"],"sources":["../../src/FactBox/FactBox.tsx"],"sourcesContent":["/**\n * Copyright (c) 2016-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"FactBox.js","names":["IconButton","React","ArrowDownShortLine"],"sources":["../../src/FactBox/FactBox.tsx"],"sourcesContent":["/**\n * Copyright (c) 2016-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { ArrowDownShortLine } from \"@ndla/icons\";\nimport { IconButton } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport React, {\n type ComponentProps,\n type ReactNode,\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { useTranslation } from \"react-i18next\";\n\ninterface Props extends ComponentProps<\"aside\"> {\n children?: ReactNode;\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\nconst StyledAside = styled(\"aside\", {\n base: {\n position: \"relative\",\n padding: \"medium\",\n display: \"grid\",\n gridTemplateRows: \"0fr\",\n transitionProperty: \"grid-template-rows\",\n transitionDuration: \"slow\",\n transitionTimingFunction: \"ease-in-out\",\n justifyItems: \"center\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n borderRadius: \"xsmall\",\n clear: \"both\",\n _open: {\n gridTemplateRows: \"1fr\",\n },\n _closed: {\n _print: {\n overflow: \"visible\",\n maxHeight: \"500vh\",\n },\n },\n \"& > div\": {\n minHeight: \"surface.3xsmall\",\n },\n },\n variants: {\n overflowHidden: {\n true: {\n \"& > div\": {\n overflow: \"hidden\",\n },\n },\n },\n },\n});\n\nconst StyledContent = styled(\"div\", {\n base: {\n position: \"relative\",\n width: \"100%\",\n // Reset the top margin of the very first child.\n \"& :first-child\": {\n marginBlockStart: \"0\",\n },\n _after: {\n content: '\"\"',\n textAlign: \"center\",\n position: \"absolute\",\n inset: \"0\",\n transitionProperty: \"opacity\",\n transitionDuration: \"slow\",\n transitionTimingFunction: \"ease-in-out\",\n gradientFrom: \"surface.default/20\",\n gradientTo: \"surface.default/95\",\n backgroundGradient: \"to-b\",\n opacity: \"1\",\n zIndex: \"base\",\n pointerEvents: \"none\",\n },\n _print: {\n overflow: \"visible\",\n _after: {\n display: \"none\",\n },\n },\n _open: {\n paddingBlockEnd: \"xsmall\",\n _after: {\n opacity: \"0\",\n },\n },\n },\n});\n\nconst StyledIconButton = styled(IconButton, {\n base: {\n position: \"absolute\",\n bottom: \"-medium\",\n zIndex: \"base\",\n \"& svg\": {\n transitionProperty: \"transform\",\n transitionTimingFunction: \"ease-in-out\",\n transitionDuration: \"fast\",\n },\n _open: {\n \"& svg\": {\n transform: \"rotate(180deg)\",\n },\n },\n _print: {\n display: \"none\",\n },\n },\n});\n\n// TODO: Consider moving the open trigger depending on whether the content is open or closed.\n\nexport const FactBox = forwardRef<HTMLElement, Props>(\n ({ children, open, onOpenChange, defaultOpen = false, ...rest }, ref) => {\n const { t } = useTranslation();\n const [state, setState] = useState<\"open\" | \"closed\">(defaultOpen ? \"open\" : \"closed\");\n const [overflowHidden, setOverflowHidden] = useState(!defaultOpen);\n const contentId = useId();\n // Inert has existed since early 2023. It allows us to disable tabindex inside the content if it is closed, allowing us to be accessible for users with newish browsers. React 18 removes this because it doesn't recognize the attribute. This is a workaround for that.\n // When running in React 18, we need to use an empty string instead of true.\n // TODO: Remove this hack once we upgrade to React 19 as a peer dep.\n const inertAttribute = useMemo(() => {\n return state === \"closed\" ? { inert: typeof React.use === \"function\" ? true : \"\" } : {};\n }, [state]) as { inert?: boolean };\n\n useEffect(() => {\n if (open !== undefined) {\n setState(open ? \"open\" : \"closed\");\n }\n }, [open]);\n\n const onClick = useCallback(() => {\n const newState = state === \"open\" ? \"closed\" : \"open\";\n setState(newState);\n onOpenChange?.(newState === \"open\");\n }, [state, onOpenChange]);\n\n return (\n <StyledAside\n data-state={state}\n data-embed-type=\"factbox\"\n {...rest}\n ref={ref}\n overflowHidden={overflowHidden}\n onTransitionStart={(e) => {\n if (e.target === e.currentTarget && state === \"closed\") {\n setOverflowHidden(true);\n }\n }}\n onTransitionEnd={(e) => {\n if (e.target === e.currentTarget && state === \"open\") {\n setOverflowHidden(false);\n }\n }}\n >\n <StyledIconButton\n data-state={state}\n onClick={onClick}\n contentEditable={false}\n aria-expanded={state === \"open\"}\n aria-controls={contentId}\n aria-label={t(`factbox.${state === \"open\" ? \"close\" : \"open\"}`)}\n >\n <ArrowDownShortLine />\n </StyledIconButton>\n <StyledContent id={contentId} data-state={state} aria-hidden={state === \"closed\"} {...inertAttribute}>\n {children}\n </StyledContent>\n </StyledAside>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;AA8BA,MAAM,kDAAqB,SAAS;CAClC,MAAM;EACJ,UAAU;EACV,SAAS;EACT,SAAS;EACT,kBAAkB;EAClB,oBAAoB;EACpB,oBAAoB;EACpB,0BAA0B;EAC1B,cAAc;EACd,QAAQ;EACR,aAAa;EACb,cAAc;EACd,OAAO;EACP,OAAO,EACL,kBAAkB,OACnB;EACD,SAAS,EACP,QAAQ;GACN,UAAU;GACV,WAAW;GACZ,EACF;EACD,WAAW,EACT,WAAW,mBACZ;EACF;CACD,UAAU,EACR,gBAAgB,EACd,MAAM,EACJ,WAAW,EACT,UAAU,UACX,EACF,EACF,EACF;CACF,CAAC;AAEF,MAAM,oDAAuB,OAAO,EAClC,MAAM;CACJ,UAAU;CACV,OAAO;CAEP,kBAAkB,EAChB,kBAAkB,KACnB;CACD,QAAQ;EACN,SAAS;EACT,WAAW;EACX,UAAU;EACV,OAAO;EACP,oBAAoB;EACpB,oBAAoB;EACpB,0BAA0B;EAC1B,cAAc;EACd,YAAY;EACZ,oBAAoB;EACpB,SAAS;EACT,QAAQ;EACR,eAAe;EAChB;CACD,QAAQ;EACN,UAAU;EACV,Q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AAW,UAAU,SAAS,UAAU,SAAS;aAE/D,2CAACC,mCAAqB;IACL,EACnB,2CAAC;GAAc,IAAI;GAAW,cAAY;GAAO,eAAa,UAAU;GAAU,GAAI;GACnF;IACa;GACJ;EAGnB"}
|
package/lib/FileList/File.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
2
|
const require_FileList = require('./FileList.js');
|
|
3
|
-
let react = require("react");
|
|
4
3
|
let _ndla_primitives = require("@ndla/primitives");
|
|
5
4
|
let _ndla_styled_system_jsx = require("@ndla/styled-system/jsx");
|
|
5
|
+
let react = require("react");
|
|
6
6
|
let react_i18next = require("react-i18next");
|
|
7
7
|
let _ndla_icons = require("@ndla/icons");
|
|
8
8
|
let _ndla_safelink = require("@ndla/safelink");
|