cozy-ui 60.8.0 → 60.9.1
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 +28 -0
- package/package.json +1 -1
- package/react/AppLinker/index.jsx +4 -1
- package/react/BarContextProvider/index.jsx +4 -1
- package/react/BarContextProvider/index.spec.jsx +25 -0
- package/react/BottomSheet/BottomSheet.jsx +6 -3
- package/react/FilePicker/FilePickerBodyItem.jsx +3 -4
- package/react/FilePicker/FilePickerBodyItem.spec.jsx +2 -2
- package/transpiled/react/AppLinker/index.js +3 -2
- package/transpiled/react/BarContextProvider/index.js +2 -1
- package/transpiled/react/BottomSheet/BottomSheet.js +3 -3
- package/transpiled/react/FilePicker/FilePickerBodyItem.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [60.9.1](https://github.com/cozy/cozy-ui/compare/v60.9.0...v60.9.1) (2022-01-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Error when attributes doesn't exists ([f2d4e41](https://github.com/cozy/cozy-ui/commit/f2d4e41))
|
|
7
|
+
|
|
8
|
+
# [60.9.0](https://github.com/cozy/cozy-ui/compare/v60.8.2...v60.9.0) (2022-01-27)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Add WebviewProvider in BarProvider ([bd2823e](https://github.com/cozy/cozy-ui/commit/bd2823e))
|
|
14
|
+
|
|
15
|
+
## [60.8.2](https://github.com/cozy/cozy-ui/compare/v60.8.1...v60.8.2) (2022-01-26)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* Auto ref on BottomSheet Header now use displayName too ([0f1e067](https://github.com/cozy/cozy-ui/commit/0f1e067))
|
|
21
|
+
|
|
22
|
+
## [60.8.1](https://github.com/cozy/cozy-ui/compare/v60.8.0...v60.8.1) (2022-01-26)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* PreventDefault on cozy-intent event ([f0ad95b](https://github.com/cozy/cozy-ui/commit/f0ad95b))
|
|
28
|
+
|
|
1
29
|
# [60.8.0](https://github.com/cozy/cozy-ui/compare/v60.7.0...v60.8.0) (2022-01-25)
|
|
2
30
|
|
|
3
31
|
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { BreakpointsProvider } from '../hooks/useBreakpoints'
|
|
|
4
4
|
|
|
5
5
|
import { CozyProvider } from 'cozy-client'
|
|
6
6
|
import { Provider } from 'react-redux'
|
|
7
|
+
import { WebviewIntentProvider } from 'cozy-intent'
|
|
7
8
|
|
|
8
9
|
const BarContextProvider = props => {
|
|
9
10
|
if (!props.children) return null
|
|
@@ -13,7 +14,9 @@ const BarContextProvider = props => {
|
|
|
13
14
|
<I18nContext.Provider
|
|
14
15
|
value={{ f: props.f, t: props.t, lang: props.lang }}
|
|
15
16
|
>
|
|
16
|
-
<BreakpointsProvider>
|
|
17
|
+
<BreakpointsProvider>
|
|
18
|
+
<WebviewIntentProvider>{props.children}</WebviewIntentProvider>
|
|
19
|
+
</BreakpointsProvider>
|
|
17
20
|
</I18nContext.Provider>
|
|
18
21
|
</CozyProvider>
|
|
19
22
|
</Provider>
|
|
@@ -7,10 +7,15 @@ import CozyClient, {
|
|
|
7
7
|
} from 'cozy-client'
|
|
8
8
|
import configureStore from 'redux-mock-store'
|
|
9
9
|
import { Provider, useStore } from 'react-redux'
|
|
10
|
+
import { isFlagshipApp } from 'cozy-device-helper'
|
|
10
11
|
|
|
11
12
|
import BarContextProvider from '.'
|
|
12
13
|
import I18n, { useI18n, translate } from '../I18n'
|
|
13
14
|
|
|
15
|
+
jest.mock('cozy-device-helper', () => ({
|
|
16
|
+
isFlagshipApp: jest.fn()
|
|
17
|
+
}))
|
|
18
|
+
|
|
14
19
|
const locales = { helloworld: 'Hello World !' }
|
|
15
20
|
const localesBar = { a: 'b' }
|
|
16
21
|
|
|
@@ -64,4 +69,24 @@ describe('BarContextProvider', () => {
|
|
|
64
69
|
)
|
|
65
70
|
expect(root.html()).toBe('<div>Hello World !<br>6 Jan<br>en</div>')
|
|
66
71
|
})
|
|
72
|
+
|
|
73
|
+
it('should try to provide a cozy-intent context', async () => {
|
|
74
|
+
const client = createMockClient({})
|
|
75
|
+
const mockStore = configureStore()
|
|
76
|
+
const store = mockStore(x => x)
|
|
77
|
+
mount(
|
|
78
|
+
<Provider store={store}>
|
|
79
|
+
<CozyProvider client={client}>
|
|
80
|
+
<I18n lang="en" dictRequire={() => locales}>
|
|
81
|
+
<App />
|
|
82
|
+
</I18n>
|
|
83
|
+
</CozyProvider>
|
|
84
|
+
</Provider>
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
// Currently only the WebviewProvider should call this function in BarContext
|
|
88
|
+
// This is an easy way to test that the provider is working, albeit brittle
|
|
89
|
+
// A full test would need to mock cozy-intent, post-me and react-native
|
|
90
|
+
expect(isFlagshipApp).toHaveBeenCalled()
|
|
91
|
+
})
|
|
67
92
|
})
|
|
@@ -120,7 +120,10 @@ const BottomSheet = ({ toolbarProps, settings, children }) => {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
const overriddenChildren = React.Children.map(children, child => {
|
|
123
|
-
if (
|
|
123
|
+
if (
|
|
124
|
+
child.type.name === 'BottomSheetHeader' ||
|
|
125
|
+
child.type.displayName === 'BottomSheetHeader'
|
|
126
|
+
) {
|
|
124
127
|
return React.cloneElement(child, { headerContentRef })
|
|
125
128
|
}
|
|
126
129
|
return child
|
|
@@ -176,9 +179,9 @@ BottomSheet.propTypes = {
|
|
|
176
179
|
/** Toolbar properties */
|
|
177
180
|
toolbarProps: PropTypes.shape({
|
|
178
181
|
/** React reference of the toolbar node */
|
|
179
|
-
ref: PropTypes.
|
|
182
|
+
ref: PropTypes.object,
|
|
180
183
|
/** Toolbar height value */
|
|
181
|
-
height: PropTypes.
|
|
184
|
+
height: PropTypes.number
|
|
182
185
|
}),
|
|
183
186
|
/** Settings that can be modified */
|
|
184
187
|
settings: PropTypes.shape({
|
|
@@ -54,10 +54,9 @@ const FilePickerBodyItem = ({
|
|
|
54
54
|
const Input = multiple ? Checkbox : Radio
|
|
55
55
|
|
|
56
56
|
const listItemSecondaryContent = isFile(file)
|
|
57
|
-
? `${f(file.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)}`
|
|
57
|
+
? `${f(file.updated_at, 'DD MMM YYYY')} - ${filesize(file.size, {
|
|
58
|
+
base: 10
|
|
59
|
+
})}`
|
|
61
60
|
: null
|
|
62
61
|
|
|
63
62
|
return (
|
|
@@ -9,13 +9,13 @@ const mockFile01 = {
|
|
|
9
9
|
_id: '001',
|
|
10
10
|
type: 'file',
|
|
11
11
|
name: 'Filename',
|
|
12
|
-
|
|
12
|
+
updated_at: '2021-01-01T12:00:00.000000+01:00'
|
|
13
13
|
}
|
|
14
14
|
const mockFolder01 = {
|
|
15
15
|
_id: '002',
|
|
16
16
|
type: 'directory',
|
|
17
17
|
name: 'Foldername',
|
|
18
|
-
|
|
18
|
+
updated_at: '2021-01-01T12:00:00.000000+01:00'
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
jest.mock('filesize', () => jest.fn())
|
|
@@ -140,8 +140,9 @@ export var AppLinker = /*#__PURE__*/function (_React$Component) {
|
|
|
140
140
|
|
|
141
141
|
if (context) {
|
|
142
142
|
return {
|
|
143
|
-
onClick: function onClick() {
|
|
144
|
-
|
|
143
|
+
onClick: function onClick(event) {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
context.call('openApp', href, app);
|
|
145
146
|
},
|
|
146
147
|
href: '#'
|
|
147
148
|
};
|
|
@@ -3,6 +3,7 @@ import { I18nContext } from "cozy-ui/transpiled/react/I18n";
|
|
|
3
3
|
import { BreakpointsProvider } from "cozy-ui/transpiled/react/hooks/useBreakpoints";
|
|
4
4
|
import { CozyProvider } from 'cozy-client';
|
|
5
5
|
import { Provider } from 'react-redux';
|
|
6
|
+
import { WebviewIntentProvider } from 'cozy-intent';
|
|
6
7
|
|
|
7
8
|
var BarContextProvider = function BarContextProvider(props) {
|
|
8
9
|
if (!props.children) return null;
|
|
@@ -16,7 +17,7 @@ var BarContextProvider = function BarContextProvider(props) {
|
|
|
16
17
|
t: props.t,
|
|
17
18
|
lang: props.lang
|
|
18
19
|
}
|
|
19
|
-
}, React.createElement(BreakpointsProvider, null, props.children))));
|
|
20
|
+
}, React.createElement(BreakpointsProvider, null, React.createElement(WebviewIntentProvider, null, props.children)))));
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
export default BarContextProvider;
|
|
@@ -130,7 +130,7 @@ var BottomSheet = function BottomSheet(_ref2) {
|
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
var overriddenChildren = React.Children.map(children, function (child) {
|
|
133
|
-
if (child.type.name === 'BottomSheetHeader') {
|
|
133
|
+
if (child.type.name === 'BottomSheetHeader' || child.type.displayName === 'BottomSheetHeader') {
|
|
134
134
|
return React.cloneElement(child, {
|
|
135
135
|
headerContentRef: headerContentRef
|
|
136
136
|
});
|
|
@@ -187,10 +187,10 @@ BottomSheet.propTypes = {
|
|
|
187
187
|
/** Toolbar properties */
|
|
188
188
|
toolbarProps: PropTypes.shape({
|
|
189
189
|
/** React reference of the toolbar node */
|
|
190
|
-
ref: PropTypes.
|
|
190
|
+
ref: PropTypes.object,
|
|
191
191
|
|
|
192
192
|
/** Toolbar height value */
|
|
193
|
-
height: PropTypes.
|
|
193
|
+
height: PropTypes.number
|
|
194
194
|
}),
|
|
195
195
|
|
|
196
196
|
/** Settings that can be modified */
|
|
@@ -52,7 +52,7 @@ var FilePickerBodyItem = function FilePickerBodyItem(_ref) {
|
|
|
52
52
|
|
|
53
53
|
var hasChoice = fileTypesAccepted.file && isFile(file) || fileTypesAccepted.folder && isDirectory(file);
|
|
54
54
|
var Input = multiple ? Checkbox : Radio;
|
|
55
|
-
var listItemSecondaryContent = isFile(file) ? "".concat(f(file.
|
|
55
|
+
var listItemSecondaryContent = isFile(file) ? "".concat(f(file.updated_at, 'DD MMM YYYY'), " - ").concat(filesize(file.size, {
|
|
56
56
|
base: 10
|
|
57
57
|
})) : null;
|
|
58
58
|
return React.createElement(React.Fragment, null, React.createElement(ListItem, {
|