ywana-core8 0.0.536 → 0.0.539
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 +19 -3
- package/dist/index.cjs +218 -36
- 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 +218 -36
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +218 -36
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/CollectionPage.css +1 -19
- package/src/domain/CollectionPage.js +33 -11
- 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 -7
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
|
@@ -4916,6 +5073,7 @@ var CollectionPage = function CollectionPage(props) {
|
|
4916
5073
|
canFilter = _props$canFilter === void 0 ? false : _props$canFilter,
|
4917
5074
|
_props$canAdd = props.canAdd,
|
4918
5075
|
canAdd = _props$canAdd === void 0 ? false : _props$canAdd,
|
5076
|
+
searchBy = props.searchBy,
|
4919
5077
|
_props$autosave = props.autosave,
|
4920
5078
|
autosave = _props$autosave === void 0 ? false : _props$autosave,
|
4921
5079
|
_props$delay = props.delay,
|
@@ -4993,10 +5151,12 @@ var CollectionPage = function CollectionPage(props) {
|
|
4993
5151
|
icon: icon,
|
4994
5152
|
levels: levels,
|
4995
5153
|
onSelect: onSelect,
|
4996
|
-
sorter: sorter
|
5154
|
+
sorter: sorter,
|
5155
|
+
searchBy: searchBy
|
4997
5156
|
}) : /*#__PURE__*/React.createElement(CollectionList, {
|
4998
5157
|
groupBy: groupBy,
|
4999
|
-
onSelect: onSelect
|
5158
|
+
onSelect: onSelect,
|
5159
|
+
searchBy: searchBy
|
5000
5160
|
})), /*#__PURE__*/React.createElement("main", {
|
5001
5161
|
key: id,
|
5002
5162
|
className: "collection-page " + className
|
@@ -5086,7 +5246,9 @@ var CollectionList = function CollectionList(props) {
|
|
5086
5246
|
};
|
5087
5247
|
|
5088
5248
|
var groupBy = props.groupBy,
|
5089
|
-
onSelect = props.onSelect
|
5249
|
+
onSelect = props.onSelect,
|
5250
|
+
_props$searchBy = props.searchBy,
|
5251
|
+
searchBy = _props$searchBy === void 0 ? [] : _props$searchBy;
|
5090
5252
|
|
5091
5253
|
var _useContext2 = useContext(PageContext),
|
5092
5254
|
pageContext = _useContext2[0],
|
@@ -5104,13 +5266,22 @@ var CollectionList = function CollectionList(props) {
|
|
5104
5266
|
setPageContext(Object.assign({}, pageContext));
|
5105
5267
|
}
|
5106
5268
|
|
5107
|
-
function
|
5269
|
+
function changeSearch(id, value) {
|
5108
5270
|
setFilter(value);
|
5109
5271
|
}
|
5110
5272
|
|
5111
|
-
|
5112
|
-
|
5113
|
-
|
5273
|
+
function search() {
|
5274
|
+
var items = filter ? all.filter(function (item) {
|
5275
|
+
var result = searchBy.some(function (fieldName) {
|
5276
|
+
var value = item[fieldName];
|
5277
|
+
return value ? value.indexOf(filter.toUpperCase()) >= 0 : false;
|
5278
|
+
});
|
5279
|
+
return result;
|
5280
|
+
}) : all;
|
5281
|
+
return items;
|
5282
|
+
}
|
5283
|
+
|
5284
|
+
var items = search();
|
5114
5285
|
var items2 = items.map(function (content) {
|
5115
5286
|
return {
|
5116
5287
|
id: content.id,
|
@@ -5129,7 +5300,7 @@ var CollectionList = function CollectionList(props) {
|
|
5129
5300
|
}, /*#__PURE__*/React.createElement(TextField, {
|
5130
5301
|
icon: "search",
|
5131
5302
|
label: "Search",
|
5132
|
-
onChange:
|
5303
|
+
onChange: changeSearch,
|
5133
5304
|
outlined: true,
|
5134
5305
|
className: "search-box"
|
5135
5306
|
}))));
|
@@ -5156,7 +5327,9 @@ var CollectionTree = function CollectionTree(props) {
|
|
5156
5327
|
icon = _props$icon === void 0 ? "description" : _props$icon,
|
5157
5328
|
levels = props.levels,
|
5158
5329
|
onSelect = props.onSelect,
|
5159
|
-
sorter = props.sorter
|
5330
|
+
sorter = props.sorter,
|
5331
|
+
_props$searchBy2 = props.searchBy,
|
5332
|
+
searchBy = _props$searchBy2 === void 0 ? [] : _props$searchBy2;
|
5160
5333
|
|
5161
5334
|
var _useContext3 = useContext(PageContext),
|
5162
5335
|
pageContext = _useContext3[0],
|
@@ -5174,7 +5347,7 @@ var CollectionTree = function CollectionTree(props) {
|
|
5174
5347
|
setPageContext(Object.assign({}, pageContext));
|
5175
5348
|
}
|
5176
5349
|
|
5177
|
-
function
|
5350
|
+
function changeSearch(id, value) {
|
5178
5351
|
setFilter(value);
|
5179
5352
|
}
|
5180
5353
|
|
@@ -5228,17 +5401,26 @@ var CollectionTree = function CollectionTree(props) {
|
|
5228
5401
|
});
|
5229
5402
|
}
|
5230
5403
|
|
5231
|
-
|
5232
|
-
|
5233
|
-
|
5234
|
-
|
5404
|
+
function search() {
|
5405
|
+
var items = filter ? all.filter(function (item) {
|
5406
|
+
var result = searchBy.some(function (fieldName) {
|
5407
|
+
var value = item[fieldName];
|
5408
|
+
return value ? value.indexOf(filter.toUpperCase()) >= 0 : false;
|
5409
|
+
});
|
5410
|
+
return result;
|
5411
|
+
}) : all;
|
5412
|
+
return items;
|
5413
|
+
}
|
5414
|
+
|
5415
|
+
var items = search();
|
5416
|
+
var items2 = sorter ? sorter(items) : items;
|
5235
5417
|
var nodes = generateNodes(levels, items2);
|
5236
5418
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(Tree, null, renderNodes(nodes))), /*#__PURE__*/React.createElement("footer", null, /*#__PURE__*/React.createElement("div", {
|
5237
5419
|
className: "search-box"
|
5238
5420
|
}, /*#__PURE__*/React.createElement(TextField, {
|
5239
5421
|
icon: "search",
|
5240
5422
|
label: "Search",
|
5241
|
-
onChange:
|
5423
|
+
onChange: changeSearch,
|
5242
5424
|
outlined: true,
|
5243
5425
|
className: "search-box"
|
5244
5426
|
}))));
|