ywana-core8 0.0.645 → 0.0.647
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 +25 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +29 -8
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +25 -8
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +25 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/table.css +29 -9
- package/src/html/table.js +15 -4
- package/src/html/table.test.js +31 -39
- package/src/html/textfield.js +1 -1
- package/src/html/tree.test.js +43 -0
package/package.json
CHANGED
package/src/html/table.css
CHANGED
@@ -17,20 +17,18 @@
|
|
17
17
|
.datatable8 thead {
|
18
18
|
position: sticky;
|
19
19
|
top: 0px;
|
20
|
-
background-color: rgba(240,240,240);
|
21
20
|
overflow: hidden;
|
22
|
-
color: var(--text-color-
|
21
|
+
color: var(--text-color-light);
|
23
22
|
z-index: 10;
|
24
23
|
}
|
25
24
|
|
26
|
-
.datatable8 thead tr {
|
27
|
-
border-bottom: solid 1px var(--divider-color);
|
28
|
-
}
|
29
|
-
|
30
25
|
.datatable8 thead th {
|
26
|
+
height: 2.1rem;
|
31
27
|
padding: 0 1rem;
|
32
28
|
text-align: left;
|
33
29
|
font-weight: 600 !important;
|
30
|
+
border-bottom: solid 1px var(--divider-color);
|
31
|
+
background-color: var(--paper-color);
|
34
32
|
}
|
35
33
|
|
36
34
|
.datatable8 thead th>div {
|
@@ -38,6 +36,8 @@
|
|
38
36
|
display: flex;
|
39
37
|
justify-content: space-between;
|
40
38
|
align-items: center;
|
39
|
+
text-transform: uppercase;
|
40
|
+
font-size: .8rem;
|
41
41
|
}
|
42
42
|
|
43
43
|
.datatable8 tbody {
|
@@ -45,8 +45,8 @@
|
|
45
45
|
height: 5rem;
|
46
46
|
}
|
47
47
|
|
48
|
-
.datatable8 tbody tr {
|
49
|
-
|
48
|
+
.datatable8 tbody tr.selected {
|
49
|
+
background-color: rgba(200,200,200,.6);
|
50
50
|
}
|
51
51
|
|
52
52
|
.datatable8 tbody tr:hover {
|
@@ -54,6 +54,10 @@
|
|
54
54
|
cursor: pointer
|
55
55
|
}
|
56
56
|
|
57
|
+
.datatable8 tbody tr.selected:hover {
|
58
|
+
background-color: rgba(200,200,200,.4);
|
59
|
+
}
|
60
|
+
|
57
61
|
.datatable8 tbody td {
|
58
62
|
height: 3rem;
|
59
63
|
padding: 0 1rem;
|
@@ -64,6 +68,22 @@
|
|
64
68
|
color: var(--text-color-light);
|
65
69
|
}
|
66
70
|
|
71
|
+
.datatable8 tbody td.index {
|
72
|
+
width: 3rem;
|
73
|
+
overflow: hidden;
|
74
|
+
color: var(--text-color-lighter);
|
75
|
+
}
|
76
|
+
|
77
|
+
.datatable8 tbody td.checked
|
78
|
+
{
|
79
|
+
width: 3rem;
|
80
|
+
overflow: hidden;
|
81
|
+
}
|
82
|
+
|
83
|
+
.datatable8 tbody td.checked .checkmark {
|
84
|
+
border-color: var(--text-color-lighter) !important;
|
85
|
+
}
|
86
|
+
|
67
87
|
.datatable8 .string-viewer img {
|
68
88
|
height: 5rem;
|
69
|
-
}
|
89
|
+
}
|
package/src/html/table.js
CHANGED
@@ -87,8 +87,8 @@ export const DataTable = (props) => {
|
|
87
87
|
return (
|
88
88
|
<th key={id} rowSpan={rowspan} colSpan={colspan}>
|
89
89
|
<div>
|
90
|
-
{id === "checked" ? <CheckBox onChange={checkAll} value={allChecked} /> : <Text key={`th_${id}`}>{label}</Text>}
|
91
|
-
{sortable ? <
|
90
|
+
{id === "checked" && onCheckAll ? <CheckBox onChange={checkAll} value={allChecked} /> : <Text key={`th_${id}`}>{label}</Text>}
|
91
|
+
{sortable ? <SortIcon sortDir={sortDir[id]} onChange={() => changeSort(id)} /> : null}
|
92
92
|
</div>
|
93
93
|
</th>
|
94
94
|
)
|
@@ -135,10 +135,11 @@ export const DataTable = (props) => {
|
|
135
135
|
*/
|
136
136
|
const DataTableRow = (props) => {
|
137
137
|
const { index, row, columns = [], onSelect, editable, expanded = false } = props
|
138
|
-
const { className } = row
|
138
|
+
const { selected = false, className } = row
|
139
139
|
const [isInfoOpen, toggleInfo] = useState(expanded)
|
140
140
|
const infoIcon = isInfoOpen ? 'expand_more' : 'expand_less'
|
141
|
-
|
141
|
+
let style = isInfoOpen ? "expanded" : ""
|
142
|
+
if (selected) style += " selected"
|
142
143
|
return (
|
143
144
|
<Fragment>
|
144
145
|
<tr className={`${style} ${className}`} onClick={ev => onSelect(row, ev)}>
|
@@ -293,3 +294,13 @@ export const StringCellEditor = ({ id, value = '', options, onChange }) => {
|
|
293
294
|
</div>
|
294
295
|
)
|
295
296
|
}
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Sort Icon
|
300
|
+
*/
|
301
|
+
const SortIcon = (props) => {
|
302
|
+
const { sortDir, onChange } = props
|
303
|
+
console.log("sortDir", sortDir)
|
304
|
+
const icon = sortDir ? sortDir > 0 ? "arrow_upward" : "arrow_downward" : "swap_vert"
|
305
|
+
return <Icon icon={icon} size="small" clickable action={onChange} />
|
306
|
+
}
|
package/src/html/table.test.js
CHANGED
@@ -6,15 +6,15 @@ export const TableTest = (prop) => {
|
|
6
6
|
|
7
7
|
const [rows, setRows] = useState(
|
8
8
|
[
|
9
|
-
{ id: 1, checked: false, name: "John Smith" , thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png"},
|
10
|
-
{ id: 2, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
11
|
-
{ id: 3, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
12
|
-
{ id: 4, checked: false, name: "
|
13
|
-
{ id: 5, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
14
|
-
{ id: 6, checked: false, name: "John Smith" , color: "#CCFFFF" },
|
15
|
-
{ id: 7, checked: false, name: "Ann Martin" , color: "#CCFFFF" },
|
16
|
-
{ id: 8, checked: false, name: "Martin Freeman", color: "#CCFFFF" },
|
17
|
-
{ id: 9, checked: false, name: "Ann Martin" , color: "#CCFFFF", date: new Date().toString() },
|
9
|
+
{ id: 1, checked: false, name: "John Smith" , description: "lorem ipsum ", thumb: "https://w7.pngwing.com/pngs/881/826/png-transparent-pikachu-ash-ketchum-pokemon-vrste-pikachu-leaf-flower-meme-thumbnail.png" },
|
10
|
+
{ id: 2, checked: false, name: "Ann Martin" , description: "lorem ipsum ", color: "#CCFFFF" },
|
11
|
+
{ id: 3, checked: false, name: "Ann Martin" , description: "lorem ipsum ", color: "#CCFFFF" },
|
12
|
+
{ id: 4, checked: false, name: "Zack McCracken", description: "lorem ipsum ", color: "#CCFFFF" },
|
13
|
+
{ id: 5, checked: false, name: "Ann Martin" , description: "lorem ipsum ", color: "#CCFFFF" },
|
14
|
+
{ id: 6, checked: false, name: "John Smith" , description: "lorem ipsum ", color: "#CCFFFF" },
|
15
|
+
{ id: 7, checked: false, name: "Ann Martin" , description: "lorem ipsum ", color: "#CCFFFF" },
|
16
|
+
{ id: 8, checked: false, name: "Martin Freeman", description: "lorem ipsum ", color: "#CCFFFF" },
|
17
|
+
{ id: 9, checked: false, name: "Ann Martin" , description: "lorem ipsum ", color: "#CCFFFF", date: new Date().toString() },
|
18
18
|
]
|
19
19
|
)
|
20
20
|
|
@@ -23,50 +23,42 @@ export const TableTest = (prop) => {
|
|
23
23
|
}
|
24
24
|
|
25
25
|
function select(row) {
|
26
|
-
|
26
|
+
const next = rows.map(r => r.id === row.id ? { ...r, selected: !r.selected } : r)
|
27
|
+
setRows(next)
|
27
28
|
}
|
28
29
|
|
29
|
-
function check(
|
30
|
-
|
30
|
+
function check(rowID, columnID, value) {
|
31
|
+
const next = rows.map(r => r.id === rowID ? { ...r, checked: value } : r)
|
32
|
+
setRows(next)
|
31
33
|
}
|
32
34
|
|
33
35
|
function checkAll(ids, checked) {
|
34
|
-
const next = rows.map(
|
36
|
+
const next = rows.map(row => Object.assign({}, row, { checked }))
|
35
37
|
setRows(next)
|
36
38
|
}
|
37
39
|
|
38
40
|
const table1 = {
|
39
41
|
className: "xxx",
|
40
42
|
editable: true,
|
41
|
-
columns
|
42
|
-
{ id: "index",
|
43
|
-
{ id: "checked", onChange: check
|
44
|
-
{ id: "name", label: "Name", type: "String",
|
45
|
-
{ id: "
|
46
|
-
{ id: "color", label: "Color", type: "String", format: FORMATS.COLOR },
|
47
|
-
{ id: "date", label: "Date", type: "String", format: FORMATS.DATE
|
43
|
+
columns: [
|
44
|
+
{ id: "index" , label: "#" , type: "INDEX" },
|
45
|
+
{ id: "checked" , onChange: check },
|
46
|
+
{ id: "name" , label: "Name" , type: "String", sortable: true, filtrable: true },
|
47
|
+
{ id: "description", label: "Description", type: "String" },
|
48
|
+
{ id: "color" , label: "Color" , type: "String", format: FORMATS.COLOR },
|
49
|
+
{ id: "date" , label: "Date" , type: "String", format: FORMATS.DATE },
|
48
50
|
],
|
49
51
|
rows
|
50
|
-
}
|
51
|
-
|
52
|
-
const table2 = {
|
53
|
-
className: "xxx",
|
54
|
-
editable: true,
|
55
|
-
columns : [
|
56
|
-
{ id: "checked", onChange: check },
|
57
|
-
{ id: "name", label: "Name", type: "String", sortable: true },
|
58
|
-
{ id: "thumb", label: "Thumb", type: "String", format: FORMATS.IMG },
|
59
|
-
{ id: "color", label: "Color", type: "String", format: FORMATS.COLOR },
|
60
|
-
{ id: "date", label: "Date", type: "String", format: FORMATS.DATE },
|
61
|
-
],
|
62
|
-
rows: []
|
63
|
-
}
|
52
|
+
}
|
64
53
|
|
65
54
|
return (
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
55
|
+
<>
|
56
|
+
<div style={{ maxHeight: "20rem", overflow: "auto", margin: "2rem", display: "flex" }}>
|
57
|
+
<DataTable {...table1} onRowSelection={select} outlined />
|
58
|
+
</div>
|
59
|
+
<div style={{ maxHeight: "20rem", overflow: "auto", margin: "2rem" }}>
|
60
|
+
<DataTable {...table1} onRowSelection={select} onCheckAll={checkAll} />
|
61
|
+
</div>
|
62
|
+
</>
|
71
63
|
)
|
72
64
|
}
|
package/src/html/textfield.js
CHANGED
@@ -52,7 +52,7 @@ export const TextField = (props) => {
|
|
52
52
|
const labelTxt = <Text>{label}</Text>
|
53
53
|
|
54
54
|
return (
|
55
|
-
<div className={`${style}`} onClick={onClick}>
|
55
|
+
<div className={`${style} ${id}`} onClick={onClick}>
|
56
56
|
<input id={id} type={type} placeholder={placeholder} value={value} required onChange={change} onKeyDown={onKeyPress} onFocus={focus} onBlur={blur} readOnly={readOnly} />
|
57
57
|
{canClear && value && value.length > 0 ? <Icon icon="close" clickable size="small" action={clear} /> : null}
|
58
58
|
<span className="bar"></span>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Tree, TreeNode, TreeItem } from './tree';
|
3
|
+
|
4
|
+
export const TreeTest = (prop) => {
|
5
|
+
|
6
|
+
const papers = []
|
7
|
+
|
8
|
+
function groupBy(items, by) {
|
9
|
+
const itemsMap = items.reduce(
|
10
|
+
(entryMap, e) => entryMap.set(e[by], [...entryMap.get(e[by]) || [], e]),
|
11
|
+
new Map()
|
12
|
+
);
|
13
|
+
const groups = (Array.from(itemsMap).map(([name, items]) => ({ name, items })))
|
14
|
+
return groups
|
15
|
+
}
|
16
|
+
|
17
|
+
const items = papers.filter(paper => {
|
18
|
+
return !search || search === '' ? true :
|
19
|
+
paper.paper.toUpperCase().indexOf(search.toUpperCase()) >= 0
|
20
|
+
|| `${paper.width}x${paper.height}`.toUpperCase().indexOf(search.toUpperCase()) >= 0
|
21
|
+
|| `${paper.grammage}`.toUpperCase().indexOf(search.toUpperCase()) >= 0
|
22
|
+
})
|
23
|
+
|
24
|
+
|
25
|
+
return (
|
26
|
+
<>
|
27
|
+
<Tree key={`tree`}>
|
28
|
+
{groupBy(items, 'type').map(types => (
|
29
|
+
<TreeNode open={expanded} icon="print" label={types.name}>
|
30
|
+
{groupBy(types.items, 'family').map(family => (
|
31
|
+
<TreeNode open={true} icon="network_check" label={`${group.name} grs.`}>
|
32
|
+
{group.items.map(paper => (
|
33
|
+
<TreeItem icon="aspect_ratio" label={`${paper.width}x${paper.height}`} onSelect={() => select(paper)} />
|
34
|
+
))}
|
35
|
+
</TreeNode>
|
36
|
+
))}
|
37
|
+
</TreeNode>
|
38
|
+
|
39
|
+
))}
|
40
|
+
</Tree>
|
41
|
+
</>
|
42
|
+
)
|
43
|
+
}
|