@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,158 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_Controls = require('./Controls.js');
|
|
3
|
+
const require_SpeechControl = require('./SpeechControl.js');
|
|
4
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
5
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
6
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
7
|
+
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
8
|
+
const __ndla_safelink = require_rolldown_runtime.__toESM(require("@ndla/safelink"));
|
|
9
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
10
|
+
|
|
11
|
+
//#region src/AudioPlayer/AudioPlayer.tsx
|
|
12
|
+
const AudioPlayerWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
13
|
+
border: "1px solid",
|
|
14
|
+
borderColor: "stroke.default",
|
|
15
|
+
borderRadius: "xsmall",
|
|
16
|
+
boxShadow: "full",
|
|
17
|
+
marginBlockEnd: "4xsmall",
|
|
18
|
+
overflow: "hidden"
|
|
19
|
+
} });
|
|
20
|
+
const InfoWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
21
|
+
display: "flex",
|
|
22
|
+
tabletWideDown: { display: "block" }
|
|
23
|
+
} });
|
|
24
|
+
const ImageWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
flex: "1 0 auto",
|
|
28
|
+
width: "surface.4xsmall",
|
|
29
|
+
height: "surface.4xsmall",
|
|
30
|
+
overflow: "hidden",
|
|
31
|
+
"& img": {
|
|
32
|
+
width: "100%",
|
|
33
|
+
height: "100%",
|
|
34
|
+
objectFit: "cover"
|
|
35
|
+
},
|
|
36
|
+
desktop: {
|
|
37
|
+
width: "260px",
|
|
38
|
+
height: "260px"
|
|
39
|
+
},
|
|
40
|
+
tabletWideDown: {
|
|
41
|
+
maxHeight: "surface.small",
|
|
42
|
+
maxWidth: "100%",
|
|
43
|
+
width: "100%",
|
|
44
|
+
height: "auto"
|
|
45
|
+
}
|
|
46
|
+
} });
|
|
47
|
+
const TextWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
48
|
+
display: "flex",
|
|
49
|
+
alignItems: "flex-start",
|
|
50
|
+
flexDirection: "column",
|
|
51
|
+
gap: "xsmall",
|
|
52
|
+
padding: "xsmall",
|
|
53
|
+
width: "100%",
|
|
54
|
+
"&[data-has-image='true']": { tablet: {
|
|
55
|
+
paddingBlock: "xsmall",
|
|
56
|
+
paddingInline: "medium"
|
|
57
|
+
} }
|
|
58
|
+
} });
|
|
59
|
+
const TitleWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
60
|
+
display: "flex",
|
|
61
|
+
flexDirection: "column",
|
|
62
|
+
gap: "xsmall",
|
|
63
|
+
fontFamily: "sans",
|
|
64
|
+
tabletWide: {
|
|
65
|
+
width: "100%",
|
|
66
|
+
flexDirection: "row",
|
|
67
|
+
justifyContent: "space-between"
|
|
68
|
+
}
|
|
69
|
+
} });
|
|
70
|
+
const TextVersionWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
71
|
+
display: "flex",
|
|
72
|
+
flexDirection: "column",
|
|
73
|
+
gap: "xsmall",
|
|
74
|
+
borderBlockStart: "1px solid",
|
|
75
|
+
borderColor: "stroke.default",
|
|
76
|
+
paddingBlock: "medium",
|
|
77
|
+
paddingInline: "xsmall",
|
|
78
|
+
tablet: { paddingInline: "medium" }
|
|
79
|
+
} });
|
|
80
|
+
const TextVersionText = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
81
|
+
maxWidth: "surface.xlarge",
|
|
82
|
+
"& span > *": { whiteSpace: "pre-wrap" },
|
|
83
|
+
"& p:not(:first-child):not(:last-child)": { marginBlock: "small" },
|
|
84
|
+
"& p[data-align=\"center\"]": { textAlign: "center" },
|
|
85
|
+
"& p:has(span[dir=\"rtl\"])": { direction: "rtl" }
|
|
86
|
+
} });
|
|
87
|
+
const TextVersionButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Button, { base: { alignSelf: "flex-start" } });
|
|
88
|
+
const ShowMoreButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Button, { base: { marginInlineStart: "3xsmall" } });
|
|
89
|
+
const DESCRIPTION_MAX_LENGTH = 200;
|
|
90
|
+
const AudioPlayer = ({ src, title, subtitle, speech, description, img, textVersion }) => {
|
|
91
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
92
|
+
const [showTextVersion, setShowTextVersion] = (0, react.useState)(false);
|
|
93
|
+
const [showFullDescription, setShowFullDescription] = (0, react.useState)(false);
|
|
94
|
+
const truncatedDescription = (0, react.useMemo)(() => description?.slice(0, DESCRIPTION_MAX_LENGTH), [description]);
|
|
95
|
+
const textDescriptionId = (0, react.useId)();
|
|
96
|
+
if (speech) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SpeechControl.SpeechControl_default, {
|
|
97
|
+
src,
|
|
98
|
+
title
|
|
99
|
+
});
|
|
100
|
+
const toggleTextVersion = () => {
|
|
101
|
+
setShowTextVersion((curr) => !curr);
|
|
102
|
+
};
|
|
103
|
+
const textVersionButton = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextVersionButton, {
|
|
104
|
+
variant: "secondary",
|
|
105
|
+
"aria-expanded": showTextVersion,
|
|
106
|
+
"aria-controls": textDescriptionId,
|
|
107
|
+
size: "small",
|
|
108
|
+
onClick: toggleTextVersion,
|
|
109
|
+
children: t(showTextVersion ? "audio.textVersion.close" : "audio.textVersion.heading")
|
|
110
|
+
});
|
|
111
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(AudioPlayerWrapper, { children: [
|
|
112
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(InfoWrapper, { children: [!!img && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
113
|
+
src: img.url,
|
|
114
|
+
alt: img.alt
|
|
115
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TextWrapper, {
|
|
116
|
+
"data-has-image": !!img,
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TitleWrapper, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [subtitle?.url ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_safelink.SafeLink, {
|
|
119
|
+
to: subtitle.url,
|
|
120
|
+
children: subtitle.title
|
|
121
|
+
}) : subtitle?.title, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Heading, {
|
|
122
|
+
asChild: true,
|
|
123
|
+
consumeCss: true,
|
|
124
|
+
textStyle: "title.large",
|
|
125
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title })
|
|
126
|
+
})] }), !!textVersion && !img && textVersionButton] }),
|
|
127
|
+
!!description && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.Text, {
|
|
128
|
+
textStyle: "body.medium",
|
|
129
|
+
children: [showFullDescription || description.length < DESCRIPTION_MAX_LENGTH ? description : `${truncatedDescription}...`, description.length > DESCRIPTION_MAX_LENGTH && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShowMoreButton, {
|
|
130
|
+
variant: "link",
|
|
131
|
+
onClick: () => setShowFullDescription((p) => !p),
|
|
132
|
+
children: t(`audio.${showFullDescription ? "readLessDescriptionLabel" : "readMoreDescriptionLabel"}`)
|
|
133
|
+
})]
|
|
134
|
+
}),
|
|
135
|
+
!!textVersion && !!img && textVersionButton
|
|
136
|
+
]
|
|
137
|
+
})] }),
|
|
138
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Controls.Controls_default, {
|
|
139
|
+
src,
|
|
140
|
+
title
|
|
141
|
+
}),
|
|
142
|
+
!!textVersion && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TextVersionWrapper, {
|
|
143
|
+
id: textDescriptionId,
|
|
144
|
+
hidden: !showTextVersion,
|
|
145
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Heading, {
|
|
146
|
+
asChild: true,
|
|
147
|
+
textStyle: "title.medium",
|
|
148
|
+
consumeCss: true,
|
|
149
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", { children: t("audio.textVersion.heading") })
|
|
150
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextVersionText, { children: textVersion })]
|
|
151
|
+
})
|
|
152
|
+
] });
|
|
153
|
+
};
|
|
154
|
+
var AudioPlayer_default = AudioPlayer;
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
exports.AudioPlayer_default = AudioPlayer_default;
|
|
158
|
+
//# sourceMappingURL=AudioPlayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioPlayer.js","names":["Button","SpeechControl","SafeLink","Heading","Text","Controls"],"sources":["../../src/AudioPlayer/AudioPlayer.tsx"],"sourcesContent":["/**\n * Copyright (c) 2017-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type ReactNode, useId, useMemo, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Heading, Text, Button } from \"@ndla/primitives\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport Controls from \"./Controls\";\nimport SpeechControl from \"./SpeechControl\";\n\n// TODO: Could the audio metadata be more tightly coupled to the audio player?\n\nconst AudioPlayerWrapper = styled(\"div\", {\n base: {\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n borderRadius: \"xsmall\",\n boxShadow: \"full\",\n marginBlockEnd: \"4xsmall\",\n overflow: \"hidden\",\n },\n});\n\nconst InfoWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n tabletWideDown: {\n display: \"block\",\n },\n },\n});\n\nconst ImageWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n flex: \"1 0 auto\",\n width: \"surface.4xsmall\",\n height: \"surface.4xsmall\",\n overflow: \"hidden\",\n \"& img\": {\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n },\n desktop: {\n width: \"260px\",\n height: \"260px\",\n },\n tabletWideDown: {\n maxHeight: \"surface.small\",\n maxWidth: \"100%\",\n width: \"100%\",\n height: \"auto\",\n },\n },\n});\n\nconst TextWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n alignItems: \"flex-start\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n padding: \"xsmall\",\n width: \"100%\",\n \"&[data-has-image='true']\": {\n tablet: {\n paddingBlock: \"xsmall\",\n paddingInline: \"medium\",\n },\n },\n },\n});\n\nconst TitleWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n fontFamily: \"sans\",\n tabletWide: {\n width: \"100%\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n },\n },\n});\n\nconst TextVersionWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n borderBlockStart: \"1px solid\",\n borderColor: \"stroke.default\",\n paddingBlock: \"medium\",\n paddingInline: \"xsmall\",\n tablet: {\n paddingInline: \"medium\",\n },\n },\n});\n\nconst TextVersionText = styled(\"div\", {\n base: {\n maxWidth: \"surface.xlarge\",\n \"& span > *\": {\n whiteSpace: \"pre-wrap\",\n },\n \"& p:not(:first-child):not(:last-child)\": {\n marginBlock: \"small\",\n },\n '& p[data-align=\"center\"]': {\n textAlign: \"center\",\n },\n '& p:has(span[dir=\"rtl\"])': {\n direction: \"rtl\",\n },\n },\n});\n\nconst TextVersionButton = styled(Button, {\n base: {\n alignSelf: \"flex-start\",\n },\n});\n\nconst ShowMoreButton = styled(Button, {\n base: {\n marginInlineStart: \"3xsmall\",\n },\n});\n\nconst DESCRIPTION_MAX_LENGTH = 200;\n\ntype Props = {\n src: string;\n title: string;\n subtitle?: {\n title: string;\n url?: string;\n };\n speech?: boolean;\n description?: string;\n textVersion?: ReactNode;\n img?: {\n url: string;\n alt: string;\n };\n};\n\nconst AudioPlayer = ({ src, title, subtitle, speech, description, img, textVersion }: Props) => {\n const { t } = useTranslation();\n const [showTextVersion, setShowTextVersion] = useState(false);\n const [showFullDescription, setShowFullDescription] = useState(false);\n const truncatedDescription = useMemo(() => description?.slice(0, DESCRIPTION_MAX_LENGTH), [description]);\n const textDescriptionId = useId();\n\n if (speech) {\n return <SpeechControl src={src} title={title} />;\n }\n\n const toggleTextVersion = () => {\n setShowTextVersion((curr) => !curr);\n };\n\n const textVersionButton = (\n <TextVersionButton\n variant=\"secondary\"\n aria-expanded={showTextVersion}\n aria-controls={textDescriptionId}\n size=\"small\"\n onClick={toggleTextVersion}\n >\n {t(showTextVersion ? \"audio.textVersion.close\" : \"audio.textVersion.heading\")}\n </TextVersionButton>\n );\n\n return (\n <AudioPlayerWrapper>\n <InfoWrapper>\n {!!img && (\n <ImageWrapper>\n <img src={img.url} alt={img.alt} />\n </ImageWrapper>\n )}\n <TextWrapper data-has-image={!!img}>\n <TitleWrapper>\n <div>\n {subtitle?.url ? <SafeLink to={subtitle.url}>{subtitle.title}</SafeLink> : subtitle?.title}\n <Heading asChild consumeCss textStyle=\"title.large\">\n <h3>{title}</h3>\n </Heading>\n </div>\n {!!textVersion && !img && textVersionButton}\n </TitleWrapper>\n {!!description && (\n <Text textStyle=\"body.medium\">\n {showFullDescription || description.length < DESCRIPTION_MAX_LENGTH\n ? description\n : `${truncatedDescription}...`}\n {description.length > DESCRIPTION_MAX_LENGTH && (\n <ShowMoreButton variant=\"link\" onClick={() => setShowFullDescription((p) => !p)}>\n {t(`audio.${showFullDescription ? \"readLessDescriptionLabel\" : \"readMoreDescriptionLabel\"}`)}\n </ShowMoreButton>\n )}\n </Text>\n )}\n {!!textVersion && !!img && textVersionButton}\n </TextWrapper>\n </InfoWrapper>\n <Controls src={src} title={title} />\n {!!textVersion && (\n <TextVersionWrapper id={textDescriptionId} hidden={!showTextVersion}>\n <Heading asChild textStyle=\"title.medium\" consumeCss>\n <h4>{t(\"audio.textVersion.heading\")}</h4>\n </Heading>\n <TextVersionText>{textVersion}</TextVersionText>\n </TextVersionWrapper>\n )}\n </AudioPlayerWrapper>\n );\n};\n\nexport default AudioPlayer;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
3
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
4
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
5
|
+
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
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
|
+
const __ark_ui_react = require_rolldown_runtime.__toESM(require("@ark-ui/react"));
|
|
9
|
+
|
|
10
|
+
//#region src/AudioPlayer/Controls.tsx
|
|
11
|
+
const ControlsWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
12
|
+
borderBlockStart: "1px solid",
|
|
13
|
+
borderColor: "stroke.default",
|
|
14
|
+
borderBottomRadius: "xsmall",
|
|
15
|
+
display: "flex",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
background: "background.default",
|
|
19
|
+
gap: "xsmall",
|
|
20
|
+
paddingBlock: "xsmall",
|
|
21
|
+
paddingInline: "medium",
|
|
22
|
+
tabletWideDown: {
|
|
23
|
+
display: "grid",
|
|
24
|
+
paddingBlock: "xsmall",
|
|
25
|
+
paddingInline: "xsmall",
|
|
26
|
+
gridTemplateColumns: "1fr repeat(5, auto) 1fr",
|
|
27
|
+
gridTemplateAreas: `
|
|
28
|
+
"track track track track track track track"
|
|
29
|
+
". speed backwards play forwards volume ."
|
|
30
|
+
`
|
|
31
|
+
},
|
|
32
|
+
mobileWideDown: { columnGap: "3xsmall" }
|
|
33
|
+
} });
|
|
34
|
+
const PlayButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.IconButton, { base: { gridArea: "play" } });
|
|
35
|
+
const Forward15SecButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.IconButton, { base: { gridArea: "forwards" } });
|
|
36
|
+
const Back15SecButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.IconButton, { base: { gridArea: "backwards" } });
|
|
37
|
+
const ProgressWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
38
|
+
flex: "1",
|
|
39
|
+
display: "flex",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
gap: "xxsmall",
|
|
42
|
+
gridArea: "track",
|
|
43
|
+
paddingBlock: "xsmall",
|
|
44
|
+
mobileDown: { paddingInline: "xsmall" }
|
|
45
|
+
} });
|
|
46
|
+
const StyledText = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Text, { base: {
|
|
47
|
+
minWidth: "xxlarge",
|
|
48
|
+
flexShrink: "0",
|
|
49
|
+
textAlign: "center"
|
|
50
|
+
} });
|
|
51
|
+
const VolumeButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.IconButton, { base: { gridArea: "volume" } });
|
|
52
|
+
const SpeedButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Button, { base: {
|
|
53
|
+
paddingBlock: "auto",
|
|
54
|
+
paddingInline: "auto",
|
|
55
|
+
maxWidth: "xxlarge",
|
|
56
|
+
maxHeight: "xxlarge",
|
|
57
|
+
minWidth: "xxlarge",
|
|
58
|
+
minHeight: "xxlarge",
|
|
59
|
+
"& span": { flex: "1" }
|
|
60
|
+
} });
|
|
61
|
+
const StyledSelectRoot = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.SelectRoot, { base: { gridArea: "speed" } });
|
|
62
|
+
const StyledSliderControl = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.SliderControl, { base: {
|
|
63
|
+
height: "surface.3xsmall",
|
|
64
|
+
minWidth: "small"
|
|
65
|
+
} });
|
|
66
|
+
const StyledPopoverContent = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.PopoverContent, { base: { paddingInline: "small" } });
|
|
67
|
+
const formatTime = (seconds) => {
|
|
68
|
+
const minutes = Math.floor(seconds / 60);
|
|
69
|
+
const currentSeconds = seconds % 60;
|
|
70
|
+
const formattedSeconds = currentSeconds < 10 ? `0${currentSeconds}` : currentSeconds;
|
|
71
|
+
return `${minutes}:${formattedSeconds}`;
|
|
72
|
+
};
|
|
73
|
+
const speedValues = (0, __ark_ui_react.createListCollection)({ items: [
|
|
74
|
+
"0.5",
|
|
75
|
+
"0.75",
|
|
76
|
+
"1",
|
|
77
|
+
"1.25",
|
|
78
|
+
"1.5",
|
|
79
|
+
"1.75",
|
|
80
|
+
"2"
|
|
81
|
+
] });
|
|
82
|
+
const Controls = ({ src, title }) => {
|
|
83
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
84
|
+
const [speedValue, setSpeedValue] = (0, react.useState)(1);
|
|
85
|
+
const [volumeValue, setVolumeValue] = (0, react.useState)(100);
|
|
86
|
+
const [currentTime, setCurrentTime] = (0, react.useState)(0);
|
|
87
|
+
const [remainingTime, setRemainingTime] = (0, react.useState)(0);
|
|
88
|
+
const [playing, setPlaying] = (0, react.useState)(false);
|
|
89
|
+
const audioRef = (0, react.useRef)(null);
|
|
90
|
+
(0, react.useEffect)(() => {
|
|
91
|
+
if (audioRef.current) audioRef.current.playbackRate = speedValue;
|
|
92
|
+
}, [speedValue]);
|
|
93
|
+
(0, react.useEffect)(() => {
|
|
94
|
+
if (audioRef.current) {
|
|
95
|
+
const audioElement = audioRef.current;
|
|
96
|
+
const handleTimeUpdate = () => {
|
|
97
|
+
const { currentTime: currentTime$1, duration } = audioElement;
|
|
98
|
+
setCurrentTime(Math.round(currentTime$1));
|
|
99
|
+
setRemainingTime(Math.round(duration - currentTime$1));
|
|
100
|
+
};
|
|
101
|
+
const handleLoadedMetaData = () => {
|
|
102
|
+
const { currentTime: currentTime$1, duration } = audioElement;
|
|
103
|
+
setCurrentTime(Math.round(currentTime$1));
|
|
104
|
+
setRemainingTime(Math.round(duration - currentTime$1));
|
|
105
|
+
};
|
|
106
|
+
const handleTimeEnded = () => {
|
|
107
|
+
setPlaying(false);
|
|
108
|
+
};
|
|
109
|
+
audioElement.addEventListener("timeupdate", handleTimeUpdate);
|
|
110
|
+
audioElement.addEventListener("loadedmetadata", handleLoadedMetaData);
|
|
111
|
+
audioElement.addEventListener("ended", handleTimeEnded);
|
|
112
|
+
return () => {
|
|
113
|
+
audioElement.removeEventListener("timeupdate", handleTimeUpdate);
|
|
114
|
+
audioElement.removeEventListener("loadedmetadata", handleLoadedMetaData);
|
|
115
|
+
audioElement.removeEventListener("ended", handleTimeEnded);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}, []);
|
|
119
|
+
const togglePlay = () => {
|
|
120
|
+
if (audioRef.current) {
|
|
121
|
+
const audioElement = audioRef.current;
|
|
122
|
+
if (!playing) audioElement.play();
|
|
123
|
+
else audioElement.pause();
|
|
124
|
+
setPlaying(!playing);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const onSeekSeconds = (seconds) => {
|
|
128
|
+
if (audioRef.current) audioRef.current.currentTime += seconds;
|
|
129
|
+
};
|
|
130
|
+
const handleSliderChange = (details) => {
|
|
131
|
+
const newValue = details.value[0];
|
|
132
|
+
if (audioRef.current && newValue != null && !isNaN(newValue)) audioRef.current.currentTime = details.value[0];
|
|
133
|
+
};
|
|
134
|
+
const handleVolumeSliderChange = (details) => {
|
|
135
|
+
if (audioRef.current) {
|
|
136
|
+
audioRef.current.volume = details.value[0] / 100;
|
|
137
|
+
setVolumeValue(details.value[0]);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("audio", {
|
|
141
|
+
ref: audioRef,
|
|
142
|
+
src,
|
|
143
|
+
title,
|
|
144
|
+
preload: "metadata"
|
|
145
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ControlsWrapper, { children: [
|
|
146
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Back15SecButton, {
|
|
147
|
+
variant: "tertiary",
|
|
148
|
+
title: t("audio.controls.rewind15sec"),
|
|
149
|
+
"aria-label": t("audio.controls.rewind15sec"),
|
|
150
|
+
onClick: () => onSeekSeconds(-15),
|
|
151
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.Replay15Line, {})
|
|
152
|
+
}),
|
|
153
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PlayButton, {
|
|
154
|
+
"aria-label": t(playing ? t("audio.pause") : t("audio.play")),
|
|
155
|
+
variant: "primary",
|
|
156
|
+
onClick: togglePlay,
|
|
157
|
+
children: playing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.PauseLine, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.PlayFill, {})
|
|
158
|
+
}),
|
|
159
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Forward15SecButton, {
|
|
160
|
+
variant: "tertiary",
|
|
161
|
+
title: t("audio.controls.forward15sec"),
|
|
162
|
+
"aria-label": t("audio.controls.forward15sec"),
|
|
163
|
+
onClick: () => onSeekSeconds(15),
|
|
164
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.Forward15Line, {})
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ProgressWrapper, { children: [
|
|
167
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledText, {
|
|
168
|
+
textStyle: "label.medium",
|
|
169
|
+
asChild: true,
|
|
170
|
+
consumeCss: true,
|
|
171
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: formatTime(currentTime) })
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.SliderRoot, {
|
|
174
|
+
value: [audioRef.current?.currentTime ?? 0],
|
|
175
|
+
defaultValue: [0],
|
|
176
|
+
step: 1,
|
|
177
|
+
max: Math.round(audioRef.current?.duration ?? 0),
|
|
178
|
+
onValueChange: handleSliderChange,
|
|
179
|
+
getAriaValueText: (value) => t("audio.valueText", {
|
|
180
|
+
start: formatTime(Math.round(value.value)),
|
|
181
|
+
end: formatTime(Math.round(audioRef.current?.duration ?? 0))
|
|
182
|
+
}),
|
|
183
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderLabel, {
|
|
184
|
+
srOnly: true,
|
|
185
|
+
children: t("audio.progressBar")
|
|
186
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.SliderControl, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderTrack, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderRange, {}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderThumb, {
|
|
187
|
+
index: 0,
|
|
188
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderHiddenInput, {})
|
|
189
|
+
})] })]
|
|
190
|
+
}),
|
|
191
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledText, {
|
|
192
|
+
textStyle: "label.medium",
|
|
193
|
+
asChild: true,
|
|
194
|
+
consumeCss: true,
|
|
195
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: ["-", formatTime(remainingTime)] })
|
|
196
|
+
})
|
|
197
|
+
] }),
|
|
198
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.FieldRoot, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledSelectRoot, {
|
|
199
|
+
collection: speedValues,
|
|
200
|
+
value: [speedValue.toString()],
|
|
201
|
+
onValueChange: (details) => setSpeedValue(parseFloat(details.value[0])),
|
|
202
|
+
positioning: { placement: "top" },
|
|
203
|
+
children: [
|
|
204
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SelectLabel, {
|
|
205
|
+
srOnly: true,
|
|
206
|
+
children: t("audio.controls.selectSpeed")
|
|
207
|
+
}),
|
|
208
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SelectControl, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SelectTrigger, {
|
|
209
|
+
asChild: true,
|
|
210
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SpeedButton, {
|
|
211
|
+
variant: "tertiary",
|
|
212
|
+
title: t("audio.controls.selectSpeed"),
|
|
213
|
+
"aria-label": t("audio.controls.selectSpeed"),
|
|
214
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: `${speedValue}x` })
|
|
215
|
+
})
|
|
216
|
+
}) }),
|
|
217
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SelectContent, { children: speedValues.items.map((speed) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.SelectItem, {
|
|
218
|
+
item: speed,
|
|
219
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.SelectItemText, { children: [speed, "x"] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SelectItemIndicator, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.CheckLine, {}) })]
|
|
220
|
+
}, speed)) })
|
|
221
|
+
]
|
|
222
|
+
}) }),
|
|
223
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.PopoverRoot, {
|
|
224
|
+
positioning: { placement: "top" },
|
|
225
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.PopoverTrigger, {
|
|
226
|
+
asChild: true,
|
|
227
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VolumeButton, {
|
|
228
|
+
variant: "tertiary",
|
|
229
|
+
"aria-label": t("audio.controls.adjustVolume"),
|
|
230
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.VolumeUpFill, {})
|
|
231
|
+
})
|
|
232
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledPopoverContent, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.SliderRoot, {
|
|
233
|
+
orientation: "vertical",
|
|
234
|
+
value: [volumeValue],
|
|
235
|
+
min: 0,
|
|
236
|
+
max: 100,
|
|
237
|
+
defaultValue: [100],
|
|
238
|
+
step: 1,
|
|
239
|
+
onValueChange: handleVolumeSliderChange,
|
|
240
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderLabel, {
|
|
241
|
+
srOnly: true,
|
|
242
|
+
children: t("audio.controls.adjustVolume")
|
|
243
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledSliderControl, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderTrack, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderRange, {}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderThumb, {
|
|
244
|
+
index: 0,
|
|
245
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.SliderHiddenInput, {})
|
|
246
|
+
})] })]
|
|
247
|
+
}) })]
|
|
248
|
+
})
|
|
249
|
+
] })] });
|
|
250
|
+
};
|
|
251
|
+
var Controls_default = Controls;
|
|
252
|
+
|
|
253
|
+
//#endregion
|
|
254
|
+
exports.Controls_default = Controls_default;
|
|
255
|
+
//# sourceMappingURL=Controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Controls.js","names":["IconButton","Text","Button","SelectRoot","SliderControl","PopoverContent","seconds: number","currentTime","details: SliderValueChangeDetails","Replay15Line","PauseLine","PlayFill","Forward15Line","SliderRoot","SliderLabel","SliderTrack","SliderRange","SliderThumb","SliderHiddenInput","FieldRoot","SelectLabel","SelectControl","SelectTrigger","SelectContent","SelectItem","SelectItemText","SelectItemIndicator","CheckLine","PopoverRoot","PopoverTrigger","VolumeUpFill"],"sources":["../../src/AudioPlayer/Controls.tsx"],"sourcesContent":["/**\n * Copyright (c) 2021-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, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { type SliderValueChangeDetails, createListCollection } from \"@ark-ui/react\";\nimport { Replay15Line, Forward15Line, PlayFill, PauseLine, VolumeUpFill, CheckLine } from \"@ndla/icons\";\nimport {\n Button,\n FieldRoot,\n IconButton,\n PopoverContent,\n PopoverRoot,\n PopoverTrigger,\n SelectContent,\n SelectControl,\n SelectItem,\n SelectItemIndicator,\n SelectItemText,\n SelectLabel,\n SelectRoot,\n SelectTrigger,\n SliderControl,\n SliderHiddenInput,\n SliderLabel,\n SliderRange,\n SliderRoot,\n SliderThumb,\n SliderTrack,\n Text,\n} from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\nconst ControlsWrapper = styled(\"div\", {\n base: {\n borderBlockStart: \"1px solid\",\n borderColor: \"stroke.default\",\n borderBottomRadius: \"xsmall\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"background.default\",\n gap: \"xsmall\",\n paddingBlock: \"xsmall\",\n paddingInline: \"medium\",\n tabletWideDown: {\n display: \"grid\",\n paddingBlock: \"xsmall\",\n paddingInline: \"xsmall\",\n gridTemplateColumns: \"1fr repeat(5, auto) 1fr\",\n gridTemplateAreas: `\n \"track track track track track track track\"\n \". speed backwards play forwards volume .\"\n`,\n },\n mobileWideDown: {\n columnGap: \"3xsmall\",\n },\n },\n});\n\nconst PlayButton = styled(IconButton, {\n base: {\n gridArea: \"play\",\n },\n});\n\nconst Forward15SecButton = styled(IconButton, {\n base: {\n gridArea: \"forwards\",\n },\n});\n\nconst Back15SecButton = styled(IconButton, {\n base: {\n gridArea: \"backwards\",\n },\n});\n\nconst ProgressWrapper = styled(\"div\", {\n base: {\n flex: \"1\",\n display: \"flex\",\n alignItems: \"center\",\n gap: \"xxsmall\",\n gridArea: \"track\",\n paddingBlock: \"xsmall\",\n mobileDown: {\n paddingInline: \"xsmall\",\n },\n },\n});\n\nconst StyledText = styled(Text, {\n base: {\n minWidth: \"xxlarge\",\n flexShrink: \"0\",\n textAlign: \"center\",\n },\n});\n\nconst VolumeButton = styled(IconButton, {\n base: {\n gridArea: \"volume\",\n },\n});\n\nconst SpeedButton = styled(Button, {\n base: {\n paddingBlock: \"auto\",\n paddingInline: \"auto\",\n maxWidth: \"xxlarge\",\n maxHeight: \"xxlarge\",\n minWidth: \"xxlarge\",\n minHeight: \"xxlarge\",\n \"& span\": {\n flex: \"1\",\n },\n },\n});\n\nconst StyledSelectRoot = styled(SelectRoot<string>, {\n base: {\n gridArea: \"speed\",\n },\n});\n\nconst StyledSliderControl = styled(SliderControl, {\n base: {\n height: \"surface.3xsmall\",\n minWidth: \"small\",\n },\n});\n\nconst StyledPopoverContent = styled(PopoverContent, {\n base: {\n paddingInline: \"small\",\n },\n});\n\nconst formatTime = (seconds: number) => {\n const minutes = Math.floor(seconds / 60);\n const currentSeconds = seconds % 60;\n\n const formattedSeconds = currentSeconds < 10 ? `0${currentSeconds}` : currentSeconds;\n return `${minutes}:${formattedSeconds}`;\n};\n\nconst speedValues = createListCollection({ items: [\"0.5\", \"0.75\", \"1\", \"1.25\", \"1.5\", \"1.75\", \"2\"] });\n\ninterface Props {\n src: string;\n title: string;\n}\n\nconst Controls = ({ src, title }: Props) => {\n const { t } = useTranslation();\n const [speedValue, setSpeedValue] = useState(1);\n const [volumeValue, setVolumeValue] = useState(100);\n const [currentTime, setCurrentTime] = useState(0);\n const [remainingTime, setRemainingTime] = useState(0);\n const [playing, setPlaying] = useState(false);\n const audioRef = useRef<HTMLAudioElement>(null);\n\n useEffect(() => {\n if (audioRef.current) {\n audioRef.current.playbackRate = speedValue;\n }\n }, [speedValue]);\n\n useEffect(() => {\n if (audioRef.current) {\n const audioElement = audioRef.current;\n const handleTimeUpdate = () => {\n const { currentTime, duration } = audioElement;\n setCurrentTime(Math.round(currentTime));\n setRemainingTime(Math.round(duration - currentTime));\n };\n\n const handleLoadedMetaData = () => {\n const { currentTime, duration } = audioElement;\n setCurrentTime(Math.round(currentTime));\n setRemainingTime(Math.round(duration - currentTime));\n };\n\n const handleTimeEnded = () => {\n setPlaying(false);\n };\n\n audioElement.addEventListener(\"timeupdate\", handleTimeUpdate);\n audioElement.addEventListener(\"loadedmetadata\", handleLoadedMetaData);\n audioElement.addEventListener(\"ended\", handleTimeEnded);\n return () => {\n audioElement.removeEventListener(\"timeupdate\", handleTimeUpdate);\n audioElement.removeEventListener(\"loadedmetadata\", handleLoadedMetaData);\n audioElement.removeEventListener(\"ended\", handleTimeEnded);\n };\n }\n }, []);\n\n const togglePlay = () => {\n if (audioRef.current) {\n const audioElement = audioRef.current;\n if (!playing) {\n audioElement.play();\n } else {\n audioElement.pause();\n }\n setPlaying(!playing);\n }\n };\n\n const onSeekSeconds = (seconds: number) => {\n if (audioRef.current) {\n audioRef.current.currentTime += seconds;\n }\n };\n\n const handleSliderChange = (details: SliderValueChangeDetails) => {\n const newValue = details.value[0];\n if (audioRef.current && newValue != null && !isNaN(newValue)) {\n audioRef.current.currentTime = details.value[0];\n }\n };\n\n const handleVolumeSliderChange = (details: SliderValueChangeDetails) => {\n if (audioRef.current) {\n audioRef.current.volume = details.value[0] / 100;\n setVolumeValue(details.value[0]);\n }\n };\n\n return (\n <div>\n {/* TODO: We should tie this up to the textual description somehow */}\n {/* eslint-disable-next-line jsx-a11y/media-has-caption */}\n <audio ref={audioRef} src={src} title={title} preload=\"metadata\" />\n <ControlsWrapper>\n <Back15SecButton\n variant=\"tertiary\"\n title={t(\"audio.controls.rewind15sec\")}\n aria-label={t(\"audio.controls.rewind15sec\")}\n onClick={() => onSeekSeconds(-15)}\n >\n <Replay15Line />\n </Back15SecButton>\n <PlayButton aria-label={t(playing ? t(\"audio.pause\") : t(\"audio.play\"))} variant=\"primary\" onClick={togglePlay}>\n {playing ? <PauseLine /> : <PlayFill />}\n </PlayButton>\n <Forward15SecButton\n variant=\"tertiary\"\n title={t(\"audio.controls.forward15sec\")}\n aria-label={t(\"audio.controls.forward15sec\")}\n onClick={() => onSeekSeconds(15)}\n >\n <Forward15Line />\n </Forward15SecButton>\n <ProgressWrapper>\n <StyledText textStyle=\"label.medium\" asChild consumeCss>\n <div>{formatTime(currentTime)}</div>\n </StyledText>\n <SliderRoot\n value={[audioRef.current?.currentTime ?? 0]}\n defaultValue={[0]}\n step={1}\n max={Math.round(audioRef.current?.duration ?? 0)}\n onValueChange={handleSliderChange}\n getAriaValueText={(value) =>\n t(\"audio.valueText\", {\n start: formatTime(Math.round(value.value)),\n end: formatTime(Math.round(audioRef.current?.duration ?? 0)),\n })\n }\n >\n <SliderLabel srOnly>{t(\"audio.progressBar\")}</SliderLabel>\n <SliderControl>\n <SliderTrack>\n <SliderRange />\n </SliderTrack>\n <SliderThumb index={0}>\n <SliderHiddenInput />\n </SliderThumb>\n </SliderControl>\n </SliderRoot>\n <StyledText textStyle=\"label.medium\" asChild consumeCss>\n <div>-{formatTime(remainingTime)}</div>\n </StyledText>\n </ProgressWrapper>\n <FieldRoot>\n <StyledSelectRoot\n collection={speedValues}\n value={[speedValue.toString()]}\n onValueChange={(details) => setSpeedValue(parseFloat(details.value[0]))}\n positioning={{ placement: \"top\" }}\n >\n <SelectLabel srOnly>{t(\"audio.controls.selectSpeed\")}</SelectLabel>\n <SelectControl>\n <SelectTrigger asChild>\n <SpeedButton\n variant=\"tertiary\"\n title={t(\"audio.controls.selectSpeed\")}\n aria-label={t(\"audio.controls.selectSpeed\")}\n >\n <span>{`${speedValue}x`}</span>\n </SpeedButton>\n </SelectTrigger>\n </SelectControl>\n <SelectContent>\n {speedValues.items.map((speed) => (\n <SelectItem key={speed} item={speed}>\n <SelectItemText>{speed}x</SelectItemText>\n <SelectItemIndicator>\n <CheckLine />\n </SelectItemIndicator>\n </SelectItem>\n ))}\n </SelectContent>\n </StyledSelectRoot>\n </FieldRoot>\n <PopoverRoot positioning={{ placement: \"top\" }}>\n <PopoverTrigger asChild>\n <VolumeButton variant=\"tertiary\" aria-label={t(\"audio.controls.adjustVolume\")}>\n <VolumeUpFill />\n </VolumeButton>\n </PopoverTrigger>\n <StyledPopoverContent>\n <SliderRoot\n orientation=\"vertical\"\n value={[volumeValue]}\n min={0}\n max={100}\n defaultValue={[100]}\n step={1}\n onValueChange={handleVolumeSliderChange}\n >\n <SliderLabel srOnly>{t(\"audio.controls.adjustVolume\")}</SliderLabel>\n <StyledSliderControl>\n <SliderTrack>\n <SliderRange />\n </SliderTrack>\n <SliderThumb index={0}>\n <SliderHiddenInput />\n </SliderThumb>\n </StyledSliderControl>\n </SliderRoot>\n </StyledPopoverContent>\n </PopoverRoot>\n </ControlsWrapper>\n </div>\n );\n};\n\nexport default Controls;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
3
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
4
|
+
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
5
|
+
const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
|
|
6
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
7
|
+
|
|
8
|
+
//#region src/AudioPlayer/SpeechControl.tsx
|
|
9
|
+
const SpeechControl = ({ src, title, type = "audio" }) => {
|
|
10
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
11
|
+
const audioRef = (0, react.useRef)(null);
|
|
12
|
+
const togglePlay = () => {
|
|
13
|
+
if (audioRef.current) {
|
|
14
|
+
const audioElement = audioRef.current;
|
|
15
|
+
if (audioElement.paused) audioElement.play();
|
|
16
|
+
else audioElement.pause();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
20
|
+
"data-embed-type": "speech",
|
|
21
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("audio", {
|
|
22
|
+
ref: audioRef,
|
|
23
|
+
src,
|
|
24
|
+
title,
|
|
25
|
+
preload: "metadata"
|
|
26
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.TooltipRoot, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TooltipTrigger, {
|
|
27
|
+
asChild: true,
|
|
28
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.IconButton, {
|
|
29
|
+
variant: "tertiary",
|
|
30
|
+
"aria-label": t(`${type}.play`),
|
|
31
|
+
onClick: togglePlay,
|
|
32
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.VolumeUpFill, {})
|
|
33
|
+
})
|
|
34
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TooltipContent, { children: t(`${type}.play`) })] })]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var SpeechControl_default = SpeechControl;
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.SpeechControl_default = SpeechControl_default;
|
|
41
|
+
//# sourceMappingURL=SpeechControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpeechControl.js","names":["TooltipRoot","TooltipTrigger","IconButton","VolumeUpFill","TooltipContent"],"sources":["../../src/AudioPlayer/SpeechControl.tsx"],"sourcesContent":["/**\n * Copyright (c) 2021-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 { useTranslation } from \"react-i18next\";\nimport { VolumeUpFill } from \"@ndla/icons\";\nimport { TooltipRoot, TooltipTrigger, TooltipContent, IconButton } from \"@ndla/primitives\";\n\ntype Props = {\n src: string;\n title: string;\n type?: \"gloss\" | \"audio\";\n};\n\nconst SpeechControl = ({ src, title, type = \"audio\" }: Props) => {\n const { t } = useTranslation();\n const audioRef = useRef<HTMLAudioElement>(null);\n\n const togglePlay = () => {\n if (audioRef.current) {\n const audioElement = audioRef.current;\n if (audioElement.paused) {\n audioElement.play();\n } else {\n audioElement.pause();\n }\n }\n };\n return (\n <div data-embed-type=\"speech\">\n {/* eslint-disable-next-line jsx-a11y/media-has-caption */}\n <audio ref={audioRef} src={src} title={title} preload=\"metadata\" />\n <TooltipRoot>\n <TooltipTrigger asChild>\n <IconButton variant=\"tertiary\" aria-label={t(`${type}.play`)} onClick={togglePlay}>\n <VolumeUpFill />\n </IconButton>\n </TooltipTrigger>\n <TooltipContent>{t(`${type}.play`)}</TooltipContent>\n </TooltipRoot>\n </div>\n );\n};\n\nexport default SpeechControl;\n"],"mappings":";;;;;;;;AAmBA,MAAM,gBAAgB,CAAC,EAAE,KAAK,OAAO,OAAO,SAAgB,KAAK;CAC/D,MAAM,EAAE,GAAG,GAAG,mCAAgB;CAC9B,MAAM,WAAW,kBAAyB,KAAK;CAE/C,MAAM,aAAa,MAAM;AACvB,MAAI,SAAS,SAAS;GACpB,MAAM,eAAe,SAAS;AAC9B,OAAI,aAAa,OACf,cAAa,MAAM;OAEnB,cAAa,OAAO;EAEvB;CACF;AACD,wBACE,4BAAC;EAAI,mBAAgB;6BAEnB,2BAAC;GAAM,KAAK;GAAe;GAAY;GAAO,SAAQ;IAAa,kBACnE,4BAACA,4DACC,2BAACC;GAAe;6BACd,2BAACC;IAAW,SAAQ;IAAW,cAAY,GAAG,EAAE,KAAK,OAAO;IAAE,SAAS;8BACrE,2BAACC,8BAAe;KACL;IACE,kBACjB,2BAACC,8CAAgB,GAAG,EAAE,KAAK,OAAO,GAAkB,IACxC;GACV;AAET;AAED,4BAAe"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_AudioPlayer = require('./AudioPlayer.js');
|
|
2
|
+
|
|
3
|
+
//#region src/AudioPlayer/index.ts
|
|
4
|
+
var AudioPlayer_default$1 = require_AudioPlayer.AudioPlayer_default;
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
exports.AudioPlayer_default = AudioPlayer_default$1;
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["AudioPlayer"],"sources":["../../src/AudioPlayer/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2021-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 AudioPlayer from \"./AudioPlayer\";\n\nexport default AudioPlayer;\n"],"mappings":";;;AAUA,4BAAeA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_BreadcrumbItem = require('./BreadcrumbItem.js');
|
|
3
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
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/Breadcrumb/Breadcrumb.tsx
|
|
9
|
+
const StyledList = (0, __ndla_styled_system_jsx.styled)("ol", { base: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexWrap: "wrap",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
listStyle: "none",
|
|
14
|
+
gap: "xxsmall",
|
|
15
|
+
mobileDown: {
|
|
16
|
+
alignItems: "flex-start",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
flexDirection: "column"
|
|
19
|
+
}
|
|
20
|
+
} });
|
|
21
|
+
const Breadcrumb = ({ items, renderItem, renderSeparator, collapseFirst, collapseLast = true }) => {
|
|
22
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
23
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
24
|
+
"aria-label": t("breadcrumb.breadcrumb"),
|
|
25
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledList, { children: items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_BreadcrumbItem.BreadcrumbItem_default, {
|
|
26
|
+
renderItem,
|
|
27
|
+
renderSeparator,
|
|
28
|
+
ref: (element) => {
|
|
29
|
+
if (element === null || !collapseFirst && index === 0 || !collapseLast && index === items.length - 1) {
|
|
30
|
+
if (element) element.setMaxWidth("none");
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
totalCount: items.length,
|
|
34
|
+
item: {
|
|
35
|
+
...item,
|
|
36
|
+
index
|
|
37
|
+
}
|
|
38
|
+
}, typeof item.to === "string" ? item.to : item.to.pathname)) })
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var Breadcrumb_default = Breadcrumb;
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.Breadcrumb_default = Breadcrumb_default;
|
|
45
|
+
//# sourceMappingURL=Breadcrumb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Breadcrumb.js","names":["BreadcrumbItem"],"sources":["../../src/Breadcrumb/Breadcrumb.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 { type ReactNode } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport BreadcrumbItem, { type IndexedBreadcrumbItem, type SimpleBreadcrumbItem } from \"./BreadcrumbItem\";\n\ninterface Props {\n items: SimpleBreadcrumbItem[];\n collapseFirst?: boolean;\n collapseLast?: boolean;\n renderItem?: (item: IndexedBreadcrumbItem, totalCount: number) => ReactNode;\n renderSeparator?: (item: IndexedBreadcrumbItem, totalCount: number) => ReactNode;\n}\n\nconst StyledList = styled(\"ol\", {\n base: {\n display: \"flex\",\n flexWrap: \"wrap\",\n alignItems: \"center\",\n listStyle: \"none\",\n gap: \"xxsmall\",\n mobileDown: {\n alignItems: \"flex-start\",\n justifyContent: \"center\",\n flexDirection: \"column\",\n },\n },\n});\n\nconst Breadcrumb = ({ items, renderItem, renderSeparator, collapseFirst, collapseLast = true }: Props) => {\n const { t } = useTranslation();\n\n return (\n <nav aria-label={t(\"breadcrumb.breadcrumb\")}>\n <StyledList>\n {items.map((item, index) => (\n <BreadcrumbItem\n renderItem={renderItem}\n renderSeparator={renderSeparator}\n ref={(element) => {\n if (\n element === null ||\n (!collapseFirst && index === 0) ||\n (!collapseLast && index === items.length - 1)\n ) {\n if (element) {\n element.setMaxWidth(\"none\");\n }\n }\n }}\n key={typeof item.to === \"string\" ? item.to : item.to.pathname}\n totalCount={items.length}\n item={{ ...item, index }}\n />\n ))}\n </StyledList>\n </nav>\n );\n};\n\nexport default Breadcrumb;\n"],"mappings":";;;;;;;;AAqBA,MAAM,aAAa,qCAAO,MAAM,EAC9B,MAAM;CACJ,SAAS;CACT,UAAU;CACV,YAAY;CACZ,WAAW;CACX,KAAK;CACL,YAAY;EACV,YAAY;EACZ,gBAAgB;EAChB,eAAe;CAChB;AACF,EACF,EAAC;AAEF,MAAM,aAAa,CAAC,EAAE,OAAO,YAAY,iBAAiB,eAAe,eAAe,MAAa,KAAK;CACxG,MAAM,EAAE,GAAG,GAAG,mCAAgB;AAE9B,wBACE,2BAAC;EAAI,cAAY,EAAE,wBAAwB;4BACzC,2BAAC,wBACE,MAAM,IAAI,CAAC,MAAM,0BAChB,2BAACA;GACa;GACK;GACjB,KAAK,CAAC,YAAY;AAChB,QACE,YAAY,SACV,iBAAiB,UAAU,MAC3B,gBAAgB,UAAU,MAAM,SAAS,GAE3C;SAAI,QACF,SAAQ,YAAY,OAAO;IAC5B;GAEJ;GAED,YAAY,MAAM;GAClB,MAAM;IAAE,GAAG;IAAM;GAAO;YAFZ,KAAK,OAAO,WAAW,KAAK,KAAK,KAAK,GAAG,SAGrD,CACF,GACS;GACT;AAET;AAED,yBAAe"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
3
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
4
|
+
const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
|
|
5
|
+
const __ndla_safelink = require_rolldown_runtime.__toESM(require("@ndla/safelink"));
|
|
6
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
7
|
+
|
|
8
|
+
//#region src/Breadcrumb/BreadcrumbItem.tsx
|
|
9
|
+
const StyledListItem = (0, __ndla_styled_system_jsx.styled)("li", { base: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
color: "inherit",
|
|
12
|
+
gap: "3xsmall",
|
|
13
|
+
alignItems: "flex-end",
|
|
14
|
+
tabletDown: { display: "block" },
|
|
15
|
+
"& a": { _visited: { color: "inherit" } }
|
|
16
|
+
} });
|
|
17
|
+
const BreadcrumbItem = (0, react.forwardRef)(({ renderItem, renderSeparator, item, totalCount }, ref) => {
|
|
18
|
+
const liRef = (0, react.useRef)(null);
|
|
19
|
+
(0, react.useImperativeHandle)(ref, () => ({ setMaxWidth: (maxWidth) => {
|
|
20
|
+
liRef.current.children[0].style.maxWidth = maxWidth;
|
|
21
|
+
} }));
|
|
22
|
+
const { to, name, index } = item;
|
|
23
|
+
const isLast = index === totalCount - 1;
|
|
24
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledListItem, {
|
|
25
|
+
ref: liRef,
|
|
26
|
+
"aria-current": isLast ? "page" : void 0,
|
|
27
|
+
children: [renderItem ? renderItem(item, totalCount) : isLast ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: name }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_safelink.SafeLink, {
|
|
28
|
+
to,
|
|
29
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: name })
|
|
30
|
+
}), renderSeparator ? renderSeparator(item, totalCount) : !isLast && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.ArrowRightShortLine, {})]
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
var BreadcrumbItem_default = BreadcrumbItem;
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.BreadcrumbItem_default = BreadcrumbItem_default;
|
|
37
|
+
//# sourceMappingURL=BreadcrumbItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BreadcrumbItem.js","names":["maxWidth: number","SafeLink","ArrowRightShortLine"],"sources":["../../src/Breadcrumb/BreadcrumbItem.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 { useRef, useImperativeHandle, type ReactNode, forwardRef } from \"react\";\nimport { ArrowRightShortLine } from \"@ndla/icons\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\nexport interface SimpleBreadcrumbItem {\n to: string | Partial<Location>;\n name: ReactNode;\n}\n\nexport interface IndexedBreadcrumbItem extends SimpleBreadcrumbItem {\n index: number;\n}\n\nexport interface BreadcrumbRenderProps {\n item: IndexedBreadcrumbItem;\n totalCount: number;\n}\n\nconst StyledListItem = styled(\"li\", {\n base: {\n display: \"flex\",\n color: \"inherit\",\n gap: \"3xsmall\",\n alignItems: \"flex-end\",\n tabletDown: {\n display: \"block\",\n },\n \"& a\": {\n _visited: {\n color: \"inherit\",\n },\n },\n },\n});\n\ninterface Props {\n item: IndexedBreadcrumbItem;\n autoCollapse?: boolean;\n totalCount: number;\n renderItem?: (item: IndexedBreadcrumbItem, totalCount: number) => ReactNode;\n renderSeparator?: (item: IndexedBreadcrumbItem, totalCount: number) => ReactNode;\n}\n\nconst BreadcrumbItem = forwardRef<any, Props>(({ renderItem, renderSeparator, item, totalCount }, ref) => {\n const liRef = useRef<any>(null);\n\n useImperativeHandle(ref, () => ({\n setMaxWidth: (maxWidth: number) => {\n liRef.current.children[0].style.maxWidth = maxWidth;\n },\n }));\n\n const { to, name, index } = item;\n const isLast = index === totalCount - 1;\n return (\n <StyledListItem ref={liRef} aria-current={isLast ? \"page\" : undefined}>\n {renderItem ? (\n renderItem(item, totalCount)\n ) : isLast ? (\n <span>{name}</span>\n ) : (\n <SafeLink to={to}>\n <span>{name}</span>\n </SafeLink>\n )}\n {renderSeparator ? renderSeparator(item, totalCount) : !isLast && <ArrowRightShortLine />}\n </StyledListItem>\n );\n});\n\nexport default BreadcrumbItem;\n"],"mappings":";;;;;;;;AA2BA,MAAM,iBAAiB,qCAAO,MAAM,EAClC,MAAM;CACJ,SAAS;CACT,OAAO;CACP,KAAK;CACL,YAAY;CACZ,YAAY,EACV,SAAS,QACV;CACD,OAAO,EACL,UAAU,EACR,OAAO,UACR,EACF;AACF,EACF,EAAC;AAUF,MAAM,iBAAiB,sBAAuB,CAAC,EAAE,YAAY,iBAAiB,MAAM,YAAY,EAAE,QAAQ;CACxG,MAAM,QAAQ,kBAAY,KAAK;AAE/B,gCAAoB,KAAK,OAAO,EAC9B,aAAa,CAACA,aAAqB;AACjC,QAAM,QAAQ,SAAS,GAAG,MAAM,WAAW;CAC5C,EACF,GAAE;CAEH,MAAM,EAAE,IAAI,MAAM,OAAO,GAAG;CAC5B,MAAM,SAAS,UAAU,aAAa;AACtC,wBACE,4BAAC;EAAe,KAAK;EAAO,gBAAc,SAAS;aAChD,aACC,WAAW,MAAM,WAAW,GAC1B,yBACF,2BAAC,oBAAM,OAAY,mBAEnB,2BAACC;GAAa;6BACZ,2BAAC,oBAAM,OAAY;IACV,EAEZ,kBAAkB,gBAAgB,MAAM,WAAW,IAAI,0BAAU,2BAACC,qCAAsB;GAC1E;AAEpB,EAAC;AAEF,6BAAe"}
|