cozy-ui 60.8.1 → 60.10.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 +36 -0
- package/package.json +3 -3
- package/react/BarContextProvider/index.jsx +24 -8
- package/react/BarContextProvider/index.spec.jsx +139 -8
- 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/BarContextProvider/index.js +18 -8
- package/transpiled/react/BottomSheet/BottomSheet.js +3 -3
- package/transpiled/react/FilePicker/FilePickerBodyItem.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
# [60.10.0](https://github.com/cozy/cozy-ui/compare/v60.9.1...v60.10.0) (2022-01-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Update cozy-intent and device helper ([87d612c](https://github.com/cozy/cozy-ui/commit/87d612c))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Inject webviewService into BarContext ([b6c269f](https://github.com/cozy/cozy-ui/commit/b6c269f))
|
|
12
|
+
* Update BarContext testing ([15803f4](https://github.com/cozy/cozy-ui/commit/15803f4))
|
|
13
|
+
* Upgrade cozy-intent to latest ([8653ad1](https://github.com/cozy/cozy-ui/commit/8653ad1))
|
|
14
|
+
|
|
15
|
+
## [60.9.1](https://github.com/cozy/cozy-ui/compare/v60.9.0...v60.9.1) (2022-01-27)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* Error when attributes doesn't exists ([f2d4e41](https://github.com/cozy/cozy-ui/commit/f2d4e41))
|
|
21
|
+
|
|
22
|
+
# [60.9.0](https://github.com/cozy/cozy-ui/compare/v60.8.2...v60.9.0) (2022-01-27)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* Add WebviewProvider in BarProvider ([bd2823e](https://github.com/cozy/cozy-ui/commit/bd2823e))
|
|
28
|
+
|
|
29
|
+
## [60.8.2](https://github.com/cozy/cozy-ui/compare/v60.8.1...v60.8.2) (2022-01-26)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* Auto ref on BottomSheet Header now use displayName too ([0f1e067](https://github.com/cozy/cozy-ui/commit/0f1e067))
|
|
35
|
+
|
|
1
36
|
## [60.8.1](https://github.com/cozy/cozy-ui/compare/v60.8.0...v60.8.1) (2022-01-26)
|
|
2
37
|
|
|
3
38
|
|
|
@@ -141,6 +176,7 @@
|
|
|
141
176
|
|
|
142
177
|
* cozy-intent@1.1.2 or later is now required
|
|
143
178
|
otherwise, AppLinker will crash
|
|
179
|
+
* Wrap your App in the WebviewIntentProvider (via import { WebviewIntentProvider } from 'cozy-intent)
|
|
144
180
|
|
|
145
181
|
## [58.5.1](https://github.com/cozy/cozy-ui/compare/v58.5.0...v58.5.1) (2022-01-07)
|
|
146
182
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "60.
|
|
3
|
+
"version": "60.10.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"commitlint-config-cozy": "0.6.0",
|
|
90
90
|
"copyfiles": "2.1.1",
|
|
91
91
|
"cozy-client": "^27.5.1",
|
|
92
|
-
"cozy-device-helper": "^1.16.
|
|
92
|
+
"cozy-device-helper": "^1.16.1",
|
|
93
93
|
"cozy-doctypes": "^1.69.0",
|
|
94
94
|
"cozy-harvest-lib": "^6.7.3",
|
|
95
|
-
"cozy-intent": "^1.
|
|
95
|
+
"cozy-intent": "^1.6.0",
|
|
96
96
|
"cozy-sharing": "^3.10.0",
|
|
97
97
|
"css-loader": "0.28.11",
|
|
98
98
|
"cssnano": "4.1.11",
|
|
@@ -4,16 +4,32 @@ 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'
|
|
8
|
+
|
|
9
|
+
const BarContextProvider = ({
|
|
10
|
+
children,
|
|
11
|
+
store,
|
|
12
|
+
client,
|
|
13
|
+
f,
|
|
14
|
+
t,
|
|
15
|
+
lang,
|
|
16
|
+
webviewService
|
|
17
|
+
}) => {
|
|
18
|
+
if (!children) return null
|
|
7
19
|
|
|
8
|
-
const BarContextProvider = props => {
|
|
9
|
-
if (!props.children) return null
|
|
10
20
|
return (
|
|
11
|
-
<Provider store={
|
|
12
|
-
<CozyProvider client={
|
|
13
|
-
<I18nContext.Provider
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
<Provider store={store}>
|
|
22
|
+
<CozyProvider client={client}>
|
|
23
|
+
<I18nContext.Provider value={{ f, t, lang }}>
|
|
24
|
+
<BreakpointsProvider>
|
|
25
|
+
{webviewService ? (
|
|
26
|
+
<WebviewIntentProvider webviewService={webviewService}>
|
|
27
|
+
{children}
|
|
28
|
+
</WebviewIntentProvider>
|
|
29
|
+
) : (
|
|
30
|
+
children
|
|
31
|
+
)}
|
|
32
|
+
</BreakpointsProvider>
|
|
17
33
|
</I18nContext.Provider>
|
|
18
34
|
</CozyProvider>
|
|
19
35
|
</Provider>
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import { Provider, useStore } from 'react-redux'
|
|
3
|
+
import configureStore from 'redux-mock-store'
|
|
4
|
+
import { render } from '@testing-library/react'
|
|
2
5
|
|
|
6
|
+
import { useWebviewIntent } from 'cozy-intent'
|
|
3
7
|
import CozyClient, {
|
|
4
8
|
createMockClient,
|
|
5
9
|
CozyProvider,
|
|
6
10
|
useClient
|
|
7
11
|
} from 'cozy-client'
|
|
8
|
-
import configureStore from 'redux-mock-store'
|
|
9
|
-
import { Provider, useStore } from 'react-redux'
|
|
10
12
|
|
|
11
13
|
import BarContextProvider from '.'
|
|
12
14
|
import I18n, { useI18n, translate } from '../I18n'
|
|
13
15
|
|
|
16
|
+
const mockWebviewService = { foo: 'bar' }
|
|
17
|
+
const mockVoidWebviewService = 'No context'
|
|
14
18
|
const locales = { helloworld: 'Hello World !' }
|
|
15
19
|
const localesBar = { a: 'b' }
|
|
16
20
|
|
|
@@ -24,6 +28,20 @@ const DumbHelloWorld = translate()(({ t, f, lang }) => (
|
|
|
24
28
|
</div>
|
|
25
29
|
))
|
|
26
30
|
|
|
31
|
+
const IntentComponent = () => {
|
|
32
|
+
let webviewIntent
|
|
33
|
+
let render
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
webviewIntent = useWebviewIntent()
|
|
37
|
+
render = webviewIntent.foo
|
|
38
|
+
} catch {
|
|
39
|
+
render = mockVoidWebviewService
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return <main>{render}</main>
|
|
43
|
+
}
|
|
44
|
+
|
|
27
45
|
const MockedBar = props => {
|
|
28
46
|
const client = new CozyClient({})
|
|
29
47
|
return (
|
|
@@ -35,33 +53,146 @@ const MockedBar = props => {
|
|
|
35
53
|
)
|
|
36
54
|
}
|
|
37
55
|
|
|
38
|
-
const App = () => {
|
|
56
|
+
const App = ({ children, webviewService }) => {
|
|
39
57
|
const { t, f, lang } = useI18n()
|
|
40
58
|
const client = useClient()
|
|
41
59
|
const store = useStore()
|
|
60
|
+
|
|
42
61
|
return (
|
|
43
62
|
<MockedBar>
|
|
44
|
-
<BarContextProvider
|
|
45
|
-
|
|
63
|
+
<BarContextProvider
|
|
64
|
+
t={t}
|
|
65
|
+
f={f}
|
|
66
|
+
lang={lang}
|
|
67
|
+
client={client}
|
|
68
|
+
store={store}
|
|
69
|
+
webviewService={webviewService}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
46
72
|
</BarContextProvider>
|
|
47
73
|
</MockedBar>
|
|
48
74
|
)
|
|
49
75
|
}
|
|
50
76
|
|
|
51
77
|
describe('BarContextProvider', () => {
|
|
78
|
+
afterAll(() => {
|
|
79
|
+
window.cozy = undefined
|
|
80
|
+
})
|
|
81
|
+
|
|
52
82
|
it('should provide the right (aka app not the one from the bar) t/f/store/client to the DumbHelloWorld', () => {
|
|
53
83
|
const client = createMockClient({})
|
|
54
84
|
const mockStore = configureStore()
|
|
55
85
|
const store = mockStore(x => x)
|
|
56
|
-
|
|
86
|
+
|
|
87
|
+
const { queryByText } = render(
|
|
88
|
+
<Provider store={store}>
|
|
89
|
+
<CozyProvider client={client}>
|
|
90
|
+
<I18n lang="en" dictRequire={() => locales}>
|
|
91
|
+
<App>
|
|
92
|
+
<DumbHelloWorld />
|
|
93
|
+
</App>
|
|
94
|
+
</I18n>
|
|
95
|
+
</CozyProvider>
|
|
96
|
+
</Provider>
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
expect(queryByText('<div>Hello World !<br>6 Jan<br>en</div>')).toBeDefined()
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('should render nothing when no children is provided', () => {
|
|
103
|
+
const { container } = render(<BarContextProvider />)
|
|
104
|
+
expect(container.firstChild).toBeNull()
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('should work without a cozy-intent context', () => {
|
|
108
|
+
// Set App Amirale context
|
|
109
|
+
window.cozy.isFlagshipApp = true
|
|
110
|
+
|
|
111
|
+
const client = createMockClient({})
|
|
112
|
+
const mockStore = configureStore()
|
|
113
|
+
const store = mockStore(x => x)
|
|
114
|
+
|
|
115
|
+
const { queryByText } = render(
|
|
57
116
|
<Provider store={store}>
|
|
58
117
|
<CozyProvider client={client}>
|
|
59
118
|
<I18n lang="en" dictRequire={() => locales}>
|
|
60
|
-
<App
|
|
119
|
+
<App>
|
|
120
|
+
<IntentComponent />
|
|
121
|
+
</App>
|
|
61
122
|
</I18n>
|
|
62
123
|
</CozyProvider>
|
|
63
124
|
</Provider>
|
|
64
125
|
)
|
|
65
|
-
|
|
126
|
+
|
|
127
|
+
expect(queryByText(mockVoidWebviewService)).toBeInTheDocument()
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('should not try to provide a cozy-intent context if one is provided', () => {
|
|
131
|
+
// Set App Amirale context
|
|
132
|
+
window.cozy.isFlagshipApp = true
|
|
133
|
+
|
|
134
|
+
const client = createMockClient({})
|
|
135
|
+
const mockStore = configureStore()
|
|
136
|
+
const store = mockStore(x => x)
|
|
137
|
+
|
|
138
|
+
const { queryByText } = render(
|
|
139
|
+
<Provider store={store}>
|
|
140
|
+
<CozyProvider client={client}>
|
|
141
|
+
<I18n lang="en" dictRequire={() => locales}>
|
|
142
|
+
<App webviewService={mockWebviewService}>
|
|
143
|
+
<IntentComponent />
|
|
144
|
+
</App>
|
|
145
|
+
</I18n>
|
|
146
|
+
</CozyProvider>
|
|
147
|
+
</Provider>
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
expect(queryByText(mockWebviewService.foo)).toBeInTheDocument()
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('should work without a cozy-intent context', () => {
|
|
154
|
+
// Set Web context
|
|
155
|
+
window.cozy.isFlagshipApp = false
|
|
156
|
+
|
|
157
|
+
const client = createMockClient({})
|
|
158
|
+
const mockStore = configureStore()
|
|
159
|
+
const store = mockStore(x => x)
|
|
160
|
+
|
|
161
|
+
const { queryByText } = render(
|
|
162
|
+
<Provider store={store}>
|
|
163
|
+
<CozyProvider client={client}>
|
|
164
|
+
<I18n lang="en" dictRequire={() => locales}>
|
|
165
|
+
<App>
|
|
166
|
+
<IntentComponent />
|
|
167
|
+
</App>
|
|
168
|
+
</I18n>
|
|
169
|
+
</CozyProvider>
|
|
170
|
+
</Provider>
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
expect(queryByText(mockVoidWebviewService)).toBeInTheDocument()
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('should not try to provide a cozy-intent context if one is provided', () => {
|
|
177
|
+
// Set Web context
|
|
178
|
+
window.cozy.isFlagshipApp = false
|
|
179
|
+
|
|
180
|
+
const client = createMockClient({})
|
|
181
|
+
const mockStore = configureStore()
|
|
182
|
+
const store = mockStore(x => x)
|
|
183
|
+
|
|
184
|
+
const { queryByText } = render(
|
|
185
|
+
<Provider store={store}>
|
|
186
|
+
<CozyProvider client={client}>
|
|
187
|
+
<I18n lang="en" dictRequire={() => locales}>
|
|
188
|
+
<App webviewService={mockWebviewService}>
|
|
189
|
+
<IntentComponent />
|
|
190
|
+
</App>
|
|
191
|
+
</I18n>
|
|
192
|
+
</CozyProvider>
|
|
193
|
+
</Provider>
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
expect(queryByText(mockWebviewService.foo)).not.toBeInTheDocument()
|
|
66
197
|
})
|
|
67
198
|
})
|
|
@@ -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())
|
|
@@ -3,20 +3,30 @@ 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
|
-
var BarContextProvider = function BarContextProvider(
|
|
8
|
-
|
|
8
|
+
var BarContextProvider = function BarContextProvider(_ref) {
|
|
9
|
+
var children = _ref.children,
|
|
10
|
+
store = _ref.store,
|
|
11
|
+
client = _ref.client,
|
|
12
|
+
f = _ref.f,
|
|
13
|
+
t = _ref.t,
|
|
14
|
+
lang = _ref.lang,
|
|
15
|
+
webviewService = _ref.webviewService;
|
|
16
|
+
if (!children) return null;
|
|
9
17
|
return React.createElement(Provider, {
|
|
10
|
-
store:
|
|
18
|
+
store: store
|
|
11
19
|
}, React.createElement(CozyProvider, {
|
|
12
|
-
client:
|
|
20
|
+
client: client
|
|
13
21
|
}, React.createElement(I18nContext.Provider, {
|
|
14
22
|
value: {
|
|
15
|
-
f:
|
|
16
|
-
t:
|
|
17
|
-
lang:
|
|
23
|
+
f: f,
|
|
24
|
+
t: t,
|
|
25
|
+
lang: lang
|
|
18
26
|
}
|
|
19
|
-
}, React.createElement(BreakpointsProvider, null,
|
|
27
|
+
}, React.createElement(BreakpointsProvider, null, webviewService ? React.createElement(WebviewIntentProvider, {
|
|
28
|
+
webviewService: webviewService
|
|
29
|
+
}, children) : children))));
|
|
20
30
|
};
|
|
21
31
|
|
|
22
32
|
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, {
|