cozy-ui 128.7.0 → 128.8.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
|
+
# [128.8.0](https://github.com/cozy/cozy-ui/compare/v128.7.0...v128.8.0) (2025-09-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **NavDesktopDropdown:** introduce NavDesktopDropdown component for enhanced navigation item management ([3cb8a44](https://github.com/cozy/cozy-ui/commit/3cb8a44))
|
|
7
|
+
|
|
1
8
|
# [128.7.0](https://github.com/cozy/cozy-ui/compare/v128.6.0...v128.7.0) (2025-09-09)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/react/Layout/Layout.md
CHANGED
|
@@ -4,6 +4,7 @@ The Layout component brings a strong context for apps with any screen resolution
|
|
|
4
4
|
* `<Content />` is the main content or your app.
|
|
5
5
|
* ⚠️ Secondary `<NavItem />` are not visible on mobile and tablets
|
|
6
6
|
* `<NavDesktopLimiter />` is a component that allows you to limit the number of visible items in a list and toggle between showing a limited view and displaying all items.
|
|
7
|
+
* `<NavDesktopDropdown />` is a component that allows you to show / hide the items in a list when the number of items exceeds a defined limit
|
|
7
8
|
|
|
8
9
|
### NavDesktopLimiter
|
|
9
10
|
|
|
@@ -16,17 +17,24 @@ It can be used to wrap any list of React elements, automatically providing funct
|
|
|
16
17
|
* **children**: React.ReactNode (required) - The list items or elements that **NavDesktopLimiter** will manage.
|
|
17
18
|
* **max**: number (optional) - The maximum number of items to display initially. Default is **5**.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
### NavDesktopDropdown
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
The **NavDesktopDropdown** component is designed to manage the display of nav items efficiently, allowing users to toggle between showing a collapsed view and displaying all items. This component enhances the UI/UX by providing a clean and intuitive way to handle dropdowns with many items.
|
|
23
|
+
|
|
24
|
+
It can be used to wrap any list of React elements, automatically providing functionality to limit the number of displayed elements based on the `limit` prop (defaulting to **5**). Users can toggle the dropdown to show or hide the items as needed.
|
|
25
|
+
|
|
26
|
+
**Props**:
|
|
27
|
+
|
|
28
|
+
* **label**: string (required) - The label for the dropdown.
|
|
29
|
+
* **children**: React.ReactNode (required) - The list items or elements that **NavDesktopDropdown** will manage.
|
|
30
|
+
* **defaultOpen**: boolean (optional) - Determines whether the dropdown is open by default. Default is **true**.
|
|
31
|
+
* **limit**: number (optional) - The maximum number of items to display before enabling collapsing. Default is **5**.
|
|
24
32
|
|
|
25
33
|
```jsx
|
|
26
34
|
import { useState } from 'react'
|
|
27
35
|
import { Layout, Main, Content } from 'cozy-ui/transpiled/react/Layout'
|
|
28
36
|
import Sidebar from 'cozy-ui/transpiled/react/Sidebar'
|
|
29
|
-
import Nav, { NavItem, NavIcon, NavText, genNavLink, NavDesktopLimiter } from 'cozy-ui/transpiled/react/Nav'
|
|
37
|
+
import Nav, { NavItem, NavIcon, NavText, genNavLink, NavDesktopLimiter, NavDesktopDropdown } from 'cozy-ui/transpiled/react/Nav'
|
|
30
38
|
import cx from 'classnames'
|
|
31
39
|
import isEqual from 'lodash/isEqual'
|
|
32
40
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
@@ -83,7 +91,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
83
91
|
}
|
|
84
92
|
}))
|
|
85
93
|
|
|
86
|
-
const initialVariants = [{ monoColumn: false, withTopBar: true, longContent: true }]
|
|
94
|
+
const initialVariants = [{ monoColumn: false, withTopBar: true, longContent: true, moreThanMax: true }]
|
|
87
95
|
const [active, setActive] = useState(['Section 1', 'Subsection 1'])
|
|
88
96
|
const [showDialog, setShowDialog] = useState(isTesting() ? true : false)
|
|
89
97
|
const styles = useStyles()
|
|
@@ -130,6 +138,17 @@ const SideBar = ({ variant }) => {
|
|
|
130
138
|
<NavText>Section 3</NavText>
|
|
131
139
|
</NavLink>
|
|
132
140
|
</NavItem>
|
|
141
|
+
<NavDesktopDropdown label="Section 4" max={5}>
|
|
142
|
+
{
|
|
143
|
+
Array.from(Array(variant.moreThanMax ? 6 : 3).keys()).map(i => (
|
|
144
|
+
<NavItem secondary key={i}>
|
|
145
|
+
<NavLink>
|
|
146
|
+
<NavText>Subsection {i}</NavText>
|
|
147
|
+
</NavLink>
|
|
148
|
+
</NavItem>
|
|
149
|
+
))
|
|
150
|
+
}
|
|
151
|
+
</NavDesktopDropdown>
|
|
133
152
|
</Nav>
|
|
134
153
|
</Sidebar>
|
|
135
154
|
)
|
package/react/Nav/index.jsx
CHANGED
|
@@ -3,9 +3,11 @@ import React, { Children, isValidElement, useState, forwardRef } from 'react'
|
|
|
3
3
|
|
|
4
4
|
import withNavLocales from './locales/withNavLocales'
|
|
5
5
|
import styles from './styles.styl'
|
|
6
|
+
import DropdownText from '../DropdownText'
|
|
6
7
|
import Icon from '../Icon'
|
|
7
8
|
import BottomIcon from '../Icons/Bottom'
|
|
8
9
|
import TopIcon from '../Icons/Top'
|
|
10
|
+
import ListItem from '../ListItem'
|
|
9
11
|
import useBreakpoints from '../providers/Breakpoints'
|
|
10
12
|
import { useI18n } from '../providers/I18n'
|
|
11
13
|
|
|
@@ -116,5 +118,46 @@ const _NavDesktopLimiter = ({ children, max = 5 }) => {
|
|
|
116
118
|
|
|
117
119
|
export const NavDesktopLimiter = withNavLocales(_NavDesktopLimiter)
|
|
118
120
|
|
|
121
|
+
export const NavDesktopDropdown = ({
|
|
122
|
+
label,
|
|
123
|
+
children,
|
|
124
|
+
defaultOpen = true,
|
|
125
|
+
limit = 5
|
|
126
|
+
}) => {
|
|
127
|
+
const { isDesktop } = useBreakpoints()
|
|
128
|
+
const [open, setOpen] = useState(defaultOpen)
|
|
129
|
+
const isActivated =
|
|
130
|
+
Children.toArray(children).filter(isValidElement).length > limit
|
|
131
|
+
|
|
132
|
+
const innerIconProps = {
|
|
133
|
+
rotate: open ? 0 : -90,
|
|
134
|
+
...(!isActivated && { className: 'u-dn' })
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!isDesktop) return null
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<>
|
|
141
|
+
<ListItem size="small" className={isActivated ? 'u-c-pointer' : ''}>
|
|
142
|
+
<DropdownText
|
|
143
|
+
variant="subtitle2"
|
|
144
|
+
color="textSecondary"
|
|
145
|
+
innerIconProps={innerIconProps}
|
|
146
|
+
onClick={() => {
|
|
147
|
+
if (!isActivated) {
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
setOpen(!open)
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
{label}
|
|
154
|
+
</DropdownText>
|
|
155
|
+
</ListItem>
|
|
156
|
+
|
|
157
|
+
{open && <>{children}</>}
|
|
158
|
+
</>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
119
162
|
export default Nav
|
|
120
163
|
Nav.NavItem = NavItem
|
|
@@ -23,6 +23,12 @@ export function NavIcon({ className, icon }: {
|
|
|
23
23
|
icon: any;
|
|
24
24
|
}): JSX.Element;
|
|
25
25
|
export const NavDesktopLimiter: any;
|
|
26
|
+
export function NavDesktopDropdown({ label, children, defaultOpen, limit }: {
|
|
27
|
+
label: any;
|
|
28
|
+
children: any;
|
|
29
|
+
defaultOpen?: boolean | undefined;
|
|
30
|
+
limit?: number | undefined;
|
|
31
|
+
}): JSX.Element | null;
|
|
26
32
|
export default Nav;
|
|
27
33
|
import React from "react";
|
|
28
34
|
declare function Nav({ className, children }: {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
5
|
var _excluded = ["className", "children", "secondary"],
|
|
5
6
|
_excluded2 = ["to", "children"];
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
|
|
6
12
|
import cx from 'classnames';
|
|
7
13
|
import React, { Children, isValidElement, useState, forwardRef } from 'react';
|
|
8
14
|
import withNavLocales from "cozy-ui/transpiled/react/Nav/locales/withNavLocales";
|
|
@@ -16,9 +22,11 @@ var styles = {
|
|
|
16
22
|
"c-nav-item-secondary": "styles__c-nav-item-secondary___k14rf",
|
|
17
23
|
"c-nav-limiter": "styles__c-nav-limiter___3oxQU"
|
|
18
24
|
};
|
|
25
|
+
import DropdownText from "cozy-ui/transpiled/react/DropdownText";
|
|
19
26
|
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
20
27
|
import BottomIcon from "cozy-ui/transpiled/react/Icons/Bottom";
|
|
21
28
|
import TopIcon from "cozy-ui/transpiled/react/Icons/Top";
|
|
29
|
+
import ListItem from "cozy-ui/transpiled/react/ListItem";
|
|
22
30
|
import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
|
|
23
31
|
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
24
32
|
export var NavItem = function NavItem(_ref) {
|
|
@@ -136,5 +144,46 @@ var _NavDesktopLimiter = function _NavDesktopLimiter(_ref7) {
|
|
|
136
144
|
};
|
|
137
145
|
|
|
138
146
|
export var NavDesktopLimiter = withNavLocales(_NavDesktopLimiter);
|
|
147
|
+
export var NavDesktopDropdown = function NavDesktopDropdown(_ref8) {
|
|
148
|
+
var label = _ref8.label,
|
|
149
|
+
children = _ref8.children,
|
|
150
|
+
_ref8$defaultOpen = _ref8.defaultOpen,
|
|
151
|
+
defaultOpen = _ref8$defaultOpen === void 0 ? true : _ref8$defaultOpen,
|
|
152
|
+
_ref8$limit = _ref8.limit,
|
|
153
|
+
limit = _ref8$limit === void 0 ? 5 : _ref8$limit;
|
|
154
|
+
|
|
155
|
+
var _useBreakpoints2 = useBreakpoints(),
|
|
156
|
+
isDesktop = _useBreakpoints2.isDesktop;
|
|
157
|
+
|
|
158
|
+
var _useState3 = useState(defaultOpen),
|
|
159
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
160
|
+
open = _useState4[0],
|
|
161
|
+
setOpen = _useState4[1];
|
|
162
|
+
|
|
163
|
+
var isActivated = Children.toArray(children).filter(isValidElement).length > limit;
|
|
164
|
+
|
|
165
|
+
var innerIconProps = _objectSpread({
|
|
166
|
+
rotate: open ? 0 : -90
|
|
167
|
+
}, !isActivated && {
|
|
168
|
+
className: 'u-dn'
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (!isDesktop) return null;
|
|
172
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ListItem, {
|
|
173
|
+
size: "small",
|
|
174
|
+
className: isActivated ? 'u-c-pointer' : ''
|
|
175
|
+
}, /*#__PURE__*/React.createElement(DropdownText, {
|
|
176
|
+
variant: "subtitle2",
|
|
177
|
+
color: "textSecondary",
|
|
178
|
+
innerIconProps: innerIconProps,
|
|
179
|
+
onClick: function onClick() {
|
|
180
|
+
if (!isActivated) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setOpen(!open);
|
|
185
|
+
}
|
|
186
|
+
}, label)), open && /*#__PURE__*/React.createElement(React.Fragment, null, children));
|
|
187
|
+
};
|
|
139
188
|
export default Nav;
|
|
140
189
|
Nav.NavItem = NavItem;
|
|
@@ -12,11 +12,11 @@ declare var _default: React.ComponentType<Pick<Pick<PropTypes.InferProps<{
|
|
|
12
12
|
component: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
13
13
|
/** placement for the popover */
|
|
14
14
|
placement: PropTypes.Requireable<string>;
|
|
15
|
-
}>, "disabled" | "
|
|
15
|
+
}>, "disabled" | "component" | "placement">> & Partial<Pick<{
|
|
16
16
|
disabled: boolean;
|
|
17
17
|
component: null;
|
|
18
18
|
placement: string;
|
|
19
|
-
}, never>>, "disabled" | "
|
|
19
|
+
}, never>>, "disabled" | "component" | "placement"> & import("@material-ui/styles/withStyles/withStyles").StyledComponentProps<"root" | "paper">>;
|
|
20
20
|
export default _default;
|
|
21
21
|
export { MenuButton };
|
|
22
22
|
import PropTypes from "prop-types";
|