@ndla/ui 45.0.6 → 45.0.8

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 (44) hide show
  1. package/README.md +1 -1
  2. package/es/CampaignBlock/CampaignBlock.js +7 -7
  3. package/es/Gloss/Gloss.js +9 -9
  4. package/es/LicenseByline/EmbedByline.js +8 -8
  5. package/es/MediaList/MediaList.js +32 -14
  6. package/es/Search/SearchResultSleeve.js +15 -24
  7. package/es/locale/messages-en.js +1 -0
  8. package/es/locale/messages-nb.js +1 -0
  9. package/es/locale/messages-nn.js +1 -0
  10. package/es/locale/messages-se.js +1 -0
  11. package/es/locale/messages-sma.js +1 -0
  12. package/lib/CampaignBlock/CampaignBlock.js +7 -7
  13. package/lib/Gloss/Gloss.d.ts +1 -1
  14. package/lib/Gloss/Gloss.js +9 -9
  15. package/lib/LicenseByline/EmbedByline.d.ts +5 -5
  16. package/lib/LicenseByline/EmbedByline.js +8 -8
  17. package/lib/MediaList/MediaList.d.ts +12 -5
  18. package/lib/MediaList/MediaList.js +31 -14
  19. package/lib/MediaList/index.d.ts +1 -0
  20. package/lib/Search/SearchResultSleeve.js +15 -24
  21. package/lib/index.d.ts +1 -0
  22. package/lib/locale/messages-en.d.ts +1 -0
  23. package/lib/locale/messages-en.js +1 -0
  24. package/lib/locale/messages-nb.d.ts +1 -0
  25. package/lib/locale/messages-nb.js +1 -0
  26. package/lib/locale/messages-nn.d.ts +1 -0
  27. package/lib/locale/messages-nn.js +1 -0
  28. package/lib/locale/messages-se.d.ts +1 -0
  29. package/lib/locale/messages-se.js +1 -0
  30. package/lib/locale/messages-sma.d.ts +1 -0
  31. package/lib/locale/messages-sma.js +1 -0
  32. package/package.json +4 -4
  33. package/src/CampaignBlock/CampaignBlock.tsx +1 -1
  34. package/src/Gloss/Gloss.tsx +2 -2
  35. package/src/LicenseByline/EmbedByline.tsx +7 -7
  36. package/src/MediaList/MediaList.tsx +38 -8
  37. package/src/MediaList/index.ts +2 -0
  38. package/src/Search/SearchResultSleeve.tsx +9 -20
  39. package/src/index.ts +2 -0
  40. package/src/locale/messages-en.ts +1 -0
  41. package/src/locale/messages-nb.ts +1 -0
  42. package/src/locale/messages-nn.ts +1 -0
  43. package/src/locale/messages-se.ts +1 -0
  44. package/src/locale/messages-sma.ts +1 -0
package/lib/index.d.ts CHANGED
@@ -68,6 +68,7 @@ export { default as ResourceGroup } from './ResourceGroup';
68
68
  export { default as LayoutItem, OneColumn, PageContainer, Content } from './Layout';
69
69
  export { FilmSlideshow, MovieGrid, AboutNdlaFilm, FilmMovieSearch, FilmMovieList, AllMoviesAlphabetically, } from './NDLAFilm';
70
70
  export { MediaList, MediaListItem, MediaListItemBody, MediaListItemActions, MediaListItemImage, MediaListItemMeta, } from './MediaList';
71
+ export type { ItemType } from './MediaList';
71
72
  export { default as ContentTypeBadge, SubjectMaterialBadge, TasksAndActivitiesBadge, AssessmentResourcesBadge, LearningPathBadge, SubjectBadge, ExternalLearningResourcesBadge, SourceMaterialBadge, } from './ContentTypeBadge';
72
73
  export { SubjectChildContent, SubjectContent, SubjectFlexWrapper, SubjectHeader, SubjectNewContent, SubjectSecondaryContent, SubjectSectionTitle, SubjectSidebarWrapper, SubjectSocialContent, SubjectSocialSection, SubjectTopics, SubjectBanner, } from './Subject';
73
74
  export { default as CopyParagraphButton, CopyParagraphButtonV2 } from './CopyParagraphButton';
@@ -891,6 +891,7 @@ declare const messages: {
891
891
  title: string;
892
892
  originator: string;
893
893
  rightsholder: string;
894
+ processed: string;
894
895
  source: string;
895
896
  published: string;
896
897
  info: string;
@@ -601,6 +601,7 @@ var messages = _objectSpread(_objectSpread({
601
601
  title: 'Title',
602
602
  originator: 'Originator',
603
603
  rightsholder: 'Rightsholder',
604
+ processed: 'The content has been processed',
604
605
  source: 'Source',
605
606
  published: 'Published',
606
607
  info: 'License information'
@@ -891,6 +891,7 @@ declare const messages: {
891
891
  title: string;
892
892
  originator: string;
893
893
  published: string;
894
+ processed: string;
894
895
  rightsholder: string;
895
896
  source: string;
896
897
  info: string;
@@ -599,6 +599,7 @@ var messages = _objectSpread(_objectSpread({
599
599
  title: 'Tittel',
600
600
  originator: 'Opphaver',
601
601
  published: 'Publiseringsdato',
602
+ processed: 'Innholdet har blitt bearbeidet',
602
603
  rightsholder: 'Rettighetshaver',
603
604
  source: 'Kilde',
604
605
  info: 'Lisensinformasjon'
@@ -890,6 +890,7 @@ declare const messages: {
890
890
  };
891
891
  title: string;
892
892
  originator: string;
893
+ processed: string;
893
894
  rightsholder: string;
894
895
  source: string;
895
896
  published: string;
@@ -598,6 +598,7 @@ var messages = _objectSpread(_objectSpread({
598
598
  },
599
599
  title: 'Tittel',
600
600
  originator: 'Opphavar',
601
+ processed: 'Innhaldet har vorte omarbeidd',
601
602
  rightsholder: 'Rettshavar',
602
603
  source: 'Kjelde',
603
604
  published: 'Publiseringsdato',
@@ -891,6 +891,7 @@ declare const messages: {
891
891
  title: string;
892
892
  originator: string;
893
893
  published: string;
894
+ processed: string;
894
895
  rightsholder: string;
895
896
  source: string;
896
897
  info: string;
@@ -599,6 +599,7 @@ var messages = _objectSpread(_objectSpread({
599
599
  title: 'Tihttel',
600
600
  originator: 'Ásaheaddji',
601
601
  published: 'Almmuhanbeaivi',
602
+ processed: 'Sisdoallu lea rievdaduvvon.',
602
603
  rightsholder: 'Vuoigatvuođaguoddi',
603
604
  source: 'Gáldu',
604
605
  info: 'Lisensinformasjon'
@@ -891,6 +891,7 @@ declare const messages: {
891
891
  title: string;
892
892
  originator: string;
893
893
  published: string;
894
+ processed: string;
894
895
  rightsholder: string;
895
896
  source: string;
896
897
  info: string;
@@ -599,6 +599,7 @@ var messages = _objectSpread(_objectSpread({
599
599
  title: 'Tihtele',
600
600
  originator: 'Opphaver',
601
601
  published: 'Publiseringsdato',
602
+ processed: 'Innhaldet har vorte omarbeidd',
602
603
  rightsholder: 'Rettighetshaver',
603
604
  source: 'Gaaltije',
604
605
  info: 'Lisensinformasjon'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "45.0.6",
3
+ "version": "45.0.8",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -40,9 +40,9 @@
40
40
  "@ndla/forms": "^4.3.23",
41
41
  "@ndla/hooks": "^2.1.0",
42
42
  "@ndla/icons": "^4.0.6",
43
- "@ndla/licenses": "^7.1.3",
43
+ "@ndla/licenses": "^7.1.4",
44
44
  "@ndla/modal": "^4.0.7",
45
- "@ndla/notion": "^5.0.23",
45
+ "@ndla/notion": "^5.0.24",
46
46
  "@ndla/safelink": "^4.1.21",
47
47
  "@ndla/select": "^2.4.12",
48
48
  "@ndla/switch": "^1.1.12",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "081b7b353f4028c92f7031e77d43a470fd08c764"
86
+ "gitHead": "4fcf1c6c35e6612269adbe3878fd773d7fdd9cd2"
87
87
  }
@@ -97,7 +97,7 @@ const CampaignBlock = ({
97
97
  const href = usePossiblyRelativeUrl(url.url, path);
98
98
  return (
99
99
  <Container className={className} data-type="campaign-block" data-image-side={imageSide}>
100
- {image && <StyledImg src={image.src} height={200} width={240} alt="" />}
100
+ {image && <StyledImg src={image.src} height={200} width={240} alt={image.src} />}
101
101
  <TextWrapper>
102
102
  <Heading css={headingStyle}>{title.title}</Heading>
103
103
  <StyledDescription>{description.text}</StyledDescription>
@@ -31,7 +31,7 @@ export interface Props {
31
31
  transcriptions: Transcription;
32
32
  examples?: Example[][];
33
33
  };
34
- audio: {
34
+ audio?: {
35
35
  title: string;
36
36
  src?: string;
37
37
  };
@@ -124,7 +124,7 @@ const Gloss = ({ title, glossData, audio }: Props) => {
124
124
  <TypeSpan aria-label={t('gloss.wordClass')}>{t(`wordClass.${glossData.wordClass}`)}</TypeSpan>
125
125
  )}
126
126
  </GlossContainer>
127
- {audio.src && <SpeechControl src={audio.src} title={audio.title}></SpeechControl>}
127
+ {audio?.src && <SpeechControl src={audio.src} title={audio.title}></SpeechControl>}
128
128
  </Wrapper>
129
129
  <span>{title.title}</span>
130
130
  </Container>
@@ -39,27 +39,27 @@ export interface EmbedBylineErrorProps extends BaseProps {
39
39
 
40
40
  interface ImageProps extends BaseProps {
41
41
  type: 'image';
42
- copyright: ImageCopyright;
42
+ copyright: ImageCopyright | undefined;
43
43
  }
44
44
 
45
45
  interface BrightcoveProps extends BaseProps {
46
46
  type: 'video';
47
- copyright: BrightcoveCopyright;
47
+ copyright: BrightcoveCopyright | undefined;
48
48
  }
49
49
 
50
50
  interface AudioProps extends BaseProps {
51
51
  type: 'audio';
52
- copyright: AudioCopyright;
52
+ copyright: AudioCopyright | undefined;
53
53
  }
54
54
 
55
55
  interface PodcastProps extends BaseProps {
56
56
  type: 'podcast';
57
- copyright: AudioCopyright;
57
+ copyright: AudioCopyright | undefined;
58
58
  }
59
59
 
60
60
  interface ConceptProps extends BaseProps {
61
61
  type: 'concept';
62
- copyright: ConceptCopyright;
62
+ copyright: ConceptCopyright | undefined;
63
63
  }
64
64
 
65
65
  export type EmbedBylineTypeProps = ImageProps | BrightcoveProps | AudioProps | PodcastProps | ConceptProps;
@@ -158,7 +158,7 @@ const EmbedByline = ({
158
158
 
159
159
  const { copyright } = props;
160
160
 
161
- const license = getLicenseByAbbreviation(copyright.license?.license ?? '', i18n.language);
161
+ const license = copyright ? getLicenseByAbbreviation(copyright.license?.license ?? '', i18n.language) : undefined;
162
162
  const authors = getLicenseCredits(copyright);
163
163
  const captionAuthors = Object.values(authors).find((i) => i.length > 0) ?? [];
164
164
 
@@ -167,7 +167,7 @@ const EmbedByline = ({
167
167
  {!!strippedDescription?.length && description && <LicenseDescription description={description} />}
168
168
  {visibleAlt ? <StyledSpan>{`Alt: ${visibleAlt}`}</StyledSpan> : null}
169
169
  <RightsWrapper data-grid={inGrid}>
170
- <LicenseLink license={license} asLink={!!license.url.length} />
170
+ {license ? <LicenseLink license={license} asLink={!!license.url.length} /> : null}
171
171
  <LicenseInformationWrapper>
172
172
  <span>
173
173
  <b>{t(`embed.type.${type}`)}: </b>
@@ -13,6 +13,7 @@ import {
13
13
  isCreativeCommonsLicense,
14
14
  metaTypes,
15
15
  } from '@ndla/licenses';
16
+ import type { MetaType } from '@ndla/licenses';
16
17
  import { LicenseDescription } from '@ndla/notion';
17
18
  import BEMHelper from 'react-bem-helper';
18
19
  import { uuid } from '@ndla/util';
@@ -182,25 +183,54 @@ export const HandleLink = ({ text, children }: HandleLinkProps) => {
182
183
 
183
184
  const attributionTypes = [metaTypes.author, metaTypes.copyrightHolder, metaTypes.contributor];
184
185
 
186
+ export type ItemType = ItemTypeWithDescription | DescriptionLessItemType;
187
+
188
+ interface ItemTypeWithDescription {
189
+ label: string;
190
+ description: string;
191
+ metaType: Omit<MetaType, 'otherWithoutDescription'>;
192
+ }
193
+
194
+ interface DescriptionLessItemType {
195
+ label: string;
196
+ metaType: 'otherWithoutDescription';
197
+ }
198
+
199
+ function isOtherWithoutDescription(item: ItemType): item is DescriptionLessItemType {
200
+ return item.metaType === metaTypes.otherWithoutDescription;
201
+ }
202
+
185
203
  interface MediaListItemMetaProps {
186
- items?: {
187
- label: string;
188
- description: string;
189
- metaType: string;
190
- }[];
204
+ items?: ItemType[];
205
+ }
206
+
207
+ const ItemText = ({ item }: { item: ItemType }) => {
208
+ if (isOtherWithoutDescription(item)) {
209
+ return <>{item.label}</>;
210
+ }
211
+
212
+ return (
213
+ <>
214
+ {item.label}: <HandleLink text={item.description}>{item.description}</HandleLink>
215
+ </>
216
+ );
217
+ };
218
+
219
+ function isAttributionItem(item: ItemType): item is ItemTypeWithDescription {
220
+ if (isOtherWithoutDescription(item)) return false;
221
+ return attributionTypes.some((type) => type === item.metaType);
191
222
  }
192
223
 
193
224
  export const MediaListItemMeta = ({ items = [] }: MediaListItemMetaProps) => {
194
- const attributionItems = items.filter((item) => attributionTypes.some((type) => type === item.metaType));
225
+ const attributionItems = items.filter(isAttributionItem);
195
226
  const attributionMeta = attributionItems.map((item) => `${item.label}: ${item.description}`).join(', ');
196
227
 
197
228
  return (
198
- //@ts-ignore
199
229
  // eslint-disable-next-line react/no-unknown-property
200
230
  <ul {...cClasses('actions')} property="cc:attributionName" content={attributionMeta}>
201
231
  {items.map((item) => (
202
232
  <li key={uuid()} className="c-medialist__meta-item">
203
- {item.label}: <HandleLink text={item.description}>{item.description}</HandleLink>
233
+ <ItemText item={item} />
204
234
  </li>
205
235
  ))}
206
236
  </ul>
@@ -13,3 +13,5 @@ export {
13
13
  MediaListItemImage,
14
14
  MediaListItemMeta,
15
15
  } from './MediaList';
16
+
17
+ export type { ItemType } from './MediaList';
@@ -253,28 +253,17 @@ const SearchResultSleeve = ({
253
253
  return findPathForKeyboardNavigation(contentRef.current, prevKeyPath, -1);
254
254
  });
255
255
  } else if (e.code === 'Enter') {
256
- e.stopPropagation();
257
- e.preventDefault();
258
256
  if (keyboardPathNavigation === GO_TO_SUGGESTION) {
259
- const anchorTag =
260
- searchSuggestionRef && searchSuggestionRef.current && searchSuggestionRef.current.closest('a');
261
- if (anchorTag) {
262
- anchorTag.click();
263
- }
264
- } else if (keyboardPathNavigation === GO_TO_SEARCHPAGE || keyboardPathNavigation === undefined) {
265
- const anchorTag = searchAllRef && searchAllRef.current && searchAllRef.current.closest('a');
266
- if (anchorTag) {
267
- anchorTag.click();
268
- }
269
- } else {
270
- if (keyboardPathNavigation instanceof HTMLElement) {
271
- const toClick =
272
- keyboardPathNavigation &&
273
- keyboardPathNavigation.querySelector &&
274
- (keyboardPathNavigation.querySelector('a') || keyboardPathNavigation.querySelector('button'));
257
+ searchSuggestionRef?.current?.closest('a')?.click();
258
+ } else if (keyboardPathNavigation instanceof HTMLElement) {
259
+ e.stopPropagation();
260
+ e.preventDefault();
261
+ const toClick =
262
+ keyboardPathNavigation &&
263
+ keyboardPathNavigation.querySelector &&
264
+ (keyboardPathNavigation.querySelector('a') || keyboardPathNavigation.querySelector('button'));
275
265
 
276
- toClick && toClick.click();
277
- }
266
+ toClick && toClick.click();
278
267
  }
279
268
  } else if (e.code === 'Tab') {
280
269
  setKeyNavigation('');
package/src/index.ts CHANGED
@@ -207,6 +207,8 @@ export {
207
207
  MediaListItemMeta,
208
208
  } from './MediaList';
209
209
 
210
+ export type { ItemType } from './MediaList';
211
+
210
212
  export {
211
213
  default as ContentTypeBadge,
212
214
  SubjectMaterialBadge,
@@ -631,6 +631,7 @@ const messages = {
631
631
  title: 'Title',
632
632
  originator: 'Originator',
633
633
  rightsholder: 'Rightsholder',
634
+ processed: 'The content has been processed',
634
635
  source: 'Source',
635
636
  published: 'Published',
636
637
  info: 'License information',
@@ -630,6 +630,7 @@ const messages = {
630
630
  title: 'Tittel',
631
631
  originator: 'Opphaver',
632
632
  published: 'Publiseringsdato',
633
+ processed: 'Innholdet har blitt bearbeidet',
633
634
  rightsholder: 'Rettighetshaver',
634
635
  source: 'Kilde',
635
636
  info: 'Lisensinformasjon',
@@ -629,6 +629,7 @@ const messages = {
629
629
  },
630
630
  title: 'Tittel',
631
631
  originator: 'Opphavar',
632
+ processed: 'Innhaldet har vorte omarbeidd',
632
633
  rightsholder: 'Rettshavar',
633
634
  source: 'Kjelde',
634
635
  published: 'Publiseringsdato',
@@ -631,6 +631,7 @@ const messages = {
631
631
  title: 'Tihttel',
632
632
  originator: 'Ásaheaddji',
633
633
  published: 'Almmuhanbeaivi',
634
+ processed: 'Sisdoallu lea rievdaduvvon.',
634
635
  rightsholder: 'Vuoigatvuođaguoddi',
635
636
  source: 'Gáldu',
636
637
  info: 'Lisensinformasjon',
@@ -634,6 +634,7 @@ const messages = {
634
634
  title: 'Tihtele',
635
635
  originator: 'Opphaver',
636
636
  published: 'Publiseringsdato',
637
+ processed: 'Innhaldet har vorte omarbeidd',
637
638
  rightsholder: 'Rettighetshaver',
638
639
  source: 'Gaaltije',
639
640
  info: 'Lisensinformasjon',