cozy-ui 90.0.0 → 90.2.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 +25 -0
- package/package.json +3 -2
- package/react/ActionsMenu/Actions/helpers.js +1 -1
- package/react/ActionsMenu/Actions/helpers.spec.js +26 -0
- package/react/CozyTheme/index.jsx +13 -2
- package/react/List/Readme.md +0 -113
- package/react/ListItem/ExpandedAttributes/helpers.js +3 -3
- package/react/ListItem/ExpandedAttributes/helpers.spec.js +2 -0
- package/react/ListItem/Readme.md +100 -0
- package/react/SquareAppIcon/__snapshots__/SquareAppIcon.spec.js.snap +2 -2
- package/react/Viewer/Panel/ActionMenuWrapper.jsx +4 -3
- package/react/Viewer/Panel/getPanelBlocks.spec.jsx +2 -0
- package/react/__snapshots__/examples.spec.jsx.snap +88 -88
- package/transpiled/react/ActionsMenu/Actions/helpers.js +1 -1
- package/transpiled/react/CozyTheme/index.js +13 -4
- package/transpiled/react/ListItem/ExpandedAttributes/helpers.js +3 -3
- package/transpiled/react/Viewer/Panel/ActionMenuWrapper.js +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
# [90.2.0](https://github.com/cozy/cozy-ui/compare/v90.1.0...v90.2.0) (2023-07-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **Viewer:** Success alert for copied item is now with a success style ([f934e3c](https://github.com/cozy/cozy-ui/commit/f934e3c))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add copy-text-to-clipboard 3.2.0 package ([c79456f](https://github.com/cozy/cozy-ui/commit/c79456f))
|
|
12
|
+
* Replace navigator.clipboard by copy-text-to-clipboard ([2884a37](https://github.com/cozy/cozy-ui/commit/2884a37))
|
|
13
|
+
|
|
14
|
+
# [90.1.0](https://github.com/cozy/cozy-ui/compare/v90.0.0...v90.1.0) (2023-07-26)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **CozyTheme:** Set default variant to "normal" ([816034d](https://github.com/cozy/cozy-ui/commit/816034d))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **ActionsMenu:** MakeActions() can now receive nullish actions ([de39ce7](https://github.com/cozy/cozy-ui/commit/de39ce7))
|
|
25
|
+
|
|
1
26
|
# [90.0.0](https://github.com/cozy/cozy-ui/compare/v89.1.0...v90.0.0) (2023-07-20)
|
|
2
27
|
|
|
3
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "90.
|
|
3
|
+
"version": "90.2.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"react-dom": "16.12.0",
|
|
135
135
|
"react-hot-loader": "^4.3.11",
|
|
136
136
|
"react-redux": "7.2.7",
|
|
137
|
-
"react-styleguidist": "
|
|
137
|
+
"react-styleguidist": "10.6.2",
|
|
138
138
|
"react-test-renderer": "16.12.0",
|
|
139
139
|
"redux": "3.7.2",
|
|
140
140
|
"redux-mock-store": "^1.5.4",
|
|
@@ -161,6 +161,7 @@
|
|
|
161
161
|
"bundlemon": "^1.3.2",
|
|
162
162
|
"chart.js": "3.7.1",
|
|
163
163
|
"classnames": "^2.2.5",
|
|
164
|
+
"copy-text-to-clipboard": "3.2.0",
|
|
164
165
|
"cozy-interapp": "^0.5.4",
|
|
165
166
|
"date-fns": "^1.28.5",
|
|
166
167
|
"filesize": "8.0.7",
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @returns {object[]} Array of actions
|
|
7
7
|
*/
|
|
8
8
|
export const makeActions = (actions = [], options = {}) => {
|
|
9
|
-
return actions.map(action => {
|
|
9
|
+
return actions.filter(Boolean).map(action => {
|
|
10
10
|
const actionMenu = action(options)
|
|
11
11
|
const name = actionMenu.name || action.name
|
|
12
12
|
|
|
@@ -7,6 +7,32 @@ describe('makeActions', () => {
|
|
|
7
7
|
expect(actions).toStrictEqual([])
|
|
8
8
|
})
|
|
9
9
|
|
|
10
|
+
it('should exclude `null` and `undefined` actions', () => {
|
|
11
|
+
const mockFuncActionWithName = jest.fn(() => ({
|
|
12
|
+
name: 'mockFuncActionWithName name'
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
const actions = makeActions([
|
|
16
|
+
undefined,
|
|
17
|
+
mockFuncActionWithName,
|
|
18
|
+
null,
|
|
19
|
+
mockFuncActionWithName
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
expect(actions).toStrictEqual([
|
|
23
|
+
{
|
|
24
|
+
'mockFuncActionWithName name': {
|
|
25
|
+
name: 'mockFuncActionWithName name'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
'mockFuncActionWithName name': {
|
|
30
|
+
name: 'mockFuncActionWithName name'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
])
|
|
34
|
+
})
|
|
35
|
+
|
|
10
36
|
it('should have object with key named with name property of the object returned by the function and value is the full object returned by the function', () => {
|
|
11
37
|
const mockFuncActionWithName = jest.fn(() => ({
|
|
12
38
|
name: 'mockFuncActionWithName name'
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React, { createContext, useContext } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
2
3
|
import cx from 'classnames'
|
|
3
4
|
|
|
4
5
|
import MuiCozyTheme from '../MuiCozyTheme'
|
|
5
6
|
|
|
6
7
|
export const CozyThemeContext = createContext()
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
+
export const useCozyTheme = () => useContext(CozyThemeContext)
|
|
10
|
+
|
|
11
|
+
const CozyTheme = ({ variant, className, children }) => (
|
|
9
12
|
<CozyThemeContext.Provider value={variant}>
|
|
10
13
|
<MuiCozyTheme variant={variant}>
|
|
11
14
|
<div
|
|
@@ -19,6 +22,14 @@ const CozyTheme = ({ variant, children, className }) => (
|
|
|
19
22
|
</CozyThemeContext.Provider>
|
|
20
23
|
)
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
CozyTheme.propTypes = {
|
|
26
|
+
variant: PropTypes.oneOf(['normal', 'inverted']),
|
|
27
|
+
className: PropTypes.string,
|
|
28
|
+
children: PropTypes.node
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
CozyTheme.defaultProps = {
|
|
32
|
+
variant: 'normal'
|
|
33
|
+
}
|
|
23
34
|
|
|
24
35
|
export default CozyTheme
|
package/react/List/Readme.md
CHANGED
|
@@ -279,116 +279,3 @@ import FiletypeTextIcon from 'cozy-ui/transpiled/react/Icons/FileTypeText'
|
|
|
279
279
|
</ListItem>
|
|
280
280
|
</List>
|
|
281
281
|
```
|
|
282
|
-
|
|
283
|
-
### Contextualized item
|
|
284
|
-
|
|
285
|
-
```jsx
|
|
286
|
-
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/hooks/useBreakpoints'
|
|
287
|
-
import List from 'cozy-ui/transpiled/react/List'
|
|
288
|
-
import ListItemByDoc from 'cozy-ui/transpiled/react/ListItem/ListItemByDoc'
|
|
289
|
-
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
290
|
-
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
291
|
-
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
292
|
-
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
293
|
-
import Divider from 'cozy-ui/transpiled/react/Divider'
|
|
294
|
-
import FiletypeTextIcon from 'cozy-ui/transpiled/react/Icons/FileTypeText'
|
|
295
|
-
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
296
|
-
|
|
297
|
-
const mockClient = {
|
|
298
|
-
plugins: {
|
|
299
|
-
realtime: {
|
|
300
|
-
subscribe: () => {},
|
|
301
|
-
unsubscribe: () => {},
|
|
302
|
-
unsubscribeAll: () => {}
|
|
303
|
-
}
|
|
304
|
-
},
|
|
305
|
-
getStackClient: () => ({
|
|
306
|
-
uri: 'https://cozy.io/'
|
|
307
|
-
}),
|
|
308
|
-
getInstanceOptions: () => ({
|
|
309
|
-
subdomain: ''
|
|
310
|
-
})
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const contacts = [
|
|
314
|
-
{
|
|
315
|
-
_id: 'id01',
|
|
316
|
-
_type: 'io.cozy.contacts',
|
|
317
|
-
displayName: 'John Doe',
|
|
318
|
-
birthday: '25/10/2022',
|
|
319
|
-
email: [{ address: 'johndoe@cozy.cc', primary: true }],
|
|
320
|
-
phone: [{ number: '0102030405', primary: true }]
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
_id: 'id02',
|
|
324
|
-
_type: 'io.cozy.contacts',
|
|
325
|
-
displayName: 'Jason Bourne',
|
|
326
|
-
birthday: '01/01/2020',
|
|
327
|
-
email: [{ address: 'jbourne@cozy.cc', primary: true }]
|
|
328
|
-
}
|
|
329
|
-
]
|
|
330
|
-
|
|
331
|
-
const files = [
|
|
332
|
-
{
|
|
333
|
-
_type: 'io.cozy.files',
|
|
334
|
-
name: 'File01.pdf',
|
|
335
|
-
metadata: {
|
|
336
|
-
number: 12345,
|
|
337
|
-
qualification: {
|
|
338
|
-
label: 'driver_license'
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
_type: 'io.cozy.files',
|
|
344
|
-
type: 'file',
|
|
345
|
-
name: 'Note01.cozy-note',
|
|
346
|
-
metadata: {
|
|
347
|
-
title: 'note title',
|
|
348
|
-
version: 0
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
]
|
|
352
|
-
|
|
353
|
-
;
|
|
354
|
-
|
|
355
|
-
<DemoProvider client={mockClient}>
|
|
356
|
-
<List>
|
|
357
|
-
<ListItem button>
|
|
358
|
-
<ListItemIcon>
|
|
359
|
-
<Icon icon={FiletypeTextIcon} width="32" height="32" />
|
|
360
|
-
</ListItemIcon>
|
|
361
|
-
<ListItemText primary="I'm a standard item" />
|
|
362
|
-
</ListItem>
|
|
363
|
-
<Divider variant="inset" />
|
|
364
|
-
<ListItemByDoc
|
|
365
|
-
doc={contacts[0]}
|
|
366
|
-
expandedAttributesProps={{ isExpandedAttributesActive: true, expandedAttributes: ['email', 'birthday'] }}
|
|
367
|
-
onClick={() => {}}
|
|
368
|
-
/>
|
|
369
|
-
<Divider variant="inset" />
|
|
370
|
-
<ListItemByDoc
|
|
371
|
-
doc={contacts[1]}
|
|
372
|
-
onClick={() => {}}
|
|
373
|
-
/>
|
|
374
|
-
<Divider variant="inset" />
|
|
375
|
-
<ListItemByDoc
|
|
376
|
-
doc={files[0]}
|
|
377
|
-
expandedAttributesProps={{ isExpandedAttributesActive: true, expandedAttributes: ['metadata.number'] }}
|
|
378
|
-
onClick={() => {}}
|
|
379
|
-
/>
|
|
380
|
-
<Divider variant="inset" />
|
|
381
|
-
<ListItemByDoc
|
|
382
|
-
doc={files[1]}
|
|
383
|
-
onClick={() => {}}
|
|
384
|
-
/>
|
|
385
|
-
<Divider variant="inset" />
|
|
386
|
-
<ListItem button>
|
|
387
|
-
<ListItemIcon>
|
|
388
|
-
<Icon icon={FiletypeTextIcon} width="32" height="32" />
|
|
389
|
-
</ListItemIcon>
|
|
390
|
-
<ListItemText primary="I'm a standard item" />
|
|
391
|
-
</ListItem>
|
|
392
|
-
</List>
|
|
393
|
-
</DemoProvider>
|
|
394
|
-
```
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import get from 'lodash/get'
|
|
2
|
+
import copy from 'copy-text-to-clipboard'
|
|
2
3
|
|
|
3
4
|
import { formatDate } from '../../Viewer/helpers'
|
|
4
5
|
|
|
@@ -67,9 +68,8 @@ export const makeDefaultExpandedAttributes = (doc, expandedAttributes) => {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
export const copyToClipboard = ({ value, setAlertProps, t }) => () => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
const hasCopied = copy(value)
|
|
72
|
+
if (hasCopied) {
|
|
73
73
|
setAlertProps({
|
|
74
74
|
open: true,
|
|
75
75
|
severity: 'success',
|
package/react/ListItem/Readme.md
CHANGED
|
@@ -97,3 +97,103 @@ const initialVariants = [{
|
|
|
97
97
|
}}
|
|
98
98
|
</Variants>
|
|
99
99
|
```
|
|
100
|
+
|
|
101
|
+
### Contextualized items
|
|
102
|
+
|
|
103
|
+
```jsx
|
|
104
|
+
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/hooks/useBreakpoints'
|
|
105
|
+
import List from 'cozy-ui/transpiled/react/List'
|
|
106
|
+
import ListItemByDoc from 'cozy-ui/transpiled/react/ListItem/ListItemByDoc'
|
|
107
|
+
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
108
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
109
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
110
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
111
|
+
import Divider from 'cozy-ui/transpiled/react/Divider'
|
|
112
|
+
import FiletypeTextIcon from 'cozy-ui/transpiled/react/Icons/FileTypeText'
|
|
113
|
+
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
114
|
+
|
|
115
|
+
const mockClient = {
|
|
116
|
+
plugins: {
|
|
117
|
+
realtime: {
|
|
118
|
+
subscribe: () => {},
|
|
119
|
+
unsubscribe: () => {},
|
|
120
|
+
unsubscribeAll: () => {}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
getStackClient: () => ({
|
|
124
|
+
uri: 'https://cozy.io/'
|
|
125
|
+
}),
|
|
126
|
+
getInstanceOptions: () => ({
|
|
127
|
+
subdomain: ''
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const contacts = [
|
|
132
|
+
{
|
|
133
|
+
_id: 'id01',
|
|
134
|
+
_type: 'io.cozy.contacts',
|
|
135
|
+
displayName: 'John Doe',
|
|
136
|
+
birthday: '25/10/2022',
|
|
137
|
+
email: [{ address: 'johndoe@cozy.cc', primary: true }],
|
|
138
|
+
phone: [{ number: '0102030405', primary: true }]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
_id: 'id02',
|
|
142
|
+
_type: 'io.cozy.contacts',
|
|
143
|
+
displayName: 'Jason Bourne',
|
|
144
|
+
birthday: '01/01/2020',
|
|
145
|
+
email: [{ address: 'jbourne@cozy.cc', primary: true }]
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
const files = [
|
|
150
|
+
{
|
|
151
|
+
_type: 'io.cozy.files',
|
|
152
|
+
name: 'File01.pdf',
|
|
153
|
+
metadata: {
|
|
154
|
+
number: 12345,
|
|
155
|
+
qualification: {
|
|
156
|
+
label: 'driver_license'
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
_type: 'io.cozy.files',
|
|
162
|
+
type: 'file',
|
|
163
|
+
name: 'Note01.cozy-note',
|
|
164
|
+
metadata: {
|
|
165
|
+
title: 'note title',
|
|
166
|
+
version: 0
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
;
|
|
172
|
+
|
|
173
|
+
<DemoProvider client={mockClient}>
|
|
174
|
+
<List>
|
|
175
|
+
<ListItemByDoc
|
|
176
|
+
doc={contacts[0]}
|
|
177
|
+
expandedAttributesProps={{
|
|
178
|
+
isExpandedAttributesActive: true,
|
|
179
|
+
expandedAttributes: ['email', 'birthday']
|
|
180
|
+
}}
|
|
181
|
+
onClick={() => {}}
|
|
182
|
+
/>
|
|
183
|
+
<Divider variant="inset" />
|
|
184
|
+
<ListItemByDoc
|
|
185
|
+
doc={files[0]}
|
|
186
|
+
expandedAttributesProps={{
|
|
187
|
+
isExpandedAttributesActive: true,
|
|
188
|
+
expandedAttributes: ['metadata.number']
|
|
189
|
+
}}
|
|
190
|
+
onClick={() => {}}
|
|
191
|
+
/>
|
|
192
|
+
<Divider variant="inset" />
|
|
193
|
+
<ListItemByDoc
|
|
194
|
+
doc={files[1]}
|
|
195
|
+
onClick={() => {}}
|
|
196
|
+
/>
|
|
197
|
+
</List>
|
|
198
|
+
</DemoProvider>
|
|
199
|
+
```
|
|
@@ -153,7 +153,7 @@ exports[`SquareAppIcon component should render correctly an app in add state 1`]
|
|
|
153
153
|
data-testid="square-app-icon"
|
|
154
154
|
>
|
|
155
155
|
<div
|
|
156
|
-
class=""
|
|
156
|
+
class="CozyTheme--normal"
|
|
157
157
|
>
|
|
158
158
|
<span
|
|
159
159
|
class="MuiBadge-root-195"
|
|
@@ -268,7 +268,7 @@ exports[`SquareAppIcon component should render correctly an app in ghost state 1
|
|
|
268
268
|
data-testid="square-app-icon"
|
|
269
269
|
>
|
|
270
270
|
<div
|
|
271
|
-
class=""
|
|
271
|
+
class="CozyTheme--normal"
|
|
272
272
|
>
|
|
273
273
|
<span
|
|
274
274
|
class="MuiBadge-root-133"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
+
import copy from 'copy-text-to-clipboard'
|
|
3
4
|
|
|
4
5
|
import { useAppLinkWithStoreFallback, useClient } from 'cozy-client'
|
|
5
6
|
|
|
@@ -40,10 +41,10 @@ const ActionMenuWrapper = forwardRef(({ onClose, file, optionFile }, ref) => {
|
|
|
40
41
|
const isAppLinkLoaded = fetchStatus === 'loaded'
|
|
41
42
|
|
|
42
43
|
const handleCopy = () => {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
const hasCopied = copy(value)
|
|
45
|
+
if (hasCopied) {
|
|
45
46
|
showViewerSnackbar(
|
|
46
|
-
'
|
|
47
|
+
'success',
|
|
47
48
|
t(`Viewer.snackbar.copiedToClipboard.success`)
|
|
48
49
|
)
|
|
49
50
|
} else {
|
|
@@ -4,6 +4,8 @@ jest.mock('cozy-harvest-lib/dist/components/KonnectorBlock', () => jest.fn())
|
|
|
4
4
|
const block1Component = jest.fn()
|
|
5
5
|
const block2Component = jest.fn()
|
|
6
6
|
|
|
7
|
+
jest.mock('copy-text-to-clipboard', () => ({ copy: jest.fn() }))
|
|
8
|
+
|
|
7
9
|
describe('getPanelBlocks', () => {
|
|
8
10
|
it('should return only blocks with truthy condition', () => {
|
|
9
11
|
// with two truthy component
|