@truedat/core 7.6.4 → 7.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "7.6.4",
3
+ "version": "7.7.1",
4
4
  "description": "Truedat Web Core",
5
5
  "sideEffects": false,
6
6
  "module": "src/index.js",
@@ -48,7 +48,7 @@
48
48
  "@testing-library/jest-dom": "^6.6.3",
49
49
  "@testing-library/react": "^16.3.0",
50
50
  "@testing-library/user-event": "^14.6.1",
51
- "@truedat/test": "7.6.4",
51
+ "@truedat/test": "7.7.1",
52
52
  "identity-obj-proxy": "^3.0.0",
53
53
  "jest": "^29.7.0",
54
54
  "redux-saga-test-plan": "^4.0.6"
@@ -85,5 +85,5 @@
85
85
  "slate-react": "^0.22.10",
86
86
  "swr": "^2.3.3"
87
87
  },
88
- "gitHead": "994343683c2e0fb3fab85a021e627b1b86a7831f"
88
+ "gitHead": "b0bbab1ace5acb5a0c670137a51d21456f5eecae"
89
89
  }
@@ -0,0 +1,60 @@
1
+ import { useIntl } from "react-intl";
2
+ import PropTypes from "prop-types";
3
+
4
+ import { Icon } from "semantic-ui-react";
5
+
6
+ export const OriginIcon = ({ origin }) => {
7
+ const { formatMessage } = useIntl();
8
+
9
+ const icon = formatMessage({
10
+ id: `origin.icon.${origin}`,
11
+ defaultMessage: "none",
12
+ }).replace("none", "");
13
+
14
+ const hoverText = formatMessage({
15
+ id: `origin.hover.${origin}`,
16
+ defaultMessage: "none",
17
+ }).replace("none", "");
18
+
19
+ return icon ? (
20
+ <span title={hoverText} className={`originLabel originIcon ${origin}Label`}>
21
+ {icon && <Icon name={icon} />}
22
+ </span>
23
+ ) : null;
24
+ };
25
+
26
+ OriginIcon.propTypes = {
27
+ origin: PropTypes.string,
28
+ };
29
+
30
+ const OriginLabel = ({ origin }) => {
31
+ const { formatMessage } = useIntl();
32
+
33
+ const icon = formatMessage({
34
+ id: `origin.label.${origin}.icon`,
35
+ defaultMessage: "none",
36
+ }).replace("none", "");
37
+
38
+ const label = formatMessage({
39
+ id: `origin.label.${origin}.label`,
40
+ defaultMessage: "none",
41
+ }).replace("none", "");
42
+
43
+ const hoverText = formatMessage({
44
+ id: `origin.hover.${origin}`,
45
+ defaultMessage: "none",
46
+ }).replace("none", "");
47
+
48
+ return icon || label ? (
49
+ <span title={hoverText} className={`originLabel ${origin}Label`}>
50
+ {icon && <Icon name={icon} />}
51
+ {label && <span>{label}</span>}
52
+ </span>
53
+ ) : null;
54
+ };
55
+
56
+ OriginLabel.propTypes = {
57
+ origin: PropTypes.string,
58
+ };
59
+
60
+ export default OriginLabel;
@@ -0,0 +1,49 @@
1
+ import { render, waitForLoad } from "@truedat/test/render";
2
+ import OriginLabel, { OriginIcon } from "../OriginLabel";
3
+
4
+ const labelRenderOpts = {
5
+ messages: {
6
+ en: {
7
+ "origin.label.test.icon": "test icon",
8
+ "origin.label.test.label": "Test Origin",
9
+ "origin.hover.test": "Generated by Test",
10
+ },
11
+ },
12
+ };
13
+
14
+ const iconRenderOpts = {
15
+ messages: {
16
+ en: {
17
+ "origin.icon.test": "test icon only",
18
+ "origin.hover.test": "Generated by Test",
19
+ },
20
+ },
21
+ };
22
+
23
+ describe("<OriginLabel />", () => {
24
+ it("matches the latest snapshot without origin", async () => {
25
+ const rendered = render(<OriginLabel />, labelRenderOpts);
26
+ await waitForLoad(rendered);
27
+ expect(rendered.container).toMatchSnapshot();
28
+ });
29
+
30
+ it("matches the latest snapshot with origin", async () => {
31
+ const rendered = render(<OriginLabel origin="test" />, labelRenderOpts);
32
+ await waitForLoad(rendered);
33
+ expect(rendered.container).toMatchSnapshot();
34
+ });
35
+ });
36
+
37
+ describe("<OriginIcon />", () => {
38
+ it("matches the latest snapshot without origin", async () => {
39
+ const rendered = render(<OriginIcon />, iconRenderOpts);
40
+ await waitForLoad(rendered);
41
+ expect(rendered.container).toMatchSnapshot();
42
+ });
43
+
44
+ it("matches the latest snapshot with origin", async () => {
45
+ const rendered = render(<OriginIcon origin="test" />, iconRenderOpts);
46
+ await waitForLoad(rendered);
47
+ expect(rendered.container).toMatchSnapshot();
48
+ });
49
+ });
@@ -0,0 +1,36 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<OriginIcon /> matches the latest snapshot with origin 1`] = `
4
+ <div>
5
+ <span
6
+ class="originLabel originIcon testLabel"
7
+ title="Generated by Test"
8
+ >
9
+ <i
10
+ aria-hidden="true"
11
+ class="test icon only icon"
12
+ />
13
+ </span>
14
+ </div>
15
+ `;
16
+
17
+ exports[`<OriginIcon /> matches the latest snapshot without origin 1`] = `<div />`;
18
+
19
+ exports[`<OriginLabel /> matches the latest snapshot with origin 1`] = `
20
+ <div>
21
+ <span
22
+ class="originLabel testLabel"
23
+ title="Generated by Test"
24
+ >
25
+ <i
26
+ aria-hidden="true"
27
+ class="test icon icon"
28
+ />
29
+ <span>
30
+ Test Origin
31
+ </span>
32
+ </span>
33
+ </div>
34
+ `;
35
+
36
+ exports[`<OriginLabel /> matches the latest snapshot without origin 1`] = `<div />`;
@@ -35,6 +35,7 @@ import Loading from "./Loading";
35
35
  import MembersMenu from "./MembersMenu";
36
36
  import OptionGroup from "./OptionGroup";
37
37
  import OptionModal from "./OptionModal";
38
+ import OriginLabel from "./OriginLabel";
38
39
  import Pagination from "./Pagination";
39
40
  import QualityMenu from "./QualityMenu";
40
41
  import Redirector from "./Redirector";
@@ -94,6 +95,7 @@ export {
94
95
  MembersMenu,
95
96
  OptionGroup,
96
97
  OptionModal,
98
+ OriginLabel,
97
99
  Pagination,
98
100
  QualityMenu,
99
101
  Redirector,