@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,150 +1,108 @@
|
|
|
1
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
3
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
4
|
+
const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
|
|
5
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
6
|
+
const __ndla_util = require_rolldown_runtime.__toESM(require("@ndla/util"));
|
|
7
|
+
const __ark_ui_react = require_rolldown_runtime.__toESM(require("@ark-ui/react"));
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
control: (0, _react.useId)()
|
|
38
|
-
};
|
|
39
|
-
const controlRef = (0, _react.useRef)(undefined);
|
|
40
|
-
(0, _react.useEffect)(() => {
|
|
41
|
-
if (!controlRef.current) {
|
|
42
|
-
controlRef.current = document.getElementById(ids.control);
|
|
43
|
-
}
|
|
44
|
-
}, [ids.control]);
|
|
45
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.ComboboxRoot, {
|
|
46
|
-
ids: ids,
|
|
47
|
-
asChild: true,
|
|
48
|
-
allowCustomValue: allowCustomValue,
|
|
49
|
-
multiple: multiple,
|
|
50
|
-
selectionBehavior: selectionBehavior,
|
|
51
|
-
onValueChange: onValueChange,
|
|
52
|
-
translations: translations,
|
|
53
|
-
onPointerDownOutside: event => {
|
|
54
|
-
if ((0, _util.contains)(controlRef.current, event.detail.originalEvent.target)) {
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
value: value,
|
|
59
|
-
...rest,
|
|
60
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(TagSelectorTagsInputRoot, {
|
|
61
|
-
ids: ids,
|
|
62
|
-
value: value,
|
|
63
|
-
editable: editable,
|
|
64
|
-
onValueChange: onValueChange,
|
|
65
|
-
addOnPaste: addOnPaste,
|
|
66
|
-
translations: translations,
|
|
67
|
-
children: children
|
|
68
|
-
})
|
|
69
|
-
});
|
|
9
|
+
//#region src/TagSelector/TagSelector.tsx
|
|
10
|
+
const TagSelectorRoot = ({ allowCustomValue = true, multiple = true, selectionBehavior = "clear", editable, addOnPaste = false, onValueChange, children, value, translations,...rest }) => {
|
|
11
|
+
const ids = {
|
|
12
|
+
root: (0, react.useId)(),
|
|
13
|
+
input: (0, react.useId)(),
|
|
14
|
+
control: (0, react.useId)()
|
|
15
|
+
};
|
|
16
|
+
const controlRef = (0, react.useRef)(void 0);
|
|
17
|
+
(0, react.useEffect)(() => {
|
|
18
|
+
if (!controlRef.current) controlRef.current = document.getElementById(ids.control);
|
|
19
|
+
}, [ids.control]);
|
|
20
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.ComboboxRoot, {
|
|
21
|
+
ids,
|
|
22
|
+
asChild: true,
|
|
23
|
+
allowCustomValue,
|
|
24
|
+
multiple,
|
|
25
|
+
selectionBehavior,
|
|
26
|
+
onValueChange,
|
|
27
|
+
translations,
|
|
28
|
+
onPointerDownOutside: (event) => {
|
|
29
|
+
if ((0, __ndla_util.contains)(controlRef.current, event.detail.originalEvent.target)) event.preventDefault();
|
|
30
|
+
},
|
|
31
|
+
value,
|
|
32
|
+
...rest,
|
|
33
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TagSelectorTagsInputRoot, {
|
|
34
|
+
ids,
|
|
35
|
+
value,
|
|
36
|
+
editable,
|
|
37
|
+
onValueChange,
|
|
38
|
+
addOnPaste,
|
|
39
|
+
translations,
|
|
40
|
+
children
|
|
41
|
+
})
|
|
42
|
+
});
|
|
70
43
|
};
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
44
|
+
const TagSelectorTagsInputRoot = (0, react.forwardRef)((props, ref) => {
|
|
45
|
+
const comboboxApi = (0, __ark_ui_react.useComboboxContext)();
|
|
46
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputRoot, {
|
|
47
|
+
ref,
|
|
48
|
+
onInputValueChange: (details) => comboboxApi.setInputValue(details.inputValue),
|
|
49
|
+
...props
|
|
50
|
+
});
|
|
79
51
|
});
|
|
80
|
-
const TagSelectorLabel =
|
|
81
|
-
const TagSelectorItemInput =
|
|
82
|
-
const TagSelectorTrigger =
|
|
83
|
-
const TagSelectorControl =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
...props,
|
|
93
|
-
children: children
|
|
94
|
-
})
|
|
95
|
-
});
|
|
52
|
+
const TagSelectorLabel = __ndla_primitives.ComboboxLabel;
|
|
53
|
+
const TagSelectorItemInput = __ndla_primitives.TagsInputItemInput;
|
|
54
|
+
const TagSelectorTrigger = __ndla_primitives.ComboboxTrigger;
|
|
55
|
+
const TagSelectorControl = (0, react.forwardRef)(({ children,...props }, ref) => {
|
|
56
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.ComboboxControl, {
|
|
57
|
+
ref,
|
|
58
|
+
asChild: true,
|
|
59
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputControl, {
|
|
60
|
+
...props,
|
|
61
|
+
children
|
|
62
|
+
})
|
|
63
|
+
});
|
|
96
64
|
});
|
|
97
|
-
const TagSelectorClearTrigger =
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
tagsApi.addValue(tagsApi.inputValue);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
...props,
|
|
115
|
-
children: children
|
|
116
|
-
})
|
|
117
|
-
});
|
|
65
|
+
const TagSelectorClearTrigger = __ndla_primitives.ComboboxClearTrigger;
|
|
66
|
+
const TagSelectorInputBase = (0, react.forwardRef)(({ children,...props }, ref) => {
|
|
67
|
+
const tagsApi = (0, __ark_ui_react.useTagsInputContext)();
|
|
68
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.ComboboxInput, {
|
|
69
|
+
ref,
|
|
70
|
+
asChild: true,
|
|
71
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputInput, {
|
|
72
|
+
onKeyDown: (event) => {
|
|
73
|
+
if (event.key === "Enter") tagsApi.addValue(tagsApi.inputValue);
|
|
74
|
+
},
|
|
75
|
+
...props,
|
|
76
|
+
children
|
|
77
|
+
})
|
|
78
|
+
});
|
|
118
79
|
});
|
|
119
|
-
const TagSelectorInput =
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
})]
|
|
149
|
-
});
|
|
150
|
-
});
|
|
80
|
+
const TagSelectorInput = (0, react.forwardRef)(({ children,...props }, ref) => {
|
|
81
|
+
const tagsApi = (0, __ark_ui_react.useTagsInputContext)();
|
|
82
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [tagsApi.value.map((value, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.TagsInputItem, {
|
|
83
|
+
index,
|
|
84
|
+
value,
|
|
85
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.TagsInputItemPreview, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputItemText, { children: value }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputItemDeleteTrigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.CloseLine, {}) })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputItemInput, {})]
|
|
86
|
+
}, value)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.ComboboxInput, {
|
|
87
|
+
ref,
|
|
88
|
+
asChild: true,
|
|
89
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputInput, {
|
|
90
|
+
onKeyDown: (event) => {
|
|
91
|
+
if (event.key === "Enter") tagsApi.addValue(tagsApi.inputValue);
|
|
92
|
+
},
|
|
93
|
+
...props,
|
|
94
|
+
children
|
|
95
|
+
})
|
|
96
|
+
})] });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
exports.TagSelectorClearTrigger = TagSelectorClearTrigger;
|
|
101
|
+
exports.TagSelectorControl = TagSelectorControl;
|
|
102
|
+
exports.TagSelectorInput = TagSelectorInput;
|
|
103
|
+
exports.TagSelectorInputBase = TagSelectorInputBase;
|
|
104
|
+
exports.TagSelectorItemInput = TagSelectorItemInput;
|
|
105
|
+
exports.TagSelectorLabel = TagSelectorLabel;
|
|
106
|
+
exports.TagSelectorRoot = TagSelectorRoot;
|
|
107
|
+
exports.TagSelectorTrigger = TagSelectorTrigger;
|
|
108
|
+
//# sourceMappingURL=TagSelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagSelector.js","names":["ComboboxRoot","TagsInputRoot","ComboboxLabel","TagsInputItemInput","ComboboxTrigger","ComboboxControl","TagsInputControl","ComboboxClearTrigger","ComboboxInput","TagsInputInput","TagsInputItem","TagsInputItemPreview","TagsInputItemText","TagsInputItemDeleteTrigger","CloseLine"],"sources":["../../src/TagSelector/TagSelector.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { forwardRef, useEffect, useId, useRef } from \"react\";\nimport { type CollectionItem, useTagsInputContext, useComboboxContext } from \"@ark-ui/react\";\nimport { CloseLine } from \"@ndla/icons\";\nimport {\n ComboboxClearTrigger,\n ComboboxControl,\n type ComboboxControlProps,\n ComboboxInput,\n type ComboboxInputProps,\n ComboboxLabel,\n ComboboxRoot,\n type ComboboxRootProps,\n ComboboxTrigger,\n TagsInputControl,\n type TagsInputControlProps,\n TagsInputInput,\n type TagsInputInputProps,\n TagsInputItem,\n TagsInputItemDeleteTrigger,\n TagsInputItemPreview,\n TagsInputItemText,\n TagsInputRoot,\n type TagsInputRootProps,\n TagsInputItemInput,\n} from \"@ndla/primitives\";\nimport { contains } from \"@ndla/util\";\n\nexport type TagSelectorRootProps<T extends CollectionItem> = ComboboxRootProps<T> & TagsInputRootProps;\n\nexport const TagSelectorRoot = <T extends CollectionItem>({\n allowCustomValue = true,\n multiple = true,\n selectionBehavior = \"clear\",\n editable,\n addOnPaste = false,\n onValueChange,\n children,\n value,\n translations,\n ...rest\n}: TagSelectorRootProps<T>) => {\n const ids = {\n root: useId(),\n input: useId(),\n control: useId(),\n };\n\n const controlRef = useRef<HTMLDivElement | undefined>(undefined);\n\n useEffect(() => {\n if (!controlRef.current) {\n controlRef.current = document.getElementById(ids.control) as HTMLDivElement | undefined;\n }\n }, [ids.control]);\n\n return (\n <ComboboxRoot\n ids={ids}\n asChild\n allowCustomValue={allowCustomValue}\n multiple={multiple}\n selectionBehavior={selectionBehavior}\n onValueChange={onValueChange}\n translations={translations}\n onPointerDownOutside={(event) => {\n if (contains(controlRef.current, event.detail.originalEvent.target)) {\n event.preventDefault();\n }\n }}\n value={value}\n {...rest}\n >\n <TagSelectorTagsInputRoot\n ids={ids}\n value={value}\n editable={editable}\n onValueChange={onValueChange}\n addOnPaste={addOnPaste}\n translations={translations}\n >\n {children}\n </TagSelectorTagsInputRoot>\n </ComboboxRoot>\n );\n};\n\nconst TagSelectorTagsInputRoot = forwardRef<HTMLDivElement, TagsInputRootProps>((props, ref) => {\n const comboboxApi = useComboboxContext();\n return (\n <TagsInputRoot\n ref={ref}\n onInputValueChange={(details) => comboboxApi.setInputValue(details.inputValue)}\n {...props}\n />\n );\n});\n\nexport type TagSelectorControlProps = ComboboxControlProps & TagsInputControlProps;\n\nexport const TagSelectorLabel = ComboboxLabel;\n\nexport const TagSelectorItemInput = TagsInputItemInput;\n\nexport const TagSelectorTrigger = ComboboxTrigger;\n\nexport const TagSelectorControl = forwardRef<HTMLDivElement, TagSelectorControlProps>(({ children, ...props }, ref) => {\n return (\n <ComboboxControl ref={ref} asChild>\n <TagsInputControl {...props}>{children}</TagsInputControl>\n </ComboboxControl>\n );\n});\n\nexport const TagSelectorClearTrigger = ComboboxClearTrigger;\n\nexport type TagSelectorInputProps = ComboboxInputProps & TagsInputInputProps;\n\n// If you need to modify the TagsInputItem, you can use this.\nexport const TagSelectorInputBase = forwardRef<HTMLInputElement, TagSelectorInputProps>(\n ({ children, ...props }, ref) => {\n const tagsApi = useTagsInputContext();\n\n return (\n <ComboboxInput ref={ref} asChild>\n <TagsInputInput\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n tagsApi.addValue(tagsApi.inputValue);\n }\n }}\n {...props}\n >\n {children}\n </TagsInputInput>\n </ComboboxInput>\n );\n },\n);\n\nexport const TagSelectorInput = forwardRef<HTMLInputElement, TagSelectorInputProps>(({ children, ...props }, ref) => {\n const tagsApi = useTagsInputContext();\n\n return (\n <>\n {tagsApi.value.map((value, index) => (\n <TagsInputItem index={index} value={value} key={value}>\n <TagsInputItemPreview>\n <TagsInputItemText>{value}</TagsInputItemText>\n <TagsInputItemDeleteTrigger>\n <CloseLine />\n </TagsInputItemDeleteTrigger>\n </TagsInputItemPreview>\n <TagsInputItemInput />\n </TagsInputItem>\n ))}\n <ComboboxInput ref={ref} asChild>\n <TagsInputInput\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n tagsApi.addValue(tagsApi.inputValue);\n }\n }}\n {...props}\n >\n {children}\n </TagsInputInput>\n </ComboboxInput>\n </>\n );\n});\n"],"mappings":";;;;;;;;;AAqCA,MAAa,kBAAkB,CAA2B,EACxD,mBAAmB,MACnB,WAAW,MACX,oBAAoB,SACpB,UACA,aAAa,OACb,eACA,UACA,OACA,aACA,GAAG,MACqB,KAAK;CAC7B,MAAM,MAAM;EACV,MAAM,kBAAO;EACb,OAAO,kBAAO;EACd,SAAS,kBAAO;CACjB;CAED,MAAM,aAAa,yBAA6C;AAEhE,sBAAU,MAAM;AACd,OAAK,WAAW,QACd,YAAW,UAAU,SAAS,eAAe,IAAI,QAAQ;CAE5D,GAAE,CAAC,IAAI,OAAQ,EAAC;AAEjB,wBACE,2BAACA;EACM;EACL;EACkB;EACR;EACS;EACJ;EACD;EACd,sBAAsB,CAAC,UAAU;AAC/B,OAAI,0BAAS,WAAW,SAAS,MAAM,OAAO,cAAc,OAAO,CACjE,OAAM,gBAAgB;EAEzB;EACM;EACP,GAAI;4BAEJ,2BAAC;GACM;GACE;GACG;GACK;GACH;GACE;GAEb;IACwB;GACd;AAElB;AAED,MAAM,2BAA2B,sBAA+C,CAAC,OAAO,QAAQ;CAC9F,MAAM,cAAc,wCAAoB;AACxC,wBACE,2BAACC;EACM;EACL,oBAAoB,CAAC,YAAY,YAAY,cAAc,QAAQ,WAAW;EAC9E,GAAI;GACJ;AAEL,EAAC;AAIF,MAAa,mBAAmBC;AAEhC,MAAa,uBAAuBC;AAEpC,MAAa,qBAAqBC;AAElC,MAAa,qBAAqB,sBAAoD,CAAC,EAAE,SAAU,GAAG,OAAO,EAAE,QAAQ;AACrH,wBACE,2BAACC;EAAqB;EAAK;4BACzB,2BAACC;GAAiB,GAAI;GAAQ;IAA4B;GAC1C;AAErB,EAAC;AAEF,MAAa,0BAA0BC;AAKvC,MAAa,uBAAuB,sBAClC,CAAC,EAAE,SAAU,GAAG,OAAO,EAAE,QAAQ;CAC/B,MAAM,UAAU,yCAAqB;AAErC,wBACE,2BAACC;EAAmB;EAAK;4BACvB,2BAACC;GACC,WAAW,CAAC,UAAU;AACpB,QAAI,MAAM,QAAQ,QAChB,SAAQ,SAAS,QAAQ,WAAW;GAEvC;GACD,GAAI;GAEH;IACc;GACH;AAEnB,EACF;AAED,MAAa,mBAAmB,sBAAoD,CAAC,EAAE,SAAU,GAAG,OAAO,EAAE,QAAQ;CACnH,MAAM,UAAU,yCAAqB;AAErC,wBACE,qEACG,QAAQ,MAAM,IAAI,CAAC,OAAO,0BACzB,4BAACC;EAAqB;EAAc;6BAClC,4BAACC,qEACC,2BAACC,iDAAmB,QAA0B,kBAC9C,2BAACC,0EACC,2BAACC,2BAAY,GACc,IACR,kBACvB,2BAACX,yCAAqB;IAPwB,MAQhC,CAChB,kBACF,2BAACK;EAAmB;EAAK;4BACvB,2BAACC;GACC,WAAW,CAAC,UAAU;AACpB,QAAI,MAAM,QAAQ,QAChB,SAAQ,SAAS,QAAQ,WAAW;GAEvC;GACD,GAAI;GAEH;IACc;GACH,IACf;AAEN,EAAC"}
|
|
@@ -1,61 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
3
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
4
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
//#region src/ZendeskButton/ZendeskButton.tsx
|
|
7
|
+
const ZendeskButton = (0, react.forwardRef)(({ locale, variant = "secondary", widgetKey, children,...rest }, ref) => {
|
|
8
|
+
const [loading, setLoading] = (0, react.useState)(false);
|
|
9
|
+
const handleClick = () => {
|
|
10
|
+
if (window && !window.zE) {
|
|
11
|
+
setLoading(true);
|
|
12
|
+
const script = document.createElement("script");
|
|
13
|
+
script.id = "ze-snippet";
|
|
14
|
+
script.type = "text/javascript";
|
|
15
|
+
script.async = true;
|
|
16
|
+
script.onload = () => {
|
|
17
|
+
if (window.zE) {
|
|
18
|
+
window.zE("webWidget", "setLocale", locale);
|
|
19
|
+
window.zE("webWidget:on", "close", () => {
|
|
20
|
+
setLoading(false);
|
|
21
|
+
});
|
|
22
|
+
window.zE("webWidget", "open");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
script.src = `https://static.zdassets.com/ekr/snippet.js?key=${widgetKey}`;
|
|
26
|
+
document.body.appendChild(script);
|
|
27
|
+
} else if (window?.zE) window.zE("webWidget", "open");
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Button, {
|
|
30
|
+
onClick: handleClick,
|
|
31
|
+
variant,
|
|
32
|
+
id: "zendeskButton",
|
|
33
|
+
disabled: loading,
|
|
34
|
+
...rest,
|
|
35
|
+
ref,
|
|
36
|
+
children
|
|
37
|
+
});
|
|
5
38
|
});
|
|
6
|
-
exports.ZendeskButton = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _primitives = require("@ndla/primitives");
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
/**
|
|
11
|
-
* Copyright (c) 2024-present, NDLA.
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
39
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let {
|
|
22
|
-
locale,
|
|
23
|
-
variant = "secondary",
|
|
24
|
-
widgetKey,
|
|
25
|
-
children,
|
|
26
|
-
...rest
|
|
27
|
-
} = _ref;
|
|
28
|
-
const [loading, setLoading] = (0, _react.useState)(false);
|
|
29
|
-
const handleClick = () => {
|
|
30
|
-
if (window && !window.zE) {
|
|
31
|
-
setLoading(true);
|
|
32
|
-
// Asynchronously load zendesk scripts for better performance
|
|
33
|
-
const script = document.createElement("script");
|
|
34
|
-
script.id = "ze-snippet";
|
|
35
|
-
script.type = "text/javascript";
|
|
36
|
-
script.async = true;
|
|
37
|
-
script.onload = () => {
|
|
38
|
-
if (window.zE) {
|
|
39
|
-
window.zE("webWidget", "setLocale", locale);
|
|
40
|
-
window.zE("webWidget:on", "close", () => {
|
|
41
|
-
setLoading(false);
|
|
42
|
-
});
|
|
43
|
-
window.zE("webWidget", "open");
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
script.src = `https://static.zdassets.com/ekr/snippet.js?key=${widgetKey}`;
|
|
47
|
-
document.body.appendChild(script);
|
|
48
|
-
} else if (window?.zE) {
|
|
49
|
-
window.zE("webWidget", "open");
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.Button, {
|
|
53
|
-
onClick: handleClick,
|
|
54
|
-
variant: variant,
|
|
55
|
-
id: "zendeskButton",
|
|
56
|
-
disabled: loading,
|
|
57
|
-
...rest,
|
|
58
|
-
ref: ref,
|
|
59
|
-
children: children
|
|
60
|
-
});
|
|
61
|
-
});
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.ZendeskButton = ZendeskButton;
|
|
42
|
+
//# sourceMappingURL=ZendeskButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZendeskButton.js","names":["Button"],"sources":["../../src/ZendeskButton/ZendeskButton.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { forwardRef, useState } from \"react\";\nimport { Button, type ButtonProps } from \"@ndla/primitives\";\n\n// TODO: Let's consider abandoning `disabled` on the button here. It should instead just open/close the widget based on its current state.\n\nexport interface ZendeskButtonProps extends ButtonProps {\n widgetKey: string;\n locale: string;\n}\n\ndeclare global {\n interface Window {\n zE: (modifier: string, action: string, callback?: (() => void) | string) => void;\n }\n}\n\nexport const ZendeskButton = forwardRef<HTMLButtonElement, ZendeskButtonProps>(\n ({ locale, variant = \"secondary\", widgetKey, children, ...rest }, ref) => {\n const [loading, setLoading] = useState(false);\n const handleClick = () => {\n if (window && !window.zE) {\n setLoading(true);\n // Asynchronously load zendesk scripts for better performance\n const script = document.createElement(\"script\");\n script.id = \"ze-snippet\";\n script.type = \"text/javascript\";\n script.async = true;\n script.onload = () => {\n if (window.zE) {\n window.zE(\"webWidget\", \"setLocale\", locale);\n window.zE(\"webWidget:on\", \"close\", () => {\n setLoading(false);\n });\n window.zE(\"webWidget\", \"open\");\n }\n };\n script.src = `https://static.zdassets.com/ekr/snippet.js?key=${widgetKey}`;\n document.body.appendChild(script);\n } else if (window?.zE) {\n window.zE(\"webWidget\", \"open\");\n }\n };\n\n return (\n <Button onClick={handleClick} variant={variant} id=\"zendeskButton\" disabled={loading} {...rest} ref={ref}>\n {children}\n </Button>\n );\n },\n);\n"],"mappings":";;;;;;AAwBA,MAAa,gBAAgB,sBAC3B,CAAC,EAAE,QAAQ,UAAU,aAAa,WAAW,SAAU,GAAG,MAAM,EAAE,QAAQ;CACxE,MAAM,CAAC,SAAS,WAAW,GAAG,oBAAS,MAAM;CAC7C,MAAM,cAAc,MAAM;AACxB,MAAI,WAAW,OAAO,IAAI;AACxB,cAAW,KAAK;GAEhB,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,UAAO,KAAK;AACZ,UAAO,OAAO;AACd,UAAO,QAAQ;AACf,UAAO,SAAS,MAAM;AACpB,QAAI,OAAO,IAAI;AACb,YAAO,GAAG,aAAa,aAAa,OAAO;AAC3C,YAAO,GAAG,gBAAgB,SAAS,MAAM;AACvC,iBAAW,MAAM;KAClB,EAAC;AACF,YAAO,GAAG,aAAa,OAAO;IAC/B;GACF;AACD,UAAO,OAAO,iDAAiD,UAAU;AACzE,YAAS,KAAK,YAAY,OAAO;EAClC,WAAU,QAAQ,GACjB,QAAO,GAAG,aAAa,OAAO;CAEjC;AAED,wBACE,2BAACA;EAAO,SAAS;EAAsB;EAAS,IAAG;EAAgB,UAAU;EAAS,GAAI;EAAW;EAClG;GACM;AAEZ,EACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
|
+
key = keys[i];
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: ((k) => from[k]).bind(null, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
|
|
31
|
+
Object.defineProperty(exports, '__export', {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return __export;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, '__toESM', {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return __toESM;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const formatNestedMessages = function (phrases) {
|
|
16
|
-
let formattedMessages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17
|
-
let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
18
|
-
const messages = formattedMessages;
|
|
19
|
-
Object.keys(phrases).forEach(key => {
|
|
20
|
-
const value = phrases[key];
|
|
21
|
-
if ({}.hasOwnProperty.call(phrases, key)) {
|
|
22
|
-
const keyWithPrefix = prefix ? `${prefix}.${key}` : key;
|
|
23
|
-
if (typeof value === "object") {
|
|
24
|
-
formatNestedMessages(value, formattedMessages, keyWithPrefix);
|
|
25
|
-
} else {
|
|
26
|
-
messages[keyWithPrefix] = value;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return messages;
|
|
2
|
+
//#region src/i18n/formatNestedMessages.ts
|
|
3
|
+
const formatNestedMessages = (phrases, formattedMessages = {}, prefix = "") => {
|
|
4
|
+
const messages = formattedMessages;
|
|
5
|
+
Object.keys(phrases).forEach((key) => {
|
|
6
|
+
const value = phrases[key];
|
|
7
|
+
if ({}.hasOwnProperty.call(phrases, key)) {
|
|
8
|
+
const keyWithPrefix = prefix ? `${prefix}.${key}` : key;
|
|
9
|
+
if (typeof value === "object") formatNestedMessages(value, formattedMessages, keyWithPrefix);
|
|
10
|
+
else messages[keyWithPrefix] = value;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return messages;
|
|
31
14
|
};
|
|
32
|
-
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.formatNestedMessages = formatNestedMessages;
|
|
18
|
+
//# 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"}
|
package/lib/i18n/i18n.js
CHANGED
|
@@ -1,41 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_messages_en = require('../locale/messages-en.js');
|
|
3
|
+
const require_messages_nb = require('../locale/messages-nb.js');
|
|
4
|
+
const require_messages_nn = require('../locale/messages-nn.js');
|
|
5
|
+
const require_messages_se = require('../locale/messages-se.js');
|
|
6
|
+
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
7
|
+
const i18next = require_rolldown_runtime.__toESM(require("i18next"));
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
9
|
+
//#region src/i18n/i18n.ts
|
|
10
|
+
const supportedTranslationLanguages = [
|
|
11
|
+
"nb",
|
|
12
|
+
"nn",
|
|
13
|
+
"en",
|
|
14
|
+
"se"
|
|
15
|
+
];
|
|
16
|
+
const i18nInstance = i18next.default.use(react_i18next.initReactI18next);
|
|
17
|
+
i18nInstance.init({
|
|
18
|
+
fallbackLng: "nb",
|
|
19
|
+
supportedLngs: supportedTranslationLanguages,
|
|
20
|
+
resources: {
|
|
21
|
+
en: { translation: require_messages_en.messages_en_default },
|
|
22
|
+
nn: { translation: require_messages_nn.messages_nn_default },
|
|
23
|
+
nb: { translation: require_messages_nb.messages_nb_default },
|
|
24
|
+
se: { translation: require_messages_se.messages_se_default }
|
|
25
|
+
}
|
|
5
26
|
});
|
|
6
|
-
exports.supportedTranslationLanguages = exports.i18nInstance = void 0;
|
|
7
|
-
var _i18next = _interopRequireDefault(require("i18next"));
|
|
8
|
-
var _reactI18next = require("react-i18next");
|
|
9
|
-
var _messagesEn = _interopRequireDefault(require("../locale/messages-en"));
|
|
10
|
-
var _messagesNb = _interopRequireDefault(require("../locale/messages-nb"));
|
|
11
|
-
var _messagesNn = _interopRequireDefault(require("../locale/messages-nn"));
|
|
12
|
-
var _messagesSe = _interopRequireDefault(require("../locale/messages-se"));
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
/**
|
|
15
|
-
* Copyright (c) 2021-present, NDLA.
|
|
16
|
-
*
|
|
17
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
18
|
-
* LICENSE file in the root directory of this source tree.
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
supportedLngs: supportedTranslationLanguages,
|
|
27
|
-
resources: {
|
|
28
|
-
en: {
|
|
29
|
-
translation: _messagesEn.default
|
|
30
|
-
},
|
|
31
|
-
nn: {
|
|
32
|
-
translation: _messagesNn.default
|
|
33
|
-
},
|
|
34
|
-
nb: {
|
|
35
|
-
translation: _messagesNb.default
|
|
36
|
-
},
|
|
37
|
-
se: {
|
|
38
|
-
translation: _messagesSe.default
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.i18nInstance = i18nInstance;
|
|
30
|
+
exports.supportedTranslationLanguages = supportedTranslationLanguages;
|
|
31
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","names":["initReactI18next","messagesEN","messagesNN","messagesNB","messagesSE"],"sources":["../../src/i18n/i18n.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 i18n from \"i18next\";\nimport { initReactI18next } from \"react-i18next\";\nimport messagesEN from \"../locale/messages-en\";\nimport messagesNB from \"../locale/messages-nb\";\nimport messagesNN from \"../locale/messages-nn\";\nimport messagesSE from \"../locale/messages-se\";\n\nexport const supportedTranslationLanguages = [\"nb\", \"nn\", \"en\", \"se\"] as const;\nconst i18nInstance = i18n.use(initReactI18next);\n\ni18nInstance.init({\n fallbackLng: \"nb\",\n supportedLngs: supportedTranslationLanguages,\n resources: {\n en: {\n translation: messagesEN,\n },\n nn: {\n translation: messagesNN,\n },\n nb: {\n translation: messagesNB,\n },\n se: {\n translation: messagesSE,\n },\n },\n});\n\nexport { i18nInstance };\n"],"mappings":";;;;;;;;;AAeA,MAAa,gCAAgC;CAAC;CAAM;CAAM;CAAM;AAAK;AACrE,MAAM,eAAe,gBAAK,IAAIA,+BAAiB;AAE/C,aAAa,KAAK;CAChB,aAAa;CACb,eAAe;CACf,WAAW;EACT,IAAI,EACF,aAAaC,wCACd;EACD,IAAI,EACF,aAAaC,wCACd;EACD,IAAI,EACF,aAAaC,wCACd;EACD,IAAI,EACF,aAAaC,wCACd;CACF;AACF,EAAC"}
|