cozy-ui 146.3.0 → 146.5.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 +22 -0
- package/package.json +1 -1
- package/react/ColorList/Readme.md +2 -0
- package/react/ColorList/index.jsx +19 -4
- package/react/ColorList/index.spec.jsx +56 -0
- package/react/EditBadge/Readme.md +1 -0
- package/react/EditBadge/index.jsx +12 -2
- package/react/MemberAutocomplete/MemberAutocomplete.spec.jsx +24 -0
- package/react/MemberAutocomplete/index.jsx +3 -2
- package/react/MemberAutocomplete/useMemberInput.js +5 -1
- package/react/MuiCozyTheme/makeTheme.jsx +12 -1
- package/transpiled/react/ColorList/index.d.ts +6 -1
- package/transpiled/react/ColorList/index.js +23 -8
- package/transpiled/react/ColorList/index.spec.d.ts +1 -0
- package/transpiled/react/EditBadge/index.d.ts +6 -1
- package/transpiled/react/EditBadge/index.js +13 -5
- package/transpiled/react/MemberAutocomplete/index.js +3 -2
- package/transpiled/react/MemberAutocomplete/useMemberInput.d.ts +1 -0
- package/transpiled/react/MemberAutocomplete/useMemberInput.js +4 -1
- package/transpiled/react/MuiCozyTheme/makeTheme.js +15 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# [146.5.0](https://github.com/cozy/cozy-ui/compare/v146.4.0...v146.5.0) (2026-11-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **ColorList:** Name the colors ([886abac](https://github.com/cozy/cozy-ui/commit/886abac))
|
|
7
|
+
|
|
8
|
+
# [146.4.0](https://github.com/cozy/cozy-ui/compare/v146.3.1...v146.4.0) (2026-11-04)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **EditBadge:** Add componentsProps to customize the badge button ([8248bc7](https://github.com/cozy/cozy-ui/commit/8248bc7))
|
|
14
|
+
|
|
15
|
+
## [146.3.1](https://github.com/cozy/cozy-ui/compare/v146.3.0...v146.3.1) (2026-11-03)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **MemberAutocomplete:** Enable Send only for a text giving members ([6ffaeb0](https://github.com/cozy/cozy-ui/commit/6ffaeb0))
|
|
21
|
+
* **MuiCozyTheme:** Stop the CircularProgress animation in screenshots ([d5025ad](https://github.com/cozy/cozy-ui/commit/d5025ad))
|
|
22
|
+
|
|
1
23
|
# [146.3.0](https://github.com/cozy/cozy-ui/compare/v146.2.2...v146.3.0) (2026-11-03)
|
|
2
24
|
|
|
3
25
|
|
package/package.json
CHANGED
|
@@ -15,8 +15,10 @@ const ColorPickerDemo = ({ variant }) => {
|
|
|
15
15
|
<div style={{ width: (variant.medium || isMobile) ? '100%' : 200 }}>
|
|
16
16
|
<ColorList
|
|
17
17
|
size={variant.medium ? 'medium' : undefined}
|
|
18
|
+
getColorLabel={color => `Color ${color}`}
|
|
18
19
|
customColorProps={{
|
|
19
20
|
enabled: true,
|
|
21
|
+
'aria-label': 'Custom color',
|
|
20
22
|
onClick: () => {}
|
|
21
23
|
}}
|
|
22
24
|
selectedColor={selectedColor}
|
|
@@ -15,7 +15,15 @@ const sizeToPx = {
|
|
|
15
15
|
medium: 41
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const ColorList = ({
|
|
18
|
+
const ColorList = ({
|
|
19
|
+
size,
|
|
20
|
+
selectedColor,
|
|
21
|
+
getColorLabel,
|
|
22
|
+
customColorProps,
|
|
23
|
+
onClick
|
|
24
|
+
}) => {
|
|
25
|
+
const { enabled: isCustomEnabled, ...customButtonProps } =
|
|
26
|
+
customColorProps ?? {}
|
|
19
27
|
const { isMobile } = useBreakpoints()
|
|
20
28
|
|
|
21
29
|
const _size = size || (isMobile ? 'medium' : 'small')
|
|
@@ -37,6 +45,8 @@ const ColorList = ({ size, selectedColor, customColorProps, onClick }) => {
|
|
|
37
45
|
<ButtonBase
|
|
38
46
|
className="u-bdrs-circle"
|
|
39
47
|
component="div"
|
|
48
|
+
aria-label={getColorLabel?.(color) ?? color}
|
|
49
|
+
aria-pressed={selectedColor?.toUpperCase() === color}
|
|
40
50
|
onClick={() => onClick?.(color)}
|
|
41
51
|
>
|
|
42
52
|
<Avatar color={color} size={avatarSize}>
|
|
@@ -49,12 +59,13 @@ const ColorList = ({ size, selectedColor, customColorProps, onClick }) => {
|
|
|
49
59
|
</ButtonBase>
|
|
50
60
|
</ImageListItem>
|
|
51
61
|
))}
|
|
52
|
-
{
|
|
62
|
+
{isCustomEnabled && (
|
|
53
63
|
<ImageListItem
|
|
54
64
|
className="u-ta-center"
|
|
55
65
|
classes={{ item: 'u-ov-visible' }}
|
|
56
66
|
>
|
|
57
67
|
<Button
|
|
68
|
+
{...customButtonProps}
|
|
58
69
|
className="u-miw-auto u-mih-auto u-p-0 u-bdrs-circle"
|
|
59
70
|
variant="ghost"
|
|
60
71
|
style={{
|
|
@@ -68,7 +79,6 @@ const ColorList = ({ size, selectedColor, customColorProps, onClick }) => {
|
|
|
68
79
|
}}
|
|
69
80
|
classes={{ label: 'u-flex u-w-auto' }}
|
|
70
81
|
label={<Icon icon={Palette} size={iconSize} color="#000" />}
|
|
71
|
-
onClick={ev => customColorProps?.onClick(ev)}
|
|
72
82
|
/>
|
|
73
83
|
</ImageListItem>
|
|
74
84
|
)}
|
|
@@ -79,9 +89,14 @@ const ColorList = ({ size, selectedColor, customColorProps, onClick }) => {
|
|
|
79
89
|
ColorList.propTypes = {
|
|
80
90
|
size: propTypes.oneOf(['small', 'medium']),
|
|
81
91
|
selectedColor: propTypes.string,
|
|
92
|
+
/** Accessible name of a color. Defaults to its hexadecimal code */
|
|
93
|
+
getColorLabel: propTypes.func,
|
|
82
94
|
customColorProps: propTypes.shape({
|
|
83
95
|
enabled: propTypes.bool,
|
|
84
|
-
onClick: propTypes.func
|
|
96
|
+
onClick: propTypes.func,
|
|
97
|
+
'aria-label': propTypes.string,
|
|
98
|
+
'aria-pressed': propTypes.bool,
|
|
99
|
+
'data-testid': propTypes.string
|
|
85
100
|
}),
|
|
86
101
|
onClick: propTypes.func
|
|
87
102
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import ColorList from '.'
|
|
5
|
+
import { BreakpointsProvider } from '../providers/Breakpoints'
|
|
6
|
+
|
|
7
|
+
const setup = props =>
|
|
8
|
+
render(
|
|
9
|
+
<BreakpointsProvider>
|
|
10
|
+
<ColorList {...props} />
|
|
11
|
+
</BreakpointsProvider>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
describe('ColorList', () => {
|
|
15
|
+
it('lets a keyboard reach and pick a color', () => {
|
|
16
|
+
const onClick = jest.fn()
|
|
17
|
+
setup({ onClick })
|
|
18
|
+
|
|
19
|
+
const color = screen.getByRole('button', { name: '#273891' })
|
|
20
|
+
expect(color.tabIndex).toBe(0)
|
|
21
|
+
fireEvent.keyDown(color, { key: 'Enter' })
|
|
22
|
+
expect(onClick).toHaveBeenCalledWith('#273891')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('names its colors and tells the selected one, whatever its case', () => {
|
|
26
|
+
setup({
|
|
27
|
+
selectedColor: '#7e57e3',
|
|
28
|
+
getColorLabel: color => (color === '#7E57E3' ? 'Purple' : color)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
expect(screen.getByRole('button', { name: 'Purple' })).toHaveAttribute(
|
|
32
|
+
'aria-pressed',
|
|
33
|
+
'true'
|
|
34
|
+
)
|
|
35
|
+
expect(screen.getByRole('button', { name: '#273891' })).toHaveAttribute(
|
|
36
|
+
'aria-pressed',
|
|
37
|
+
'false'
|
|
38
|
+
)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('passes its props to the custom color button', () => {
|
|
42
|
+
const onClick = jest.fn()
|
|
43
|
+
setup({
|
|
44
|
+
customColorProps: {
|
|
45
|
+
enabled: true,
|
|
46
|
+
onClick,
|
|
47
|
+
'aria-label': 'Custom color',
|
|
48
|
+
'data-testid': 'custom'
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
fireEvent.click(screen.getByRole('button', { name: 'Custom color' }))
|
|
53
|
+
expect(onClick).toHaveBeenCalledTimes(1)
|
|
54
|
+
expect(screen.queryByTestId('custom')).toBeInTheDocument()
|
|
55
|
+
})
|
|
56
|
+
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Icon, Pen } from '@linagora/twake-icons'
|
|
2
|
+
import cx from 'classnames'
|
|
2
3
|
import PropTypes from 'prop-types'
|
|
3
4
|
import React, { useState, useRef } from 'react'
|
|
4
5
|
|
|
@@ -12,6 +13,7 @@ const EditBadge = ({
|
|
|
12
13
|
onUpload,
|
|
13
14
|
onDelete,
|
|
14
15
|
anchorOrigin,
|
|
16
|
+
componentsProps,
|
|
15
17
|
children,
|
|
16
18
|
...props
|
|
17
19
|
}) => {
|
|
@@ -28,9 +30,13 @@ const EditBadge = ({
|
|
|
28
30
|
badgeContent={
|
|
29
31
|
<>
|
|
30
32
|
<Button
|
|
33
|
+
{...componentsProps?.button}
|
|
31
34
|
ref={menuAnchorRef}
|
|
32
35
|
component="div"
|
|
33
|
-
className=
|
|
36
|
+
className={cx(
|
|
37
|
+
'u-miw-auto u-w-2-half u-h-2-half u-bdrs-circle',
|
|
38
|
+
componentsProps?.button?.className
|
|
39
|
+
)}
|
|
34
40
|
classes={{ label: 'u-flex u-w-auto' }}
|
|
35
41
|
style={{
|
|
36
42
|
outline: '4px solid var(--paperBackgroundColor)'
|
|
@@ -74,7 +80,11 @@ EditBadge.defaultProps = {
|
|
|
74
80
|
EditBadge.propTypes = {
|
|
75
81
|
src: PropTypes.func.isRequired,
|
|
76
82
|
onUpload: PropTypes.func.isRequired,
|
|
77
|
-
onDelete: PropTypes.func.isRequired
|
|
83
|
+
onDelete: PropTypes.func.isRequired,
|
|
84
|
+
componentsProps: PropTypes.shape({
|
|
85
|
+
/** Props spread to the badge button */
|
|
86
|
+
button: PropTypes.object
|
|
87
|
+
})
|
|
78
88
|
}
|
|
79
89
|
|
|
80
90
|
export default EditBadge
|
|
@@ -80,4 +80,28 @@ describe('MemberAutocomplete', () => {
|
|
|
80
80
|
|
|
81
81
|
expect(input.value).toBe('bo')
|
|
82
82
|
})
|
|
83
|
+
|
|
84
|
+
it('enables Send only for a typed text that gives members', () => {
|
|
85
|
+
const getMembersWithDomain = text =>
|
|
86
|
+
(text.match(/\S+@\S+\.\S+/g) || []).map(email => ({ id: email }))
|
|
87
|
+
render(
|
|
88
|
+
<DemoProvider>
|
|
89
|
+
<MemberAutocomplete
|
|
90
|
+
value={[]}
|
|
91
|
+
getMembersFromText={getMembersWithDomain}
|
|
92
|
+
placeholder="Add people"
|
|
93
|
+
onChange={() => {}}
|
|
94
|
+
onSubmit={() => {}}
|
|
95
|
+
/>
|
|
96
|
+
</DemoProvider>
|
|
97
|
+
)
|
|
98
|
+
const input = screen.getByPlaceholderText('Add people')
|
|
99
|
+
const send = screen.getByRole('button', { name: 'Send' })
|
|
100
|
+
|
|
101
|
+
fireEvent.change(input, { target: { value: 'bob@example' } })
|
|
102
|
+
expect(send).toBeDisabled()
|
|
103
|
+
|
|
104
|
+
fireEvent.change(input, { target: { value: 'bob@example.com' } })
|
|
105
|
+
expect(send).toBeEnabled()
|
|
106
|
+
})
|
|
83
107
|
})
|
|
@@ -6,7 +6,7 @@ import { useI18n, useExtendI18n } from 'twake-i18n'
|
|
|
6
6
|
import MemberAutocompleteActions from './MemberAutocompleteActions'
|
|
7
7
|
import MemberChip from './MemberChip'
|
|
8
8
|
import MemberSuggestion from './MemberSuggestion'
|
|
9
|
-
import { getUnpickedMembers
|
|
9
|
+
import { getUnpickedMembers } from './helpers'
|
|
10
10
|
import { locales } from './locales'
|
|
11
11
|
import { useMemberInput } from './useMemberInput'
|
|
12
12
|
import { useMemberSuggestions } from './useMemberSuggestions'
|
|
@@ -89,6 +89,7 @@ const MemberAutocomplete = ({
|
|
|
89
89
|
debounceMs
|
|
90
90
|
})
|
|
91
91
|
const {
|
|
92
|
+
isTextAddedOnBlur,
|
|
92
93
|
handleChange,
|
|
93
94
|
handleInputChange,
|
|
94
95
|
handleKeyDown,
|
|
@@ -112,7 +113,7 @@ const MemberAutocomplete = ({
|
|
|
112
113
|
const titleId = `${inputId}-title`
|
|
113
114
|
const isTitleShown = title !== undefined
|
|
114
115
|
const isSubmitShown = onSubmit !== undefined
|
|
115
|
-
const hasMembersToSend = value.length > 0 ||
|
|
116
|
+
const hasMembersToSend = value.length > 0 || isTextAddedOnBlur
|
|
116
117
|
const isLoading = loading || isFetching
|
|
117
118
|
const unpickedSuggestions = getUnpickedMembers(suggestions, value)
|
|
118
119
|
const fieldPlaceholder = value.length === 0 ? placeholder : undefined
|
|
@@ -64,13 +64,17 @@ export const useMemberInput = ({
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
const isTextAddedOnBlur =
|
|
68
|
+
isEmailLike(inputValue) && getKnownMembersFromText(inputValue).length > 0
|
|
69
|
+
|
|
67
70
|
const handleBlur = () => {
|
|
68
|
-
if (
|
|
71
|
+
if (isTextAddedOnBlur && addMembersFromText(inputValue)) {
|
|
69
72
|
onInputValueChange('')
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
return {
|
|
77
|
+
isTextAddedOnBlur,
|
|
74
78
|
handleChange,
|
|
75
79
|
handleInputChange,
|
|
76
80
|
handleKeyDown,
|
|
@@ -35,6 +35,14 @@ const themesCommonConfig = {
|
|
|
35
35
|
...(isTesting() && { transitions: { create: () => 'none' } })
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// Keyframe animations ignore `transitions`, so they would change each screenshot
|
|
39
|
+
const testingOverrides = {
|
|
40
|
+
MuiCircularProgress: {
|
|
41
|
+
indeterminate: { animation: 'none' },
|
|
42
|
+
circleIndeterminate: { animation: 'none' }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
export const makeTheme = type => {
|
|
39
47
|
// to hold the values of css variables, recoverable by getCssVariableValue()
|
|
40
48
|
createNodeWithThemeCssVars(type)
|
|
@@ -48,7 +56,10 @@ export const makeTheme = type => {
|
|
|
48
56
|
palette
|
|
49
57
|
})
|
|
50
58
|
|
|
51
|
-
const overrides =
|
|
59
|
+
const overrides = {
|
|
60
|
+
...makeOverridesByTheme(theme)[type],
|
|
61
|
+
...(isTesting() && testingOverrides)
|
|
62
|
+
}
|
|
52
63
|
|
|
53
64
|
return {
|
|
54
65
|
...theme,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { COLORS };
|
|
2
2
|
export default ColorList;
|
|
3
3
|
import { COLORS } from "./helpers";
|
|
4
|
-
declare function ColorList({ size, selectedColor, customColorProps, onClick }: {
|
|
4
|
+
declare function ColorList({ size, selectedColor, getColorLabel, customColorProps, onClick }: {
|
|
5
5
|
size: any;
|
|
6
6
|
selectedColor: any;
|
|
7
|
+
getColorLabel: any;
|
|
7
8
|
customColorProps: any;
|
|
8
9
|
onClick: any;
|
|
9
10
|
}): JSX.Element;
|
|
@@ -11,9 +12,13 @@ declare namespace ColorList {
|
|
|
11
12
|
namespace propTypes {
|
|
12
13
|
const size: propTypes.Requireable<string>;
|
|
13
14
|
const selectedColor: propTypes.Requireable<string>;
|
|
15
|
+
const getColorLabel: propTypes.Requireable<(...args: any[]) => any>;
|
|
14
16
|
const customColorProps: propTypes.Requireable<propTypes.InferProps<{
|
|
15
17
|
enabled: propTypes.Requireable<boolean>;
|
|
16
18
|
onClick: propTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
'aria-label': propTypes.Requireable<string>;
|
|
20
|
+
'aria-pressed': propTypes.Requireable<boolean>;
|
|
21
|
+
'data-testid': propTypes.Requireable<string>;
|
|
17
22
|
}>>;
|
|
18
23
|
const onClick: propTypes.Requireable<(...args: any[]) => any>;
|
|
19
24
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["enabled"];
|
|
1
4
|
import { Icon, Check, Palette } from '@linagora/twake-icons';
|
|
2
5
|
import propTypes from 'prop-types';
|
|
3
6
|
import React from 'react';
|
|
@@ -16,9 +19,14 @@ var sizeToPx = {
|
|
|
16
19
|
var ColorList = function ColorList(_ref) {
|
|
17
20
|
var size = _ref.size,
|
|
18
21
|
selectedColor = _ref.selectedColor,
|
|
22
|
+
getColorLabel = _ref.getColorLabel,
|
|
19
23
|
customColorProps = _ref.customColorProps,
|
|
20
24
|
_onClick = _ref.onClick;
|
|
21
25
|
|
|
26
|
+
var _ref2 = customColorProps !== null && customColorProps !== void 0 ? customColorProps : {},
|
|
27
|
+
isCustomEnabled = _ref2.enabled,
|
|
28
|
+
customButtonProps = _objectWithoutProperties(_ref2, _excluded);
|
|
29
|
+
|
|
22
30
|
var _useBreakpoints = useBreakpoints(),
|
|
23
31
|
isMobile = _useBreakpoints.isMobile;
|
|
24
32
|
|
|
@@ -31,6 +39,8 @@ var ColorList = function ColorList(_ref) {
|
|
|
31
39
|
rowHeight: avatarSize,
|
|
32
40
|
gap: _size === 'medium' ? 16 : 5
|
|
33
41
|
}, COLORS.map(function (color) {
|
|
42
|
+
var _getColorLabel;
|
|
43
|
+
|
|
34
44
|
return /*#__PURE__*/React.createElement(ImageListItem, {
|
|
35
45
|
key: color,
|
|
36
46
|
className: "u-ta-center",
|
|
@@ -40,6 +50,8 @@ var ColorList = function ColorList(_ref) {
|
|
|
40
50
|
}, /*#__PURE__*/React.createElement(ButtonBase, {
|
|
41
51
|
className: "u-bdrs-circle",
|
|
42
52
|
component: "div",
|
|
53
|
+
"aria-label": (_getColorLabel = getColorLabel === null || getColorLabel === void 0 ? void 0 : getColorLabel(color)) !== null && _getColorLabel !== void 0 ? _getColorLabel : color,
|
|
54
|
+
"aria-pressed": (selectedColor === null || selectedColor === void 0 ? void 0 : selectedColor.toUpperCase()) === color,
|
|
43
55
|
onClick: function onClick() {
|
|
44
56
|
return _onClick === null || _onClick === void 0 ? void 0 : _onClick(color);
|
|
45
57
|
}
|
|
@@ -50,12 +62,12 @@ var ColorList = function ColorList(_ref) {
|
|
|
50
62
|
icon: Check,
|
|
51
63
|
size: iconSize
|
|
52
64
|
}) : ' ')));
|
|
53
|
-
}),
|
|
65
|
+
}), isCustomEnabled && /*#__PURE__*/React.createElement(ImageListItem, {
|
|
54
66
|
className: "u-ta-center",
|
|
55
67
|
classes: {
|
|
56
68
|
item: 'u-ov-visible'
|
|
57
69
|
}
|
|
58
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
70
|
+
}, /*#__PURE__*/React.createElement(Button, _extends({}, customButtonProps, {
|
|
59
71
|
className: "u-miw-auto u-mih-auto u-p-0 u-bdrs-circle",
|
|
60
72
|
variant: "ghost",
|
|
61
73
|
style: {
|
|
@@ -73,19 +85,22 @@ var ColorList = function ColorList(_ref) {
|
|
|
73
85
|
icon: Palette,
|
|
74
86
|
size: iconSize,
|
|
75
87
|
color: "#000"
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
return customColorProps === null || customColorProps === void 0 ? void 0 : customColorProps.onClick(ev);
|
|
79
|
-
}
|
|
80
|
-
})));
|
|
88
|
+
})
|
|
89
|
+
}))));
|
|
81
90
|
};
|
|
82
91
|
|
|
83
92
|
ColorList.propTypes = {
|
|
84
93
|
size: propTypes.oneOf(['small', 'medium']),
|
|
85
94
|
selectedColor: propTypes.string,
|
|
95
|
+
|
|
96
|
+
/** Accessible name of a color. Defaults to its hexadecimal code */
|
|
97
|
+
getColorLabel: propTypes.func,
|
|
86
98
|
customColorProps: propTypes.shape({
|
|
87
99
|
enabled: propTypes.bool,
|
|
88
|
-
onClick: propTypes.func
|
|
100
|
+
onClick: propTypes.func,
|
|
101
|
+
'aria-label': propTypes.string,
|
|
102
|
+
'aria-pressed': propTypes.bool,
|
|
103
|
+
'data-testid': propTypes.string
|
|
89
104
|
}),
|
|
90
105
|
onClick: propTypes.func
|
|
91
106
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export default EditBadge;
|
|
2
|
-
declare function EditBadge({ src, onUpload, onDelete, anchorOrigin, children, ...props }: {
|
|
2
|
+
declare function EditBadge({ src, onUpload, onDelete, anchorOrigin, componentsProps, children, ...props }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
src: any;
|
|
5
5
|
onUpload: any;
|
|
6
6
|
onDelete: any;
|
|
7
7
|
anchorOrigin: any;
|
|
8
|
+
componentsProps: any;
|
|
8
9
|
children: any;
|
|
9
10
|
}): JSX.Element;
|
|
10
11
|
declare namespace EditBadge {
|
|
@@ -18,6 +19,10 @@ declare namespace EditBadge {
|
|
|
18
19
|
const src: PropTypes.Validator<(...args: any[]) => any>;
|
|
19
20
|
const onUpload: PropTypes.Validator<(...args: any[]) => any>;
|
|
20
21
|
const onDelete: PropTypes.Validator<(...args: any[]) => any>;
|
|
22
|
+
const componentsProps: PropTypes.Requireable<PropTypes.InferProps<{
|
|
23
|
+
/** Props spread to the badge button */
|
|
24
|
+
button: PropTypes.Requireable<object>;
|
|
25
|
+
}>>;
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
import PropTypes from "prop-types";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["src", "onUpload", "onDelete", "anchorOrigin", "children"];
|
|
4
|
+
var _excluded = ["src", "onUpload", "onDelete", "anchorOrigin", "componentsProps", "children"];
|
|
5
5
|
import { Icon, Pen } from '@linagora/twake-icons';
|
|
6
|
+
import cx from 'classnames';
|
|
6
7
|
import PropTypes from 'prop-types';
|
|
7
8
|
import React, { useState, useRef } from 'react';
|
|
8
9
|
import EditMenu from "cozy-ui/transpiled/react/EditBadge/EditMenu";
|
|
@@ -11,10 +12,13 @@ import Badge from "cozy-ui/transpiled/react/Badge";
|
|
|
11
12
|
import Button from "cozy-ui/transpiled/react/Buttons";
|
|
12
13
|
|
|
13
14
|
var EditBadge = function EditBadge(_ref) {
|
|
15
|
+
var _componentsProps$butt;
|
|
16
|
+
|
|
14
17
|
var src = _ref.src,
|
|
15
18
|
onUpload = _ref.onUpload,
|
|
16
19
|
onDelete = _ref.onDelete,
|
|
17
20
|
anchorOrigin = _ref.anchorOrigin,
|
|
21
|
+
componentsProps = _ref.componentsProps,
|
|
18
22
|
children = _ref.children,
|
|
19
23
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
20
24
|
|
|
@@ -37,10 +41,10 @@ var EditBadge = function EditBadge(_ref) {
|
|
|
37
41
|
var menuAnchorRef = useRef(null);
|
|
38
42
|
return /*#__PURE__*/React.createElement(Badge, _extends({}, props, {
|
|
39
43
|
anchorOrigin: anchorOrigin,
|
|
40
|
-
badgeContent: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
44
|
+
badgeContent: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.button, {
|
|
41
45
|
ref: menuAnchorRef,
|
|
42
46
|
component: "div",
|
|
43
|
-
className:
|
|
47
|
+
className: cx('u-miw-auto u-w-2-half u-h-2-half u-bdrs-circle', componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$butt = componentsProps.button) === null || _componentsProps$butt === void 0 ? void 0 : _componentsProps$butt.className),
|
|
44
48
|
classes: {
|
|
45
49
|
label: 'u-flex u-w-auto'
|
|
46
50
|
},
|
|
@@ -56,7 +60,7 @@ var EditBadge = function EditBadge(_ref) {
|
|
|
56
60
|
return !v;
|
|
57
61
|
});
|
|
58
62
|
}
|
|
59
|
-
}), /*#__PURE__*/React.createElement(EditMenu, {
|
|
63
|
+
})), /*#__PURE__*/React.createElement(EditMenu, {
|
|
60
64
|
anchorRef: menuAnchorRef.current,
|
|
61
65
|
status: status,
|
|
62
66
|
showMenu: showMenu,
|
|
@@ -83,6 +87,10 @@ EditBadge.defaultProps = {
|
|
|
83
87
|
EditBadge.propTypes = {
|
|
84
88
|
src: PropTypes.func.isRequired,
|
|
85
89
|
onUpload: PropTypes.func.isRequired,
|
|
86
|
-
onDelete: PropTypes.func.isRequired
|
|
90
|
+
onDelete: PropTypes.func.isRequired,
|
|
91
|
+
componentsProps: PropTypes.shape({
|
|
92
|
+
/** Props spread to the badge button */
|
|
93
|
+
button: PropTypes.object
|
|
94
|
+
})
|
|
87
95
|
};
|
|
88
96
|
export default EditBadge;
|
|
@@ -13,7 +13,7 @@ import { useI18n, useExtendI18n } from 'twake-i18n';
|
|
|
13
13
|
import MemberAutocompleteActions from "cozy-ui/transpiled/react/MemberAutocomplete/MemberAutocompleteActions";
|
|
14
14
|
import MemberChip from "cozy-ui/transpiled/react/MemberAutocomplete/MemberChip";
|
|
15
15
|
import MemberSuggestion from "cozy-ui/transpiled/react/MemberAutocomplete/MemberSuggestion";
|
|
16
|
-
import { getUnpickedMembers
|
|
16
|
+
import { getUnpickedMembers } from "cozy-ui/transpiled/react/MemberAutocomplete/helpers";
|
|
17
17
|
import { locales } from "cozy-ui/transpiled/react/MemberAutocomplete/locales";
|
|
18
18
|
import { useMemberInput } from "cozy-ui/transpiled/react/MemberAutocomplete/useMemberInput";
|
|
19
19
|
import { useMemberSuggestions } from "cozy-ui/transpiled/react/MemberAutocomplete/useMemberSuggestions";
|
|
@@ -133,6 +133,7 @@ var MemberAutocomplete = function MemberAutocomplete(_ref2) {
|
|
|
133
133
|
onInputValueChange: setInputValue,
|
|
134
134
|
onChange: onChange
|
|
135
135
|
}),
|
|
136
|
+
isTextAddedOnBlur = _useMemberInput.isTextAddedOnBlur,
|
|
136
137
|
handleChange = _useMemberInput.handleChange,
|
|
137
138
|
handleInputChange = _useMemberInput.handleInputChange,
|
|
138
139
|
handleKeyDown = _useMemberInput.handleKeyDown,
|
|
@@ -148,7 +149,7 @@ var MemberAutocomplete = function MemberAutocomplete(_ref2) {
|
|
|
148
149
|
var titleId = "".concat(inputId, "-title");
|
|
149
150
|
var isTitleShown = title !== undefined;
|
|
150
151
|
var isSubmitShown = onSubmit !== undefined;
|
|
151
|
-
var hasMembersToSend = value.length > 0 ||
|
|
152
|
+
var hasMembersToSend = value.length > 0 || isTextAddedOnBlur;
|
|
152
153
|
var isLoading = loading || isFetching;
|
|
153
154
|
var unpickedSuggestions = getUnpickedMembers(suggestions, value);
|
|
154
155
|
var fieldPlaceholder = value.length === 0 ? placeholder : undefined;
|
|
@@ -6,6 +6,7 @@ export function useMemberInput({ inputValue, value, suggestions, getMembersFromT
|
|
|
6
6
|
onInputValueChange: Function;
|
|
7
7
|
onChange: Function;
|
|
8
8
|
}): {
|
|
9
|
+
isTextAddedOnBlur: boolean;
|
|
9
10
|
handleChange: (event: any, newValue: any, reason: any) => void;
|
|
10
11
|
handleInputChange: (event: any, newInputValue: any, reason: any) => void;
|
|
11
12
|
handleKeyDown: (event: any) => void;
|
|
@@ -60,13 +60,16 @@ export var useMemberInput = function useMemberInput(_ref) {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
var isTextAddedOnBlur = isEmailLike(inputValue) && getKnownMembersFromText(inputValue).length > 0;
|
|
64
|
+
|
|
63
65
|
var handleBlur = function handleBlur() {
|
|
64
|
-
if (
|
|
66
|
+
if (isTextAddedOnBlur && addMembersFromText(inputValue)) {
|
|
65
67
|
onInputValueChange('');
|
|
66
68
|
}
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
return {
|
|
72
|
+
isTextAddedOnBlur: isTextAddedOnBlur,
|
|
70
73
|
handleChange: handleChange,
|
|
71
74
|
handleInputChange: handleInputChange,
|
|
72
75
|
handleKeyDown: handleKeyDown,
|
|
@@ -43,8 +43,19 @@ var themesCommonConfig = _objectSpread({
|
|
|
43
43
|
return 'none';
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
});
|
|
46
|
+
}); // Keyframe animations ignore `transitions`, so they would change each screenshot
|
|
47
47
|
|
|
48
|
+
|
|
49
|
+
var testingOverrides = {
|
|
50
|
+
MuiCircularProgress: {
|
|
51
|
+
indeterminate: {
|
|
52
|
+
animation: 'none'
|
|
53
|
+
},
|
|
54
|
+
circleIndeterminate: {
|
|
55
|
+
animation: 'none'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
48
59
|
export var makeTheme = function makeTheme(type) {
|
|
49
60
|
// to hold the values of css variables, recoverable by getCssVariableValue()
|
|
50
61
|
createNodeWithThemeCssVars(type);
|
|
@@ -55,7 +66,9 @@ export var makeTheme = function makeTheme(type) {
|
|
|
55
66
|
type: type,
|
|
56
67
|
palette: palette
|
|
57
68
|
}));
|
|
58
|
-
|
|
69
|
+
|
|
70
|
+
var overrides = _objectSpread(_objectSpread({}, makeOverridesByTheme(theme)[type]), isTesting() && testingOverrides);
|
|
71
|
+
|
|
59
72
|
return _objectSpread(_objectSpread({}, theme), {}, {
|
|
60
73
|
overrides: overrides
|
|
61
74
|
});
|