ywana-core8 0.0.537 → 0.0.540
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 +189 -22
- 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 +189 -22
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +189 -22
- 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/html/tokenfield.js +12 -2
- package/src/site/site.test.js +12 -9
package/dist/index.modern.js
CHANGED
@@ -2057,8 +2057,18 @@ var TokenField = function TokenField(_ref) {
|
|
2057
2057
|
return /*#__PURE__*/React.createElement("div", {
|
2058
2058
|
className: "tokenField"
|
2059
2059
|
}, /*#__PURE__*/React.createElement("label", null, label), tks.map(function (text, index) {
|
2060
|
+
var text2 = text;
|
2061
|
+
|
2062
|
+
if (options) {
|
2063
|
+
var lbl = options.find(function (opt) {
|
2064
|
+
return opt.value == text;
|
2065
|
+
});
|
2066
|
+
if (lbl) text2 = lbl.label;
|
2067
|
+
console.log(text, lbl, text2, options);
|
2068
|
+
}
|
2069
|
+
|
2060
2070
|
return /*#__PURE__*/React.createElement(Token, {
|
2061
|
-
text:
|
2071
|
+
text: text2,
|
2062
2072
|
onDelete: function onDelete() {
|
2063
2073
|
return remove(index);
|
2064
2074
|
}
|
@@ -4044,7 +4054,7 @@ var TabbedContentEditor = function TabbedContentEditor(_ref2) {
|
|
4044
4054
|
fields = section.fields;
|
4045
4055
|
return /*#__PURE__*/React.createElement("section", {
|
4046
4056
|
key: title
|
4047
|
-
},
|
4057
|
+
}, grouped ? group(section).map(function (group) {
|
4048
4058
|
return /*#__PURE__*/React.createElement(Fragment, null, group.name.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
4049
4059
|
className: "group-caption"
|
4050
4060
|
}, group.name) : null, group.fields.filter(function (field) {
|
@@ -4070,7 +4080,7 @@ var TabbedContentEditor = function TabbedContentEditor(_ref2) {
|
|
4070
4080
|
onChange: change,
|
4071
4081
|
content: content
|
4072
4082
|
});
|
4073
|
-
}))
|
4083
|
+
}));
|
4074
4084
|
})));
|
4075
4085
|
};
|
4076
4086
|
/**
|
@@ -4533,9 +4543,7 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4533
4543
|
Feeder = field.Feeder,
|
4534
4544
|
Renderer = field.Renderer,
|
4535
4545
|
_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;
|
4546
|
+
Adder = _field$Adder === void 0 ? true : _field$Adder;
|
4539
4547
|
|
4540
4548
|
function add(rows) {
|
4541
4549
|
if (onChange) {
|
@@ -4561,7 +4569,9 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4561
4569
|
}
|
4562
4570
|
}
|
4563
4571
|
|
4564
|
-
var columns = Object.values(item).
|
4572
|
+
var columns = Object.values(item).filter(function (field) {
|
4573
|
+
return field.column === true;
|
4574
|
+
}).map(function (item) {
|
4565
4575
|
return _extends({}, item, {
|
4566
4576
|
onChange: change
|
4567
4577
|
});
|
@@ -4570,7 +4580,7 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4570
4580
|
id: 'actions',
|
4571
4581
|
label: 'Actions'
|
4572
4582
|
});
|
4573
|
-
|
4583
|
+
value.map(function (item, index) {
|
4574
4584
|
return _extends({}, item, {
|
4575
4585
|
id: index,
|
4576
4586
|
actions: [/*#__PURE__*/React.createElement(Icon, {
|
@@ -4583,26 +4593,23 @@ var CollectionEditor$1 = function CollectionEditor(_ref10) {
|
|
4583
4593
|
})]
|
4584
4594
|
});
|
4585
4595
|
});
|
4586
|
-
var table = {
|
4587
|
-
columns: columns,
|
4588
|
-
rows: rows
|
4589
|
-
};
|
4590
4596
|
return /*#__PURE__*/React.createElement("div", {
|
4591
4597
|
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, {
|
4598
|
+
}, Renderer ? /*#__PURE__*/React.createElement(Renderer, {
|
4599
4599
|
field: field,
|
4600
4600
|
value: value,
|
4601
4601
|
onRemove: remove,
|
4602
4602
|
onChange: onChange
|
4603
|
-
}) :
|
4604
|
-
|
4605
|
-
|
4603
|
+
}) // : <DataTable {...table} editable={editable} />
|
4604
|
+
: /*#__PURE__*/React.createElement(TableEditor$2, {
|
4605
|
+
icon: "info",
|
4606
|
+
title: label,
|
4607
|
+
data: value,
|
4608
|
+
schema: item,
|
4609
|
+
groupBy: "field1"
|
4610
|
+
}), /*#__PURE__*/React.createElement("footer", null, Feeder ? /*#__PURE__*/React.createElement(Feeder, {
|
4611
|
+
onAdd: add
|
4612
|
+
}) : null, Adder ? /*#__PURE__*/React.createElement(CollectionAdder, {
|
4606
4613
|
item: item,
|
4607
4614
|
onAdd: add
|
4608
4615
|
}) : null));
|
@@ -4677,6 +4684,166 @@ var CollectionAdder = function CollectionAdder(_ref11) {
|
|
4677
4684
|
action: toggle
|
4678
4685
|
}));
|
4679
4686
|
};
|
4687
|
+
/**
|
4688
|
+
* Table Editor
|
4689
|
+
*/
|
4690
|
+
|
4691
|
+
|
4692
|
+
var TableEditor$2 = function TableEditor(props) {
|
4693
|
+
var select = function select(row) {
|
4694
|
+
try {
|
4695
|
+
if (onSelect) onSelect(row.id);
|
4696
|
+
return Promise.resolve();
|
4697
|
+
} catch (e) {
|
4698
|
+
return Promise.reject(e);
|
4699
|
+
}
|
4700
|
+
};
|
4701
|
+
|
4702
|
+
var _props$data = props.data,
|
4703
|
+
data = _props$data === void 0 ? [] : _props$data,
|
4704
|
+
icon = props.icon,
|
4705
|
+
title = props.title,
|
4706
|
+
schema = props.schema,
|
4707
|
+
editable = props.editable,
|
4708
|
+
canDelete = props.canDelete,
|
4709
|
+
filter = props.filter,
|
4710
|
+
actions = props.actions,
|
4711
|
+
className = props.className;
|
4712
|
+
|
4713
|
+
var _useState5 = useState(props.groupBy),
|
4714
|
+
groupBy = _useState5[0],
|
4715
|
+
setGroupBy = _useState5[1];
|
4716
|
+
|
4717
|
+
function changeGroup(id, value) {
|
4718
|
+
setGroupBy(value);
|
4719
|
+
}
|
4720
|
+
|
4721
|
+
function renderGroupLabel(groupName) {
|
4722
|
+
var grouper = schema[groupBy];
|
4723
|
+
if (!groupName || !grouper) return "";
|
4724
|
+
|
4725
|
+
if (grouper.options) {
|
4726
|
+
var options = CHECK['isFunction'](grouper.options) ? grouper.options() : grouper.options;
|
4727
|
+
var option = options.find(function (option) {
|
4728
|
+
return option.value === groupName;
|
4729
|
+
});
|
4730
|
+
return option ? option.label : groupName;
|
4731
|
+
} else {
|
4732
|
+
return groupName;
|
4733
|
+
}
|
4734
|
+
}
|
4735
|
+
|
4736
|
+
function renderGroups() {
|
4737
|
+
var items = filter ? filter(data) : data;
|
4738
|
+
if (items.length === 0) return /*#__PURE__*/React.createElement("div", {
|
4739
|
+
className: "empty-message"
|
4740
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
4741
|
+
icon: "search_off"
|
4742
|
+
}), /*#__PURE__*/React.createElement(Text, null, "No Result Found"));
|
4743
|
+
var groups = items.reduce(function (groups, item) {
|
4744
|
+
var groupName = item[groupBy];
|
4745
|
+
var group = groups[groupName];
|
4746
|
+
if (!group) groups[groupName] = [];
|
4747
|
+
groups[groupName].push(item);
|
4748
|
+
return groups;
|
4749
|
+
}, {});
|
4750
|
+
return Object.keys(groups).map(function (groupName) {
|
4751
|
+
var table = {
|
4752
|
+
columns: Object.values(schema).filter(function (field) {
|
4753
|
+
return field.column === true;
|
4754
|
+
}).map(function (field) {
|
4755
|
+
var options = field.options;
|
4756
|
+
|
4757
|
+
if (options && typeof options == 'function') {
|
4758
|
+
options = options();
|
4759
|
+
}
|
4760
|
+
|
4761
|
+
return {
|
4762
|
+
id: field.id,
|
4763
|
+
label: field.label,
|
4764
|
+
type: field.type,
|
4765
|
+
format: field.format,
|
4766
|
+
item: field.item ? field.item : [],
|
4767
|
+
onChange: field.id === "checked" ? checkOne : field.editable ? change : null,
|
4768
|
+
|
4769
|
+
/* checked has it´s own handler */
|
4770
|
+
options: options
|
4771
|
+
};
|
4772
|
+
}),
|
4773
|
+
rows: groups[groupName].map(function (item) {
|
4774
|
+
item.actions = actions ? actions.map(function (_action) {
|
4775
|
+
return _action.filter ? _action.filter(item) ? /*#__PURE__*/React.createElement(Icon, {
|
4776
|
+
icon: _action.icon,
|
4777
|
+
clickable: true,
|
4778
|
+
size: "small",
|
4779
|
+
action: function action() {
|
4780
|
+
return run(_action, item);
|
4781
|
+
}
|
4782
|
+
}) : null : /*#__PURE__*/React.createElement(Icon, {
|
4783
|
+
icon: _action.icon,
|
4784
|
+
clickable: true,
|
4785
|
+
size: "small",
|
4786
|
+
action: function action() {
|
4787
|
+
return run(_action, item);
|
4788
|
+
}
|
4789
|
+
});
|
4790
|
+
}) : [];
|
4791
|
+
if (canDelete) item.actions.push( /*#__PURE__*/React.createElement(Icon, {
|
4792
|
+
icon: "delete",
|
4793
|
+
size: "small",
|
4794
|
+
clickable: true,
|
4795
|
+
action: function action() {
|
4796
|
+
return remove(item.id);
|
4797
|
+
}
|
4798
|
+
}));
|
4799
|
+
return item;
|
4800
|
+
})
|
4801
|
+
};
|
4802
|
+
table.columns.push({
|
4803
|
+
id: "actions"
|
4804
|
+
});
|
4805
|
+
var groupSize = groups[groupName].length;
|
4806
|
+
var title = /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", {
|
4807
|
+
className: "size"
|
4808
|
+
}, groupSize), renderGroupLabel(groupName));
|
4809
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
4810
|
+
key: groupName
|
4811
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
4812
|
+
title: title
|
4813
|
+
}, /*#__PURE__*/React.createElement("span", {
|
4814
|
+
className: "size"
|
4815
|
+
}, groupSize)), /*#__PURE__*/React.createElement(DataTable, _extends({}, table, {
|
4816
|
+
onRowSelection: select,
|
4817
|
+
editable: editable,
|
4818
|
+
className: className
|
4819
|
+
})));
|
4820
|
+
});
|
4821
|
+
}
|
4822
|
+
|
4823
|
+
function buildGroupOptions(schema) {
|
4824
|
+
return Object.values(schema).filter(function (field) {
|
4825
|
+
return field.grouper === true;
|
4826
|
+
}).map(function (field) {
|
4827
|
+
return {
|
4828
|
+
label: field.label,
|
4829
|
+
value: field.id
|
4830
|
+
};
|
4831
|
+
});
|
4832
|
+
}
|
4833
|
+
|
4834
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
4835
|
+
icon: icon,
|
4836
|
+
title: /*#__PURE__*/React.createElement(Text, null, title)
|
4837
|
+
}, /*#__PURE__*/React.createElement(DropDown, {
|
4838
|
+
id: "groupBy",
|
4839
|
+
label: "Agrupar Por",
|
4840
|
+
value: groupBy,
|
4841
|
+
options: buildGroupOptions(schema),
|
4842
|
+
onChange: changeGroup
|
4843
|
+
})), /*#__PURE__*/React.createElement("main", {
|
4844
|
+
className: "table-editor"
|
4845
|
+
}, renderGroups()));
|
4846
|
+
};
|
4680
4847
|
|
4681
4848
|
/**
|
4682
4849
|
* Create Content Dialog
|