ywana-core8 0.0.707 → 0.0.708
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 +41 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +27 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +41 -4
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +41 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain2/CollectionFilters.css +2 -0
- package/src/domain2/CollectionList.css +17 -0
- package/src/domain2/CollectionList.js +31 -11
- package/src/domain2/CollectionPage.css +8 -0
- package/src/domain2/CollectionPage.js +4 -3
- package/src/domain2/CollectionPage.test.js +13 -0
package/package.json
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
flex-direction: column;
|
4
4
|
width: 30rem;
|
5
5
|
background-color: rgb(243, 243, 243);
|
6
|
+
border-right: solid 1px var(--divider-color);
|
6
7
|
}
|
7
8
|
|
8
9
|
.collection-filters>header {
|
@@ -48,4 +49,5 @@
|
|
48
49
|
display: flex;
|
49
50
|
flex-direction: column;
|
50
51
|
padding: 0 0 1rem 0;
|
52
|
+
border-bottom: solid 1px var(--divider-color);
|
51
53
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
.collection-list {
|
2
|
+
overflow: hidden;
|
3
|
+
display: flex;
|
4
|
+
flex-direction: column;
|
5
|
+
border-right: solid 1px var(--divider-color);
|
6
|
+
}
|
7
|
+
|
8
|
+
.collection-list .list {
|
9
|
+
flex: 1;
|
10
|
+
}
|
11
|
+
|
12
|
+
.collection-list .search-box {
|
13
|
+
border-top: solid 1px var(--divider-color);
|
14
|
+
padding: .5rem;
|
15
|
+
display: flex;
|
16
|
+
align-items: center;
|
17
|
+
}
|
@@ -1,35 +1,55 @@
|
|
1
|
-
import React, { useContext, useEffect } from 'react'
|
2
|
-
import { List } from '../html'
|
1
|
+
import React, { useContext, useEffect, useState } from 'react'
|
2
|
+
import { List, TextField, Icon } from '../html'
|
3
3
|
import { CollectionContext } from './CollectionContext'
|
4
|
+
import './CollectionList.css'
|
4
5
|
|
5
6
|
/**
|
6
7
|
* Collection List
|
7
8
|
*/
|
8
9
|
export const CollectionList = (props) => {
|
9
10
|
|
11
|
+
const { itemRenderer, groupBy, searchBy = [] } = props
|
10
12
|
const context = useContext(CollectionContext)
|
11
13
|
const { all = [], selected, filters, customFilters } = context
|
14
|
+
const [search, setSearch] = useState('')
|
12
15
|
|
13
16
|
useEffect(() => {
|
14
17
|
context.load()
|
15
18
|
}, [filters, customFilters])
|
16
19
|
|
20
|
+
function changeSearch(id, value) {
|
21
|
+
setSearch(value)
|
22
|
+
}
|
23
|
+
|
17
24
|
function select(id) {
|
18
25
|
context.select(id)
|
19
26
|
}
|
20
27
|
|
21
|
-
const
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
const searched = searchBy.length > 0 && search.length > 0 ? all.filter(item => {
|
29
|
+
const text = searchBy.map(field => item[field]).join(' ').toLowerCase()
|
30
|
+
return text.includes(search.toLowerCase())
|
31
|
+
}) : all
|
32
|
+
|
33
|
+
const items = searched
|
34
|
+
.map(item => {
|
35
|
+
if (itemRenderer) return itemRenderer(item)
|
36
|
+
return {
|
37
|
+
id: item.id,
|
38
|
+
icon: "folder",
|
39
|
+
line1: item.name,
|
40
|
+
meta: item.state,
|
41
|
+
}
|
42
|
+
})
|
29
43
|
|
30
44
|
return (
|
31
45
|
<div className="collection-list">
|
32
|
-
<List items={items} onSelect={select} />
|
46
|
+
<List items={items} onSelect={select} groupBy={groupBy} />
|
47
|
+
{searchBy.length > 0 ? (
|
48
|
+
<div className="search-box">
|
49
|
+
<Icon icon="search" size="small" />
|
50
|
+
<TextField placeholder="Search" onChange={changeSearch} outlined />
|
51
|
+
</div>
|
52
|
+
) : null}
|
33
53
|
</div>
|
34
54
|
)
|
35
55
|
}
|
@@ -1,3 +1,10 @@
|
|
1
|
+
.collection-page {
|
2
|
+
border: solid 3px red;
|
3
|
+
width: 100%;
|
4
|
+
height: 100%;
|
5
|
+
overflow: hidden;
|
6
|
+
}
|
7
|
+
|
1
8
|
.collection-page.ide {
|
2
9
|
display: grid;
|
3
10
|
grid-template-areas: "header header"
|
@@ -9,6 +16,7 @@
|
|
9
16
|
|
10
17
|
.collection-page.ide .header {
|
11
18
|
grid-area: header;
|
19
|
+
border-bottom: solid 1px var(--divider-color);
|
12
20
|
}
|
13
21
|
|
14
22
|
.collection-page.ide .collection-filters {
|
@@ -13,9 +13,10 @@ export const CollectionPage = (props) => {
|
|
13
13
|
|
14
14
|
const {
|
15
15
|
host, url, schema,
|
16
|
-
layout,
|
16
|
+
layout,
|
17
17
|
title,
|
18
18
|
canFilter, customFilters,
|
19
|
+
listGroupBy, listSearchBy, listItemRenderer,
|
19
20
|
customEditor
|
20
21
|
} = props
|
21
22
|
|
@@ -24,8 +25,8 @@ export const CollectionPage = (props) => {
|
|
24
25
|
<CollectionContextProvider host={host} url={url}>
|
25
26
|
<Header title={title} />
|
26
27
|
{canFilter ? <CollectionFilters schema={schema} >{customFilters}</CollectionFilters> : null}
|
27
|
-
<CollectionList />
|
28
|
-
<CollectionEditor customEditor={customEditor}/>
|
28
|
+
<CollectionList itemRenderer={listItemRenderer} groupBy={listGroupBy} searchBy={listSearchBy} />
|
29
|
+
<CollectionEditor customEditor={customEditor} />
|
29
30
|
</CollectionContextProvider>
|
30
31
|
</div>
|
31
32
|
|
@@ -16,6 +16,16 @@ const CollectionPageTest = (prop) => {
|
|
16
16
|
}
|
17
17
|
}
|
18
18
|
|
19
|
+
const listItemRenderer = (item) => {
|
20
|
+
return {
|
21
|
+
id: item.id,
|
22
|
+
icon: "star",
|
23
|
+
line1: item.name,
|
24
|
+
line2: item.name,
|
25
|
+
meta: item.state,
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
19
29
|
const props = {
|
20
30
|
host: "http://localhost:3000",
|
21
31
|
url: "/references",
|
@@ -24,6 +34,9 @@ const CollectionPageTest = (prop) => {
|
|
24
34
|
title: <CustomTitle />,
|
25
35
|
canFilter: true,
|
26
36
|
customFilters: [<CustomFilter1 />, <CustomFilter2 />],
|
37
|
+
listSearchBy: ["name"],
|
38
|
+
listGroupBy: "name",
|
39
|
+
listItemRenderer,
|
27
40
|
customEditor: <CustomEditor />
|
28
41
|
}
|
29
42
|
|