cozy-ui 89.0.0 → 90.0.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 +21 -0
- package/package.json +4 -4
- package/react/ButtonBase/Readme.md +1 -0
- package/react/ButtonBase/index.js +3 -0
- package/react/List/Readme.md +14 -2
- package/react/ListItem/ListItemFile/ItemIcon.jsx +3 -1
- package/react/QualificationGrid/Readme.md +25 -0
- package/react/QualificationGrid/helpers.js +7 -0
- package/react/QualificationGrid/index.jsx +88 -0
- package/react/QualificationGrid/locales/en.json +15 -0
- package/react/QualificationGrid/locales/fr.json +15 -0
- package/react/QualificationGrid/locales/withLocales.jsx +11 -0
- package/react/QualificationItem/Readme.md +8 -0
- package/react/QualificationItem/index.jsx +64 -0
- package/react/index.js +3 -0
- package/transpiled/react/ButtonBase/index.js +2 -0
- package/transpiled/react/ListItem/ListItemFile/ItemIcon.js +3 -1
- package/transpiled/react/QualificationGrid/helpers.js +7 -0
- package/transpiled/react/QualificationGrid/index.js +97 -0
- package/transpiled/react/QualificationGrid/locales/withLocales.js +36 -0
- package/transpiled/react/QualificationItem/index.js +63 -0
- package/transpiled/react/index.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [90.0.0](https://github.com/cozy/cozy-ui/compare/v89.1.0...v90.0.0) (2023-07-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add ButtonBase component ([9e77485](https://github.com/cozy/cozy-ui/commit/9e77485))
|
|
7
|
+
* Add QualificationGrid and QualificationItem components ([b773099](https://github.com/cozy/cozy-ui/commit/b773099))
|
|
8
|
+
* Upgrade cozy-client from 35.2.0 to 38.11.1 ([d59b93b](https://github.com/cozy/cozy-ui/commit/d59b93b))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### BREAKING CHANGES
|
|
12
|
+
|
|
13
|
+
* you must have `cozy-client >= 38.11.1`
|
|
14
|
+
|
|
15
|
+
# [89.1.0](https://github.com/cozy/cozy-ui/compare/v89.0.0...v89.1.0) (2023-07-18)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **ListItemFile:** Show correct icon for notes ([ab03f13](https://github.com/cozy/cozy-ui/commit/ab03f13))
|
|
21
|
+
|
|
1
22
|
# [89.0.0](https://github.com/cozy/cozy-ui/compare/v88.6.0...v89.0.0) (2023-07-13)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "90.0.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -91,14 +91,14 @@
|
|
|
91
91
|
"babel-preset-cozy-app": "2.0.2",
|
|
92
92
|
"browserslist-config-cozy": "0.4.0",
|
|
93
93
|
"copyfiles": "2.4.1",
|
|
94
|
-
"cozy-client": "^
|
|
94
|
+
"cozy-client": "^38.11.1",
|
|
95
95
|
"cozy-device-helper": "2.0.0",
|
|
96
96
|
"cozy-flags": "^2.10.1",
|
|
97
97
|
"cozy-harvest-lib": "^6.7.3",
|
|
98
98
|
"cozy-intent": "1.16.1",
|
|
99
99
|
"cozy-logger": "^1.9.0",
|
|
100
100
|
"cozy-sharing": "^3.10.0",
|
|
101
|
-
"cozy-stack-client": "^
|
|
101
|
+
"cozy-stack-client": "^38.9.2",
|
|
102
102
|
"css-loader": "0.28.11",
|
|
103
103
|
"cssnano": "4.1.11",
|
|
104
104
|
"cssnano-preset-advanced": "4.0.8",
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
"rooks": "^5.11.2"
|
|
182
182
|
},
|
|
183
183
|
"peerDependencies": {
|
|
184
|
-
"cozy-client": ">=
|
|
184
|
+
"cozy-client": ">=38.11.1",
|
|
185
185
|
"cozy-device-helper": "^2.0.0",
|
|
186
186
|
"cozy-harvest-lib": "^6.7.3",
|
|
187
187
|
"cozy-intent": ">=1.3.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Re-export of @material-ui. See [the official API](https://v4.mui.com/api/button-base/).
|
package/react/List/Readme.md
CHANGED
|
@@ -285,8 +285,6 @@ import FiletypeTextIcon from 'cozy-ui/transpiled/react/Icons/FileTypeText'
|
|
|
285
285
|
```jsx
|
|
286
286
|
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/hooks/useBreakpoints'
|
|
287
287
|
import List from 'cozy-ui/transpiled/react/List'
|
|
288
|
-
import ListItemContact from 'cozy-ui/transpiled/react/ListItem/ListItemContact'
|
|
289
|
-
import ListItemFile from 'cozy-ui/transpiled/react/ListItem/ListItemFile'
|
|
290
288
|
import ListItemByDoc from 'cozy-ui/transpiled/react/ListItem/ListItemByDoc'
|
|
291
289
|
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
292
290
|
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
@@ -340,6 +338,15 @@ const files = [
|
|
|
340
338
|
label: 'driver_license'
|
|
341
339
|
}
|
|
342
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
|
+
}
|
|
343
350
|
}
|
|
344
351
|
]
|
|
345
352
|
|
|
@@ -371,6 +378,11 @@ const files = [
|
|
|
371
378
|
onClick={() => {}}
|
|
372
379
|
/>
|
|
373
380
|
<Divider variant="inset" />
|
|
381
|
+
<ListItemByDoc
|
|
382
|
+
doc={files[1]}
|
|
383
|
+
onClick={() => {}}
|
|
384
|
+
/>
|
|
385
|
+
<Divider variant="inset" />
|
|
374
386
|
<ListItem button>
|
|
375
387
|
<ListItemIcon>
|
|
376
388
|
<Icon icon={FiletypeTextIcon} width="32" height="32" />
|
|
@@ -2,9 +2,11 @@ import React from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
4
|
import { useClient } from 'cozy-client'
|
|
5
|
+
import { isNote } from 'cozy-client/dist/models/file'
|
|
5
6
|
|
|
6
7
|
import Icon from '../../Icon'
|
|
7
8
|
import FiletypeTextIcon from '../../Icons/FileTypeText'
|
|
9
|
+
import FiletypeNoteIcon from '../../Icons/FileTypeNote'
|
|
8
10
|
import FileImageLoader from '../../FileImageLoader'
|
|
9
11
|
import Thumbnail from '../../Thumbnail'
|
|
10
12
|
import Skeleton from '../../Skeleton'
|
|
@@ -32,7 +34,7 @@ const ItemIcon = ({ icon, file }) => {
|
|
|
32
34
|
}}
|
|
33
35
|
renderFallback={() => (
|
|
34
36
|
<Thumbnail>
|
|
35
|
-
<Icon icon={FiletypeTextIcon} />
|
|
37
|
+
<Icon icon={isNote(file) ? FiletypeNoteIcon : FiletypeTextIcon} />
|
|
36
38
|
</Thumbnail>
|
|
37
39
|
)}
|
|
38
40
|
/>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
```jsx
|
|
2
|
+
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
3
|
+
import QualificationGrid from 'cozy-ui/transpiled/react/QualificationGrid'
|
|
4
|
+
import Variants from 'cozy-ui/docs/components/Variants'
|
|
5
|
+
|
|
6
|
+
const initialVariants = [{ noUndefined: false, noOthers: false }]
|
|
7
|
+
initialState = { selectedQualification: undefined }
|
|
8
|
+
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
<DemoProvider>
|
|
12
|
+
<Variants initialVariants={initialVariants} screenshotAllVariants>
|
|
13
|
+
{variant => (
|
|
14
|
+
<>
|
|
15
|
+
<div className="u-mb-1">Selected qualification: {state.selectedQualification}</div>
|
|
16
|
+
<QualificationGrid
|
|
17
|
+
noUndefined={variant.noUndefined}
|
|
18
|
+
noOthers={variant.noOthers}
|
|
19
|
+
onClick={qualification => setState({ selectedQualification: qualification })}
|
|
20
|
+
/>
|
|
21
|
+
</>
|
|
22
|
+
)}
|
|
23
|
+
</Variants>
|
|
24
|
+
</DemoProvider>
|
|
25
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { Fragment, useState } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import Grid from '../Grid'
|
|
5
|
+
import QualificationItem from '../QualificationItem'
|
|
6
|
+
import { useI18n } from '../I18n'
|
|
7
|
+
import PeopleIcon from '../Icons/People'
|
|
8
|
+
import TeamIcon from '../Icons/Team'
|
|
9
|
+
import CompanyIcon from '../Icons/Company'
|
|
10
|
+
import HeartIcon from '../Icons/Heart'
|
|
11
|
+
import HomeIcon from '../Icons/Home'
|
|
12
|
+
import CarIcon from '../Icons/Car'
|
|
13
|
+
import CompassIcon from '../Icons/Compass'
|
|
14
|
+
import BankIcon from '../Icons/Bank'
|
|
15
|
+
import BillIcon from '../Icons/Bill'
|
|
16
|
+
import DotsIcon from '../Icons/Dots'
|
|
17
|
+
|
|
18
|
+
import withLocales from './locales/withLocales'
|
|
19
|
+
import { getThemesList } from './helpers'
|
|
20
|
+
|
|
21
|
+
const IconByName = {
|
|
22
|
+
people: PeopleIcon,
|
|
23
|
+
team: TeamIcon,
|
|
24
|
+
company: CompanyIcon,
|
|
25
|
+
heart: HeartIcon,
|
|
26
|
+
home: HomeIcon,
|
|
27
|
+
car: CarIcon,
|
|
28
|
+
compass: CompassIcon,
|
|
29
|
+
bank: BankIcon,
|
|
30
|
+
bill: BillIcon,
|
|
31
|
+
dots: DotsIcon
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const QualificationGrid = ({ noUndefined, noOthers, onClick }) => {
|
|
35
|
+
const themesList = getThemesList()
|
|
36
|
+
const { t } = useI18n()
|
|
37
|
+
const [selectedQualification, setSelectedQualification] = useState()
|
|
38
|
+
|
|
39
|
+
const handleClick = theme => {
|
|
40
|
+
onClick(theme?.label)
|
|
41
|
+
setSelectedQualification(theme?.label)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Grid container spacing={1}>
|
|
46
|
+
{!noUndefined && (
|
|
47
|
+
<Grid item xs={3} sm={2}>
|
|
48
|
+
<QualificationItem
|
|
49
|
+
label={t('themes.undefined')}
|
|
50
|
+
isSelected={selectedQualification === undefined}
|
|
51
|
+
onClick={() => handleClick()}
|
|
52
|
+
/>
|
|
53
|
+
</Grid>
|
|
54
|
+
)}
|
|
55
|
+
{themesList.map((theme, index) => (
|
|
56
|
+
<Fragment key={index}>
|
|
57
|
+
{(!noOthers || theme.label !== 'others') && (
|
|
58
|
+
<Grid item xs={3} sm={2}>
|
|
59
|
+
<QualificationItem
|
|
60
|
+
label={t(`themes.${theme.label}`)}
|
|
61
|
+
icon={IconByName[theme.icon]}
|
|
62
|
+
isSelected={theme.label === selectedQualification}
|
|
63
|
+
onClick={() => handleClick(theme)}
|
|
64
|
+
/>
|
|
65
|
+
</Grid>
|
|
66
|
+
)}
|
|
67
|
+
</Fragment>
|
|
68
|
+
))}
|
|
69
|
+
</Grid>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
QualificationGrid.defaultProps = {
|
|
74
|
+
noUndefined: false,
|
|
75
|
+
noOthers: false,
|
|
76
|
+
onClick: () => {}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
QualificationGrid.propTypes = {
|
|
80
|
+
/** Remove `undefined` theme */
|
|
81
|
+
noUndefined: PropTypes.bool,
|
|
82
|
+
/** Remove `others` theme */
|
|
83
|
+
noOthers: PropTypes.bool,
|
|
84
|
+
/** Triggered when an item is clicked */
|
|
85
|
+
onClick: PropTypes.func
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default withLocales(QualificationGrid)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"themes": {
|
|
3
|
+
"activity": "Activity",
|
|
4
|
+
"family": "Family",
|
|
5
|
+
"finance": "Finance",
|
|
6
|
+
"health": "Health",
|
|
7
|
+
"home": "Home",
|
|
8
|
+
"identity": "Identity",
|
|
9
|
+
"invoice": "Invoice",
|
|
10
|
+
"others": "Others",
|
|
11
|
+
"transport": "Transport",
|
|
12
|
+
"undefined": "Undefined",
|
|
13
|
+
"work_study": "Work"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"themes": {
|
|
3
|
+
"activity": "Loisirs",
|
|
4
|
+
"family": "Famille",
|
|
5
|
+
"finance": "Finances",
|
|
6
|
+
"health": "Santé",
|
|
7
|
+
"home": "Logement",
|
|
8
|
+
"identity": "Identité",
|
|
9
|
+
"invoice": "Factures",
|
|
10
|
+
"others": "Autres",
|
|
11
|
+
"transport": "Transport",
|
|
12
|
+
"undefined": "Indéfini",
|
|
13
|
+
"work_study": "Travail"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import ButtonBase from '../ButtonBase'
|
|
5
|
+
import Icon, { iconPropType } from '../Icon'
|
|
6
|
+
import FileDuotoneIcon from '../Icons/FileDuotone'
|
|
7
|
+
import IconStack from '../IconStack'
|
|
8
|
+
import Typography from '../Typography'
|
|
9
|
+
import { makeStyles } from '../styles'
|
|
10
|
+
|
|
11
|
+
const useStyles = makeStyles({
|
|
12
|
+
item: {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
width: '100%',
|
|
16
|
+
height: 84,
|
|
17
|
+
marginBottom: 8,
|
|
18
|
+
borderRadius: 4,
|
|
19
|
+
borderColor: ({ isSelected }) =>
|
|
20
|
+
isSelected ? 'var(--primaryColor)' : 'var(--borderMainColor)',
|
|
21
|
+
border: '1px solid'
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const QualificationItem = ({ icon, label, isSelected, onClick, ...props }) => {
|
|
26
|
+
const styles = useStyles({ isSelected })
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ButtonBase {...props} className={styles.item} onClick={onClick}>
|
|
30
|
+
<IconStack
|
|
31
|
+
className="u-mb-half"
|
|
32
|
+
foreground={
|
|
33
|
+
icon && (
|
|
34
|
+
<Icon
|
|
35
|
+
icon={icon}
|
|
36
|
+
color={
|
|
37
|
+
isSelected ? 'var(--primaryColor)' : 'var(--secondaryTextColor)'
|
|
38
|
+
}
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
background={
|
|
43
|
+
<Icon
|
|
44
|
+
icon={FileDuotoneIcon}
|
|
45
|
+
size="32"
|
|
46
|
+
color={
|
|
47
|
+
isSelected ? 'var(--primaryColor)' : 'var(--secondaryTextColor)'
|
|
48
|
+
}
|
|
49
|
+
/>
|
|
50
|
+
}
|
|
51
|
+
/>
|
|
52
|
+
<Typography variant="caption">{label}</Typography>
|
|
53
|
+
</ButtonBase>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
QualificationItem.propTypes = {
|
|
58
|
+
icon: PropTypes.oneOfType([PropTypes.node, iconPropType]),
|
|
59
|
+
label: PropTypes.string,
|
|
60
|
+
isSelected: PropTypes.bool,
|
|
61
|
+
onClick: PropTypes.func
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default QualificationItem
|
package/react/index.js
CHANGED
|
@@ -121,3 +121,6 @@ export { default as InputAdornment } from './InputAdornment'
|
|
|
121
121
|
export { default as InputBase } from './InputBase'
|
|
122
122
|
export { default as SearchBar } from './SearchBar'
|
|
123
123
|
export { default as Thumbnail } from './Thumbnail'
|
|
124
|
+
export { default as ButtonBase } from './ButtonBase'
|
|
125
|
+
export { default as QualificationGrid } from './QualificationGrid'
|
|
126
|
+
export { default as QualificationItem } from './QualificationItem'
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useClient } from 'cozy-client';
|
|
4
|
+
import { isNote } from 'cozy-client/dist/models/file';
|
|
4
5
|
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
5
6
|
import FiletypeTextIcon from "cozy-ui/transpiled/react/Icons/FileTypeText";
|
|
7
|
+
import FiletypeNoteIcon from "cozy-ui/transpiled/react/Icons/FileTypeNote";
|
|
6
8
|
import FileImageLoader from "cozy-ui/transpiled/react/FileImageLoader";
|
|
7
9
|
import Thumbnail from "cozy-ui/transpiled/react/Thumbnail";
|
|
8
10
|
import Skeleton from "cozy-ui/transpiled/react/Skeleton";
|
|
@@ -27,7 +29,7 @@ var ItemIcon = function ItemIcon(_ref) {
|
|
|
27
29
|
},
|
|
28
30
|
renderFallback: function renderFallback() {
|
|
29
31
|
return /*#__PURE__*/React.createElement(Thumbnail, null, /*#__PURE__*/React.createElement(Icon, {
|
|
30
|
-
icon: FiletypeTextIcon
|
|
32
|
+
icon: isNote(file) ? FiletypeNoteIcon : FiletypeTextIcon
|
|
31
33
|
}));
|
|
32
34
|
}
|
|
33
35
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { themesList } from 'cozy-client/dist/models/document/documentTypeData';
|
|
2
|
+
import flag from 'cozy-flags';
|
|
3
|
+
export var getThemesList = function getThemesList() {
|
|
4
|
+
return flag('hide.healthTheme.enabled') ? themesList.filter(function (theme) {
|
|
5
|
+
return theme.label !== 'health';
|
|
6
|
+
}) : themesList;
|
|
7
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { Fragment, useState } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import Grid from "cozy-ui/transpiled/react/Grid";
|
|
5
|
+
import QualificationItem from "cozy-ui/transpiled/react/QualificationItem";
|
|
6
|
+
import { useI18n } from "cozy-ui/transpiled/react/I18n";
|
|
7
|
+
import PeopleIcon from "cozy-ui/transpiled/react/Icons/People";
|
|
8
|
+
import TeamIcon from "cozy-ui/transpiled/react/Icons/Team";
|
|
9
|
+
import CompanyIcon from "cozy-ui/transpiled/react/Icons/Company";
|
|
10
|
+
import HeartIcon from "cozy-ui/transpiled/react/Icons/Heart";
|
|
11
|
+
import HomeIcon from "cozy-ui/transpiled/react/Icons/Home";
|
|
12
|
+
import CarIcon from "cozy-ui/transpiled/react/Icons/Car";
|
|
13
|
+
import CompassIcon from "cozy-ui/transpiled/react/Icons/Compass";
|
|
14
|
+
import BankIcon from "cozy-ui/transpiled/react/Icons/Bank";
|
|
15
|
+
import BillIcon from "cozy-ui/transpiled/react/Icons/Bill";
|
|
16
|
+
import DotsIcon from "cozy-ui/transpiled/react/Icons/Dots";
|
|
17
|
+
import withLocales from "cozy-ui/transpiled/react/QualificationGrid/locales/withLocales";
|
|
18
|
+
import { getThemesList } from "cozy-ui/transpiled/react/QualificationGrid/helpers";
|
|
19
|
+
var IconByName = {
|
|
20
|
+
people: PeopleIcon,
|
|
21
|
+
team: TeamIcon,
|
|
22
|
+
company: CompanyIcon,
|
|
23
|
+
heart: HeartIcon,
|
|
24
|
+
home: HomeIcon,
|
|
25
|
+
car: CarIcon,
|
|
26
|
+
compass: CompassIcon,
|
|
27
|
+
bank: BankIcon,
|
|
28
|
+
bill: BillIcon,
|
|
29
|
+
dots: DotsIcon
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var QualificationGrid = function QualificationGrid(_ref) {
|
|
33
|
+
var noUndefined = _ref.noUndefined,
|
|
34
|
+
noOthers = _ref.noOthers,
|
|
35
|
+
onClick = _ref.onClick;
|
|
36
|
+
var themesList = getThemesList();
|
|
37
|
+
|
|
38
|
+
var _useI18n = useI18n(),
|
|
39
|
+
t = _useI18n.t;
|
|
40
|
+
|
|
41
|
+
var _useState = useState(),
|
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
+
selectedQualification = _useState2[0],
|
|
44
|
+
setSelectedQualification = _useState2[1];
|
|
45
|
+
|
|
46
|
+
var handleClick = function handleClick(theme) {
|
|
47
|
+
onClick(theme === null || theme === void 0 ? void 0 : theme.label);
|
|
48
|
+
setSelectedQualification(theme === null || theme === void 0 ? void 0 : theme.label);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
52
|
+
container: true,
|
|
53
|
+
spacing: 1
|
|
54
|
+
}, !noUndefined && /*#__PURE__*/React.createElement(Grid, {
|
|
55
|
+
item: true,
|
|
56
|
+
xs: 3,
|
|
57
|
+
sm: 2
|
|
58
|
+
}, /*#__PURE__*/React.createElement(QualificationItem, {
|
|
59
|
+
label: t('themes.undefined'),
|
|
60
|
+
isSelected: selectedQualification === undefined,
|
|
61
|
+
onClick: function onClick() {
|
|
62
|
+
return handleClick();
|
|
63
|
+
}
|
|
64
|
+
})), themesList.map(function (theme, index) {
|
|
65
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
66
|
+
key: index
|
|
67
|
+
}, (!noOthers || theme.label !== 'others') && /*#__PURE__*/React.createElement(Grid, {
|
|
68
|
+
item: true,
|
|
69
|
+
xs: 3,
|
|
70
|
+
sm: 2
|
|
71
|
+
}, /*#__PURE__*/React.createElement(QualificationItem, {
|
|
72
|
+
label: t("themes.".concat(theme.label)),
|
|
73
|
+
icon: IconByName[theme.icon],
|
|
74
|
+
isSelected: theme.label === selectedQualification,
|
|
75
|
+
onClick: function onClick() {
|
|
76
|
+
return handleClick(theme);
|
|
77
|
+
}
|
|
78
|
+
})));
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
QualificationGrid.defaultProps = {
|
|
83
|
+
noUndefined: false,
|
|
84
|
+
noOthers: false,
|
|
85
|
+
onClick: function onClick() {}
|
|
86
|
+
};
|
|
87
|
+
QualificationGrid.propTypes = {
|
|
88
|
+
/** Remove `undefined` theme */
|
|
89
|
+
noUndefined: PropTypes.bool,
|
|
90
|
+
|
|
91
|
+
/** Remove `others` theme */
|
|
92
|
+
noOthers: PropTypes.bool,
|
|
93
|
+
|
|
94
|
+
/** Triggered when an item is clicked */
|
|
95
|
+
onClick: PropTypes.func
|
|
96
|
+
};
|
|
97
|
+
export default withLocales(QualificationGrid);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import withOnlyLocales from "cozy-ui/transpiled/react/I18n/withOnlyLocales";
|
|
2
|
+
var en = {
|
|
3
|
+
themes: {
|
|
4
|
+
activity: "Activity",
|
|
5
|
+
family: "Family",
|
|
6
|
+
finance: "Finance",
|
|
7
|
+
health: "Health",
|
|
8
|
+
home: "Home",
|
|
9
|
+
identity: "Identity",
|
|
10
|
+
invoice: "Invoice",
|
|
11
|
+
others: "Others",
|
|
12
|
+
transport: "Transport",
|
|
13
|
+
undefined: "Undefined",
|
|
14
|
+
work_study: "Work"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var fr = {
|
|
18
|
+
themes: {
|
|
19
|
+
activity: "Loisirs",
|
|
20
|
+
family: "Famille",
|
|
21
|
+
finance: "Finances",
|
|
22
|
+
health: "Sant\xE9",
|
|
23
|
+
home: "Logement",
|
|
24
|
+
identity: "Identit\xE9",
|
|
25
|
+
invoice: "Factures",
|
|
26
|
+
others: "Autres",
|
|
27
|
+
transport: "Transport",
|
|
28
|
+
undefined: "Ind\xE9fini",
|
|
29
|
+
work_study: "Travail"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export var locales = {
|
|
33
|
+
en: en,
|
|
34
|
+
fr: fr
|
|
35
|
+
};
|
|
36
|
+
export default withOnlyLocales(locales);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["icon", "label", "isSelected", "onClick"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import ButtonBase from "cozy-ui/transpiled/react/ButtonBase";
|
|
7
|
+
import Icon, { iconPropType } from "cozy-ui/transpiled/react/Icon";
|
|
8
|
+
import FileDuotoneIcon from "cozy-ui/transpiled/react/Icons/FileDuotone";
|
|
9
|
+
import IconStack from "cozy-ui/transpiled/react/IconStack";
|
|
10
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
11
|
+
import { makeStyles } from "cozy-ui/transpiled/react/styles";
|
|
12
|
+
var useStyles = makeStyles({
|
|
13
|
+
item: {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
flexDirection: 'column',
|
|
16
|
+
width: '100%',
|
|
17
|
+
height: 84,
|
|
18
|
+
marginBottom: 8,
|
|
19
|
+
borderRadius: 4,
|
|
20
|
+
borderColor: function borderColor(_ref) {
|
|
21
|
+
var isSelected = _ref.isSelected;
|
|
22
|
+
return isSelected ? 'var(--primaryColor)' : 'var(--borderMainColor)';
|
|
23
|
+
},
|
|
24
|
+
border: '1px solid'
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
var QualificationItem = function QualificationItem(_ref2) {
|
|
29
|
+
var icon = _ref2.icon,
|
|
30
|
+
label = _ref2.label,
|
|
31
|
+
isSelected = _ref2.isSelected,
|
|
32
|
+
onClick = _ref2.onClick,
|
|
33
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
34
|
+
|
|
35
|
+
var styles = useStyles({
|
|
36
|
+
isSelected: isSelected
|
|
37
|
+
});
|
|
38
|
+
return /*#__PURE__*/React.createElement(ButtonBase, _extends({}, props, {
|
|
39
|
+
className: styles.item,
|
|
40
|
+
onClick: onClick
|
|
41
|
+
}), /*#__PURE__*/React.createElement(IconStack, {
|
|
42
|
+
className: "u-mb-half",
|
|
43
|
+
foreground: icon && /*#__PURE__*/React.createElement(Icon, {
|
|
44
|
+
icon: icon,
|
|
45
|
+
color: isSelected ? 'var(--primaryColor)' : 'var(--secondaryTextColor)'
|
|
46
|
+
}),
|
|
47
|
+
background: /*#__PURE__*/React.createElement(Icon, {
|
|
48
|
+
icon: FileDuotoneIcon,
|
|
49
|
+
size: "32",
|
|
50
|
+
color: isSelected ? 'var(--primaryColor)' : 'var(--secondaryTextColor)'
|
|
51
|
+
})
|
|
52
|
+
}), /*#__PURE__*/React.createElement(Typography, {
|
|
53
|
+
variant: "caption"
|
|
54
|
+
}, label));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
QualificationItem.propTypes = {
|
|
58
|
+
icon: PropTypes.oneOfType([PropTypes.node, iconPropType]),
|
|
59
|
+
label: PropTypes.string,
|
|
60
|
+
isSelected: PropTypes.bool,
|
|
61
|
+
onClick: PropTypes.func
|
|
62
|
+
};
|
|
63
|
+
export default QualificationItem;
|
|
@@ -94,4 +94,7 @@ export { default as Skeleton } from './Skeleton';
|
|
|
94
94
|
export { default as InputAdornment } from './InputAdornment';
|
|
95
95
|
export { default as InputBase } from './InputBase';
|
|
96
96
|
export { default as SearchBar } from './SearchBar';
|
|
97
|
-
export { default as Thumbnail } from './Thumbnail';
|
|
97
|
+
export { default as Thumbnail } from './Thumbnail';
|
|
98
|
+
export { default as ButtonBase } from './ButtonBase';
|
|
99
|
+
export { default as QualificationGrid } from './QualificationGrid';
|
|
100
|
+
export { default as QualificationItem } from './QualificationItem';
|