ywana-core8 0.0.712 → 0.0.714
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 +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +11 -2
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +11 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain2/CollectionFilters.js +2 -1
- package/src/domain2/CollectionPage.js +2 -2
- package/src/domain2/CollectionPage.test.js +1 -0
- package/src/html/list.css +2 -2
- package/src/html/list.js +9 -8
package/package.json
CHANGED
@@ -9,12 +9,13 @@ import './CollectionFilters.css'
|
|
9
9
|
*/
|
10
10
|
export const CollectionFilters = (props) => {
|
11
11
|
|
12
|
-
const { schema, children } = props
|
12
|
+
const { schema, children, value } = props
|
13
13
|
const context = useContext(CollectionContext)
|
14
14
|
const { filters } = context
|
15
15
|
const [open, setOpen] = useState(false)
|
16
16
|
|
17
17
|
useEffect(() => {
|
18
|
+
context.setFilters(value)
|
18
19
|
const likes = Object.keys(schema).filter(id => schema[id].like === true)
|
19
20
|
context.setLikes(likes)
|
20
21
|
}, [schema])
|
@@ -15,7 +15,7 @@ export const CollectionPage = (props) => {
|
|
15
15
|
host, url, schema,
|
16
16
|
layout,
|
17
17
|
title, actions,
|
18
|
-
canFilter, customFilters,
|
18
|
+
canFilter, customFilters, filtersValue,
|
19
19
|
listGroupBy, listSearchBy, listItemRenderer,
|
20
20
|
customEditor,
|
21
21
|
} = props
|
@@ -26,7 +26,7 @@ export const CollectionPage = (props) => {
|
|
26
26
|
<Header title={title} >
|
27
27
|
{actions}
|
28
28
|
</Header>
|
29
|
-
{canFilter ? <CollectionFilters schema={schema} >{customFilters}</CollectionFilters> : null}
|
29
|
+
{canFilter ? <CollectionFilters schema={schema} value={filtersValue} >{customFilters}</CollectionFilters> : null}
|
30
30
|
<CollectionList itemRenderer={listItemRenderer} groupBy={listGroupBy} searchBy={listSearchBy} />
|
31
31
|
<CollectionEditor customEditor={customEditor} />
|
32
32
|
</CollectionContextProvider>
|
package/src/html/list.css
CHANGED
package/src/html/list.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, {
|
1
|
+
import React, { Fragment } from 'react'
|
2
2
|
import { Icon } from './icon';
|
3
3
|
import { Text } from './text';
|
4
4
|
import "./list.css"
|
@@ -8,7 +8,7 @@ import "./list.css"
|
|
8
8
|
*/
|
9
9
|
export const List = (props) => {
|
10
10
|
|
11
|
-
const { items = [], children, onSelect, groupBy } = props
|
11
|
+
const { items = [], children, selected, onSelect, groupBy } = props
|
12
12
|
|
13
13
|
function select(id) {
|
14
14
|
if (onSelect) onSelect(id)
|
@@ -28,14 +28,14 @@ export const List = (props) => {
|
|
28
28
|
* Grouped List
|
29
29
|
*/
|
30
30
|
const GroupedList = (props) => {
|
31
|
-
const { items = [], children, onSelect, groupBy } = props
|
31
|
+
const { items = [], children, selected, onSelect, groupBy } = props
|
32
32
|
|
33
33
|
const groups = items.reduce((groups, item) => {
|
34
34
|
let group = groups.find(g => g.name === item[groupBy])
|
35
35
|
if (!group) {
|
36
|
-
group = { name: item[groupBy], items: []}
|
36
|
+
group = { name: item[groupBy], items: [] }
|
37
37
|
groups.push(group)
|
38
|
-
}
|
38
|
+
}
|
39
39
|
group.items.push(item)
|
40
40
|
return groups
|
41
41
|
}, [])
|
@@ -46,7 +46,7 @@ const GroupedList = (props) => {
|
|
46
46
|
<Fragment key={group.name}>
|
47
47
|
<header key={`${group.name}-header`}><Text>{group.name}</Text></header>
|
48
48
|
<ul key={`${group.name}-ul`}>
|
49
|
-
{group.items.map(item => <ListItem key={item.id} item={item} onSelect={onSelect} />)}
|
49
|
+
{group.items.map(item => <ListItem key={item.id} item={item} selected={selected} onSelect={onSelect} />)}
|
50
50
|
</ul>
|
51
51
|
</Fragment>
|
52
52
|
))}
|
@@ -58,15 +58,16 @@ const GroupedList = (props) => {
|
|
58
58
|
/**
|
59
59
|
* List Item
|
60
60
|
*/
|
61
|
-
const ListItem = ({ item, onSelect }) => {
|
61
|
+
const ListItem = ({ item, selected, onSelect }) => {
|
62
62
|
const { id, icon, line1, line2, meta } = item
|
63
63
|
|
64
64
|
function select() {
|
65
65
|
if (onSelect) onSelect(id)
|
66
66
|
}
|
67
67
|
|
68
|
+
const style = selected === id ? "selected" : ""
|
68
69
|
return (
|
69
|
-
<li onClick={select}>
|
70
|
+
<li className={`${style}`} onClick={select}>
|
70
71
|
{icon ? <Icon icon={icon} size="small" /> : null}
|
71
72
|
<main>
|
72
73
|
<div className="primary-line"><Text>{line1}</Text></div>
|