@reltio/components 1.4.1954 → 1.4.1955

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.
@@ -8,14 +8,15 @@ var react_1 = __importDefault(require("react"));
8
8
  var ui_i18n_1 = __importDefault(require("ui-i18n"));
9
9
  var classnames_1 = __importDefault(require("classnames"));
10
10
  var Link_1 = __importDefault(require("@mui/material/Link"));
11
- var ArrowDropDown_1 = __importDefault(require("@mui/icons-material/ArrowDropDown"));
11
+ var ExpandMore_1 = __importDefault(require("@mui/icons-material/ExpandMore"));
12
+ var ExpandLess_1 = __importDefault(require("@mui/icons-material/ExpandLess"));
12
13
  var styles_1 = require("./styles");
13
14
  var ViewMoreToggle = function (_a) {
14
- var _b;
15
15
  var active = _a.active, onClick = _a.onClick, className = _a.className;
16
16
  var styles = (0, styles_1.useStyles)();
17
- return (react_1.default.createElement(Link_1.default, { className: (0, classnames_1.default)(styles.viewMoreLessLink, className), onClick: onClick, underline: "none" },
18
- react_1.default.createElement(ArrowDropDown_1.default, { "data-reltio-id": "more-arrow-icon", className: (0, classnames_1.default)(styles.arrow, (_b = {}, _b[styles.rotated] = active, _b)) }),
17
+ var Icon = active ? ExpandLess_1.default : ExpandMore_1.default;
18
+ return (react_1.default.createElement(Link_1.default, { className: (0, classnames_1.default)(styles.link, className), onClick: onClick, underline: "none" },
19
+ react_1.default.createElement(Icon, { className: styles.icon }),
19
20
  active ? ui_i18n_1.default.text('View less') : ui_i18n_1.default.text('View more')));
20
21
  };
21
22
  exports.ViewMoreToggle = ViewMoreToggle;
@@ -53,6 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
53
  var react_1 = __importDefault(require("react"));
54
54
  var react_2 = require("@testing-library/react");
55
55
  var user_event_1 = __importDefault(require("@testing-library/user-event"));
56
+ var test_utils_1 = require("../test-utils");
56
57
  var ViewMoreToggle_1 = require("./ViewMoreToggle");
57
58
  describe('ViewMoreToggle tests', function () {
58
59
  var defaultProps = {
@@ -64,15 +65,15 @@ describe('ViewMoreToggle tests', function () {
64
65
  var user = user_event_1.default.setup();
65
66
  return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(ViewMoreToggle_1.ViewMoreToggle, __assign({}, defaultProps, props))));
66
67
  };
67
- it('should render Link with "View less" label and arrow icon rotated if props.active is true', function () {
68
+ it('should render Link with "View less" label and expand less icon if props.active is true', function () {
68
69
  setUp({ active: true });
69
- expect(react_2.screen.getByText('View less')).toBeInTheDocument();
70
- expect(react_2.screen.getByTestId('more-arrow-icon')).toHaveClass('rotated');
70
+ react_2.screen.getByText('View less');
71
+ expect((0, test_utils_1.getMuiIconByName)('ExpandLess')).toBeInTheDocument();
71
72
  });
72
- it('should render Link with "View more" label and arrow icon if props.active is false', function () {
73
+ it('should render Link with "View more" label and expand more icon if props.active is false', function () {
73
74
  setUp({ active: false });
74
- expect(react_2.screen.getByText('View more')).toBeInTheDocument();
75
- expect(react_2.screen.getByTestId('more-arrow-icon')).not.toHaveClass('rotated');
75
+ react_2.screen.getByText('View more');
76
+ expect((0, test_utils_1.getMuiIconByName)('ExpandMore')).toBeInTheDocument();
76
77
  });
77
78
  it('should call props.onClick on Link click', function () { return __awaiter(void 0, void 0, void 0, function () {
78
79
  var user;
@@ -1 +1 @@
1
- export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"arrow" | "viewMoreLessLink" | "rotated">;
1
+ export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"icon" | "link">;
@@ -2,19 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useStyles = void 0;
4
4
  var styles_1 = require("@mui/styles");
5
- exports.useStyles = (0, styles_1.makeStyles)(function () { return ({
6
- viewMoreLessLink: {
5
+ exports.useStyles = (0, styles_1.makeStyles)({
6
+ link: {
7
7
  display: 'flex',
8
8
  alignItems: 'center',
9
9
  cursor: 'pointer'
10
10
  },
11
- arrow: {
12
- marginRight: '8px',
13
- marginLeft: '-2px',
14
- transform: 'rotate(0deg)',
15
- transition: 'transform 0.35s ease'
16
- },
17
- rotated: {
18
- transform: 'rotate(-180deg)'
11
+ icon: {
12
+ fontSize: '20px',
13
+ marginRight: '4px',
14
+ marginLeft: '-2px'
19
15
  }
20
- }); });
16
+ });
@@ -2,13 +2,14 @@ import React from 'react';
2
2
  import i18n from 'ui-i18n';
3
3
  import classnames from 'classnames';
4
4
  import Link from '@mui/material/Link';
5
- import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
5
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
6
+ import ExpandLessIcon from '@mui/icons-material/ExpandLess';
6
7
  import { useStyles } from './styles';
7
8
  export var ViewMoreToggle = function (_a) {
8
- var _b;
9
9
  var active = _a.active, onClick = _a.onClick, className = _a.className;
10
10
  var styles = useStyles();
11
- return (React.createElement(Link, { className: classnames(styles.viewMoreLessLink, className), onClick: onClick, underline: "none" },
12
- React.createElement(ArrowDropDownIcon, { "data-reltio-id": "more-arrow-icon", className: classnames(styles.arrow, (_b = {}, _b[styles.rotated] = active, _b)) }),
11
+ var Icon = active ? ExpandLessIcon : ExpandMoreIcon;
12
+ return (React.createElement(Link, { className: classnames(styles.link, className), onClick: onClick, underline: "none" },
13
+ React.createElement(Icon, { className: styles.icon }),
13
14
  active ? i18n.text('View less') : i18n.text('View more')));
14
15
  };
@@ -48,6 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  import React from 'react';
49
49
  import { render, screen } from '@testing-library/react';
50
50
  import userEvent from '@testing-library/user-event';
51
+ import { getMuiIconByName } from '../test-utils';
51
52
  import { ViewMoreToggle } from './ViewMoreToggle';
52
53
  describe('ViewMoreToggle tests', function () {
53
54
  var defaultProps = {
@@ -59,15 +60,15 @@ describe('ViewMoreToggle tests', function () {
59
60
  var user = userEvent.setup();
60
61
  return __assign({ user: user }, render(React.createElement(ViewMoreToggle, __assign({}, defaultProps, props))));
61
62
  };
62
- it('should render Link with "View less" label and arrow icon rotated if props.active is true', function () {
63
+ it('should render Link with "View less" label and expand less icon if props.active is true', function () {
63
64
  setUp({ active: true });
64
- expect(screen.getByText('View less')).toBeInTheDocument();
65
- expect(screen.getByTestId('more-arrow-icon')).toHaveClass('rotated');
65
+ screen.getByText('View less');
66
+ expect(getMuiIconByName('ExpandLess')).toBeInTheDocument();
66
67
  });
67
- it('should render Link with "View more" label and arrow icon if props.active is false', function () {
68
+ it('should render Link with "View more" label and expand more icon if props.active is false', function () {
68
69
  setUp({ active: false });
69
- expect(screen.getByText('View more')).toBeInTheDocument();
70
- expect(screen.getByTestId('more-arrow-icon')).not.toHaveClass('rotated');
70
+ screen.getByText('View more');
71
+ expect(getMuiIconByName('ExpandMore')).toBeInTheDocument();
71
72
  });
72
73
  it('should call props.onClick on Link click', function () { return __awaiter(void 0, void 0, void 0, function () {
73
74
  var user;
@@ -1 +1 @@
1
- export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"arrow" | "viewMoreLessLink" | "rotated">;
1
+ export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"icon" | "link">;
@@ -1,17 +1,13 @@
1
1
  import { makeStyles } from '@mui/styles';
2
- export var useStyles = makeStyles(function () { return ({
3
- viewMoreLessLink: {
2
+ export var useStyles = makeStyles({
3
+ link: {
4
4
  display: 'flex',
5
5
  alignItems: 'center',
6
6
  cursor: 'pointer'
7
7
  },
8
- arrow: {
9
- marginRight: '8px',
10
- marginLeft: '-2px',
11
- transform: 'rotate(0deg)',
12
- transition: 'transform 0.35s ease'
13
- },
14
- rotated: {
15
- transform: 'rotate(-180deg)'
8
+ icon: {
9
+ fontSize: '20px',
10
+ marginRight: '4px',
11
+ marginLeft: '-2px'
16
12
  }
17
- }); });
13
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1954",
3
+ "version": "1.4.1955",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",