@ndla/ui 45.0.7 → 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.
@@ -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.7",
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": "5d97f47146fd65e33858db400db6d3b408503237"
86
+ "gitHead": "4fcf1c6c35e6612269adbe3878fd773d7fdd9cd2"
87
87
  }
@@ -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>
@@ -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';
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',