ywana-core8 0.1.72 → 0.1.73
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 +17 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +17 -5
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +17 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/ContentEditor.js +17 -5
- package/src/domain/ContentEditor.test.js +10 -1
package/package.json
CHANGED
@@ -430,6 +430,12 @@ export const CollectionEditor = ({ field, value = [], onChange, onReload }) => {
|
|
430
430
|
}
|
431
431
|
}
|
432
432
|
|
433
|
+
function changeItem(index, fieldID, newValue) {
|
434
|
+
const next = value.slice()
|
435
|
+
next[index][fieldID] = newValue
|
436
|
+
onChange(id, next)
|
437
|
+
}
|
438
|
+
|
433
439
|
function reload() {
|
434
440
|
if (onReload) onReload()
|
435
441
|
}
|
@@ -440,7 +446,7 @@ export const CollectionEditor = ({ field, value = [], onChange, onReload }) => {
|
|
440
446
|
Renderer ?
|
441
447
|
<Renderer field={field} value={value} onRemove={remove} onChange={onChange} onReload={reload} />
|
442
448
|
// : <DataTable {...table} editable={editable} />
|
443
|
-
: <TableEditor icon={"info"} title={label} data={value} schema={item} groupBy={groupBy} canDelete={true} remove={remove} />
|
449
|
+
: <TableEditor icon={"info"} title={label} data={value} schema={item} groupBy={groupBy} canDelete={true} remove={remove} onChange={changeItem} />
|
444
450
|
|
445
451
|
}
|
446
452
|
<footer>
|
@@ -496,9 +502,13 @@ const CollectionAdder = ({ item, onAdd }) => {
|
|
496
502
|
*/
|
497
503
|
const TableEditor = (props) => {
|
498
504
|
|
499
|
-
const { data = [], icon, title, schema, editable, canDelete, remove, filter, actions, className } = props
|
505
|
+
const { data = [], icon, title, schema, editable, canDelete, remove, filter, actions, className, onChange } = props
|
500
506
|
const [groupBy, setGroupBy] = useState(props.groupBy)
|
501
507
|
|
508
|
+
function change(rowID,fieldID,value) {
|
509
|
+
if (onChange) onChange(rowID, fieldID, value)
|
510
|
+
}
|
511
|
+
|
502
512
|
function changeGroup(id, value) {
|
503
513
|
setGroupBy(value)
|
504
514
|
}
|
@@ -562,13 +572,15 @@ const TableEditor = (props) => {
|
|
562
572
|
}),
|
563
573
|
rows: groups[groupName]
|
564
574
|
.map((item, index) => {
|
565
|
-
|
575
|
+
const row = Object.assign({}, item)
|
576
|
+
if (!row.id) row.id = index
|
577
|
+
row.actions = actions ? actions.map(action => {
|
566
578
|
return action.filter ?
|
567
579
|
action.filter(item) ? <Icon icon={action.icon} clickable size="small" action={() => run(action, item)} /> : null
|
568
580
|
: <Icon icon={action.icon} clickable size="small" action={() => run(action, item)} />
|
569
581
|
}) : []
|
570
|
-
if (canDelete)
|
571
|
-
return
|
582
|
+
if (canDelete) row.actions.push(<Icon icon="delete" size="small" clickable action={() => remove(index)} />)
|
583
|
+
return row
|
572
584
|
})
|
573
585
|
}
|
574
586
|
table.columns.push({ id: "actions" })
|
@@ -10,6 +10,10 @@ function buildTokenOptions() {
|
|
10
10
|
{label: "Thressse", value: 3 },
|
11
11
|
]
|
12
12
|
}
|
13
|
+
export const OPTION = {
|
14
|
+
label : { id: "label" , required: true , type: TYPES.STRING, column: true, label: "Label" },
|
15
|
+
value : { id: "value" , required: true , type: TYPES.STRING, column: true, label: "Value", editable: true },
|
16
|
+
}
|
13
17
|
|
14
18
|
const schema = {
|
15
19
|
name : { id: "name" , type: TYPES.STRING, format: FORMATS.NONE , required: true, editable: false, label: "Name" , defValue: "John" },
|
@@ -19,11 +23,16 @@ const schema = {
|
|
19
23
|
field4: { id: "field4", type: TYPES.STRING, format: FORMATS.COLOR , required: true, editable: true , label: "Color" },
|
20
24
|
field5: { id: "field5", type: TYPES.STRING, format: FORMATS.TOKENS, required: true, editable: true , label: "field5" , multivalue: true },
|
21
25
|
field6: { id: "field6", type: TYPES.STRING, format: FORMATS.PASSWORD, required: true, editable: true , label: "Password" },
|
26
|
+
options : { id: "options" , editable: false, type: TYPES.ARRAY , item: OPTION , label: "Options" },
|
22
27
|
|
23
28
|
}
|
24
29
|
|
25
30
|
const value = {
|
26
|
-
|
31
|
+
options: [
|
32
|
+
{ label: "One", value: 1 },
|
33
|
+
{ label: "Two", value: 2 },
|
34
|
+
{ label: "Thressse", value: 3 },
|
35
|
+
],
|
27
36
|
}
|
28
37
|
|
29
38
|
const ContentEditorTest = (prop) => {
|