cozy-ui 93.0.1 → 93.1.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 +7 -0
- package/package.json +1 -1
- package/react/NestedSelect/ItemRow.jsx +9 -1
- package/react/NestedSelect/NestedSelect.jsx +11 -2
- package/react/NestedSelect/NestedSelect.md +13 -0
- package/transpiled/react/NestedSelect/ItemRow.js +9 -4
- package/transpiled/react/NestedSelect/NestedSelect.js +14 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [93.1.0](https://github.com/cozy/cozy-ui/compare/v93.0.1...v93.1.0) (2023-09-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **NestedSelect:** Manage ellipsis ([adbabc9](https://github.com/cozy/cozy-ui/commit/adbabc9))
|
|
7
|
+
|
|
1
8
|
## [93.0.1](https://github.com/cozy/cozy-ui/compare/v93.0.0...v93.0.1) (2023-09-14)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -12,13 +12,21 @@ import Typography from '../Typography'
|
|
|
12
12
|
|
|
13
13
|
const infoStyle = { color: 'var(--secondaryTextColor)' }
|
|
14
14
|
|
|
15
|
-
const ItemRow = ({
|
|
15
|
+
const ItemRow = ({
|
|
16
|
+
item,
|
|
17
|
+
onClick,
|
|
18
|
+
isSelected,
|
|
19
|
+
radioPosition,
|
|
20
|
+
isLast,
|
|
21
|
+
ellipsis
|
|
22
|
+
}) => {
|
|
16
23
|
const { isDesktop } = useBreakpoints()
|
|
17
24
|
|
|
18
25
|
return (
|
|
19
26
|
<>
|
|
20
27
|
<ListItem
|
|
21
28
|
gutters={isDesktop ? 'double' : 'default'}
|
|
29
|
+
{...(ellipsis === false && { ellipsis: false })}
|
|
22
30
|
button
|
|
23
31
|
onClick={() => onClick(item)}
|
|
24
32
|
>
|
|
@@ -80,7 +80,8 @@ class NestedSelect extends Component {
|
|
|
80
80
|
isSelected,
|
|
81
81
|
title,
|
|
82
82
|
transformParentItem,
|
|
83
|
-
radioPosition
|
|
83
|
+
radioPosition,
|
|
84
|
+
ellipsis
|
|
84
85
|
} = this.props
|
|
85
86
|
const { history, searchValue, searchResult } = this.state
|
|
86
87
|
const current = history[0]
|
|
@@ -117,6 +118,7 @@ class NestedSelect extends Component {
|
|
|
117
118
|
item={parentItem}
|
|
118
119
|
onClick={this.handleClickItem}
|
|
119
120
|
isSelected={isSelectedWithLevel(parentItem)}
|
|
121
|
+
ellipsis={ellipsis}
|
|
120
122
|
/>
|
|
121
123
|
) : null}
|
|
122
124
|
{searchOptions && level === 0 && (
|
|
@@ -146,6 +148,7 @@ class NestedSelect extends Component {
|
|
|
146
148
|
onClick={this.handleClickItem}
|
|
147
149
|
isSelected={isSelectedWithLevel(item)}
|
|
148
150
|
isLast={index === searchResult.length - 1}
|
|
151
|
+
ellipsis={ellipsis}
|
|
149
152
|
/>
|
|
150
153
|
))
|
|
151
154
|
)
|
|
@@ -158,6 +161,7 @@ class NestedSelect extends Component {
|
|
|
158
161
|
onClick={this.handleClickItem}
|
|
159
162
|
isSelected={isSelectedWithLevel(item)}
|
|
160
163
|
isLast={index === children.length - 1}
|
|
164
|
+
ellipsis={ellipsis}
|
|
161
165
|
/>
|
|
162
166
|
))
|
|
163
167
|
)}
|
|
@@ -236,7 +240,12 @@ NestedSelect.propTypes = {
|
|
|
236
240
|
placeholderSearch: PropTypes.string.isRequired,
|
|
237
241
|
noDataLabel: PropTypes.string.isRequired,
|
|
238
242
|
onSearch: PropTypes.func.isRequired
|
|
239
|
-
})
|
|
243
|
+
}),
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* To manage ellipsis on ItemRow
|
|
247
|
+
*/
|
|
248
|
+
ellipsis: PropTypes.bool
|
|
240
249
|
}
|
|
241
250
|
|
|
242
251
|
export default NestedSelect
|
|
@@ -107,6 +107,7 @@ const isParent = (item, childItem) => {
|
|
|
107
107
|
const InteractiveExample = () => {
|
|
108
108
|
const [leftRadio, setLeftRadio] = useState(false)
|
|
109
109
|
const [searchOptions, setSearchOptions] = useState(null)
|
|
110
|
+
const [withEllipsis, setWithEllipsis] = useState(true)
|
|
110
111
|
const [showingModal, setShowingModal] = useState(false)
|
|
111
112
|
const [selectedItem, setSelected] = useState({ title: 'A' })
|
|
112
113
|
const showModal = () => setShowingModal(true)
|
|
@@ -125,6 +126,9 @@ const InteractiveExample = () => {
|
|
|
125
126
|
const handleClickLeftRadio = () => {
|
|
126
127
|
setLeftRadio(!leftRadio)
|
|
127
128
|
}
|
|
129
|
+
const handleClickWithEllipsis = () => {
|
|
130
|
+
setWithEllipsis(prev => !prev)
|
|
131
|
+
}
|
|
128
132
|
|
|
129
133
|
const handleClickWithSearch = e => {
|
|
130
134
|
if (e.target.checked) {
|
|
@@ -173,6 +177,14 @@ const InteractiveExample = () => {
|
|
|
173
177
|
checked={!!searchOptions}
|
|
174
178
|
onClick={handleClickWithSearch}
|
|
175
179
|
/>
|
|
180
|
+
<Checkbox
|
|
181
|
+
label='without ellipsis'
|
|
182
|
+
readOnly
|
|
183
|
+
name='withEllipsis'
|
|
184
|
+
value={!!withEllipsis}
|
|
185
|
+
checked={!!withEllipsis}
|
|
186
|
+
onClick={handleClickWithEllipsis}
|
|
187
|
+
/>
|
|
176
188
|
{ selectedItem && (
|
|
177
189
|
<>Selected: { selectedItem.title }<br/></>
|
|
178
190
|
)}
|
|
@@ -188,6 +200,7 @@ const InteractiveExample = () => {
|
|
|
188
200
|
title="Please select letter"
|
|
189
201
|
transformParentItem={transformParentItem}
|
|
190
202
|
searchOptions={searchOptions}
|
|
203
|
+
ellipsis={withEllipsis}
|
|
191
204
|
/>
|
|
192
205
|
)}
|
|
193
206
|
</>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
|
|
3
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -23,18 +24,22 @@ var ItemRow = function ItemRow(_ref) {
|
|
|
23
24
|
_onClick = _ref.onClick,
|
|
24
25
|
isSelected = _ref.isSelected,
|
|
25
26
|
radioPosition = _ref.radioPosition,
|
|
26
|
-
isLast = _ref.isLast
|
|
27
|
+
isLast = _ref.isLast,
|
|
28
|
+
ellipsis = _ref.ellipsis;
|
|
27
29
|
|
|
28
30
|
var _useBreakpoints = useBreakpoints(),
|
|
29
31
|
isDesktop = _useBreakpoints.isDesktop;
|
|
30
32
|
|
|
31
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ListItem, {
|
|
32
|
-
gutters: isDesktop ? 'double' : 'default'
|
|
33
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ListItem, _extends({
|
|
34
|
+
gutters: isDesktop ? 'double' : 'default'
|
|
35
|
+
}, ellipsis === false && {
|
|
36
|
+
ellipsis: false
|
|
37
|
+
}, {
|
|
33
38
|
button: true,
|
|
34
39
|
onClick: function onClick() {
|
|
35
40
|
return _onClick(item);
|
|
36
41
|
}
|
|
37
|
-
}, radioPosition === 'left' && /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Radio, {
|
|
42
|
+
}), radioPosition === 'left' && /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Radio, {
|
|
38
43
|
readOnly: true,
|
|
39
44
|
name: item.title,
|
|
40
45
|
value: item.title,
|
|
@@ -117,7 +117,8 @@ var NestedSelect = /*#__PURE__*/function (_Component) {
|
|
|
117
117
|
isSelected = _this$props.isSelected,
|
|
118
118
|
title = _this$props.title,
|
|
119
119
|
transformParentItem = _this$props.transformParentItem,
|
|
120
|
-
radioPosition = _this$props.radioPosition
|
|
120
|
+
radioPosition = _this$props.radioPosition,
|
|
121
|
+
ellipsis = _this$props.ellipsis;
|
|
121
122
|
var _this$state = this.state,
|
|
122
123
|
history = _this$state.history,
|
|
123
124
|
searchValue = _this$state.searchValue,
|
|
@@ -157,7 +158,8 @@ var NestedSelect = /*#__PURE__*/function (_Component) {
|
|
|
157
158
|
radioPosition: radioPosition,
|
|
158
159
|
item: parentItem,
|
|
159
160
|
onClick: this.handleClickItem,
|
|
160
|
-
isSelected: isSelectedWithLevel(parentItem)
|
|
161
|
+
isSelected: isSelectedWithLevel(parentItem),
|
|
162
|
+
ellipsis: ellipsis
|
|
161
163
|
}) : null, searchOptions && level === 0 && /*#__PURE__*/React.createElement("div", {
|
|
162
164
|
className: "u-mh-1 u-mb-half"
|
|
163
165
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
@@ -174,7 +176,8 @@ var NestedSelect = /*#__PURE__*/function (_Component) {
|
|
|
174
176
|
item: item,
|
|
175
177
|
onClick: _this2.handleClickItem,
|
|
176
178
|
isSelected: isSelectedWithLevel(item),
|
|
177
|
-
isLast: index === searchResult.length - 1
|
|
179
|
+
isLast: index === searchResult.length - 1,
|
|
180
|
+
ellipsis: ellipsis
|
|
178
181
|
});
|
|
179
182
|
}) : children.map(function (item, index) {
|
|
180
183
|
return /*#__PURE__*/React.createElement(ItemRow, {
|
|
@@ -183,7 +186,8 @@ var NestedSelect = /*#__PURE__*/function (_Component) {
|
|
|
183
186
|
item: item,
|
|
184
187
|
onClick: _this2.handleClickItem,
|
|
185
188
|
isSelected: isSelectedWithLevel(item),
|
|
186
|
-
isLast: index === children.length - 1
|
|
189
|
+
isLast: index === children.length - 1,
|
|
190
|
+
ellipsis: ellipsis
|
|
187
191
|
});
|
|
188
192
|
})));
|
|
189
193
|
}
|
|
@@ -265,6 +269,11 @@ NestedSelect.propTypes = {
|
|
|
265
269
|
placeholderSearch: PropTypes.string.isRequired,
|
|
266
270
|
noDataLabel: PropTypes.string.isRequired,
|
|
267
271
|
onSearch: PropTypes.func.isRequired
|
|
268
|
-
})
|
|
272
|
+
}),
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* To manage ellipsis on ItemRow
|
|
276
|
+
*/
|
|
277
|
+
ellipsis: PropTypes.bool
|
|
269
278
|
};
|
|
270
279
|
export default NestedSelect;
|