@ndla/ui 56.0.123-alpha.0 → 56.0.124-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Article/Article.js +122 -194
- package/es/Article/Article.js.map +1 -0
- package/es/Article/ArticleByline.js +121 -170
- package/es/Article/ArticleByline.js.map +1 -0
- package/es/Article/ArticleFootNotes.js +38 -58
- package/es/Article/ArticleFootNotes.js.map +1 -0
- package/es/AudioPlayer/AudioPlayer.js +151 -212
- package/es/AudioPlayer/AudioPlayer.js.map +1 -0
- package/es/AudioPlayer/Controls.js +246 -324
- package/es/AudioPlayer/Controls.js.map +1 -0
- package/es/AudioPlayer/SpeechControl.js +36 -52
- package/es/AudioPlayer/SpeechControl.js.map +1 -0
- package/es/AudioPlayer/index.js +7 -9
- package/es/AudioPlayer/index.js.map +1 -0
- package/es/Breadcrumb/Breadcrumb.js +42 -58
- package/es/Breadcrumb/Breadcrumb.js.map +1 -0
- package/es/Breadcrumb/BreadcrumbItem.js +33 -59
- package/es/Breadcrumb/BreadcrumbItem.js.map +1 -0
- package/es/Breadcrumb/HomeBreadcrumb.js +41 -74
- package/es/Breadcrumb/HomeBreadcrumb.js.map +1 -0
- package/es/Breadcrumb/index.js +8 -10
- package/es/Breadcrumb/index.js.map +1 -0
- package/es/CampaignBlock/CampaignBlock.js +124 -173
- package/es/CampaignBlock/CampaignBlock.js.map +1 -0
- package/es/CodeBlock/CodeBlock.js +21 -31
- package/es/CodeBlock/CodeBlock.js.map +1 -0
- package/es/CodeBlock/codeLanguageOptions.js +112 -82
- package/es/CodeBlock/codeLanguageOptions.js.map +1 -0
- package/es/Concept/Concept.js +46 -68
- package/es/Concept/Concept.js.map +1 -0
- package/es/ContactBlock/ContactBlock.js +137 -191
- package/es/ContactBlock/ContactBlock.js.map +1 -0
- package/es/ContentTypeBadge/ContentTypeBadge.js +38 -47
- package/es/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +21 -28
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +21 -28
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
- package/es/ContentTypeHero/ContentTypeHero.js +36 -47
- package/es/ContentTypeHero/ContentTypeHero.js.map +1 -0
- package/es/CopyParagraphButton/CopyParagraphButton.js +57 -78
- package/es/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
- package/es/CopyParagraphButton/index.js +7 -10
- package/es/CopyParagraphButton/index.js.map +1 -0
- package/es/Embed/AudioEmbed.js +49 -73
- package/es/Embed/AudioEmbed.js.map +1 -0
- package/es/Embed/BrightcoveEmbed.js +90 -127
- package/es/Embed/BrightcoveEmbed.js.map +1 -0
- package/es/Embed/CodeEmbed.js +55 -73
- package/es/Embed/CodeEmbed.js.map +1 -0
- package/es/Embed/ConceptEmbed.js +72 -117
- package/es/Embed/ConceptEmbed.js.map +1 -0
- package/es/Embed/ConceptInlineTriggerButton.js +39 -44
- package/es/Embed/ConceptInlineTriggerButton.js.map +1 -0
- package/es/Embed/ContentLinkEmbed.js +29 -49
- package/es/Embed/ContentLinkEmbed.js.map +1 -0
- package/es/Embed/CopyrightEmbed.js +21 -31
- package/es/Embed/CopyrightEmbed.js.map +1 -0
- package/es/Embed/EmbedErrorPlaceholder.js +40 -55
- package/es/Embed/EmbedErrorPlaceholder.js.map +1 -0
- package/es/Embed/EmbedWrapper.js +21 -46
- package/es/Embed/EmbedWrapper.js.map +1 -0
- package/es/Embed/ExternalEmbed.js +50 -70
- package/es/Embed/ExternalEmbed.js.map +1 -0
- package/es/Embed/FootnoteEmbed.js +25 -42
- package/es/Embed/FootnoteEmbed.js.map +1 -0
- package/es/Embed/GlossEmbed.js +49 -77
- package/es/Embed/GlossEmbed.js.map +1 -0
- package/es/Embed/H5pEmbed.js +35 -58
- package/es/Embed/H5pEmbed.js.map +1 -0
- package/es/Embed/IframeEmbed.js +65 -89
- package/es/Embed/IframeEmbed.js.map +1 -0
- package/es/Embed/ImageEmbed.js +167 -225
- package/es/Embed/ImageEmbed.js.map +1 -0
- package/es/Embed/InlineTriggerButton.js +20 -32
- package/es/Embed/InlineTriggerButton.js.map +1 -0
- package/es/Embed/RelatedContentEmbed.js +36 -53
- package/es/Embed/RelatedContentEmbed.js.map +1 -0
- package/es/Embed/UnknownEmbed.js +18 -29
- package/es/Embed/UnknownEmbed.js.map +1 -0
- package/es/Embed/UuDisclaimerEmbed.js +51 -85
- package/es/Embed/UuDisclaimerEmbed.js.map +1 -0
- package/es/ErrorMessage/ErrorMessage.js +51 -92
- package/es/ErrorMessage/ErrorMessage.js.map +1 -0
- package/es/ErrorMessage/index.js +7 -9
- package/es/ErrorMessage/index.js.map +1 -0
- package/es/FactBox/FactBox.js +114 -170
- package/es/FactBox/FactBox.js.map +1 -0
- package/es/FactBox/index.js +7 -9
- package/es/FactBox/index.js.map +1 -0
- package/es/FileList/File.js +70 -95
- package/es/FileList/File.js.map +1 -0
- package/es/FileList/FileList.js +31 -46
- package/es/FileList/FileList.js.map +1 -0
- package/es/FileList/PdfFile.js +27 -49
- package/es/FileList/PdfFile.js.map +1 -0
- package/es/Gloss/Gloss.js +133 -166
- package/es/Gloss/Gloss.js.map +1 -0
- package/es/Gloss/GlossExample.js +42 -60
- package/es/Gloss/GlossExample.js.map +1 -0
- package/es/Grid/Grid.js +63 -91
- package/es/Grid/Grid.js.map +1 -0
- package/es/Grid/GridParallaxItem.js +19 -30
- package/es/Grid/GridParallaxItem.js.map +1 -0
- package/es/KeyFigure/KeyFigure.js +44 -61
- package/es/KeyFigure/KeyFigure.js.map +1 -0
- package/es/LicenseByline/EmbedByline.js +126 -206
- package/es/LicenseByline/EmbedByline.js.map +1 -0
- package/es/LicenseByline/LicenseLink.js +28 -53
- package/es/LicenseByline/LicenseLink.js.map +1 -0
- package/es/LinkBlock/LinkBlock.js +70 -99
- package/es/LinkBlock/LinkBlock.js.map +1 -0
- package/es/LinkBlock/LinkBlockSection.js +20 -32
- package/es/LinkBlock/LinkBlockSection.js.map +1 -0
- package/es/Pitch/Pitch.js +59 -80
- package/es/Pitch/Pitch.js.map +1 -0
- package/es/RelatedArticleList/RelatedArticleList.js +91 -129
- package/es/RelatedArticleList/RelatedArticleList.js.map +1 -0
- package/es/RelatedArticleList/index.js +7 -10
- package/es/RelatedArticleList/index.js.map +1 -0
- package/es/ResourceBox/ResourceBox.js +71 -96
- package/es/ResourceBox/ResourceBox.js.map +1 -0
- package/es/TagSelector/TagSelector.js +93 -136
- package/es/TagSelector/TagSelector.js.map +1 -0
- package/es/ZendeskButton/ZendeskButton.js +38 -52
- package/es/ZendeskButton/ZendeskButton.js.map +1 -0
- package/es/_virtual/rolldown_runtime.js +11 -0
- package/es/i18n/formatNestedMessages.js +16 -24
- package/es/i18n/formatNestedMessages.js.map +1 -0
- package/es/i18n/i18n.js +25 -31
- package/es/i18n/i18n.js.map +1 -0
- package/es/i18n/useComponentTranslations.js +147 -203
- package/es/i18n/useComponentTranslations.js.map +1 -0
- package/es/index.js +64 -44
- package/es/locale/messages-en.js +435 -459
- package/es/locale/messages-en.js.map +1 -0
- package/es/locale/messages-nb.js +435 -459
- package/es/locale/messages-nb.js.map +1 -0
- package/es/locale/messages-nn.js +435 -459
- package/es/locale/messages-nn.js.map +1 -0
- package/es/locale/messages-se.js +435 -459
- package/es/locale/messages-se.js.map +1 -0
- package/es/model/ContentType.js +69 -65
- package/es/model/ContentType.js.map +1 -0
- package/es/model/SubjectCategories.js +23 -10
- package/es/model/SubjectCategories.js.map +1 -0
- package/es/model/SubjectTypes.js +21 -9
- package/es/model/SubjectTypes.js.map +1 -0
- package/es/model/WordClass.js +51 -43
- package/es/model/WordClass.js.map +1 -0
- package/es/model/index.js +16 -18
- package/es/model/index.js.map +1 -0
- package/es/utils/licenseAttributes.js +15 -17
- package/es/utils/licenseAttributes.js.map +1 -0
- package/es/utils/relativeUrl.js +21 -32
- package/es/utils/relativeUrl.js.map +1 -0
- package/lib/Article/Article.js +130 -203
- package/lib/Article/Article.js.map +1 -0
- package/lib/Article/ArticleByline.js +125 -179
- package/lib/Article/ArticleByline.js.map +1 -0
- package/lib/Article/ArticleFootNotes.js +39 -65
- package/lib/Article/ArticleFootNotes.js.map +1 -0
- package/lib/AudioPlayer/AudioPlayer.js +155 -221
- package/lib/AudioPlayer/AudioPlayer.js.map +1 -0
- package/lib/AudioPlayer/Controls.js +249 -332
- package/lib/AudioPlayer/Controls.js.map +1 -0
- package/lib/AudioPlayer/SpeechControl.js +39 -60
- package/lib/AudioPlayer/SpeechControl.js.map +1 -0
- package/lib/AudioPlayer/index.js +7 -15
- package/lib/AudioPlayer/index.js.map +1 -0
- package/lib/Breadcrumb/Breadcrumb.js +43 -65
- package/lib/Breadcrumb/Breadcrumb.js.map +1 -0
- package/lib/Breadcrumb/BreadcrumbItem.js +34 -65
- package/lib/Breadcrumb/BreadcrumbItem.js.map +1 -0
- package/lib/Breadcrumb/HomeBreadcrumb.js +43 -82
- package/lib/Breadcrumb/HomeBreadcrumb.js.map +1 -0
- package/lib/Breadcrumb/index.js +8 -22
- package/lib/Breadcrumb/index.js.map +1 -0
- package/lib/CampaignBlock/CampaignBlock.js +128 -183
- package/lib/CampaignBlock/CampaignBlock.js.map +1 -0
- package/lib/CodeBlock/CodeBlock.js +23 -38
- package/lib/CodeBlock/CodeBlock.js.map +1 -0
- package/lib/CodeBlock/codeLanguageOptions.js +112 -87
- package/lib/CodeBlock/codeLanguageOptions.js.map +1 -0
- package/lib/Concept/Concept.js +48 -75
- package/lib/Concept/Concept.js.map +1 -0
- package/lib/ContactBlock/ContactBlock.js +141 -200
- package/lib/ContactBlock/ContactBlock.js.map +1 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.js +40 -54
- package/lib/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +23 -35
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +23 -35
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
- package/lib/ContentTypeHero/ContentTypeHero.js +37 -54
- package/lib/ContentTypeHero/ContentTypeHero.js.map +1 -0
- package/lib/CopyParagraphButton/CopyParagraphButton.js +61 -87
- package/lib/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
- package/lib/CopyParagraphButton/index.js +7 -21
- package/lib/CopyParagraphButton/index.js.map +1 -0
- package/lib/Embed/AudioEmbed.js +51 -82
- package/lib/Embed/AudioEmbed.js.map +1 -0
- package/lib/Embed/BrightcoveEmbed.js +93 -138
- package/lib/Embed/BrightcoveEmbed.js.map +1 -0
- package/lib/Embed/CodeEmbed.js +59 -83
- package/lib/Embed/CodeEmbed.js.map +1 -0
- package/lib/Embed/ConceptEmbed.js +77 -127
- package/lib/Embed/ConceptEmbed.js.map +1 -0
- package/lib/Embed/ConceptInlineTriggerButton.js +39 -49
- package/lib/Embed/ConceptInlineTriggerButton.js.map +1 -0
- package/lib/Embed/ContentLinkEmbed.js +30 -55
- package/lib/Embed/ContentLinkEmbed.js.map +1 -0
- package/lib/Embed/CopyrightEmbed.js +22 -37
- package/lib/Embed/CopyrightEmbed.js.map +1 -0
- package/lib/Embed/EmbedErrorPlaceholder.js +42 -62
- package/lib/Embed/EmbedErrorPlaceholder.js.map +1 -0
- package/lib/Embed/EmbedWrapper.js +24 -54
- package/lib/Embed/EmbedWrapper.js.map +1 -0
- package/lib/Embed/ExternalEmbed.js +53 -79
- package/lib/Embed/ExternalEmbed.js.map +1 -0
- package/lib/Embed/FootnoteEmbed.js +26 -48
- package/lib/Embed/FootnoteEmbed.js.map +1 -0
- package/lib/Embed/GlossEmbed.js +51 -86
- package/lib/Embed/GlossEmbed.js.map +1 -0
- package/lib/Embed/H5pEmbed.js +37 -66
- package/lib/Embed/H5pEmbed.js.map +1 -0
- package/lib/Embed/IframeEmbed.js +68 -98
- package/lib/Embed/IframeEmbed.js.map +1 -0
- package/lib/Embed/ImageEmbed.js +173 -238
- package/lib/Embed/ImageEmbed.js.map +1 -0
- package/lib/Embed/InlineTriggerButton.js +23 -40
- package/lib/Embed/InlineTriggerButton.js.map +1 -0
- package/lib/Embed/RelatedContentEmbed.js +37 -59
- package/lib/Embed/RelatedContentEmbed.js.map +1 -0
- package/lib/Embed/UnknownEmbed.js +19 -35
- package/lib/Embed/UnknownEmbed.js.map +1 -0
- package/lib/Embed/UuDisclaimerEmbed.js +53 -92
- package/lib/Embed/UuDisclaimerEmbed.js.map +1 -0
- package/lib/ErrorMessage/ErrorMessage.js +53 -99
- package/lib/ErrorMessage/ErrorMessage.js.map +1 -0
- package/lib/ErrorMessage/index.js +7 -15
- package/lib/ErrorMessage/index.js.map +1 -0
- package/lib/FactBox/FactBox.js +118 -180
- package/lib/FactBox/FactBox.js.map +1 -0
- package/lib/FactBox/index.js +7 -15
- package/lib/FactBox/index.js.map +1 -0
- package/lib/FileList/File.js +75 -105
- package/lib/FileList/File.js.map +1 -0
- package/lib/FileList/FileList.js +33 -52
- package/lib/FileList/FileList.js.map +1 -0
- package/lib/FileList/PdfFile.js +27 -55
- package/lib/FileList/PdfFile.js.map +1 -0
- package/lib/Gloss/Gloss.js +138 -176
- package/lib/Gloss/Gloss.js.map +1 -0
- package/lib/Gloss/GlossExample.js +45 -68
- package/lib/Gloss/GlossExample.js.map +1 -0
- package/lib/Grid/Grid.js +64 -98
- package/lib/Grid/Grid.js.map +1 -0
- package/lib/Grid/GridParallaxItem.js +19 -36
- package/lib/Grid/GridParallaxItem.js.map +1 -0
- package/lib/KeyFigure/KeyFigure.js +45 -68
- package/lib/KeyFigure/KeyFigure.js.map +1 -0
- package/lib/LicenseByline/EmbedByline.js +130 -216
- package/lib/LicenseByline/EmbedByline.js.map +1 -0
- package/lib/LicenseByline/LicenseLink.js +29 -59
- package/lib/LicenseByline/LicenseLink.js.map +1 -0
- package/lib/LinkBlock/LinkBlock.js +73 -108
- package/lib/LinkBlock/LinkBlock.js.map +1 -0
- package/lib/LinkBlock/LinkBlockSection.js +22 -39
- package/lib/LinkBlock/LinkBlockSection.js.map +1 -0
- package/lib/Pitch/Pitch.js +61 -89
- package/lib/Pitch/Pitch.js.map +1 -0
- package/lib/RelatedArticleList/RelatedArticleList.js +96 -140
- package/lib/RelatedArticleList/RelatedArticleList.js.map +1 -0
- package/lib/RelatedArticleList/index.js +7 -20
- package/lib/RelatedArticleList/index.js.map +1 -0
- package/lib/ResourceBox/ResourceBox.js +73 -104
- package/lib/ResourceBox/ResourceBox.js.map +1 -0
- package/lib/TagSelector/TagSelector.js +103 -145
- package/lib/TagSelector/TagSelector.js.map +1 -0
- package/lib/ZendeskButton/ZendeskButton.js +39 -58
- package/lib/ZendeskButton/ZendeskButton.js.map +1 -0
- package/lib/_virtual/rolldown_runtime.js +42 -0
- package/lib/i18n/formatNestedMessages.js +16 -30
- package/lib/i18n/formatNestedMessages.js.map +1 -0
- package/lib/i18n/i18n.js +28 -38
- package/lib/i18n/i18n.js.map +1 -0
- package/lib/i18n/useComponentTranslations.js +154 -215
- package/lib/i18n/useComponentTranslations.js.map +1 -0
- package/lib/index.js +156 -598
- package/lib/locale/messages-en.js +436 -466
- package/lib/locale/messages-en.js.map +1 -0
- package/lib/locale/messages-nb.js +436 -466
- package/lib/locale/messages-nb.js.map +1 -0
- package/lib/locale/messages-nn.js +436 -466
- package/lib/locale/messages-nn.js.map +1 -0
- package/lib/locale/messages-se.js +436 -466
- package/lib/locale/messages-se.js.map +1 -0
- package/lib/model/ContentType.js +90 -70
- package/lib/model/ContentType.js.map +1 -0
- package/lib/model/SubjectCategories.js +26 -14
- package/lib/model/SubjectCategories.js.map +1 -0
- package/lib/model/SubjectTypes.js +24 -13
- package/lib/model/SubjectTypes.js.map +1 -0
- package/lib/model/WordClass.js +55 -48
- package/lib/model/WordClass.js.map +1 -0
- package/lib/model/index.js +16 -25
- package/lib/model/index.js.map +1 -0
- package/lib/utils/licenseAttributes.js +14 -22
- package/lib/utils/licenseAttributes.js.map +1 -0
- package/lib/utils/relativeUrl.js +20 -38
- package/lib/utils/relativeUrl.js.map +1 -0
- package/package.json +12 -11
- package/es/Article/index.js +0 -11
- package/es/CampaignBlock/index.js +0 -9
- package/es/CodeBlock/index.js +0 -10
- package/es/ContactBlock/index.js +0 -9
- package/es/ContentTypeHero/index.js +0 -9
- package/es/Embed/index.js +0 -25
- package/es/Embed/types.js +0 -1
- package/es/FileList/index.js +0 -11
- package/es/Gloss/index.js +0 -10
- package/es/Grid/index.js +0 -10
- package/es/KeyFigure/index.js +0 -9
- package/es/LicenseByline/index.js +0 -10
- package/es/LinkBlock/index.js +0 -10
- package/es/Pitch/index.js +0 -9
- package/es/ResourceBox/index.js +0 -10
- package/es/i18n/index.js +0 -11
- package/es/types.js +0 -1
- package/lib/Article/index.js +0 -68
- package/lib/CampaignBlock/index.js +0 -13
- package/lib/CodeBlock/index.js +0 -20
- package/lib/ContactBlock/index.js +0 -18
- package/lib/ContentTypeHero/index.js +0 -12
- package/lib/Embed/index.js +0 -150
- package/lib/Embed/types.js +0 -5
- package/lib/FileList/index.js +0 -44
- package/lib/Gloss/index.js +0 -20
- package/lib/Grid/index.js +0 -19
- package/lib/KeyFigure/index.js +0 -13
- package/lib/LicenseByline/index.js +0 -19
- package/lib/LinkBlock/index.js +0 -20
- package/lib/Pitch/index.js +0 -12
- package/lib/ResourceBox/index.js +0 -13
- package/lib/i18n/index.js +0 -68
- package/lib/types.js +0 -5
|
@@ -1,99 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { breakpoints } from "@ndla/core";
|
|
10
|
-
import { ShareBoxLine } from "@ndla/icons";
|
|
11
1
|
import { Heading, Image, Text } from "@ndla/primitives";
|
|
12
|
-
import { SafeLinkButton } from "@ndla/safelink";
|
|
13
2
|
import { styled } from "@ndla/styled-system/jsx";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
textStyle: "label.large",
|
|
81
|
-
fontWeight: "bold",
|
|
82
|
-
asChild: true,
|
|
83
|
-
consumeCss: true,
|
|
84
|
-
children: /*#__PURE__*/_jsx("h3", {
|
|
85
|
-
children: title
|
|
86
|
-
})
|
|
87
|
-
}), /*#__PURE__*/_jsx(StyledText, {
|
|
88
|
-
textStyle: "body.medium",
|
|
89
|
-
children: caption
|
|
90
|
-
}), /*#__PURE__*/_jsxs(SafeLinkButton, {
|
|
91
|
-
to: url,
|
|
92
|
-
target: "_blank",
|
|
93
|
-
variant: "secondary",
|
|
94
|
-
children: [buttonText, /*#__PURE__*/_jsx(ShareBoxLine, {})]
|
|
95
|
-
})]
|
|
96
|
-
})]
|
|
97
|
-
});
|
|
3
|
+
import { ShareBoxLine } from "@ndla/icons";
|
|
4
|
+
import { SafeLinkButton } from "@ndla/safelink";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { breakpoints } from "@ndla/core";
|
|
7
|
+
|
|
8
|
+
//#region src/ResourceBox/ResourceBox.tsx
|
|
9
|
+
const Container = styled("div", { base: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
padding: "medium",
|
|
12
|
+
borderRadius: "xsmall",
|
|
13
|
+
border: "1px solid",
|
|
14
|
+
borderColor: "stroke.default",
|
|
15
|
+
boxShadow: "full",
|
|
16
|
+
marginBlockEnd: "medium",
|
|
17
|
+
gap: "medium",
|
|
18
|
+
tabletWideDown: { padding: "xsmall" },
|
|
19
|
+
tabletDown: {
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
gap: "0",
|
|
22
|
+
padding: "0"
|
|
23
|
+
}
|
|
24
|
+
} });
|
|
25
|
+
const ContentWrapper = styled("div", { base: {
|
|
26
|
+
display: "flex",
|
|
27
|
+
flexDirection: "column",
|
|
28
|
+
alignItems: "flex-start",
|
|
29
|
+
gap: "xsmall",
|
|
30
|
+
flex: "1",
|
|
31
|
+
tabletDown: { padding: "xsmall" }
|
|
32
|
+
} });
|
|
33
|
+
const StyledImage = styled(Image, { base: {
|
|
34
|
+
objectFit: "cover",
|
|
35
|
+
borderRadius: "xsmall",
|
|
36
|
+
width: "fit-content",
|
|
37
|
+
aspectRatio: "1/1",
|
|
38
|
+
tabletDown: {
|
|
39
|
+
width: "100%",
|
|
40
|
+
borderRadius: "0"
|
|
41
|
+
}
|
|
42
|
+
} });
|
|
43
|
+
const StyledText = styled(Text, { base: { flex: "1" } });
|
|
44
|
+
const ResourceBox = ({ image, title, caption, url, buttonText }) => {
|
|
45
|
+
return /* @__PURE__ */ jsxs(Container, { children: [image ? /* @__PURE__ */ jsx(StyledImage, {
|
|
46
|
+
src: image.src,
|
|
47
|
+
alt: image.alt,
|
|
48
|
+
sizes: `(min-width: ${breakpoints.desktop}) 150px, (max-width: ${breakpoints.tablet} ) 400px, 200px`,
|
|
49
|
+
variant: "rounded"
|
|
50
|
+
}) : null, /* @__PURE__ */ jsxs(ContentWrapper, { children: [
|
|
51
|
+
/* @__PURE__ */ jsx(Heading, {
|
|
52
|
+
textStyle: "label.large",
|
|
53
|
+
fontWeight: "bold",
|
|
54
|
+
asChild: true,
|
|
55
|
+
consumeCss: true,
|
|
56
|
+
children: /* @__PURE__ */ jsx("h3", { children: title })
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ jsx(StyledText, {
|
|
59
|
+
textStyle: "body.medium",
|
|
60
|
+
children: caption
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ jsxs(SafeLinkButton, {
|
|
63
|
+
to: url,
|
|
64
|
+
target: "_blank",
|
|
65
|
+
variant: "secondary",
|
|
66
|
+
children: [buttonText, /* @__PURE__ */ jsx(ShareBoxLine, {})]
|
|
67
|
+
})
|
|
68
|
+
] })] });
|
|
98
69
|
};
|
|
99
|
-
|
|
70
|
+
var ResourceBox_default = ResourceBox;
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { ResourceBox_default };
|
|
74
|
+
//# sourceMappingURL=ResourceBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceBox.js","names":[],"sources":["../../src/ResourceBox/ResourceBox.tsx"],"sourcesContent":["/**\n * Copyright (c) 2022-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { breakpoints } from \"@ndla/core\";\nimport { ShareBoxLine } from \"@ndla/icons\";\nimport { Heading, Image, Text } from \"@ndla/primitives\";\nimport { SafeLinkButton } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\nconst Container = styled(\"div\", {\n base: {\n display: \"flex\",\n padding: \"medium\",\n borderRadius: \"xsmall\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n boxShadow: \"full\",\n marginBlockEnd: \"medium\",\n gap: \"medium\",\n tabletWideDown: {\n padding: \"xsmall\",\n },\n tabletDown: {\n flexDirection: \"column\",\n gap: \"0\",\n padding: \"0\",\n },\n },\n});\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n gap: \"xsmall\",\n flex: \"1\",\n tabletDown: {\n padding: \"xsmall\",\n },\n },\n});\n\nconst StyledImage = styled(Image, {\n base: {\n objectFit: \"cover\",\n borderRadius: \"xsmall\",\n width: \"fit-content\",\n aspectRatio: \"1/1\",\n tabletDown: {\n width: \"100%\",\n borderRadius: \"0\",\n },\n },\n});\n\nconst StyledText = styled(Text, {\n base: {\n flex: \"1\",\n },\n});\n\ninterface ImageMeta {\n src: string | undefined;\n alt: string;\n}\n\ninterface Props {\n image?: ImageMeta;\n title: string;\n caption: string;\n url: string;\n buttonText: string;\n}\n\nexport const ResourceBox = ({ image, title, caption, url, buttonText }: Props) => {\n return (\n <Container>\n {image ? (\n <StyledImage\n src={image.src}\n alt={image.alt}\n sizes={`(min-width: ${breakpoints.desktop}) 150px, (max-width: ${breakpoints.tablet} ) 400px, 200px`}\n variant=\"rounded\"\n />\n ) : null}\n <ContentWrapper>\n <Heading textStyle=\"label.large\" fontWeight=\"bold\" asChild consumeCss>\n <h3>{title}</h3>\n </Heading>\n <StyledText textStyle=\"body.medium\">{caption}</StyledText>\n <SafeLinkButton to={url} target=\"_blank\" variant=\"secondary\">\n {buttonText}\n <ShareBoxLine />\n </SafeLinkButton>\n </ContentWrapper>\n </Container>\n );\n};\n\nexport default ResourceBox;\n"],"mappings":";;;;;;;;AAcA,MAAM,YAAY,OAAO,OAAO,EAC9B,MAAM;CACJ,SAAS;CACT,SAAS;CACT,cAAc;CACd,QAAQ;CACR,aAAa;CACb,WAAW;CACX,gBAAgB;CAChB,KAAK;CACL,gBAAgB,EACd,SAAS,SACV;CACD,YAAY;EACV,eAAe;EACf,KAAK;EACL,SAAS;CACV;AACF,EACF,EAAC;AAEF,MAAM,iBAAiB,OAAO,OAAO,EACnC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,YAAY;CACZ,KAAK;CACL,MAAM;CACN,YAAY,EACV,SAAS,SACV;AACF,EACF,EAAC;AAEF,MAAM,cAAc,OAAO,OAAO,EAChC,MAAM;CACJ,WAAW;CACX,cAAc;CACd,OAAO;CACP,aAAa;CACb,YAAY;EACV,OAAO;EACP,cAAc;CACf;AACF,EACF,EAAC;AAEF,MAAM,aAAa,OAAO,MAAM,EAC9B,MAAM,EACJ,MAAM,IACP,EACF,EAAC;AAeF,MAAa,cAAc,CAAC,EAAE,OAAO,OAAO,SAAS,KAAK,YAAmB,KAAK;AAChF,wBACE,KAAC,wBACE,wBACC,IAAC;EACC,KAAK,MAAM;EACX,KAAK,MAAM;EACX,QAAQ,cAAc,YAAY,QAAQ,uBAAuB,YAAY,OAAO;EACpF,SAAQ;GACR,GACA,sBACJ,KAAC;kBACC,IAAC;GAAQ,WAAU;GAAc,YAAW;GAAO;GAAQ;6BACzD,IAAC,kBAAI,QAAW;IACR;kBACV,IAAC;GAAW,WAAU;aAAe;IAAqB;kBAC1D,KAAC;GAAe,IAAI;GAAK,QAAO;GAAS,SAAQ;cAC9C,4BACD,IAAC,iBAAe;IACD;KACF,IACP;AAEf;AAED,0BAAe"}
|
|
@@ -1,143 +1,100 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
1
|
import { forwardRef, useEffect, useId, useRef } from "react";
|
|
10
|
-
import {
|
|
2
|
+
import { ComboboxClearTrigger, ComboboxControl, ComboboxInput, ComboboxLabel, ComboboxRoot, ComboboxTrigger, TagsInputControl, TagsInputInput, TagsInputItem, TagsInputItemDeleteTrigger, TagsInputItemInput, TagsInputItemPreview, TagsInputItemText, TagsInputRoot } from "@ndla/primitives";
|
|
11
3
|
import { CloseLine } from "@ndla/icons";
|
|
12
|
-
import {
|
|
4
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
5
|
import { contains } from "@ndla/util";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
value: value,
|
|
53
|
-
...rest,
|
|
54
|
-
children: /*#__PURE__*/_jsx(TagSelectorTagsInputRoot, {
|
|
55
|
-
ids: ids,
|
|
56
|
-
value: value,
|
|
57
|
-
editable: editable,
|
|
58
|
-
onValueChange: onValueChange,
|
|
59
|
-
addOnPaste: addOnPaste,
|
|
60
|
-
translations: translations,
|
|
61
|
-
children: children
|
|
62
|
-
})
|
|
63
|
-
});
|
|
6
|
+
import { useComboboxContext, useTagsInputContext } from "@ark-ui/react";
|
|
7
|
+
|
|
8
|
+
//#region src/TagSelector/TagSelector.tsx
|
|
9
|
+
const TagSelectorRoot = ({ allowCustomValue = true, multiple = true, selectionBehavior = "clear", editable, addOnPaste = false, onValueChange, children, value, translations,...rest }) => {
|
|
10
|
+
const ids = {
|
|
11
|
+
root: useId(),
|
|
12
|
+
input: useId(),
|
|
13
|
+
control: useId()
|
|
14
|
+
};
|
|
15
|
+
const controlRef = useRef(void 0);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!controlRef.current) controlRef.current = document.getElementById(ids.control);
|
|
18
|
+
}, [ids.control]);
|
|
19
|
+
return /* @__PURE__ */ jsx(ComboboxRoot, {
|
|
20
|
+
ids,
|
|
21
|
+
asChild: true,
|
|
22
|
+
allowCustomValue,
|
|
23
|
+
multiple,
|
|
24
|
+
selectionBehavior,
|
|
25
|
+
onValueChange,
|
|
26
|
+
translations,
|
|
27
|
+
onPointerDownOutside: (event) => {
|
|
28
|
+
if (contains(controlRef.current, event.detail.originalEvent.target)) event.preventDefault();
|
|
29
|
+
},
|
|
30
|
+
value,
|
|
31
|
+
...rest,
|
|
32
|
+
children: /* @__PURE__ */ jsx(TagSelectorTagsInputRoot, {
|
|
33
|
+
ids,
|
|
34
|
+
value,
|
|
35
|
+
editable,
|
|
36
|
+
onValueChange,
|
|
37
|
+
addOnPaste,
|
|
38
|
+
translations,
|
|
39
|
+
children
|
|
40
|
+
})
|
|
41
|
+
});
|
|
64
42
|
};
|
|
65
|
-
const TagSelectorTagsInputRoot =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
43
|
+
const TagSelectorTagsInputRoot = forwardRef((props, ref) => {
|
|
44
|
+
const comboboxApi = useComboboxContext();
|
|
45
|
+
return /* @__PURE__ */ jsx(TagsInputRoot, {
|
|
46
|
+
ref,
|
|
47
|
+
onInputValueChange: (details) => comboboxApi.setInputValue(details.inputValue),
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
72
50
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
...props,
|
|
86
|
-
children: children
|
|
87
|
-
})
|
|
88
|
-
});
|
|
51
|
+
const TagSelectorLabel = ComboboxLabel;
|
|
52
|
+
const TagSelectorItemInput = TagsInputItemInput;
|
|
53
|
+
const TagSelectorTrigger = ComboboxTrigger;
|
|
54
|
+
const TagSelectorControl = forwardRef(({ children,...props }, ref) => {
|
|
55
|
+
return /* @__PURE__ */ jsx(ComboboxControl, {
|
|
56
|
+
ref,
|
|
57
|
+
asChild: true,
|
|
58
|
+
children: /* @__PURE__ */ jsx(TagsInputControl, {
|
|
59
|
+
...props,
|
|
60
|
+
children
|
|
61
|
+
})
|
|
62
|
+
});
|
|
89
63
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
tagsApi.addValue(tagsApi.inputValue);
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
...props,
|
|
108
|
-
children: children
|
|
109
|
-
})
|
|
110
|
-
});
|
|
64
|
+
const TagSelectorClearTrigger = ComboboxClearTrigger;
|
|
65
|
+
const TagSelectorInputBase = forwardRef(({ children,...props }, ref) => {
|
|
66
|
+
const tagsApi = useTagsInputContext();
|
|
67
|
+
return /* @__PURE__ */ jsx(ComboboxInput, {
|
|
68
|
+
ref,
|
|
69
|
+
asChild: true,
|
|
70
|
+
children: /* @__PURE__ */ jsx(TagsInputInput, {
|
|
71
|
+
onKeyDown: (event) => {
|
|
72
|
+
if (event.key === "Enter") tagsApi.addValue(tagsApi.inputValue);
|
|
73
|
+
},
|
|
74
|
+
...props,
|
|
75
|
+
children
|
|
76
|
+
})
|
|
77
|
+
});
|
|
111
78
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (event.key === "Enter") {
|
|
135
|
-
tagsApi.addValue(tagsApi.inputValue);
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
...props,
|
|
139
|
-
children: children
|
|
140
|
-
})
|
|
141
|
-
})]
|
|
142
|
-
});
|
|
143
|
-
});
|
|
79
|
+
const TagSelectorInput = forwardRef(({ children,...props }, ref) => {
|
|
80
|
+
const tagsApi = useTagsInputContext();
|
|
81
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [tagsApi.value.map((value, index) => /* @__PURE__ */ jsxs(TagsInputItem, {
|
|
82
|
+
index,
|
|
83
|
+
value,
|
|
84
|
+
children: [/* @__PURE__ */ jsxs(TagsInputItemPreview, { children: [/* @__PURE__ */ jsx(TagsInputItemText, { children: value }), /* @__PURE__ */ jsx(TagsInputItemDeleteTrigger, { children: /* @__PURE__ */ jsx(CloseLine, {}) })] }), /* @__PURE__ */ jsx(TagsInputItemInput, {})]
|
|
85
|
+
}, value)), /* @__PURE__ */ jsx(ComboboxInput, {
|
|
86
|
+
ref,
|
|
87
|
+
asChild: true,
|
|
88
|
+
children: /* @__PURE__ */ jsx(TagsInputInput, {
|
|
89
|
+
onKeyDown: (event) => {
|
|
90
|
+
if (event.key === "Enter") tagsApi.addValue(tagsApi.inputValue);
|
|
91
|
+
},
|
|
92
|
+
...props,
|
|
93
|
+
children
|
|
94
|
+
})
|
|
95
|
+
})] });
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
export { TagSelectorClearTrigger, TagSelectorControl, TagSelectorInput, TagSelectorInputBase, TagSelectorItemInput, TagSelectorLabel, TagSelectorRoot, TagSelectorTrigger };
|
|
100
|
+
//# sourceMappingURL=TagSelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagSelector.js","names":[],"sources":["../../src/TagSelector/TagSelector.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { forwardRef, useEffect, useId, useRef } from \"react\";\nimport { type CollectionItem, useTagsInputContext, useComboboxContext } from \"@ark-ui/react\";\nimport { CloseLine } from \"@ndla/icons\";\nimport {\n ComboboxClearTrigger,\n ComboboxControl,\n type ComboboxControlProps,\n ComboboxInput,\n type ComboboxInputProps,\n ComboboxLabel,\n ComboboxRoot,\n type ComboboxRootProps,\n ComboboxTrigger,\n TagsInputControl,\n type TagsInputControlProps,\n TagsInputInput,\n type TagsInputInputProps,\n TagsInputItem,\n TagsInputItemDeleteTrigger,\n TagsInputItemPreview,\n TagsInputItemText,\n TagsInputRoot,\n type TagsInputRootProps,\n TagsInputItemInput,\n} from \"@ndla/primitives\";\nimport { contains } from \"@ndla/util\";\n\nexport type TagSelectorRootProps<T extends CollectionItem> = ComboboxRootProps<T> & TagsInputRootProps;\n\nexport const TagSelectorRoot = <T extends CollectionItem>({\n allowCustomValue = true,\n multiple = true,\n selectionBehavior = \"clear\",\n editable,\n addOnPaste = false,\n onValueChange,\n children,\n value,\n translations,\n ...rest\n}: TagSelectorRootProps<T>) => {\n const ids = {\n root: useId(),\n input: useId(),\n control: useId(),\n };\n\n const controlRef = useRef<HTMLDivElement | undefined>(undefined);\n\n useEffect(() => {\n if (!controlRef.current) {\n controlRef.current = document.getElementById(ids.control) as HTMLDivElement | undefined;\n }\n }, [ids.control]);\n\n return (\n <ComboboxRoot\n ids={ids}\n asChild\n allowCustomValue={allowCustomValue}\n multiple={multiple}\n selectionBehavior={selectionBehavior}\n onValueChange={onValueChange}\n translations={translations}\n onPointerDownOutside={(event) => {\n if (contains(controlRef.current, event.detail.originalEvent.target)) {\n event.preventDefault();\n }\n }}\n value={value}\n {...rest}\n >\n <TagSelectorTagsInputRoot\n ids={ids}\n value={value}\n editable={editable}\n onValueChange={onValueChange}\n addOnPaste={addOnPaste}\n translations={translations}\n >\n {children}\n </TagSelectorTagsInputRoot>\n </ComboboxRoot>\n );\n};\n\nconst TagSelectorTagsInputRoot = forwardRef<HTMLDivElement, TagsInputRootProps>((props, ref) => {\n const comboboxApi = useComboboxContext();\n return (\n <TagsInputRoot\n ref={ref}\n onInputValueChange={(details) => comboboxApi.setInputValue(details.inputValue)}\n {...props}\n />\n );\n});\n\nexport type TagSelectorControlProps = ComboboxControlProps & TagsInputControlProps;\n\nexport const TagSelectorLabel = ComboboxLabel;\n\nexport const TagSelectorItemInput = TagsInputItemInput;\n\nexport const TagSelectorTrigger = ComboboxTrigger;\n\nexport const TagSelectorControl = forwardRef<HTMLDivElement, TagSelectorControlProps>(({ children, ...props }, ref) => {\n return (\n <ComboboxControl ref={ref} asChild>\n <TagsInputControl {...props}>{children}</TagsInputControl>\n </ComboboxControl>\n );\n});\n\nexport const TagSelectorClearTrigger = ComboboxClearTrigger;\n\nexport type TagSelectorInputProps = ComboboxInputProps & TagsInputInputProps;\n\n// If you need to modify the TagsInputItem, you can use this.\nexport const TagSelectorInputBase = forwardRef<HTMLInputElement, TagSelectorInputProps>(\n ({ children, ...props }, ref) => {\n const tagsApi = useTagsInputContext();\n\n return (\n <ComboboxInput ref={ref} asChild>\n <TagsInputInput\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n tagsApi.addValue(tagsApi.inputValue);\n }\n }}\n {...props}\n >\n {children}\n </TagsInputInput>\n </ComboboxInput>\n );\n },\n);\n\nexport const TagSelectorInput = forwardRef<HTMLInputElement, TagSelectorInputProps>(({ children, ...props }, ref) => {\n const tagsApi = useTagsInputContext();\n\n return (\n <>\n {tagsApi.value.map((value, index) => (\n <TagsInputItem index={index} value={value} key={value}>\n <TagsInputItemPreview>\n <TagsInputItemText>{value}</TagsInputItemText>\n <TagsInputItemDeleteTrigger>\n <CloseLine />\n </TagsInputItemDeleteTrigger>\n </TagsInputItemPreview>\n <TagsInputItemInput />\n </TagsInputItem>\n ))}\n <ComboboxInput ref={ref} asChild>\n <TagsInputInput\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n tagsApi.addValue(tagsApi.inputValue);\n }\n }}\n {...props}\n >\n {children}\n </TagsInputInput>\n </ComboboxInput>\n </>\n );\n});\n"],"mappings":";;;;;;;;AAqCA,MAAa,kBAAkB,CAA2B,EACxD,mBAAmB,MACnB,WAAW,MACX,oBAAoB,SACpB,UACA,aAAa,OACb,eACA,UACA,OACA,aACA,GAAG,MACqB,KAAK;CAC7B,MAAM,MAAM;EACV,MAAM,OAAO;EACb,OAAO,OAAO;EACd,SAAS,OAAO;CACjB;CAED,MAAM,aAAa,cAA6C;AAEhE,WAAU,MAAM;AACd,OAAK,WAAW,QACd,YAAW,UAAU,SAAS,eAAe,IAAI,QAAQ;CAE5D,GAAE,CAAC,IAAI,OAAQ,EAAC;AAEjB,wBACE,IAAC;EACM;EACL;EACkB;EACR;EACS;EACJ;EACD;EACd,sBAAsB,CAAC,UAAU;AAC/B,OAAI,SAAS,WAAW,SAAS,MAAM,OAAO,cAAc,OAAO,CACjE,OAAM,gBAAgB;EAEzB;EACM;EACP,GAAI;4BAEJ,IAAC;GACM;GACE;GACG;GACK;GACH;GACE;GAEb;IACwB;GACd;AAElB;AAED,MAAM,2BAA2B,WAA+C,CAAC,OAAO,QAAQ;CAC9F,MAAM,cAAc,oBAAoB;AACxC,wBACE,IAAC;EACM;EACL,oBAAoB,CAAC,YAAY,YAAY,cAAc,QAAQ,WAAW;EAC9E,GAAI;GACJ;AAEL,EAAC;AAIF,MAAa,mBAAmB;AAEhC,MAAa,uBAAuB;AAEpC,MAAa,qBAAqB;AAElC,MAAa,qBAAqB,WAAoD,CAAC,EAAE,SAAU,GAAG,OAAO,EAAE,QAAQ;AACrH,wBACE,IAAC;EAAqB;EAAK;4BACzB,IAAC;GAAiB,GAAI;GAAQ;IAA4B;GAC1C;AAErB,EAAC;AAEF,MAAa,0BAA0B;AAKvC,MAAa,uBAAuB,WAClC,CAAC,EAAE,SAAU,GAAG,OAAO,EAAE,QAAQ;CAC/B,MAAM,UAAU,qBAAqB;AAErC,wBACE,IAAC;EAAmB;EAAK;4BACvB,IAAC;GACC,WAAW,CAAC,UAAU;AACpB,QAAI,MAAM,QAAQ,QAChB,SAAQ,SAAS,QAAQ,WAAW;GAEvC;GACD,GAAI;GAEH;IACc;GACH;AAEnB,EACF;AAED,MAAa,mBAAmB,WAAoD,CAAC,EAAE,SAAU,GAAG,OAAO,EAAE,QAAQ;CACnH,MAAM,UAAU,qBAAqB;AAErC,wBACE,8BACG,QAAQ,MAAM,IAAI,CAAC,OAAO,0BACzB,KAAC;EAAqB;EAAc;6BAClC,KAAC,mDACC,IAAC,+BAAmB,QAA0B,kBAC9C,IAAC,wDACC,IAAC,cAAY,GACc,IACR,kBACvB,IAAC,uBAAqB;IAPwB,MAQhC,CAChB,kBACF,IAAC;EAAmB;EAAK;4BACvB,IAAC;GACC,WAAW,CAAC,UAAU;AACpB,QAAI,MAAM,QAAQ,QAChB,SAAQ,SAAS,QAAQ,WAAW;GAEvC;GACD,GAAI;GAEH;IACc;GACH,IACf;AAEN,EAAC"}
|
|
@@ -1,55 +1,41 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
1
|
import { forwardRef, useState } from "react";
|
|
10
2
|
import { Button } from "@ndla/primitives";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/ZendeskButton/ZendeskButton.tsx
|
|
6
|
+
const ZendeskButton = forwardRef(({ locale, variant = "secondary", widgetKey, children,...rest }, ref) => {
|
|
7
|
+
const [loading, setLoading] = useState(false);
|
|
8
|
+
const handleClick = () => {
|
|
9
|
+
if (window && !window.zE) {
|
|
10
|
+
setLoading(true);
|
|
11
|
+
const script = document.createElement("script");
|
|
12
|
+
script.id = "ze-snippet";
|
|
13
|
+
script.type = "text/javascript";
|
|
14
|
+
script.async = true;
|
|
15
|
+
script.onload = () => {
|
|
16
|
+
if (window.zE) {
|
|
17
|
+
window.zE("webWidget", "setLocale", locale);
|
|
18
|
+
window.zE("webWidget:on", "close", () => {
|
|
19
|
+
setLoading(false);
|
|
20
|
+
});
|
|
21
|
+
window.zE("webWidget", "open");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
script.src = `https://static.zdassets.com/ekr/snippet.js?key=${widgetKey}`;
|
|
25
|
+
document.body.appendChild(script);
|
|
26
|
+
} else if (window?.zE) window.zE("webWidget", "open");
|
|
27
|
+
};
|
|
28
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
29
|
+
onClick: handleClick,
|
|
30
|
+
variant,
|
|
31
|
+
id: "zendeskButton",
|
|
32
|
+
disabled: loading,
|
|
33
|
+
...rest,
|
|
34
|
+
ref,
|
|
35
|
+
children
|
|
36
|
+
});
|
|
37
|
+
});
|
|
11
38
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let {
|
|
16
|
-
locale,
|
|
17
|
-
variant = "secondary",
|
|
18
|
-
widgetKey,
|
|
19
|
-
children,
|
|
20
|
-
...rest
|
|
21
|
-
} = _ref;
|
|
22
|
-
const [loading, setLoading] = useState(false);
|
|
23
|
-
const handleClick = () => {
|
|
24
|
-
if (window && !window.zE) {
|
|
25
|
-
setLoading(true);
|
|
26
|
-
// Asynchronously load zendesk scripts for better performance
|
|
27
|
-
const script = document.createElement("script");
|
|
28
|
-
script.id = "ze-snippet";
|
|
29
|
-
script.type = "text/javascript";
|
|
30
|
-
script.async = true;
|
|
31
|
-
script.onload = () => {
|
|
32
|
-
if (window.zE) {
|
|
33
|
-
window.zE("webWidget", "setLocale", locale);
|
|
34
|
-
window.zE("webWidget:on", "close", () => {
|
|
35
|
-
setLoading(false);
|
|
36
|
-
});
|
|
37
|
-
window.zE("webWidget", "open");
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
script.src = `https://static.zdassets.com/ekr/snippet.js?key=${widgetKey}`;
|
|
41
|
-
document.body.appendChild(script);
|
|
42
|
-
} else if (window?.zE) {
|
|
43
|
-
window.zE("webWidget", "open");
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
return /*#__PURE__*/_jsx(Button, {
|
|
47
|
-
onClick: handleClick,
|
|
48
|
-
variant: variant,
|
|
49
|
-
id: "zendeskButton",
|
|
50
|
-
disabled: loading,
|
|
51
|
-
...rest,
|
|
52
|
-
ref: ref,
|
|
53
|
-
children: children
|
|
54
|
-
});
|
|
55
|
-
});
|
|
39
|
+
//#endregion
|
|
40
|
+
export { ZendeskButton };
|
|
41
|
+
//# sourceMappingURL=ZendeskButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZendeskButton.js","names":[],"sources":["../../src/ZendeskButton/ZendeskButton.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { forwardRef, useState } from \"react\";\nimport { Button, type ButtonProps } from \"@ndla/primitives\";\n\n// TODO: Let's consider abandoning `disabled` on the button here. It should instead just open/close the widget based on its current state.\n\nexport interface ZendeskButtonProps extends ButtonProps {\n widgetKey: string;\n locale: string;\n}\n\ndeclare global {\n interface Window {\n zE: (modifier: string, action: string, callback?: (() => void) | string) => void;\n }\n}\n\nexport const ZendeskButton = forwardRef<HTMLButtonElement, ZendeskButtonProps>(\n ({ locale, variant = \"secondary\", widgetKey, children, ...rest }, ref) => {\n const [loading, setLoading] = useState(false);\n const handleClick = () => {\n if (window && !window.zE) {\n setLoading(true);\n // Asynchronously load zendesk scripts for better performance\n const script = document.createElement(\"script\");\n script.id = \"ze-snippet\";\n script.type = \"text/javascript\";\n script.async = true;\n script.onload = () => {\n if (window.zE) {\n window.zE(\"webWidget\", \"setLocale\", locale);\n window.zE(\"webWidget:on\", \"close\", () => {\n setLoading(false);\n });\n window.zE(\"webWidget\", \"open\");\n }\n };\n script.src = `https://static.zdassets.com/ekr/snippet.js?key=${widgetKey}`;\n document.body.appendChild(script);\n } else if (window?.zE) {\n window.zE(\"webWidget\", \"open\");\n }\n };\n\n return (\n <Button onClick={handleClick} variant={variant} id=\"zendeskButton\" disabled={loading} {...rest} ref={ref}>\n {children}\n </Button>\n );\n },\n);\n"],"mappings":";;;;;AAwBA,MAAa,gBAAgB,WAC3B,CAAC,EAAE,QAAQ,UAAU,aAAa,WAAW,SAAU,GAAG,MAAM,EAAE,QAAQ;CACxE,MAAM,CAAC,SAAS,WAAW,GAAG,SAAS,MAAM;CAC7C,MAAM,cAAc,MAAM;AACxB,MAAI,WAAW,OAAO,IAAI;AACxB,cAAW,KAAK;GAEhB,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,UAAO,KAAK;AACZ,UAAO,OAAO;AACd,UAAO,QAAQ;AACf,UAAO,SAAS,MAAM;AACpB,QAAI,OAAO,IAAI;AACb,YAAO,GAAG,aAAa,aAAa,OAAO;AAC3C,YAAO,GAAG,gBAAgB,SAAS,MAAM;AACvC,iBAAW,MAAM;KAClB,EAAC;AACF,YAAO,GAAG,aAAa,OAAO;IAC/B;GACF;AACD,UAAO,OAAO,iDAAiD,UAAU;AACzE,YAAS,KAAK,YAAY,OAAO;EAClC,WAAU,QAAQ,GACjB,QAAO,GAAG,aAAa,OAAO;CAEjC;AAED,wBACE,IAAC;EAAO,SAAS;EAAsB;EAAS,IAAG;EAAgB,UAAU;EAAS,GAAI;EAAW;EAClG;GACM;AAEZ,EACF"}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region src/i18n/formatNestedMessages.ts
|
|
2
|
+
const formatNestedMessages = (phrases, formattedMessages = {}, prefix = "") => {
|
|
3
|
+
const messages = formattedMessages;
|
|
4
|
+
Object.keys(phrases).forEach((key) => {
|
|
5
|
+
const value = phrases[key];
|
|
6
|
+
if ({}.hasOwnProperty.call(phrases, key)) {
|
|
7
|
+
const keyWithPrefix = prefix ? `${prefix}.${key}` : key;
|
|
8
|
+
if (typeof value === "object") formatNestedMessages(value, formattedMessages, keyWithPrefix);
|
|
9
|
+
else messages[keyWithPrefix] = value;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return messages;
|
|
13
|
+
};
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const messages = formattedMessages;
|
|
13
|
-
Object.keys(phrases).forEach(key => {
|
|
14
|
-
const value = phrases[key];
|
|
15
|
-
if ({}.hasOwnProperty.call(phrases, key)) {
|
|
16
|
-
const keyWithPrefix = prefix ? `${prefix}.${key}` : key;
|
|
17
|
-
if (typeof value === "object") {
|
|
18
|
-
formatNestedMessages(value, formattedMessages, keyWithPrefix);
|
|
19
|
-
} else {
|
|
20
|
-
messages[keyWithPrefix] = value;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return messages;
|
|
25
|
-
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { formatNestedMessages };
|
|
17
|
+
//# sourceMappingURL=formatNestedMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatNestedMessages.js","names":["phrases: Phrases","formattedMessages: FormattedMessages","prefix: string"],"sources":["../../src/i18n/formatNestedMessages.ts"],"sourcesContent":["/**\n * Copyright (c) 2017-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\ninterface Phrases {\n [key: string]: string | Phrases;\n}\n\ninterface FormattedMessages {\n [key: string]: string;\n}\n\nexport const formatNestedMessages = (\n phrases: Phrases,\n formattedMessages: FormattedMessages = {},\n prefix: string = \"\",\n) => {\n const messages = formattedMessages;\n\n Object.keys(phrases).forEach((key) => {\n const value = phrases[key];\n if ({}.hasOwnProperty.call(phrases, key)) {\n const keyWithPrefix = prefix ? `${prefix}.${key}` : key;\n if (typeof value === \"object\") {\n formatNestedMessages(value, formattedMessages, keyWithPrefix);\n } else {\n messages[keyWithPrefix] = value;\n }\n }\n });\n\n return messages;\n};\n"],"mappings":";AAgBA,MAAa,uBAAuB,CAClCA,SACAC,oBAAuC,CAAE,GACzCC,SAAiB,OACd;CACH,MAAM,WAAW;AAEjB,QAAO,KAAK,QAAQ,CAAC,QAAQ,CAAC,QAAQ;EACpC,MAAM,QAAQ,QAAQ;AACtB,MAAI,CAAE,EAAC,eAAe,KAAK,SAAS,IAAI,EAAE;GACxC,MAAM,gBAAgB,UAAU,EAAE,OAAO,GAAG,IAAI,IAAI;AACpD,cAAW,UAAU,SACnB,sBAAqB,OAAO,mBAAmB,cAAc;OAE7D,UAAS,iBAAiB;EAE7B;CACF,EAAC;AAEF,QAAO;AACR"}
|