cozy-ui 73.1.0 → 73.2.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [73.2.0](https://github.com/cozy/cozy-ui/compare/v73.1.0...v73.2.0) (2022-08-26)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add genNavLinkForV6() in Nav component ([b5df157](https://github.com/cozy/cozy-ui/commit/b5df157))
7
+
1
8
  # [73.1.0](https://github.com/cozy/cozy-ui/compare/v73.0.1...v73.1.0) (2022-08-26)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "73.1.0",
3
+ "version": "73.2.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { forwardRef } from 'react'
2
2
  import Icon from '../Icon'
3
3
  import styles from './styles.styl'
4
4
  import cx from 'classnames'
@@ -24,6 +24,7 @@ export const NavLink = {
24
24
  activeClassName: styles['is-active']
25
25
  }
26
26
 
27
+ // Generates a styled NavLink for react-routeur v5 and older
27
28
  export const genNavLink = RRNavLink => ({ to, children, ...rest }) => (
28
29
  <RRNavLink
29
30
  to={to}
@@ -35,6 +36,18 @@ export const genNavLink = RRNavLink => ({ to, children, ...rest }) => (
35
36
  </RRNavLink>
36
37
  )
37
38
 
39
+ // Generates a styled NavLink for react-routeur v6
40
+ export const genNavLinkForV6 = RRNavLink =>
41
+ forwardRef((props, ref) => (
42
+ <RRNavLink
43
+ ref={ref}
44
+ className={({ isActive }) =>
45
+ styles['c-nav-link'] + (isActive ? ` ${styles['is-active']}` : '')
46
+ }
47
+ {...props}
48
+ />
49
+ ))
50
+
38
51
  export const NavIcon = ({ icon }) => (
39
52
  <span className={cx(styles['c-nav-icon'])}>
40
53
  <Icon icon={icon} aria-hidden="true" focusable="false" />
@@ -2,6 +2,8 @@ On desktop shows a vertical menu on the left. On mobile, shows a horizontal bott
2
2
 
3
3
  ⚠️ `NavLink` must be imported normally from `react-router-dom` and used as follows.
4
4
 
5
+ ⚠️ You must use `genNavLinkForV6` instead of `genNavLink` for `react-router-dom` version 6.
6
+
5
7
  ```jsx static
6
8
  import { NavLink as RouterLink } from 'react-router'
7
9
  import { genNavLink } from 'cozy-ui/transpiled/react/Nav'
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["children", "secondary"],
4
4
  _excluded2 = ["to", "children"];
5
- import React from 'react';
5
+ import React, { forwardRef } from 'react';
6
6
  import Icon from "cozy-ui/transpiled/react/Icon";
7
7
  var styles = {
8
8
  "CozyTheme--inverted": "styles__CozyTheme--inverted____lEpp",
@@ -34,7 +34,8 @@ export var NavText = function NavText(_ref2) {
34
34
  export var NavLink = {
35
35
  className: styles['c-nav-link'],
36
36
  activeClassName: styles['is-active']
37
- };
37
+ }; // Generates a styled NavLink for react-routeur v5 and older
38
+
38
39
  export var genNavLink = function genNavLink(RRNavLink) {
39
40
  return function (_ref3) {
40
41
  var to = _ref3.to,
@@ -47,9 +48,21 @@ export var genNavLink = function genNavLink(RRNavLink) {
47
48
  activeClassName: NavLink.activeClassName
48
49
  }, rest), children);
49
50
  };
51
+ }; // Generates a styled NavLink for react-routeur v6
52
+
53
+ export var genNavLinkForV6 = function genNavLinkForV6(RRNavLink) {
54
+ return /*#__PURE__*/forwardRef(function (props, ref) {
55
+ return /*#__PURE__*/React.createElement(RRNavLink, _extends({
56
+ ref: ref,
57
+ className: function className(_ref4) {
58
+ var isActive = _ref4.isActive;
59
+ return styles['c-nav-link'] + (isActive ? " ".concat(styles['is-active']) : '');
60
+ }
61
+ }, props));
62
+ });
50
63
  };
51
- export var NavIcon = function NavIcon(_ref4) {
52
- var icon = _ref4.icon;
64
+ export var NavIcon = function NavIcon(_ref5) {
65
+ var icon = _ref5.icon;
53
66
  return /*#__PURE__*/React.createElement("span", {
54
67
  className: cx(styles['c-nav-icon'])
55
68
  }, /*#__PURE__*/React.createElement(Icon, {
@@ -59,8 +72,8 @@ export var NavIcon = function NavIcon(_ref4) {
59
72
  }));
60
73
  };
61
74
 
62
- var Nav = function Nav(_ref5) {
63
- var children = _ref5.children;
75
+ var Nav = function Nav(_ref6) {
76
+ var children = _ref6.children;
64
77
  return /*#__PURE__*/React.createElement("nav", {
65
78
  role: "navigation"
66
79
  }, /*#__PURE__*/React.createElement("ul", {