@ndla/ui 48.0.0 → 49.0.1

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.
Files changed (176) hide show
  1. package/es/BlogPost/BlogPost.js +6 -6
  2. package/es/CampaignBlock/CampaignBlock.js +8 -8
  3. package/es/ContactBlock/ContactBlock.js +29 -20
  4. package/es/CopyParagraphButton/CopyParagraphButton.js +30 -58
  5. package/es/CopyParagraphButton/index.js +1 -3
  6. package/es/Embed/BrightcoveEmbed.js +8 -6
  7. package/es/Embed/ImageEmbed.js +7 -5
  8. package/es/Embed/RelatedContentEmbed.js +3 -3
  9. package/es/FactBox/FactBox.js +64 -19
  10. package/es/FactBox/index.js +0 -1
  11. package/es/Figure/index.js +0 -2
  12. package/es/FileList/File.js +46 -24
  13. package/es/FileList/FileList.js +18 -14
  14. package/es/FileList/index.js +0 -2
  15. package/es/LinkBlock/LinkBlock.js +7 -7
  16. package/es/Messages/index.js +1 -2
  17. package/es/Navigation/index.js +1 -2
  18. package/es/RelatedArticleList/RelatedArticleList.js +80 -35
  19. package/es/RelatedArticleList/index.js +2 -3
  20. package/es/Search/index.js +0 -1
  21. package/es/all.css +1 -1
  22. package/es/i18n/i18n.js +2 -1
  23. package/es/index.js +9 -11
  24. package/es/utils/relativeUrl.js +17 -2
  25. package/lib/BlogPost/BlogPost.js +5 -5
  26. package/lib/CampaignBlock/CampaignBlock.js +7 -7
  27. package/lib/ContactBlock/ContactBlock.js +28 -19
  28. package/lib/CopyParagraphButton/CopyParagraphButton.d.ts +5 -4
  29. package/lib/CopyParagraphButton/CopyParagraphButton.js +29 -57
  30. package/lib/CopyParagraphButton/index.d.ts +1 -3
  31. package/lib/CopyParagraphButton/index.js +0 -14
  32. package/lib/Embed/BrightcoveEmbed.d.ts +3 -2
  33. package/lib/Embed/BrightcoveEmbed.js +8 -6
  34. package/lib/Embed/ImageEmbed.d.ts +3 -2
  35. package/lib/Embed/ImageEmbed.js +7 -5
  36. package/lib/Embed/RelatedContentEmbed.js +3 -3
  37. package/lib/Embed/index.d.ts +1 -1
  38. package/lib/Embed/types.d.ts +1 -0
  39. package/lib/FactBox/FactBox.d.ts +1 -4
  40. package/lib/FactBox/FactBox.js +72 -27
  41. package/lib/FactBox/index.d.ts +0 -1
  42. package/lib/FactBox/index.js +0 -7
  43. package/lib/Figure/index.d.ts +0 -2
  44. package/lib/Figure/index.js +0 -14
  45. package/lib/FileList/File.d.ts +22 -3
  46. package/lib/FileList/File.js +45 -25
  47. package/lib/FileList/FileList.d.ts +10 -14
  48. package/lib/FileList/FileList.js +17 -15
  49. package/lib/FileList/index.d.ts +0 -2
  50. package/lib/FileList/index.js +0 -14
  51. package/lib/LinkBlock/LinkBlock.js +6 -6
  52. package/lib/Messages/index.d.ts +1 -2
  53. package/lib/Messages/index.js +0 -7
  54. package/lib/Navigation/index.d.ts +1 -2
  55. package/lib/Navigation/index.js +0 -7
  56. package/lib/RelatedArticleList/RelatedArticleList.d.ts +16 -17
  57. package/lib/RelatedArticleList/RelatedArticleList.js +78 -35
  58. package/lib/RelatedArticleList/index.d.ts +2 -3
  59. package/lib/RelatedArticleList/index.js +2 -12
  60. package/lib/Search/index.d.ts +0 -1
  61. package/lib/Search/index.js +0 -7
  62. package/lib/all.css +1 -1
  63. package/lib/i18n/i18n.d.ts +1 -0
  64. package/lib/i18n/i18n.js +4 -2
  65. package/lib/index.d.ts +10 -12
  66. package/lib/index.js +9 -89
  67. package/lib/utils/relativeUrl.d.ts +1 -1
  68. package/lib/utils/relativeUrl.js +19 -4
  69. package/package.json +17 -17
  70. package/src/BlogPost/BlogPost.tsx +2 -2
  71. package/src/CampaignBlock/CampaignBlock.tsx +2 -2
  72. package/src/ContactBlock/ContactBlock.tsx +12 -6
  73. package/src/CopyParagraphButton/CopyParagraphButton.tsx +24 -46
  74. package/src/CopyParagraphButton/index.tsx +1 -3
  75. package/src/Embed/BrightcoveEmbed.tsx +6 -5
  76. package/src/Embed/ImageEmbed.tsx +14 -5
  77. package/src/Embed/RelatedContentEmbed.stories.tsx +9 -9
  78. package/src/Embed/RelatedContentEmbed.tsx +3 -3
  79. package/src/Embed/index.ts +1 -1
  80. package/src/Embed/types.ts +2 -0
  81. package/src/FactBox/FactBox.tsx +29 -16
  82. package/src/FactBox/Factbox.stories.tsx +4 -4
  83. package/src/FactBox/index.ts +0 -2
  84. package/src/Figure/index.ts +0 -2
  85. package/src/FileList/File.tsx +62 -32
  86. package/src/FileList/FileList.stories.tsx +15 -15
  87. package/src/FileList/FileList.tsx +21 -27
  88. package/src/FileList/index.ts +0 -2
  89. package/src/LinkBlock/LinkBlock.tsx +2 -2
  90. package/src/Messages/index.ts +1 -2
  91. package/src/Navigation/index.ts +1 -2
  92. package/src/RelatedArticleList/RelatedArticleList.tsx +53 -47
  93. package/src/RelatedArticleList/index.ts +2 -3
  94. package/src/Search/index.ts +0 -1
  95. package/src/i18n/i18n.ts +2 -1
  96. package/src/index.ts +11 -14
  97. package/src/main.scss +0 -1
  98. package/src/utils/__tests__/relativeUrl-test.tsx +72 -0
  99. package/src/utils/relativeUrl.ts +19 -2
  100. package/es/CopyParagraphButton/CopyParagraphButtonV2.js +0 -87
  101. package/es/CopyParagraphButton/initCopyParagraphButtons.js +0 -29
  102. package/es/FactBox/FactBoxV2.js +0 -93
  103. package/es/Figure/FigureBylineExpandButton.js +0 -29
  104. package/es/Figure/FigureExpandButton.js +0 -30
  105. package/es/FileList/FileListV2.js +0 -47
  106. package/es/FileList/FileV2.js +0 -32
  107. package/es/Masthead/MastheadSearchModal.js +0 -82
  108. package/es/Messages/MessageBoxTag.js +0 -33
  109. package/es/MultidisciplinarySubject/List.js +0 -52
  110. package/es/MultidisciplinarySubject/ListItem.js +0 -90
  111. package/es/MultidisciplinarySubject/MultidisciplinarySubject.js +0 -125
  112. package/es/MultidisciplinarySubject/index.js +0 -10
  113. package/es/Navigation/NavigationTopicAbout.js +0 -164
  114. package/es/RelatedArticleList/RelatedArticleV2.js +0 -125
  115. package/es/Search/ToggleSearchButton.js +0 -51
  116. package/es/Translation/Translation.js +0 -33
  117. package/es/Translation/TranslationLine.js +0 -47
  118. package/es/Translation/index.js +0 -2
  119. package/lib/CopyParagraphButton/CopyParagraphButtonV2.d.ts +0 -15
  120. package/lib/CopyParagraphButton/CopyParagraphButtonV2.js +0 -92
  121. package/lib/CopyParagraphButton/initCopyParagraphButtons.d.ts +0 -2
  122. package/lib/CopyParagraphButton/initCopyParagraphButtons.js +0 -38
  123. package/lib/FactBox/FactBoxV2.d.ts +0 -13
  124. package/lib/FactBox/FactBoxV2.js +0 -98
  125. package/lib/Figure/FigureBylineExpandButton.d.ts +0 -16
  126. package/lib/Figure/FigureBylineExpandButton.js +0 -35
  127. package/lib/Figure/FigureExpandButton.d.ts +0 -16
  128. package/lib/Figure/FigureExpandButton.js +0 -35
  129. package/lib/FileList/FileListV2.d.ts +0 -13
  130. package/lib/FileList/FileListV2.js +0 -52
  131. package/lib/FileList/FileV2.d.ts +0 -15
  132. package/lib/FileList/FileV2.js +0 -40
  133. package/lib/Masthead/MastheadSearchModal.d.ts +0 -8
  134. package/lib/Masthead/MastheadSearchModal.js +0 -89
  135. package/lib/Messages/MessageBoxTag.d.ts +0 -12
  136. package/lib/Messages/MessageBoxTag.js +0 -40
  137. package/lib/MultidisciplinarySubject/List.d.ts +0 -7
  138. package/lib/MultidisciplinarySubject/List.js +0 -59
  139. package/lib/MultidisciplinarySubject/ListItem.d.ts +0 -10
  140. package/lib/MultidisciplinarySubject/ListItem.js +0 -97
  141. package/lib/MultidisciplinarySubject/MultidisciplinarySubject.d.ts +0 -13
  142. package/lib/MultidisciplinarySubject/MultidisciplinarySubject.js +0 -135
  143. package/lib/MultidisciplinarySubject/index.d.ts +0 -9
  144. package/lib/MultidisciplinarySubject/index.js +0 -17
  145. package/lib/Navigation/NavigationTopicAbout.d.ts +0 -13
  146. package/lib/Navigation/NavigationTopicAbout.js +0 -171
  147. package/lib/RelatedArticleList/RelatedArticleV2.d.ts +0 -26
  148. package/lib/RelatedArticleList/RelatedArticleV2.js +0 -131
  149. package/lib/Search/ToggleSearchButton.d.ts +0 -14
  150. package/lib/Search/ToggleSearchButton.js +0 -57
  151. package/lib/Translation/Translation.d.ts +0 -14
  152. package/lib/Translation/Translation.js +0 -38
  153. package/lib/Translation/TranslationLine.d.ts +0 -16
  154. package/lib/Translation/TranslationLine.js +0 -51
  155. package/lib/Translation/index.d.ts +0 -2
  156. package/lib/Translation/index.js +0 -20
  157. package/src/CopyParagraphButton/CopyParagraphButtonV2.tsx +0 -85
  158. package/src/CopyParagraphButton/initCopyParagraphButtons.tsx +0 -27
  159. package/src/FactBox/FactBoxV2.tsx +0 -56
  160. package/src/Figure/FigureBylineExpandButton.tsx +0 -34
  161. package/src/Figure/FigureExpandButton.tsx +0 -35
  162. package/src/FileList/FileListV2.tsx +0 -58
  163. package/src/FileList/FileV2.tsx +0 -33
  164. package/src/Masthead/MastheadSearchModal.tsx +0 -101
  165. package/src/Messages/MessageBoxTag.tsx +0 -34
  166. package/src/MultidisciplinarySubject/List.tsx +0 -49
  167. package/src/MultidisciplinarySubject/ListItem.tsx +0 -74
  168. package/src/MultidisciplinarySubject/MultidisciplinarySubject.tsx +0 -117
  169. package/src/MultidisciplinarySubject/index.ts +0 -11
  170. package/src/Navigation/NavigationTopicAbout.tsx +0 -171
  171. package/src/RelatedArticleList/RelatedArticleV2.tsx +0 -101
  172. package/src/Search/ToggleSearchButton.tsx +0 -64
  173. package/src/Translation/Translation.tsx +0 -29
  174. package/src/Translation/TranslationLine.tsx +0 -42
  175. package/src/Translation/component.translation.scss +0 -53
  176. package/src/Translation/index.ts +0 -2
@@ -1,2 +1,3 @@
1
+ export declare const supportedTranslationLanguages: readonly ["nb", "nn", "en", "se", "sma"];
1
2
  declare const i18nInstance: import("i18next").i18n;
2
3
  export { i18nInstance };
package/lib/i18n/i18n.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.i18nInstance = void 0;
6
+ exports.supportedTranslationLanguages = exports.i18nInstance = void 0;
7
7
  var _i18next = _interopRequireDefault(require("i18next"));
8
8
  var _reactI18next = require("react-i18next");
9
9
  var _i18nextBrowserLanguagedetector = _interopRequireDefault(require("i18next-browser-languagedetector"));
@@ -26,13 +26,15 @@ var DETECTION_OPTIONS = {
26
26
  caches: ['localStorage'],
27
27
  lookupLocalStorage: 'i18nextLng'
28
28
  };
29
+ var supportedTranslationLanguages = ['nb', 'nn', 'en', 'se', 'sma'];
30
+ exports.supportedTranslationLanguages = supportedTranslationLanguages;
29
31
  var i18nInstance = _i18next.default.use(_reactI18next.initReactI18next).use(_i18nextBrowserLanguagedetector.default);
30
32
  exports.i18nInstance = i18nInstance;
31
33
  i18nInstance.init({
32
34
  compatibilityJSON: 'v3',
33
35
  detection: DETECTION_OPTIONS,
34
36
  fallbackLng: 'nb',
35
- supportedLngs: ['nb', 'nn', 'en', 'se', 'sma'],
37
+ supportedLngs: supportedTranslationLanguages,
36
38
  resources: {
37
39
  en: {
38
40
  translation: _messagesEn.default
package/lib/index.d.ts CHANGED
@@ -10,40 +10,38 @@ export { default as FramedContent } from './FramedContent';
10
10
  export { default as SectionHeading } from './SectionHeading';
11
11
  export { ConceptNotionV2, ImageEmbed, AudioEmbed, H5pEmbed, ExternalEmbed, IframeEmbed, FootnoteEmbed, BrightcoveEmbed, ContentLinkEmbed, RelatedContentEmbed, ConceptEmbed, ConceptListEmbed, UnknownEmbed, InlineConcept, BlockConcept, } from './Embed';
12
12
  export { ArticleByline, ArticleFootNotes, ArticleIntroduction, ArticleTitle, ArticleWrapper, ArticleHeaderWrapper, default as Article, } from './Article';
13
+ export { getPossiblyRelativeUrl } from './utils/relativeUrl';
13
14
  export { default as Table, TableStyling } from './Table';
14
15
  export { default as ResourcesWrapper, ResourcesTopicTitle } from './ResourcesWrapper';
15
16
  export { default as NoContentBox } from './NoContentBox';
16
17
  export { default as Masthead, getMastheadHeight, useMastheadHeight, SkipToMainContent } from './Masthead';
17
18
  export { default as ContentLoader } from './ContentLoader';
18
- export { default as RelatedArticleList, RelatedArticle, RelatedArticleListV2 } from './RelatedArticleList';
19
+ export { default as RelatedArticleList, RelatedArticle } from './RelatedArticleList';
19
20
  export { ErrorResourceAccessDenied, default as ErrorMessage } from './ErrorMessage';
20
- export { default as FileList, File, FileListV2, FileV2, PdfFile } from './FileList';
21
+ export { default as FileList, File, PdfFile } from './FileList';
21
22
  export { default as Logo } from './Logo';
22
- export { default as FactBox, FactBoxV2 } from './FactBox';
23
+ export { default as FactBox } from './FactBox';
23
24
  export { default as Image, ImageLink, makeSrcQueryString } from './Image';
24
25
  export type { ImageCrop, ImageFocalPoint } from './Image';
25
26
  export type { HeroContentType } from './Hero';
26
27
  export { SubjectMaterialHero, TasksAndActivitiesHero, AssessmentResourcesHero, SubjectHero, ExternalLearningResourcesHero, SourceMaterialHero, Hero, NdlaFilmHero, HeroContent, } from './Hero';
27
28
  export { FilterList, FilterListPhone, FilterButtons, ToggleItem } from './Filter';
28
29
  export { Footer, EditorName, FooterText } from './Footer';
29
- export { Figure, FigureExpandButton, FigureOpenDialogButton, FigureBylineExpandButton } from './Figure';
30
+ export { Figure, FigureOpenDialogButton } from './Figure';
30
31
  export type { FigureType } from './Figure';
31
32
  export { LanguageSelector } from './LanguageSelector';
32
33
  export { LearningPathWrapper, LearningPathContent, LearningPathMenu, LearningPathSticky, LearningPathInformation, LearningPathStickySibling, LearningPathStickyPlaceholder, LearningPathLastStepNavigation, LearningPathMobileStepInfo, LearningPathMobileHeader, } from './LearningPaths';
33
- export { Translation, TranslationLine } from './Translation';
34
34
  export { default as SearchResultSleeve } from './Search/SearchResultSleeve';
35
35
  export { default as ContentTypeResult } from './Search/ContentTypeResult';
36
36
  export { SearchFieldForm } from './Search/SearchFieldForm';
37
- export { default as MastheadSearchModal } from './Masthead/MastheadSearchModal';
38
37
  export { default as resourceTypeColor } from './utils/resourceTypeColor';
39
38
  export { default as CreatedBy } from './CreatedBy';
40
- export { MessageBox, MessageBoxTag, MessageBanner } from './Messages';
39
+ export { MessageBox, MessageBanner } from './Messages';
41
40
  export { ResourceBox } from './ResourceBox';
42
41
  export { default as AudioPlayer } from './AudioPlayer';
43
- export { NavigationBox, NavigationTopicAbout } from './Navigation';
42
+ export { NavigationBox } from './Navigation';
44
43
  export { default as Programme } from './Programme';
45
44
  export { default as CompetenceGoalTab } from './CompetenceGoalTab';
46
- export { default as MultidisciplinarySubject } from './MultidisciplinarySubject';
47
45
  export { SearchTypeResult, SearchHeader, SearchFieldHeader, SearchNotionsResult, SearchSubjectResult, SearchFilterContent, } from './SearchTypeResult';
48
46
  export { default as constants } from './model';
49
47
  export { default as messagesNB } from './locale/messages-nb';
@@ -66,7 +64,7 @@ export { MediaList, MediaListItem, MediaListItemBody, MediaListItemActions, Medi
66
64
  export type { ItemType } from './MediaList';
67
65
  export { default as ContentTypeBadge, SubjectMaterialBadge, TasksAndActivitiesBadge, AssessmentResourcesBadge, LearningPathBadge, SubjectBadge, ExternalLearningResourcesBadge, SourceMaterialBadge, } from './ContentTypeBadge';
68
66
  export { SubjectHeader, SubjectBanner } from './Subject';
69
- export { default as CopyParagraphButton, CopyParagraphButtonV2 } from './CopyParagraphButton';
67
+ export { default as CopyParagraphButton } from './CopyParagraphButton';
70
68
  export { default as ContentPlaceholder } from './ContentPlaceholder';
71
69
  export { Notion } from './Notion';
72
70
  export { BannerCard } from './BannerCard';
@@ -79,14 +77,14 @@ export { SnackbarProvider, useSnack, BaseSnack, DefaultSnackbar } from './SnackB
79
77
  export type { Snack, SnackContext } from './SnackBar';
80
78
  export { TreeStructure } from './TreeStructure';
81
79
  export type { TreeStructureProps } from './TreeStructure';
82
- export { SearchField, SearchResultList, SearchResultItem, ActiveFilters, ToggleSearchButton } from './Search';
80
+ export { SearchField, SearchResultList, SearchResultItem, ActiveFilters } from './Search';
83
81
  export { default as LetterFilter } from './LetterFilter';
84
82
  export { OrderedList, UnOrderedList } from './List';
85
83
  export { BlogPostV2 } from './BlogPost';
86
84
  export { ProgrammeCard } from './ProgrammeCard';
87
85
  export { KeyFigure } from './KeyFigure';
88
86
  export { default as ContactBlock } from './ContactBlock';
89
- export type { HeartButtonType } from './Embed';
87
+ export type { HeartButtonType, RenderContext } from './Embed';
90
88
  export { CampaignBlock } from './CampaignBlock';
91
89
  export { Grid, GridParallaxItem } from './Grid';
92
90
  export type { GridType } from './Grid';
package/lib/index.js CHANGED
@@ -214,12 +214,6 @@ Object.defineProperty(exports, "CopyParagraphButton", {
214
214
  return _CopyParagraphButton.default;
215
215
  }
216
216
  });
217
- Object.defineProperty(exports, "CopyParagraphButtonV2", {
218
- enumerable: true,
219
- get: function get() {
220
- return _CopyParagraphButton.CopyParagraphButtonV2;
221
- }
222
- });
223
217
  Object.defineProperty(exports, "CreatedBy", {
224
218
  enumerable: true,
225
219
  get: function get() {
@@ -304,30 +298,12 @@ Object.defineProperty(exports, "FactBox", {
304
298
  return _FactBox.default;
305
299
  }
306
300
  });
307
- Object.defineProperty(exports, "FactBoxV2", {
308
- enumerable: true,
309
- get: function get() {
310
- return _FactBox.FactBoxV2;
311
- }
312
- });
313
301
  Object.defineProperty(exports, "Figure", {
314
302
  enumerable: true,
315
303
  get: function get() {
316
304
  return _Figure.Figure;
317
305
  }
318
306
  });
319
- Object.defineProperty(exports, "FigureBylineExpandButton", {
320
- enumerable: true,
321
- get: function get() {
322
- return _Figure.FigureBylineExpandButton;
323
- }
324
- });
325
- Object.defineProperty(exports, "FigureExpandButton", {
326
- enumerable: true,
327
- get: function get() {
328
- return _Figure.FigureExpandButton;
329
- }
330
- });
331
307
  Object.defineProperty(exports, "FigureOpenDialogButton", {
332
308
  enumerable: true,
333
309
  get: function get() {
@@ -346,18 +322,6 @@ Object.defineProperty(exports, "FileList", {
346
322
  return _FileList.default;
347
323
  }
348
324
  });
349
- Object.defineProperty(exports, "FileListV2", {
350
- enumerable: true,
351
- get: function get() {
352
- return _FileList.FileListV2;
353
- }
354
- });
355
- Object.defineProperty(exports, "FileV2", {
356
- enumerable: true,
357
- get: function get() {
358
- return _FileList.FileV2;
359
- }
360
- });
361
325
  Object.defineProperty(exports, "FilmMovieList", {
362
326
  enumerable: true,
363
327
  get: function get() {
@@ -634,12 +598,6 @@ Object.defineProperty(exports, "Masthead", {
634
598
  return _Masthead.default;
635
599
  }
636
600
  });
637
- Object.defineProperty(exports, "MastheadSearchModal", {
638
- enumerable: true,
639
- get: function get() {
640
- return _MastheadSearchModal.default;
641
- }
642
- });
643
601
  Object.defineProperty(exports, "MediaList", {
644
602
  enumerable: true,
645
603
  get: function get() {
@@ -688,36 +646,18 @@ Object.defineProperty(exports, "MessageBox", {
688
646
  return _Messages.MessageBox;
689
647
  }
690
648
  });
691
- Object.defineProperty(exports, "MessageBoxTag", {
692
- enumerable: true,
693
- get: function get() {
694
- return _Messages.MessageBoxTag;
695
- }
696
- });
697
649
  Object.defineProperty(exports, "MovieGrid", {
698
650
  enumerable: true,
699
651
  get: function get() {
700
652
  return _NDLAFilm.MovieGrid;
701
653
  }
702
654
  });
703
- Object.defineProperty(exports, "MultidisciplinarySubject", {
704
- enumerable: true,
705
- get: function get() {
706
- return _MultidisciplinarySubject.default;
707
- }
708
- });
709
655
  Object.defineProperty(exports, "NavigationBox", {
710
656
  enumerable: true,
711
657
  get: function get() {
712
658
  return _Navigation.NavigationBox;
713
659
  }
714
660
  });
715
- Object.defineProperty(exports, "NavigationTopicAbout", {
716
- enumerable: true,
717
- get: function get() {
718
- return _Navigation.NavigationTopicAbout;
719
- }
720
- });
721
661
  Object.defineProperty(exports, "NdlaFilmHero", {
722
662
  enumerable: true,
723
663
  get: function get() {
@@ -790,12 +730,6 @@ Object.defineProperty(exports, "RelatedArticleList", {
790
730
  return _RelatedArticleList.default;
791
731
  }
792
732
  });
793
- Object.defineProperty(exports, "RelatedArticleListV2", {
794
- enumerable: true,
795
- get: function get() {
796
- return _RelatedArticleList.RelatedArticleListV2;
797
- }
798
- });
799
733
  Object.defineProperty(exports, "RelatedContentEmbed", {
800
734
  enumerable: true,
801
735
  get: function get() {
@@ -994,12 +928,6 @@ Object.defineProperty(exports, "ToggleItem", {
994
928
  return _Filter.ToggleItem;
995
929
  }
996
930
  });
997
- Object.defineProperty(exports, "ToggleSearchButton", {
998
- enumerable: true,
999
- get: function get() {
1000
- return _Search.ToggleSearchButton;
1001
- }
1002
- });
1003
931
  Object.defineProperty(exports, "ToolboxInfo", {
1004
932
  enumerable: true,
1005
933
  get: function get() {
@@ -1012,18 +940,6 @@ Object.defineProperty(exports, "Topic", {
1012
940
  return _Topic.default;
1013
941
  }
1014
942
  });
1015
- Object.defineProperty(exports, "Translation", {
1016
- enumerable: true,
1017
- get: function get() {
1018
- return _Translation.Translation;
1019
- }
1020
- });
1021
- Object.defineProperty(exports, "TranslationLine", {
1022
- enumerable: true,
1023
- get: function get() {
1024
- return _Translation.TranslationLine;
1025
- }
1026
- });
1027
943
  Object.defineProperty(exports, "TreeStructure", {
1028
944
  enumerable: true,
1029
945
  get: function get() {
@@ -1066,6 +982,12 @@ Object.defineProperty(exports, "getMastheadHeight", {
1066
982
  return _Masthead.getMastheadHeight;
1067
983
  }
1068
984
  });
985
+ Object.defineProperty(exports, "getPossiblyRelativeUrl", {
986
+ enumerable: true,
987
+ get: function get() {
988
+ return _relativeUrl.getPossiblyRelativeUrl;
989
+ }
990
+ });
1069
991
  Object.defineProperty(exports, "i18nInstance", {
1070
992
  enumerable: true,
1071
993
  get: function get() {
@@ -1131,6 +1053,7 @@ var _FramedContent = _interopRequireDefault(require("./FramedContent"));
1131
1053
  var _SectionHeading = _interopRequireDefault(require("./SectionHeading"));
1132
1054
  var _Embed = require("./Embed");
1133
1055
  var _Article = _interopRequireWildcard(require("./Article"));
1056
+ var _relativeUrl = require("./utils/relativeUrl");
1134
1057
  var _Table = _interopRequireWildcard(require("./Table"));
1135
1058
  var _ResourcesWrapper = _interopRequireWildcard(require("./ResourcesWrapper"));
1136
1059
  var _NoContentBox = _interopRequireDefault(require("./NoContentBox"));
@@ -1140,7 +1063,7 @@ var _RelatedArticleList = _interopRequireWildcard(require("./RelatedArticleList"
1140
1063
  var _ErrorMessage = _interopRequireWildcard(require("./ErrorMessage"));
1141
1064
  var _FileList = _interopRequireWildcard(require("./FileList"));
1142
1065
  var _Logo = _interopRequireDefault(require("./Logo"));
1143
- var _FactBox = _interopRequireWildcard(require("./FactBox"));
1066
+ var _FactBox = _interopRequireDefault(require("./FactBox"));
1144
1067
  var _Image = _interopRequireWildcard(require("./Image"));
1145
1068
  var _Hero = require("./Hero");
1146
1069
  var _Filter = require("./Filter");
@@ -1148,11 +1071,9 @@ var _Footer = require("./Footer");
1148
1071
  var _Figure = require("./Figure");
1149
1072
  var _LanguageSelector = require("./LanguageSelector");
1150
1073
  var _LearningPaths = require("./LearningPaths");
1151
- var _Translation = require("./Translation");
1152
1074
  var _SearchResultSleeve = _interopRequireDefault(require("./Search/SearchResultSleeve"));
1153
1075
  var _ContentTypeResult = _interopRequireDefault(require("./Search/ContentTypeResult"));
1154
1076
  var _SearchFieldForm = require("./Search/SearchFieldForm");
1155
- var _MastheadSearchModal = _interopRequireDefault(require("./Masthead/MastheadSearchModal"));
1156
1077
  var _resourceTypeColor = _interopRequireDefault(require("./utils/resourceTypeColor"));
1157
1078
  var _CreatedBy = _interopRequireDefault(require("./CreatedBy"));
1158
1079
  var _Messages = require("./Messages");
@@ -1161,7 +1082,6 @@ var _AudioPlayer = _interopRequireDefault(require("./AudioPlayer"));
1161
1082
  var _Navigation = require("./Navigation");
1162
1083
  var _Programme = _interopRequireDefault(require("./Programme"));
1163
1084
  var _CompetenceGoalTab = _interopRequireDefault(require("./CompetenceGoalTab"));
1164
- var _MultidisciplinarySubject = _interopRequireDefault(require("./MultidisciplinarySubject"));
1165
1085
  var _SearchTypeResult = require("./SearchTypeResult");
1166
1086
  var _model = _interopRequireDefault(require("./model"));
1167
1087
  var _messagesNb = _interopRequireDefault(require("./locale/messages-nb"));
@@ -1181,7 +1101,7 @@ var _NDLAFilm = require("./NDLAFilm");
1181
1101
  var _MediaList = require("./MediaList");
1182
1102
  var _ContentTypeBadge = _interopRequireWildcard(require("./ContentTypeBadge"));
1183
1103
  var _Subject = require("./Subject");
1184
- var _CopyParagraphButton = _interopRequireWildcard(require("./CopyParagraphButton"));
1104
+ var _CopyParagraphButton = _interopRequireDefault(require("./CopyParagraphButton"));
1185
1105
  var _ContentPlaceholder = _interopRequireDefault(require("./ContentPlaceholder"));
1186
1106
  var _Notion = require("./Notion");
1187
1107
  var _BannerCard = require("./BannerCard");
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare const usePossiblyRelativeUrl: (url: string, path?: string) => string;
8
+ export declare const getPossiblyRelativeUrl: (url: string, path?: string) => string;
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.usePossiblyRelativeUrl = void 0;
6
+ exports.getPossiblyRelativeUrl = void 0;
7
+ var _i18n = require("../i18n/i18n");
7
8
  /**
8
9
  * Copyright (c) 2023-present, NDLA.
9
10
  *
@@ -13,13 +14,27 @@ exports.usePossiblyRelativeUrl = void 0;
13
14
  */
14
15
 
15
16
  var ENV_REGEX = /(staging|test)\.?/;
17
+ var LANGUAGE_REGEX = new RegExp("^\\/((?:".concat(_i18n.supportedTranslationLanguages.join('|'), ")(?:$|\\/))"), '');
16
18
  var NDLA_URL = /(.*\.)?ndla.no.*/;
17
- var usePossiblyRelativeUrl = function usePossiblyRelativeUrl(url, path) {
19
+ var REPLACE_WWW = /^www\./;
20
+ var getPossiblyRelativeUrl = function getPossiblyRelativeUrl(url, path) {
18
21
  if (!path) return url;
22
+ // If not on NDLA, or if url is not a NDLA url, return url as is
19
23
  if (!NDLA_URL.test(url) || !NDLA_URL.test(path)) return url;
24
+ //Remove environment info
20
25
  var urlObj = new URL(url.replace(ENV_REGEX, ''));
21
26
  var pathObj = new URL(path.replace(ENV_REGEX, ''));
22
- if (urlObj.host === pathObj.host) return urlObj.pathname;
27
+ // If the host is the same, return the relative path
28
+ if (urlObj.hostname.replace(REPLACE_WWW, '') === pathObj.hostname.replace(REPLACE_WWW, '')) {
29
+ // Replace the language part of the url with the language part of the path
30
+ // If the path language part does not exist, remove it.
31
+ var urlMatch = urlObj.pathname.match(LANGUAGE_REGEX);
32
+ var pathMatch = pathObj.pathname.match(LANGUAGE_REGEX);
33
+ if (urlMatch !== null && urlMatch !== void 0 && urlMatch[1] && (urlMatch === null || urlMatch === void 0 ? void 0 : urlMatch[1]) !== (pathMatch === null || pathMatch === void 0 ? void 0 : pathMatch[1])) {
34
+ return urlObj.pathname.replace(urlMatch[1], (pathMatch === null || pathMatch === void 0 ? void 0 : pathMatch[1]) || '');
35
+ }
36
+ return urlObj.pathname;
37
+ }
23
38
  return url;
24
39
  };
25
- exports.usePossiblyRelativeUrl = usePossiblyRelativeUrl;
40
+ exports.getPossiblyRelativeUrl = getPossiblyRelativeUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "48.0.0",
3
+ "version": "49.0.1",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -31,23 +31,23 @@
31
31
  "types"
32
32
  ],
33
33
  "dependencies": {
34
- "@ndla/accordion": "^3.0.0",
35
- "@ndla/button": "^12.0.6",
36
- "@ndla/carousel": "^4.0.9",
37
- "@ndla/core": "^4.2.3",
38
- "@ndla/dropdown-menu": "^1.0.12",
39
- "@ndla/forms": "^5.0.8",
34
+ "@ndla/accordion": "^3.0.2",
35
+ "@ndla/button": "^12.0.8",
36
+ "@ndla/carousel": "^4.0.10",
37
+ "@ndla/core": "^4.2.4",
38
+ "@ndla/dropdown-menu": "^1.0.13",
39
+ "@ndla/forms": "^5.0.10",
40
40
  "@ndla/hooks": "^2.1.1",
41
- "@ndla/icons": "^4.1.4",
41
+ "@ndla/icons": "^4.1.5",
42
42
  "@ndla/licenses": "^7.2.2",
43
- "@ndla/modal": "^5.0.6",
44
- "@ndla/notion": "^6.0.8",
45
- "@ndla/safelink": "^4.1.31",
46
- "@ndla/select": "^3.1.4",
47
- "@ndla/switch": "^1.1.18",
48
- "@ndla/tabs": "^3.1.3",
49
- "@ndla/tooltip": "^5.0.6",
50
- "@ndla/typography": "^0.2.5",
43
+ "@ndla/modal": "^5.0.7",
44
+ "@ndla/notion": "^6.0.10",
45
+ "@ndla/safelink": "^4.1.33",
46
+ "@ndla/select": "^3.1.5",
47
+ "@ndla/switch": "^1.1.19",
48
+ "@ndla/tabs": "^3.1.4",
49
+ "@ndla/tooltip": "^6.0.1",
50
+ "@ndla/typography": "^0.2.6",
51
51
  "@ndla/util": "^4.0.0",
52
52
  "@radix-ui/react-popover": "^1.0.7",
53
53
  "@radix-ui/react-radio-group": "^1.1.3",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "ed966f21f13cb62868b6aa70406c9acf8234bc75"
83
+ "gitHead": "613a1b7bd697142fdcee7cca42c743f4c2431a40"
84
84
  }
@@ -12,7 +12,7 @@ import SafeLink from '@ndla/safelink';
12
12
  import { breakpoints, colors, fonts, misc, mq, spacing } from '@ndla/core';
13
13
  import { HeadingLevel } from '@ndla/typography';
14
14
  import { useTranslation } from 'react-i18next';
15
- import { usePossiblyRelativeUrl } from '../utils/relativeUrl';
15
+ import { getPossiblyRelativeUrl } from '../utils/relativeUrl';
16
16
 
17
17
  export interface Props {
18
18
  title: {
@@ -84,7 +84,7 @@ const StyledImg = styled.img`
84
84
 
85
85
  const BlogPost = ({ title, author, url, metaImage, headingLevel: Heading = 'h3', size = 'normal', path }: Props) => {
86
86
  const { t } = useTranslation();
87
- const href = usePossiblyRelativeUrl(url, path);
87
+ const href = getPossiblyRelativeUrl(url, path);
88
88
  return (
89
89
  <Container data-size={size} to={href}>
90
90
  <Heading className="blog-title" css={headingCss} lang={title.language}>
@@ -12,7 +12,7 @@ import SafeLink from '@ndla/safelink';
12
12
  import { Forward } from '@ndla/icons/common';
13
13
  import { breakpoints, colors, fonts, spacing, mq, misc } from '@ndla/core';
14
14
  import { HeadingLevel } from '@ndla/typography';
15
- import { usePossiblyRelativeUrl } from '../utils/relativeUrl';
15
+ import { getPossiblyRelativeUrl } from '../utils/relativeUrl';
16
16
 
17
17
  interface Image {
18
18
  src: string;
@@ -94,7 +94,7 @@ const CampaignBlock = ({
94
94
  path,
95
95
  className,
96
96
  }: Props) => {
97
- const href = usePossiblyRelativeUrl(url.url, path);
97
+ const href = getPossiblyRelativeUrl(url.url, path);
98
98
  return (
99
99
  <Container className={className} data-type="campaign-block" data-image-side={imageSide}>
100
100
  {image && <StyledImg src={image.src} height={200} width={240} alt={image.alt} />}
@@ -6,15 +6,17 @@
6
6
  *
7
7
  */
8
8
 
9
+ import { useTranslation } from 'react-i18next';
10
+ import concat from 'lodash/concat';
9
11
  import { css } from '@emotion/react';
10
12
  import styled from '@emotion/styled';
11
13
  import { IImageMetaInformationV3 } from '@ndla/types-backend/image-api';
12
14
  import { spacing, fonts, colors, mq, breakpoints, misc } from '@ndla/core';
13
15
  import { BlobPointy, BlobRound } from '@ndla/icons/common';
14
- import { useTranslation } from 'react-i18next';
15
- import concat from 'lodash/concat';
16
+ import { getLicenseByAbbreviation } from '@ndla/licenses';
16
17
  import { errorSvgSrc } from '../Embed/ImageEmbed';
17
18
  import Image from '../Image';
19
+ import LicenseLink from '../LicenseByline/LicenseLink';
18
20
 
19
21
  const BLOB_WIDTH = 90;
20
22
 
@@ -137,10 +139,13 @@ const ContactBlock = ({
137
139
  blob = 'pointy',
138
140
  lang,
139
141
  }: Props) => {
140
- const { t } = useTranslation();
142
+ const { t, i18n } = useTranslation();
141
143
  const isGreenBlob = blobColor === 'green';
142
144
  const Blob = blob === 'pointy' ? BlobPointy : BlobRound;
143
145
  const authors = concat(image?.copyright.processors, image?.copyright.creators, image?.copyright.rightsholders);
146
+ const license = image?.copyright
147
+ ? getLicenseByAbbreviation(image.copyright.license.license, i18n.language)
148
+ : undefined;
144
149
 
145
150
  return (
146
151
  <BlockWrapper>
@@ -152,9 +157,10 @@ const ContactBlock = ({
152
157
  src={image.image.imageUrl}
153
158
  sizes={`(min-width: ${breakpoints.tablet}) 240px, (max-width: ${breakpoints.tablet}) 500px`}
154
159
  />
155
- {`${t('photo')}: ${authors.reduce((acc, name) => (acc = `${acc} ${name?.name}`), '')} ${
156
- image.copyright.license.license
157
- }`}
160
+ <span>
161
+ {`${t('photo')}: ${authors.reduce((acc, name) => (acc = `${acc} ${name?.name}`), '')} `}
162
+ {!!license && <LicenseLink license={license} asLink={!!license.url.length} />}
163
+ </span>
158
164
  </>
159
165
  ) : (
160
166
  <img alt={t('image.error.url')} src={errorSvgSrc} />
@@ -6,19 +6,17 @@
6
6
  *
7
7
  */
8
8
 
9
- import { useEffect, useState, MouseEvent } from 'react';
10
-
11
- import styled from '@emotion/styled';
12
- import { Link } from '@ndla/icons/common';
9
+ import { ReactNode, useCallback, useEffect, useMemo, useState } from 'react';
13
10
  import { useTranslation } from 'react-i18next';
11
+ import styled from '@emotion/styled';
12
+ import { colors } from '@ndla/core';
14
13
  import Tooltip from '@ndla/tooltip';
14
+ import { Link } from '@ndla/icons/common';
15
15
  import { copyTextToClipboard } from '@ndla/util';
16
- import { colors } from '@ndla/core';
17
16
 
18
17
  const ContainerDiv = styled.div`
19
18
  position: relative;
20
19
  `;
21
-
22
20
  const IconButton = styled.button`
23
21
  position: absolute;
24
22
  left: -3em;
@@ -43,63 +41,43 @@ const IconButton = styled.button`
43
41
  `;
44
42
 
45
43
  interface Props {
46
- title?: string | null;
47
- content?: string | null;
48
- hydrate?: boolean;
49
- }
50
-
51
- interface CopyButtonProps {
52
- title: string;
53
- onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
54
- tooltip: string;
55
- content?: string | null;
44
+ // What to render within the h2
45
+ children: ReactNode;
46
+ copyText: string;
47
+ lang?: string;
56
48
  }
57
-
58
- const CopyButton = ({ onClick, title, tooltip, content }: CopyButtonProps) => {
59
- return (
60
- <div>
61
- <Tooltip tooltip={tooltip}>
62
- <IconButton onClick={onClick} data-title={title} aria-label={`${tooltip}: ${content}`}>
63
- <Link title={''} />
64
- </IconButton>
65
- </Tooltip>
66
- <h2 id={title} tabIndex={-1} dangerouslySetInnerHTML={{ __html: content || '' }} />
67
- </div>
68
- );
69
- };
70
-
71
- const CopyParagraphButton = ({ title, content, hydrate }: Props) => {
72
- const { t } = useTranslation();
49
+ const CopyParagraphButton = ({ children, copyText, lang }: Props) => {
73
50
  const [hasCopied, setHasCopied] = useState(false);
51
+ const { t } = useTranslation();
52
+ const sanitizedTitle = useMemo(() => encodeURIComponent(copyText.replace(/ /g, '-')), [copyText]);
53
+
74
54
  useEffect(() => {
75
55
  if (hasCopied) {
76
56
  setTimeout(() => setHasCopied(false), 3000);
77
57
  }
78
58
  }, [hasCopied]);
79
59
 
80
- if (!title) return null;
81
-
82
- const onCopyClick = (event: MouseEvent<HTMLButtonElement>): void => {
60
+ const onCopyClick = useCallback(() => {
83
61
  setHasCopied(true);
84
- const copyId = event.currentTarget.getAttribute('data-title');
85
62
  const { location } = window;
86
- const newHash = `#${copyId}`;
63
+ const newHash = `#${sanitizedTitle}`;
87
64
  const port = location.port ? `:${location.port}` : '';
88
65
  const urlToCopy = `${location.protocol}//${location.hostname}${port}${location.pathname}${location.search}${newHash}`;
89
66
 
90
67
  copyTextToClipboard(urlToCopy);
91
- };
68
+ }, [sanitizedTitle]);
92
69
 
93
- const sanitizedTitle = encodeURIComponent(title.replace(/ /g, '-'));
94
70
  const tooltip = hasCopied ? t('article.copyPageLinkCopied') : t('article.copyHeaderLink');
95
-
96
- if (hydrate) {
97
- return <CopyButton onClick={onCopyClick} title={sanitizedTitle} tooltip={tooltip} content={content} />;
98
- }
99
-
100
71
  return (
101
- <ContainerDiv data-header-copy-container data-title={title}>
102
- <CopyButton onClick={onCopyClick} title={sanitizedTitle} tooltip={tooltip} content={content} />
72
+ <ContainerDiv>
73
+ <Tooltip tooltip={tooltip}>
74
+ <IconButton onClick={onCopyClick} aria-label={`${tooltip}: ${copyText}`}>
75
+ <Link />
76
+ </IconButton>
77
+ </Tooltip>
78
+ <h2 id={sanitizedTitle} tabIndex={-1} lang={lang}>
79
+ {children}
80
+ </h2>
103
81
  </ContainerDiv>
104
82
  );
105
83
  };
@@ -7,8 +7,6 @@
7
7
  */
8
8
 
9
9
  import CopyParagraphButton from './CopyParagraphButton';
10
- import CopyParagraphButtonV2 from './CopyParagraphButtonV2';
11
- import initCopyParagraphButtons from './initCopyParagraphButtons';
12
10
 
13
- export { CopyParagraphButton, initCopyParagraphButtons, CopyParagraphButtonV2 };
11
+ export { CopyParagraphButton };
14
12
  export default CopyParagraphButton;