ywana-core8 0.0.537 → 0.0.538
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/db/db.json +17 -1
- package/dist/index.cjs +178 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +66 -59
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +178 -21
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +178 -21
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.css +1 -19
- package/src/domain/ContentEditor.css +47 -22
- package/src/domain/ContentEditor.js +147 -41
- package/src/domain/TablePage.js +1 -0
- package/src/site/site.test.js +12 -9
package/dist/index.modern.js
CHANGED
@@ -4044,7 +4044,7 @@ var TabbedContentEditor = function TabbedContentEditor(_ref2) {
|
|
4044
4044
|
fields = section.fields;
|
4045
4045
|
return /*#__PURE__*/React.createElement("section", {
|
4046
4046
|
key: title
|
4047
|
-
},
|
4047
|
+
}, grouped ? group(section).map(function (group) {
|
4048
4048
|
return /*#__PURE__*/React.createElement(Fragment, null, group.name.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
4049
4049
|
className: "group-caption"
|
4050
4050
|
}, group.name) : null, group.fields.filter(function (field) {
|
@@ -4070,7 +4070,7 @@ var TabbedContentEditor = function TabbedContentEditor(_ref2) {
|
|
4070
4070
|
onChange: change,
|
4071
4071
|
content: content
|
4072
4072
|
});
|
4073
|
-
}))
|
4073
|
+
}));
|
4074
4074
|
})));
|
4075
4075
|
};
|
4076
4076
|
/**
|
@@ -4533,9 +4533,7 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4533
4533
|
Feeder = field.Feeder,
|
4534
4534
|
Renderer = field.Renderer,
|
4535
4535
|
_field$Adder = field.Adder,
|
4536
|
-
Adder = _field$Adder === void 0 ? true : _field$Adder
|
4537
|
-
_field$editable3 = field.editable,
|
4538
|
-
editable = _field$editable3 === void 0 ? true : _field$editable3;
|
4536
|
+
Adder = _field$Adder === void 0 ? true : _field$Adder;
|
4539
4537
|
|
4540
4538
|
function add(rows) {
|
4541
4539
|
if (onChange) {
|
@@ -4561,7 +4559,9 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4561
4559
|
}
|
4562
4560
|
}
|
4563
4561
|
|
4564
|
-
var columns = Object.values(item).
|
4562
|
+
var columns = Object.values(item).filter(function (field) {
|
4563
|
+
return field.column === true;
|
4564
|
+
}).map(function (item) {
|
4565
4565
|
return _extends({}, item, {
|
4566
4566
|
onChange: change
|
4567
4567
|
});
|
@@ -4570,7 +4570,7 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4570
4570
|
id: 'actions',
|
4571
4571
|
label: 'Actions'
|
4572
4572
|
});
|
4573
|
-
|
4573
|
+
value.map(function (item, index) {
|
4574
4574
|
return _extends({}, item, {
|
4575
4575
|
id: index,
|
4576
4576
|
actions: [/*#__PURE__*/React.createElement(Icon, {
|
@@ -4583,26 +4583,23 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4583
4583
|
})]
|
4584
4584
|
});
|
4585
4585
|
});
|
4586
|
-
var table = {
|
4587
|
-
columns: columns,
|
4588
|
-
rows: rows
|
4589
|
-
};
|
4590
4586
|
return /*#__PURE__*/React.createElement("div", {
|
4591
4587
|
className: "collection-editor"
|
4592
|
-
},
|
4593
|
-
use: "caption"
|
4594
|
-
}, label), /*#__PURE__*/React.createElement("div", {
|
4595
|
-
className: "actions"
|
4596
|
-
}, Feeder ? /*#__PURE__*/React.createElement(Feeder, {
|
4597
|
-
onAdd: add
|
4598
|
-
}) : null)), Renderer ? /*#__PURE__*/React.createElement(Renderer, {
|
4588
|
+
}, Renderer ? /*#__PURE__*/React.createElement(Renderer, {
|
4599
4589
|
field: field,
|
4600
4590
|
value: value,
|
4601
4591
|
onRemove: remove,
|
4602
4592
|
onChange: onChange
|
4603
|
-
}) :
|
4604
|
-
|
4605
|
-
|
4593
|
+
}) // : <DataTable {...table} editable={editable} />
|
4594
|
+
: /*#__PURE__*/React.createElement(TableEditor$2, {
|
4595
|
+
icon: "info",
|
4596
|
+
title: label,
|
4597
|
+
data: value,
|
4598
|
+
schema: item,
|
4599
|
+
groupBy: "field1"
|
4600
|
+
}), /*#__PURE__*/React.createElement("footer", null, Feeder ? /*#__PURE__*/React.createElement(Feeder, {
|
4601
|
+
onAdd: add
|
4602
|
+
}) : null, Adder ? /*#__PURE__*/React.createElement(CollectionAdder, {
|
4606
4603
|
item: item,
|
4607
4604
|
onAdd: add
|
4608
4605
|
}) : null));
|
@@ -4677,6 +4674,166 @@ var CollectionAdder = function CollectionAdder(_ref11) {
|
|
4677
4674
|
action: toggle
|
4678
4675
|
}));
|
4679
4676
|
};
|
4677
|
+
/**
|
4678
|
+
* Table Editor
|
4679
|
+
*/
|
4680
|
+
|
4681
|
+
|
4682
|
+
var TableEditor$2 = function TableEditor(props) {
|
4683
|
+
var select = function select(row) {
|
4684
|
+
try {
|
4685
|
+
if (onSelect) onSelect(row.id);
|
4686
|
+
return Promise.resolve();
|
4687
|
+
} catch (e) {
|
4688
|
+
return Promise.reject(e);
|
4689
|
+
}
|
4690
|
+
};
|
4691
|
+
|
4692
|
+
var _props$data = props.data,
|
4693
|
+
data = _props$data === void 0 ? [] : _props$data,
|
4694
|
+
icon = props.icon,
|
4695
|
+
title = props.title,
|
4696
|
+
schema = props.schema,
|
4697
|
+
editable = props.editable,
|
4698
|
+
canDelete = props.canDelete,
|
4699
|
+
filter = props.filter,
|
4700
|
+
actions = props.actions,
|
4701
|
+
className = props.className;
|
4702
|
+
|
4703
|
+
var _useState5 = useState(props.groupBy),
|
4704
|
+
groupBy = _useState5[0],
|
4705
|
+
setGroupBy = _useState5[1];
|
4706
|
+
|
4707
|
+
function changeGroup(id, value) {
|
4708
|
+
setGroupBy(value);
|
4709
|
+
}
|
4710
|
+
|
4711
|
+
function renderGroupLabel(groupName) {
|
4712
|
+
var grouper = schema[groupBy];
|
4713
|
+
if (!groupName || !grouper) return "";
|
4714
|
+
|
4715
|
+
if (grouper.options) {
|
4716
|
+
var options = CHECK['isFunction'](grouper.options) ? grouper.options() : grouper.options;
|
4717
|
+
var option = options.find(function (option) {
|
4718
|
+
return option.value === groupName;
|
4719
|
+
});
|
4720
|
+
return option ? option.label : groupName;
|
4721
|
+
} else {
|
4722
|
+
return groupName;
|
4723
|
+
}
|
4724
|
+
}
|
4725
|
+
|
4726
|
+
function renderGroups() {
|
4727
|
+
var items = filter ? filter(data) : data;
|
4728
|
+
if (items.length === 0) return /*#__PURE__*/React.createElement("div", {
|
4729
|
+
className: "empty-message"
|
4730
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
4731
|
+
icon: "search_off"
|
4732
|
+
}), /*#__PURE__*/React.createElement(Text, null, "No Result Found"));
|
4733
|
+
var groups = items.reduce(function (groups, item) {
|
4734
|
+
var groupName = item[groupBy];
|
4735
|
+
var group = groups[groupName];
|
4736
|
+
if (!group) groups[groupName] = [];
|
4737
|
+
groups[groupName].push(item);
|
4738
|
+
return groups;
|
4739
|
+
}, {});
|
4740
|
+
return Object.keys(groups).map(function (groupName) {
|
4741
|
+
var table = {
|
4742
|
+
columns: Object.values(schema).filter(function (field) {
|
4743
|
+
return field.column === true;
|
4744
|
+
}).map(function (field) {
|
4745
|
+
var options = field.options;
|
4746
|
+
|
4747
|
+
if (options && typeof options == 'function') {
|
4748
|
+
options = options();
|
4749
|
+
}
|
4750
|
+
|
4751
|
+
return {
|
4752
|
+
id: field.id,
|
4753
|
+
label: field.label,
|
4754
|
+
type: field.type,
|
4755
|
+
format: field.format,
|
4756
|
+
item: field.item ? field.item : [],
|
4757
|
+
onChange: field.id === "checked" ? checkOne : field.editable ? change : null,
|
4758
|
+
|
4759
|
+
/* checked has it´s own handler */
|
4760
|
+
options: options
|
4761
|
+
};
|
4762
|
+
}),
|
4763
|
+
rows: groups[groupName].map(function (item) {
|
4764
|
+
item.actions = actions ? actions.map(function (_action) {
|
4765
|
+
return _action.filter ? _action.filter(item) ? /*#__PURE__*/React.createElement(Icon, {
|
4766
|
+
icon: _action.icon,
|
4767
|
+
clickable: true,
|
4768
|
+
size: "small",
|
4769
|
+
action: function action() {
|
4770
|
+
return run(_action, item);
|
4771
|
+
}
|
4772
|
+
}) : null : /*#__PURE__*/React.createElement(Icon, {
|
4773
|
+
icon: _action.icon,
|
4774
|
+
clickable: true,
|
4775
|
+
size: "small",
|
4776
|
+
action: function action() {
|
4777
|
+
return run(_action, item);
|
4778
|
+
}
|
4779
|
+
});
|
4780
|
+
}) : [];
|
4781
|
+
if (canDelete) item.actions.push( /*#__PURE__*/React.createElement(Icon, {
|
4782
|
+
icon: "delete",
|
4783
|
+
size: "small",
|
4784
|
+
clickable: true,
|
4785
|
+
action: function action() {
|
4786
|
+
return remove(item.id);
|
4787
|
+
}
|
4788
|
+
}));
|
4789
|
+
return item;
|
4790
|
+
})
|
4791
|
+
};
|
4792
|
+
table.columns.push({
|
4793
|
+
id: "actions"
|
4794
|
+
});
|
4795
|
+
var groupSize = groups[groupName].length;
|
4796
|
+
var title = /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", {
|
4797
|
+
className: "size"
|
4798
|
+
}, groupSize), renderGroupLabel(groupName));
|
4799
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
4800
|
+
key: groupName
|
4801
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
4802
|
+
title: title
|
4803
|
+
}, /*#__PURE__*/React.createElement("span", {
|
4804
|
+
className: "size"
|
4805
|
+
}, groupSize)), /*#__PURE__*/React.createElement(DataTable, _extends({}, table, {
|
4806
|
+
onRowSelection: select,
|
4807
|
+
editable: editable,
|
4808
|
+
className: className
|
4809
|
+
})));
|
4810
|
+
});
|
4811
|
+
}
|
4812
|
+
|
4813
|
+
function buildGroupOptions(schema) {
|
4814
|
+
return Object.values(schema).filter(function (field) {
|
4815
|
+
return field.grouper === true;
|
4816
|
+
}).map(function (field) {
|
4817
|
+
return {
|
4818
|
+
label: field.label,
|
4819
|
+
value: field.id
|
4820
|
+
};
|
4821
|
+
});
|
4822
|
+
}
|
4823
|
+
|
4824
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
4825
|
+
icon: icon,
|
4826
|
+
title: /*#__PURE__*/React.createElement(Text, null, title)
|
4827
|
+
}, /*#__PURE__*/React.createElement(DropDown, {
|
4828
|
+
id: "groupBy",
|
4829
|
+
label: "Agrupar Por",
|
4830
|
+
value: groupBy,
|
4831
|
+
options: buildGroupOptions(schema),
|
4832
|
+
onChange: changeGroup
|
4833
|
+
})), /*#__PURE__*/React.createElement("main", {
|
4834
|
+
className: "table-editor"
|
4835
|
+
}, renderGroups()));
|
4836
|
+
};
|
4680
4837
|
|
4681
4838
|
/**
|
4682
4839
|
* Create Content Dialog
|