@ndla/ui 56.0.109-alpha.0 → 56.0.111-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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": "0.52.0",
2
+ "schemaVersion": "0.53.3",
3
3
  "styles": {
4
4
  "atomic": [
5
5
  "background]___[value:background.default",
@@ -101,6 +101,7 @@ const BrightcoveEmbed = _ref => {
101
101
  videoid: linkedVideoId
102
102
  }, data.sources) : undefined;
103
103
  const licenseProps = licenseAttributes(data?.copyright?.license.license, lang, embedData.pageUrl);
104
+ const title = data.name?.trim() ? `${t("embed.type.video")}: ${data.name}` : fallbackTitle;
104
105
  return /*#__PURE__*/_jsxs(Figure, {
105
106
  "data-embed-type": "brightcove",
106
107
  ...licenseProps,
@@ -109,8 +110,8 @@ const BrightcoveEmbed = _ref => {
109
110
  children: /*#__PURE__*/_jsx(BrightcoveIframe, {
110
111
  ref: iframeRef,
111
112
  className: "original",
112
- title: embedData.alt || data.name || fallbackTitle,
113
- "aria-label": embedData.alt || data.name || fallbackTitle,
113
+ title: title,
114
+ "aria-label": title,
114
115
  ...(alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps),
115
116
  allow: "fullscreen; encrypted-media"
116
117
  })
@@ -6,6 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
+ import { useTranslation } from "react-i18next";
9
10
  import { Figure } from "@ndla/primitives";
10
11
  import { styled } from "@ndla/styled-system/jsx";
11
12
  import EmbedErrorPlaceholder from "./EmbedErrorPlaceholder";
@@ -30,6 +31,9 @@ const H5pEmbed = _ref => {
30
31
  let {
31
32
  embed
32
33
  } = _ref;
34
+ const {
35
+ t
36
+ } = useTranslation();
33
37
  if (embed.status === "error") {
34
38
  return /*#__PURE__*/_jsx(EmbedErrorPlaceholder, {
35
39
  type: "h5p"
@@ -43,11 +47,13 @@ const H5pEmbed = _ref => {
43
47
  }
44
48
  });
45
49
  }
50
+ const title = embed.embedData.title?.trim() ? embed.embedData.title : embed.data.h5pLicenseInformation?.h5p.title?.trim() ? embed.data.h5pLicenseInformation.h5p.title : embed.embedData.url;
51
+ const titleWithPrefix = `${t("embed.type.h5p")}: ${title}`;
46
52
  return /*#__PURE__*/_jsx(StyledFigure, {
47
53
  "data-embed-type": "h5p",
48
54
  children: /*#__PURE__*/_jsx("iframe", {
49
- title: embed.embedData.url,
50
- "aria-label": embed.embedData.url,
55
+ title: titleWithPrefix,
56
+ "aria-label": titleWithPrefix,
51
57
  src: embed.embedData.url
52
58
  })
53
59
  });
@@ -71,18 +71,17 @@ const IframeEmbed = _ref => {
71
71
  const {
72
72
  width,
73
73
  height,
74
- title,
75
74
  url
76
75
  } = embedData;
77
76
  const strippedWidth = typeof width === "number" ? width : width?.replace(/\s*px/, "");
78
77
  const strippedHeight = typeof height === "number" ? height : height?.replace(/\s*px/, "");
79
- const urlOrTitle = title || url;
78
+ const title = `${t("embed.type.external")}: ${embedData.title?.trim() ? embedData.title : url}`;
80
79
  return /*#__PURE__*/_jsx(StyledFigure, {
81
80
  "data-embed-type": "iframe",
82
81
  children: /*#__PURE__*/_jsx(StyledIframe, {
83
82
  ref: iframeRef,
84
- title: urlOrTitle,
85
- "aria-label": urlOrTitle,
83
+ title: title,
84
+ "aria-label": title,
86
85
  src: url,
87
86
  width: strippedWidth,
88
87
  height: strippedHeight,
@@ -5,5 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
+
8
9
  import ErrorMessage from "./ErrorMessage";
9
10
  export default ErrorMessage;
@@ -141,6 +141,7 @@ const FactBox = /*#__PURE__*/forwardRef((_ref, ref) => {
141
141
  children: [/*#__PURE__*/_jsx(StyledIconButton, {
142
142
  "data-state": state,
143
143
  onClick: onClick,
144
+ contentEditable: false,
144
145
  "aria-expanded": state === "open",
145
146
  "aria-controls": contentId,
146
147
  "aria-label": t(`factbox.${state === "open" ? "close" : "open"}`),
@@ -110,6 +110,7 @@ const BrightcoveEmbed = _ref => {
110
110
  videoid: linkedVideoId
111
111
  }, data.sources) : undefined;
112
112
  const licenseProps = (0, _licenseAttributes.licenseAttributes)(data?.copyright?.license.license, lang, embedData.pageUrl);
113
+ const title = data.name?.trim() ? `${t("embed.type.video")}: ${data.name}` : fallbackTitle;
113
114
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_primitives.Figure, {
114
115
  "data-embed-type": "brightcove",
115
116
  ...licenseProps,
@@ -118,8 +119,8 @@ const BrightcoveEmbed = _ref => {
118
119
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BrightcoveIframe, {
119
120
  ref: iframeRef,
120
121
  className: "original",
121
- title: embedData.alt || data.name || fallbackTitle,
122
- "aria-label": embedData.alt || data.name || fallbackTitle,
122
+ title: title,
123
+ "aria-label": title,
123
124
  ...(alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps),
124
125
  allow: "fullscreen; encrypted-media"
125
126
  })
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _reactI18next = require("react-i18next");
7
8
  var _primitives = require("@ndla/primitives");
8
9
  var _jsx2 = require("@ndla/styled-system/jsx");
9
10
  var _EmbedErrorPlaceholder = _interopRequireDefault(require("./EmbedErrorPlaceholder"));
@@ -37,6 +38,9 @@ const H5pEmbed = _ref => {
37
38
  let {
38
39
  embed
39
40
  } = _ref;
41
+ const {
42
+ t
43
+ } = (0, _reactI18next.useTranslation)();
40
44
  if (embed.status === "error") {
41
45
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedErrorPlaceholder.default, {
42
46
  type: "h5p"
@@ -50,11 +54,13 @@ const H5pEmbed = _ref => {
50
54
  }
51
55
  });
52
56
  }
57
+ const title = embed.embedData.title?.trim() ? embed.embedData.title : embed.data.h5pLicenseInformation?.h5p.title?.trim() ? embed.data.h5pLicenseInformation.h5p.title : embed.embedData.url;
58
+ const titleWithPrefix = `${t("embed.type.h5p")}: ${title}`;
53
59
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledFigure, {
54
60
  "data-embed-type": "h5p",
55
61
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {
56
- title: embed.embedData.url,
57
- "aria-label": embed.embedData.url,
62
+ title: titleWithPrefix,
63
+ "aria-label": titleWithPrefix,
58
64
  src: embed.embedData.url
59
65
  })
60
66
  });
@@ -78,18 +78,17 @@ const IframeEmbed = _ref => {
78
78
  const {
79
79
  width,
80
80
  height,
81
- title,
82
81
  url
83
82
  } = embedData;
84
83
  const strippedWidth = typeof width === "number" ? width : width?.replace(/\s*px/, "");
85
84
  const strippedHeight = typeof height === "number" ? height : height?.replace(/\s*px/, "");
86
- const urlOrTitle = title || url;
85
+ const title = `${t("embed.type.external")}: ${embedData.title?.trim() ? embedData.title : url}`;
87
86
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledFigure, {
88
87
  "data-embed-type": "iframe",
89
88
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledIframe, {
90
89
  ref: iframeRef,
91
- title: urlOrTitle,
92
- "aria-label": urlOrTitle,
90
+ title: title,
91
+ "aria-label": title,
93
92
  src: url,
94
93
  width: strippedWidth,
95
94
  height: strippedHeight,
@@ -149,6 +149,7 @@ const FactBox = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
149
149
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StyledIconButton, {
150
150
  "data-state": state,
151
151
  onClick: onClick,
152
+ contentEditable: false,
152
153
  "aria-expanded": state === "open",
153
154
  "aria-controls": contentId,
154
155
  "aria-label": t(`factbox.${state === "open" ? "close" : "open"}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "56.0.109-alpha.0",
3
+ "version": "56.0.111-alpha.0",
4
4
  "description": "UI component library for NDLA",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -33,12 +33,12 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@ndla/core": "^5.0.3",
36
- "@ndla/icons": "^8.0.52-alpha.0",
36
+ "@ndla/icons": "^8.0.53-alpha.0",
37
37
  "@ndla/licenses": "^9.0.1",
38
- "@ndla/primitives": "^1.0.83-alpha.0",
39
- "@ndla/safelink": "^7.0.84-alpha.0",
40
- "@ndla/styled-system": "^0.0.32",
41
- "@ndla/util": "^5.0.6-alpha.0",
38
+ "@ndla/primitives": "^1.0.85-alpha.0",
39
+ "@ndla/safelink": "^7.0.86-alpha.0",
40
+ "@ndla/styled-system": "^0.0.33",
41
+ "@ndla/util": "^5.0.7-alpha.0",
42
42
  "html-react-parser": "^5.1.19"
43
43
  },
44
44
  "peerDependencies": {
@@ -49,13 +49,13 @@
49
49
  "react-router-dom": "> 6.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@ndla/preset-panda": "^0.0.51",
53
- "@ndla/types-backend": "^1.0.1",
54
- "@ndla/types-embed": "^5.0.11-alpha.0",
55
- "@pandacss/dev": "^0.52.0"
52
+ "@ndla/preset-panda": "^0.0.52",
53
+ "@ndla/types-backend": "^1.0.39",
54
+ "@ndla/types-embed": "^5.0.12-alpha.0",
55
+ "@pandacss/dev": "^0.53.3"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "0495950a3a24defc5d51cdbf14c2d989e9996f82"
60
+ "gitHead": "2636009581467510d1675793f45f1762065b5a81"
61
61
  }
@@ -96,10 +96,10 @@ export default {
96
96
  description: "Creative Commons Attribution-ShareAlike 4.0 International",
97
97
  url: "https://creativecommons.org/licenses/by-sa/4.0/",
98
98
  },
99
- creators: [{ type: "Writer", name: "Sissel Paaske" }],
99
+ creators: [{ type: "writer", name: "Sissel Paaske" }],
100
100
  processors: [
101
- { type: "Processor", name: "Totaltekst" },
102
- { type: "Correction", name: "Arbeidets art" },
101
+ { type: "processor", name: "Totaltekst" },
102
+ { type: "correction", name: "Arbeidets art" },
103
103
  ],
104
104
  rightsholders: [],
105
105
  processed: false,
@@ -104,14 +104,16 @@ const BrightcoveEmbed = ({ embed, renderContext = "article", lang }: Props) => {
104
104
 
105
105
  const licenseProps = licenseAttributes(data?.copyright?.license.license, lang, embedData.pageUrl);
106
106
 
107
+ const title = data.name?.trim() ? `${t("embed.type.video")}: ${data.name}` : fallbackTitle;
108
+
107
109
  return (
108
110
  <Figure data-embed-type="brightcove" {...licenseProps}>
109
111
  <div className="brightcove-video">
110
112
  <BrightcoveIframe
111
113
  ref={iframeRef}
112
114
  className="original"
113
- title={embedData.alt || data.name || fallbackTitle}
114
- aria-label={embedData.alt || data.name || fallbackTitle}
115
+ title={title}
116
+ aria-label={title}
115
117
  {...(alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps)}
116
118
  allow="fullscreen; encrypted-media"
117
119
  />
@@ -43,27 +43,20 @@ const conceptMetaData: ConceptData["concept"] = {
43
43
  description: "Creative Commons Attribution-ShareAlike 4.0 International",
44
44
  url: "https://creativecommons.org/licenses/by-sa/4.0/",
45
45
  },
46
- creators: [{ type: "Writer", name: "Sissel Paaske" }],
46
+ creators: [{ type: "writer", name: "Sissel Paaske" }],
47
47
  processors: [
48
- { type: "Processor", name: "Totaltekst" },
49
- { type: "Correction", name: "Arbeidets art" },
48
+ { type: "processor", name: "Totaltekst" },
49
+ { type: "correction", name: "Arbeidets art" },
50
50
  ],
51
51
  rightsholders: [],
52
52
  processed: false,
53
53
  },
54
54
  source: "",
55
- metaImage: {
56
- url: "https://api.test.ndla.no/image-api/raw/id/52863",
57
- alt: "Eksempel på hvordan borevæsken kan trenge ut i formasjonen fra borehullet og skade formasjonens permeabilitet. Illustrasjon.",
58
- language: "nb",
59
- },
60
55
  tags: { tags: ["Brønn:Reservoar:"], language: "nb" },
61
- subjectIds: ["urn:subject:6"],
62
56
  created: "2018-07-02T10:53:40Z",
63
57
  updated: "2020-11-18T08:58:33Z",
64
58
  updatedBy: ["sPHJn0BEtfxw2d2DUpIuS3iY", "KBAJskRqPXZUv9LFjAbz8btB", "eEIRDzflTh9oUp_3CgpuIMOg"],
65
59
  supportedLanguages: ["nb", "nn"],
66
- articleIds: [],
67
60
  status: { current: "PUBLISHED", other: [] },
68
61
  visualElement: {
69
62
  visualElement:
@@ -104,7 +97,7 @@ const visualElementData: ConceptData["visualElement"] = {
104
97
  origin: "",
105
98
  creators: [
106
99
  {
107
- type: "Illustrator",
100
+ type: "illustrator",
108
101
  name: "Sissel Paaske",
109
102
  },
110
103
  ],
@@ -43,16 +43,10 @@ const glossMetaData: ConceptData["concept"] = {
43
43
  processed: false,
44
44
  },
45
45
  source: "",
46
- metaImage: {
47
- url: "",
48
- alt: "",
49
- language: "und",
50
- },
51
46
  created: "2023-07-19T09:30:40.000Z",
52
47
  updated: "2023-09-19T17:13:56.573Z",
53
48
  updatedBy: ["XxnkdI7rApMl58MeG3p4g4B8", "hd5ZL5Lm4kKkumWgN2gjy9wx"],
54
49
  supportedLanguages: ["nb"],
55
- articleIds: [],
56
50
  status: {
57
51
  current: "IN_PROGRESS",
58
52
  other: [],
@@ -6,6 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
+ import { useTranslation } from "react-i18next";
9
10
  import { Figure } from "@ndla/primitives";
10
11
  import { styled } from "@ndla/styled-system/jsx";
11
12
  import type { H5pMetaData } from "@ndla/types-embed";
@@ -34,6 +35,7 @@ const FigureOembed = styled(Figure, {
34
35
  });
35
36
 
36
37
  const H5pEmbed = ({ embed }: Props) => {
38
+ const { t } = useTranslation();
37
39
  if (embed.status === "error") {
38
40
  return <EmbedErrorPlaceholder type="h5p" />;
39
41
  }
@@ -42,9 +44,17 @@ const H5pEmbed = ({ embed }: Props) => {
42
44
  return <FigureOembed data-embed-type="h5p" dangerouslySetInnerHTML={{ __html: embed.data.oembed.html ?? "" }} />;
43
45
  }
44
46
 
47
+ const title = embed.embedData.title?.trim()
48
+ ? embed.embedData.title
49
+ : embed.data.h5pLicenseInformation?.h5p.title?.trim()
50
+ ? embed.data.h5pLicenseInformation.h5p.title
51
+ : embed.embedData.url;
52
+
53
+ const titleWithPrefix = `${t("embed.type.h5p")}: ${title}`;
54
+
45
55
  return (
46
56
  <StyledFigure data-embed-type="h5p">
47
- <iframe title={embed.embedData.url} aria-label={embed.embedData.url} src={embed.embedData.url} />
57
+ <iframe title={titleWithPrefix} aria-label={titleWithPrefix} src={embed.embedData.url} />
48
58
  </StyledFigure>
49
59
  );
50
60
  };
@@ -68,18 +68,18 @@ const IframeEmbed = ({ embed }: Props) => {
68
68
  );
69
69
  }
70
70
 
71
- const { width, height, title, url } = embedData;
71
+ const { width, height, url } = embedData;
72
72
 
73
73
  const strippedWidth = typeof width === "number" ? width : width?.replace(/\s*px/, "");
74
74
  const strippedHeight = typeof height === "number" ? height : height?.replace(/\s*px/, "");
75
- const urlOrTitle = title || url;
75
+ const title = `${t("embed.type.external")}: ${embedData.title?.trim() ? embedData.title : url}`;
76
76
 
77
77
  return (
78
78
  <StyledFigure data-embed-type="iframe">
79
79
  <StyledIframe
80
80
  ref={iframeRef}
81
- title={urlOrTitle}
82
- aria-label={urlOrTitle}
81
+ title={title}
82
+ aria-label={title}
83
83
  src={url}
84
84
  width={strippedWidth}
85
85
  height={strippedHeight}
@@ -42,17 +42,17 @@ const filmResourceMeta: RelatedContentMetaData = {
42
42
  origin: "",
43
43
  creators: [
44
44
  {
45
- type: "Writer",
45
+ type: "writer",
46
46
  name: "Elisabeth Thoresen Olseng",
47
47
  },
48
48
  ],
49
49
  processors: [
50
50
  {
51
- type: "Processor",
51
+ type: "processor",
52
52
  name: "Tone Hadler-Olsen",
53
53
  },
54
54
  {
55
- type: "Correction",
55
+ type: "correction",
56
56
  name: "Totaltekst",
57
57
  },
58
58
  ],
@@ -231,7 +231,7 @@ const learningResourceMeta: RelatedContentMetaData = {
231
231
  origin: "",
232
232
  creators: [
233
233
  {
234
- type: "Writer",
234
+ type: "writer",
235
235
  name: "Albertine Aaberge",
236
236
  },
237
237
  ],
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
+
8
9
  import ErrorMessage from "./ErrorMessage";
9
10
 
10
11
  export default ErrorMessage;
@@ -149,6 +149,7 @@ const FactBox = forwardRef<HTMLElement, Props>(
149
149
  <StyledIconButton
150
150
  data-state={state}
151
151
  onClick={onClick}
152
+ contentEditable={false}
152
153
  aria-expanded={state === "open"}
153
154
  aria-controls={contentId}
154
155
  aria-label={t(`factbox.${state === "open" ? "close" : "open"}`)}