cozy-ui 90.2.0 → 90.3.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 +7 -0
- package/package.json +1 -1
- package/react/ActionsMenu/ActionsItems.jsx +5 -4
- package/react/ActionsMenu/ActionsMenuWrapper.jsx +1 -1
- package/react/ActionsMenu/Readme.md +4 -1
- package/transpiled/react/ActionsMenu/ActionsItems.js +7 -5
- package/transpiled/react/ActionsMenu/ActionsMenuWrapper.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [90.3.0](https://github.com/cozy/cozy-ui/compare/v90.2.0...v90.3.0) (2023-08-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **ActionsItems:** Add possibility to spread arg between onClick and actions ([ef54841](https://github.com/cozy/cozy-ui/commit/ef54841))
|
|
7
|
+
|
|
1
8
|
# [90.2.0](https://github.com/cozy/cozy-ui/compare/v90.1.0...v90.2.0) (2023-07-31)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { useI18n } from '../I18n'
|
|
|
6
6
|
import { getActionName, getOnlyNeededActions } from './Actions/helpers'
|
|
7
7
|
|
|
8
8
|
const ActionsItems = forwardRef(
|
|
9
|
-
({ doc, actions, actionOptions, onClick, ...props }, ref) => {
|
|
9
|
+
({ doc, actions, actionOptions, onClick: overridedClick, ...props }, ref) => {
|
|
10
10
|
const client = useClient()
|
|
11
11
|
const { t } = useI18n()
|
|
12
12
|
const cleanedActions = useMemo(() => getOnlyNeededActions(actions, doc), [
|
|
@@ -20,9 +20,9 @@ const ActionsItems = forwardRef(
|
|
|
20
20
|
|
|
21
21
|
const { Component: ActionComponent, action, disabled } = actionDefinition
|
|
22
22
|
|
|
23
|
-
const handleClick =
|
|
24
|
-
action && action(doc, { client, t, ...actionOptions })
|
|
25
|
-
|
|
23
|
+
const handleClick = clickProps => {
|
|
24
|
+
action && action(doc, { client, t, ...actionOptions, ...clickProps })
|
|
25
|
+
overridedClick && overridedClick()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return (
|
|
@@ -45,6 +45,7 @@ ActionsItems.propTypes = {
|
|
|
45
45
|
actions: PropTypes.array,
|
|
46
46
|
/** Props spread to action method of Actions component */
|
|
47
47
|
actionOptions: PropTypes.object,
|
|
48
|
+
/** The overrideClick function from ActionsMenuWrapper */
|
|
48
49
|
onClick: PropTypes.func
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -11,10 +11,13 @@ Use `makeActions` method and create (or use the predefined actions) to build the
|
|
|
11
11
|
```bash
|
|
12
12
|
const action1 = ({ option1, option2 }) => ({
|
|
13
13
|
name: action1,
|
|
14
|
-
|
|
14
|
+
action: ({ option3, option4 }) => {}
|
|
15
|
+
Component: ({ onClick, ...props }) => <SomeComponent {...props} onClick={() => onClick({ option3 })}} />
|
|
15
16
|
})
|
|
16
17
|
|
|
17
18
|
const actions = makeActions([action1, action2], { option1, option2 })
|
|
19
|
+
|
|
20
|
+
<ActionsMenu actions={actions} componentsProps={{ actionsItems: { actionOptions: { option4 }} }}
|
|
18
21
|
```
|
|
19
22
|
|
|
20
23
|
#### How to create actions
|
|
@@ -16,7 +16,7 @@ var ActionsItems = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
16
16
|
var doc = _ref.doc,
|
|
17
17
|
actions = _ref.actions,
|
|
18
18
|
actionOptions = _ref.actionOptions,
|
|
19
|
-
|
|
19
|
+
overridedClick = _ref.onClick,
|
|
20
20
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
21
|
|
|
22
22
|
var client = useClient();
|
|
@@ -34,12 +34,12 @@ var ActionsItems = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
34
34
|
action = actionDefinition.action,
|
|
35
35
|
disabled = actionDefinition.disabled;
|
|
36
36
|
|
|
37
|
-
var handleClick = function handleClick() {
|
|
38
|
-
action && action(doc, _objectSpread({
|
|
37
|
+
var handleClick = function handleClick(clickProps) {
|
|
38
|
+
action && action(doc, _objectSpread(_objectSpread({
|
|
39
39
|
client: client,
|
|
40
40
|
t: t
|
|
41
|
-
}, actionOptions));
|
|
42
|
-
|
|
41
|
+
}, actionOptions), clickProps));
|
|
42
|
+
overridedClick && overridedClick();
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
return /*#__PURE__*/React.createElement(ActionComponent, _extends({}, props, {
|
|
@@ -58,6 +58,8 @@ ActionsItems.propTypes = {
|
|
|
58
58
|
|
|
59
59
|
/** Props spread to action method of Actions component */
|
|
60
60
|
actionOptions: PropTypes.object,
|
|
61
|
+
|
|
62
|
+
/** The overrideClick function from ActionsMenuWrapper */
|
|
61
63
|
onClick: PropTypes.func
|
|
62
64
|
};
|
|
63
65
|
export default ActionsItems;
|
|
@@ -26,7 +26,8 @@ var ActionsMenuWrapper = function ActionsMenuWrapper(_ref) {
|
|
|
26
26
|
return function () {
|
|
27
27
|
var _props$onClick;
|
|
28
28
|
|
|
29
|
-
(_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props);
|
|
29
|
+
(_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props); // this is ActionsItems onClick prop
|
|
30
|
+
|
|
30
31
|
autoClose && (onClose === null || onClose === void 0 ? void 0 : onClose());
|
|
31
32
|
};
|
|
32
33
|
};
|