ywana-core8 0.0.96 → 0.0.100
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 +37 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +37 -4
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +37 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/TablePage.js +5 -1
- package/src/html/table.js +8 -3
package/package.json
CHANGED
package/src/domain/TablePage.js
CHANGED
@@ -224,6 +224,10 @@ const TableEditor = (props) => {
|
|
224
224
|
setPageContext(Object.assign({}, pageContext))
|
225
225
|
}
|
226
226
|
|
227
|
+
async function check(ids = []) {
|
228
|
+
console.log("check: ", ids)
|
229
|
+
}
|
230
|
+
|
227
231
|
function run(action, item) {
|
228
232
|
action.action(item.id, pageContext, async () => {
|
229
233
|
await pageContext.load()
|
@@ -281,7 +285,7 @@ const TableEditor = (props) => {
|
|
281
285
|
<Header title={groupName} >
|
282
286
|
<span className="size">{groupSize}</span>
|
283
287
|
</Header>
|
284
|
-
<DataTable {...table} onRowSelection={select} editable={editable} />
|
288
|
+
<DataTable {...table} onRowSelection={select} editable={editable} onCheckAll={check}/>
|
285
289
|
</Fragment>
|
286
290
|
)
|
287
291
|
})
|
package/src/html/table.js
CHANGED
@@ -10,7 +10,7 @@ import './table.css'
|
|
10
10
|
*/
|
11
11
|
export const DataTable = (props) => {
|
12
12
|
|
13
|
-
const { columns = [], rows = [], onRowSelection, onSort, editable, outlined } = props
|
13
|
+
const { columns = [], rows = [], onRowSelection, onSort, onCheckAll, editable, outlined } = props
|
14
14
|
const [sortDir, setSortDir] = useState({})
|
15
15
|
|
16
16
|
function multiSort(array, sortObject = {}) {
|
@@ -60,6 +60,11 @@ export const DataTable = (props) => {
|
|
60
60
|
if (onSort) onSort(dragged, dropped)
|
61
61
|
}
|
62
62
|
|
63
|
+
function checkAll() {
|
64
|
+
const ids = rows.map(row => row.id)
|
65
|
+
if (onCheckAll) onCheckAll(ids)
|
66
|
+
}
|
67
|
+
|
63
68
|
const style = outlined ? "outlined" : ""
|
64
69
|
return (
|
65
70
|
<div className={`datatable8 ${style}`}>
|
@@ -70,7 +75,7 @@ export const DataTable = (props) => {
|
|
70
75
|
const sort = sortDir[id] ? sortDir[id] : null
|
71
76
|
return (
|
72
77
|
<th>
|
73
|
-
<Text>{label}</Text>
|
78
|
+
{id === "checked" ? <CheckBox onChange={checkAll}/> : <Text>{label}</Text>}
|
74
79
|
{sortable ? <Icon icon="arrow_up" size="small" clickable /> : null}
|
75
80
|
</th>
|
76
81
|
)
|
@@ -122,7 +127,7 @@ const DataTableCell = ({ row, column, cell, editable }) => {
|
|
122
127
|
const render = (type) => {
|
123
128
|
const { id, disabled = false, min, max, onChange, options } = column
|
124
129
|
if (id === "checked") {
|
125
|
-
<CheckBox id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
|
130
|
+
return <CheckBox id={id} value={cell} onChange={(id, value) => onChange(row.id, id, value)} />
|
126
131
|
} else if (editable && onChange) {
|
127
132
|
switch (type) {
|
128
133
|
case "ICON": return <Icon icon={cell} />
|