cozy-ui 77.3.0 → 77.5.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 +14 -0
- package/package.json +1 -1
- package/react/CozyDialogs/Readme.md +55 -0
- package/react/CozyDialogs/useCozyDialog.js +11 -6
- package/react/Table/Readme.md +2 -1
- package/react/Table/index.jsx +48 -18
- package/transpiled/react/CozyDialogs/useCozyDialog.js +8 -4
- package/transpiled/react/Table/index.js +55 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [77.5.0](https://github.com/cozy/cozy-ui/compare/v77.4.0...v77.5.0) (2022-11-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Table components now forward ref ([f599a39](https://github.com/cozy/cozy-ui/commit/f599a39))
|
|
7
|
+
|
|
8
|
+
# [77.4.0](https://github.com/cozy/cozy-ui/compare/v77.3.0...v77.4.0) (2022-11-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **CozyDialogs:** Add possibility to override DialogTitle props ([c4a1995](https://github.com/cozy/cozy-ui/commit/c4a1995))
|
|
14
|
+
|
|
1
15
|
# [77.3.0](https://github.com/cozy/cozy-ui/compare/v77.2.0...v77.3.0) (2022-11-08)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -30,6 +30,8 @@ import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
|
30
30
|
|
|
31
31
|
### Props
|
|
32
32
|
|
|
33
|
+
* **componentsProps** : `<object>` – overriden properties of specific components
|
|
34
|
+
* **dialogTitle** : `<object>` – DialogTitle component properties
|
|
33
35
|
* **size** : `<string>` – Can be "s", "m" (default) or "l"
|
|
34
36
|
* **open** : `<boolean>` (required) – To open/close the modal
|
|
35
37
|
* **disableTitleAutoPadding** : `<boolean>` (optional) – Disable title padding calculation that would prevent overlapping with close and back buttons
|
|
@@ -341,3 +343,56 @@ const initialVariants = [{
|
|
|
341
343
|
</Variants>
|
|
342
344
|
</BreakpointsProvider>
|
|
343
345
|
```
|
|
346
|
+
|
|
347
|
+
### Dialogs with title button
|
|
348
|
+
|
|
349
|
+
```jsx
|
|
350
|
+
import cx from 'classnames'
|
|
351
|
+
import useBreakpoints, { BreakpointsProvider } from 'cozy-ui/transpiled/react/hooks/useBreakpoints'
|
|
352
|
+
|
|
353
|
+
import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs'
|
|
354
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
355
|
+
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
356
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
357
|
+
import DotsIcon from 'cozy-ui/transpiled/react/Icons/Dots'
|
|
358
|
+
|
|
359
|
+
initialState = { showModal: false }
|
|
360
|
+
|
|
361
|
+
const Modal = () => {
|
|
362
|
+
const { isMobile } = useBreakpoints()
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<Dialog
|
|
366
|
+
open
|
|
367
|
+
title={
|
|
368
|
+
<>
|
|
369
|
+
This is the title
|
|
370
|
+
<IconButton>
|
|
371
|
+
<Icon icon={DotsIcon} />
|
|
372
|
+
</IconButton>
|
|
373
|
+
</>
|
|
374
|
+
}
|
|
375
|
+
content="Here's the content"
|
|
376
|
+
actions={
|
|
377
|
+
<Button label="Close" onClick={() => setState({ showModal: false })} />
|
|
378
|
+
}
|
|
379
|
+
componentsProps={{
|
|
380
|
+
dialogTitle: {
|
|
381
|
+
className: "u-flex u-flex-items-center u-flex-justify-between u-pv-0-s u-pv-1 u-pr-0-s"
|
|
382
|
+
}
|
|
383
|
+
}}
|
|
384
|
+
onClose={() => setState({ showModal: false })}
|
|
385
|
+
/>
|
|
386
|
+
)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
;
|
|
390
|
+
|
|
391
|
+
<BreakpointsProvider>
|
|
392
|
+
<Button label="Open modal" onClick={() => setState({ showModal: true })}/>
|
|
393
|
+
|
|
394
|
+
{state.showModal && (
|
|
395
|
+
<Modal />
|
|
396
|
+
)}
|
|
397
|
+
</BreakpointsProvider>
|
|
398
|
+
```
|
|
@@ -32,6 +32,7 @@ const useCozyDialog = props => {
|
|
|
32
32
|
disableGutters,
|
|
33
33
|
titleRef,
|
|
34
34
|
background,
|
|
35
|
+
componentsProps,
|
|
35
36
|
...otherProps
|
|
36
37
|
} = props
|
|
37
38
|
const { isMobile } = useBreakpoints()
|
|
@@ -66,15 +67,19 @@ const useCozyDialog = props => {
|
|
|
66
67
|
const showBackButton = onBack || (fullScreen && onClose) // back and close buttons are merged in fullScreen
|
|
67
68
|
|
|
68
69
|
const dialogTitleProps = {
|
|
70
|
+
...componentsProps?.dialogTitle,
|
|
69
71
|
id: `modal-title-${id}`,
|
|
70
72
|
ref: titleRef,
|
|
71
73
|
disableTypography: true,
|
|
72
|
-
className: cx(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
className: cx(
|
|
75
|
+
{
|
|
76
|
+
'u-ellipsis': !isFluidTitle,
|
|
77
|
+
dialogTitleFluid: isFluidTitle,
|
|
78
|
+
dialogTitleWithClose: showCloseButton && !disableTitleAutoPadding,
|
|
79
|
+
dialogTitleWithBack: showBackButton && !disableTitleAutoPadding
|
|
80
|
+
},
|
|
81
|
+
componentsProps?.dialogTitle?.className
|
|
82
|
+
)
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
const listItemClassName = 'listItem--dialog'
|
package/react/Table/Readme.md
CHANGED
|
@@ -8,11 +8,12 @@ import {
|
|
|
8
8
|
TableCell
|
|
9
9
|
} from 'cozy-ui/transpiled/react/Table';
|
|
10
10
|
|
|
11
|
+
let refRow = ''
|
|
11
12
|
const cellStyles = { flexGrow: 1 };
|
|
12
13
|
|
|
13
14
|
<Table>
|
|
14
15
|
<TableHead>
|
|
15
|
-
<TableRow>
|
|
16
|
+
<TableRow ref={c => (refRow = c)} onClick={() => alert(refRow)}>
|
|
16
17
|
<TableHeader style={cellStyles}>Firstname</TableHeader>
|
|
17
18
|
<TableHeader style={cellStyles}>Lastname</TableHeader>
|
|
18
19
|
</TableRow>
|
package/react/Table/index.jsx
CHANGED
|
@@ -1,39 +1,69 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import styles from './styles.styl'
|
|
3
2
|
import cx from 'classnames'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
|
|
5
|
+
import styles from './styles.styl'
|
|
4
6
|
|
|
5
|
-
export const Table = props => {
|
|
7
|
+
export const Table = React.forwardRef((props, ref) => {
|
|
6
8
|
const { className, ...rest } = props
|
|
7
9
|
|
|
8
|
-
return <div className={cx(styles.Table, className)} {...rest} />
|
|
9
|
-
}
|
|
10
|
+
return <div className={cx(styles.Table, className)} {...rest} ref={ref} />
|
|
11
|
+
})
|
|
10
12
|
|
|
11
|
-
export const TableHead = props => {
|
|
13
|
+
export const TableHead = React.forwardRef((props, ref) => {
|
|
12
14
|
const { className, ...rest } = props
|
|
13
15
|
|
|
14
|
-
return <div className={cx(styles.TableHead, className)} {...rest} />
|
|
15
|
-
}
|
|
16
|
+
return <div className={cx(styles.TableHead, className)} {...rest} ref={ref} />
|
|
17
|
+
})
|
|
16
18
|
|
|
17
|
-
export const TableBody = props => {
|
|
19
|
+
export const TableBody = React.forwardRef((props, ref) => {
|
|
18
20
|
const { className, ...rest } = props
|
|
19
21
|
|
|
20
|
-
return <div className={cx(styles.TableBody, className)} {...rest} />
|
|
21
|
-
}
|
|
22
|
+
return <div className={cx(styles.TableBody, className)} {...rest} ref={ref} />
|
|
23
|
+
})
|
|
22
24
|
|
|
23
|
-
export const TableRow = props => {
|
|
25
|
+
export const TableRow = React.forwardRef((props, ref) => {
|
|
24
26
|
const { className, ...rest } = props
|
|
25
27
|
|
|
26
|
-
return <div className={cx(styles.TableRow, className)} {...rest} />
|
|
27
|
-
}
|
|
28
|
+
return <div className={cx(styles.TableRow, className)} {...rest} ref={ref} />
|
|
29
|
+
})
|
|
28
30
|
|
|
29
|
-
export const TableCell = props => {
|
|
31
|
+
export const TableCell = React.forwardRef((props, ref) => {
|
|
30
32
|
const { className, ...rest } = props
|
|
31
33
|
|
|
32
|
-
return <div className={cx(styles.TableCell, className)} {...rest} />
|
|
33
|
-
}
|
|
34
|
+
return <div className={cx(styles.TableCell, className)} {...rest} ref={ref} />
|
|
35
|
+
})
|
|
34
36
|
|
|
35
|
-
export const TableHeader = props => {
|
|
37
|
+
export const TableHeader = React.forwardRef((props, ref) => {
|
|
36
38
|
const { className, ...rest } = props
|
|
37
39
|
|
|
38
|
-
return
|
|
40
|
+
return (
|
|
41
|
+
<div className={cx(styles.TableHeader, className)} {...rest} ref={ref} />
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
Table.propTypes = {
|
|
46
|
+
className: PropTypes.string,
|
|
47
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
48
|
+
}
|
|
49
|
+
TableHead.propTypes = {
|
|
50
|
+
className: PropTypes.string,
|
|
51
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
52
|
+
}
|
|
53
|
+
TableBody.propTypes = {
|
|
54
|
+
className: PropTypes.string,
|
|
55
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
TableRow.propTypes = {
|
|
59
|
+
className: PropTypes.string,
|
|
60
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
61
|
+
}
|
|
62
|
+
TableCell.propTypes = {
|
|
63
|
+
className: PropTypes.string,
|
|
64
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
65
|
+
}
|
|
66
|
+
TableHeader.propTypes = {
|
|
67
|
+
className: PropTypes.string,
|
|
68
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
39
69
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["size", "actions", "actionsLayout", "title", "content", "open", "opened", "onBack", "onClose", "align", "disableTitleAutoPadding", "isFluidTitle", "disableGutters", "titleRef", "background"];
|
|
4
|
+
var _excluded = ["size", "actions", "actionsLayout", "title", "content", "open", "opened", "onBack", "onClose", "align", "disableTitleAutoPadding", "isFluidTitle", "disableGutters", "titleRef", "background", "componentsProps"];
|
|
5
5
|
|
|
6
6
|
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; }
|
|
7
7
|
|
|
@@ -24,6 +24,8 @@ var useStyles = makeStyles({
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
var useCozyDialog = function useCozyDialog(props) {
|
|
27
|
+
var _componentsProps$dial;
|
|
28
|
+
|
|
27
29
|
var size = props.size,
|
|
28
30
|
actions = props.actions,
|
|
29
31
|
actionsLayout = props.actionsLayout,
|
|
@@ -39,6 +41,7 @@ var useCozyDialog = function useCozyDialog(props) {
|
|
|
39
41
|
disableGutters = props.disableGutters,
|
|
40
42
|
titleRef = props.titleRef,
|
|
41
43
|
background = props.background,
|
|
44
|
+
componentsProps = props.componentsProps,
|
|
42
45
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
43
46
|
|
|
44
47
|
var _useBreakpoints = useBreakpoints(),
|
|
@@ -75,7 +78,7 @@ var useCozyDialog = function useCozyDialog(props) {
|
|
|
75
78
|
var showCloseButton = !fullScreen && onClose;
|
|
76
79
|
var showBackButton = onBack || fullScreen && onClose; // back and close buttons are merged in fullScreen
|
|
77
80
|
|
|
78
|
-
var dialogTitleProps = {
|
|
81
|
+
var dialogTitleProps = _objectSpread(_objectSpread({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.dialogTitle), {}, {
|
|
79
82
|
id: "modal-title-".concat(id),
|
|
80
83
|
ref: titleRef,
|
|
81
84
|
disableTypography: true,
|
|
@@ -84,8 +87,9 @@ var useCozyDialog = function useCozyDialog(props) {
|
|
|
84
87
|
dialogTitleFluid: isFluidTitle,
|
|
85
88
|
dialogTitleWithClose: showCloseButton && !disableTitleAutoPadding,
|
|
86
89
|
dialogTitleWithBack: showBackButton && !disableTitleAutoPadding
|
|
87
|
-
})
|
|
88
|
-
};
|
|
90
|
+
}, componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$dial = componentsProps.dialogTitle) === null || _componentsProps$dial === void 0 ? void 0 : _componentsProps$dial.className)
|
|
91
|
+
});
|
|
92
|
+
|
|
89
93
|
var listItemClassName = 'listItem--dialog';
|
|
90
94
|
var listItemProps = {
|
|
91
95
|
classes: {
|
|
@@ -7,6 +7,8 @@ var _excluded = ["className"],
|
|
|
7
7
|
_excluded5 = ["className"],
|
|
8
8
|
_excluded6 = ["className"];
|
|
9
9
|
import React from 'react';
|
|
10
|
+
import cx from 'classnames';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
10
12
|
var styles = {
|
|
11
13
|
"Table": "styles__Table___x3ZsI",
|
|
12
14
|
"TableHead": "styles__TableHead___1rqhM",
|
|
@@ -15,52 +17,87 @@ var styles = {
|
|
|
15
17
|
"TableCell": "styles__TableCell___yJCq7",
|
|
16
18
|
"TableHeader": "styles__TableHeader___FWkmV"
|
|
17
19
|
};
|
|
18
|
-
|
|
19
|
-
export var Table = function Table(props) {
|
|
20
|
+
export var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
20
21
|
var className = props.className,
|
|
21
22
|
rest = _objectWithoutProperties(props, _excluded);
|
|
22
23
|
|
|
23
24
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
24
25
|
className: cx(styles.Table, className)
|
|
25
|
-
}, rest
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
}, rest, {
|
|
27
|
+
ref: ref
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
export var TableHead = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
28
31
|
var className = props.className,
|
|
29
32
|
rest = _objectWithoutProperties(props, _excluded2);
|
|
30
33
|
|
|
31
34
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
32
35
|
className: cx(styles.TableHead, className)
|
|
33
|
-
}, rest
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
}, rest, {
|
|
37
|
+
ref: ref
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
export var TableBody = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
36
41
|
var className = props.className,
|
|
37
42
|
rest = _objectWithoutProperties(props, _excluded3);
|
|
38
43
|
|
|
39
44
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
40
45
|
className: cx(styles.TableBody, className)
|
|
41
|
-
}, rest
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
}, rest, {
|
|
47
|
+
ref: ref
|
|
48
|
+
}));
|
|
49
|
+
});
|
|
50
|
+
export var TableRow = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
44
51
|
var className = props.className,
|
|
45
52
|
rest = _objectWithoutProperties(props, _excluded4);
|
|
46
53
|
|
|
47
54
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
48
55
|
className: cx(styles.TableRow, className)
|
|
49
|
-
}, rest
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
}, rest, {
|
|
57
|
+
ref: ref
|
|
58
|
+
}));
|
|
59
|
+
});
|
|
60
|
+
export var TableCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
52
61
|
var className = props.className,
|
|
53
62
|
rest = _objectWithoutProperties(props, _excluded5);
|
|
54
63
|
|
|
55
64
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
56
65
|
className: cx(styles.TableCell, className)
|
|
57
|
-
}, rest
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
}, rest, {
|
|
67
|
+
ref: ref
|
|
68
|
+
}));
|
|
69
|
+
});
|
|
70
|
+
export var TableHeader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
60
71
|
var className = props.className,
|
|
61
72
|
rest = _objectWithoutProperties(props, _excluded6);
|
|
62
73
|
|
|
63
74
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
64
75
|
className: cx(styles.TableHeader, className)
|
|
65
|
-
}, rest
|
|
76
|
+
}, rest, {
|
|
77
|
+
ref: ref
|
|
78
|
+
}));
|
|
79
|
+
});
|
|
80
|
+
Table.propTypes = {
|
|
81
|
+
className: PropTypes.string,
|
|
82
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
83
|
+
};
|
|
84
|
+
TableHead.propTypes = {
|
|
85
|
+
className: PropTypes.string,
|
|
86
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
87
|
+
};
|
|
88
|
+
TableBody.propTypes = {
|
|
89
|
+
className: PropTypes.string,
|
|
90
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
91
|
+
};
|
|
92
|
+
TableRow.propTypes = {
|
|
93
|
+
className: PropTypes.string,
|
|
94
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
95
|
+
};
|
|
96
|
+
TableCell.propTypes = {
|
|
97
|
+
className: PropTypes.string,
|
|
98
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
99
|
+
};
|
|
100
|
+
TableHeader.propTypes = {
|
|
101
|
+
className: PropTypes.string,
|
|
102
|
+
ref: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
66
103
|
};
|