ywana-core8 0.0.739 → 0.0.740
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/dist/index.cjs +16 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +16 -3
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +16 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain2/CollectionList.js +12 -2
- package/src/domain2/CollectionPage.js +2 -1
package/package.json
CHANGED
@@ -8,7 +8,7 @@ import './CollectionList.css'
|
|
8
8
|
*/
|
9
9
|
export const CollectionList = (props) => {
|
10
10
|
|
11
|
-
const { itemRenderer, groupBy, searchBy = [] } = props
|
11
|
+
const { itemRenderer, groupBy, searchBy = [], sortBy, sortDir } = props
|
12
12
|
const context = useContext(CollectionContext)
|
13
13
|
const { all = [], selected, filters, customFilters } = context
|
14
14
|
const [search, setSearch] = useState('')
|
@@ -26,7 +26,15 @@ export const CollectionList = (props) => {
|
|
26
26
|
return text.includes(search.toLowerCase())
|
27
27
|
}) : all
|
28
28
|
|
29
|
-
const
|
29
|
+
const sorted = sortBy ? searched.sort((a, b) => {
|
30
|
+
const valueA = a[sortBy]
|
31
|
+
const valueB = b[sortBy]
|
32
|
+
if (valueA < valueB) return sortDir === 'asc' ? -1 : 1
|
33
|
+
if (valueA > valueB) return sortDir === 'asc' ? 1 : -1
|
34
|
+
return 0
|
35
|
+
}) : searched
|
36
|
+
|
37
|
+
const items = sorted
|
30
38
|
.map(item => {
|
31
39
|
if (itemRenderer) return itemRenderer(item)
|
32
40
|
return {
|
@@ -37,6 +45,8 @@ export const CollectionList = (props) => {
|
|
37
45
|
}
|
38
46
|
})
|
39
47
|
|
48
|
+
|
49
|
+
|
40
50
|
const style = selected ? 'selected' : ''
|
41
51
|
|
42
52
|
return (
|
@@ -16,6 +16,7 @@ export const CollectionPage = (props) => {
|
|
16
16
|
layout,
|
17
17
|
title, actions,
|
18
18
|
canFilter, customFilters, filtersValue,
|
19
|
+
sortBy, sortDir,
|
19
20
|
listGroupBy, listSearchBy, listItemRenderer,
|
20
21
|
customEditor,
|
21
22
|
} = props
|
@@ -27,7 +28,7 @@ export const CollectionPage = (props) => {
|
|
27
28
|
{actions}
|
28
29
|
</Header>
|
29
30
|
{canFilter ? <CollectionFilters schema={schema} >{customFilters}</CollectionFilters> : null}
|
30
|
-
<CollectionList itemRenderer={listItemRenderer} groupBy={listGroupBy} searchBy={listSearchBy} />
|
31
|
+
<CollectionList itemRenderer={listItemRenderer} groupBy={listGroupBy} searchBy={listSearchBy} sortBy={sortBy} sortDir={sortDir} />
|
31
32
|
<CollectionEditor customEditor={customEditor} />
|
32
33
|
</CollectionContextProvider>
|
33
34
|
</div>
|