ywana-core8 0.0.100 → 0.0.104

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.
@@ -978,10 +978,14 @@ var DropDown = function DropDown(props) {
978
978
  }) : null)) : null);
979
979
  };
980
980
 
981
+ var isFunction$1 = function isFunction(value) {
982
+ return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
983
+ };
981
984
  /**
982
985
  * DataTable
983
986
  */
984
987
 
988
+
985
989
  var DataTable = function DataTable(props) {
986
990
  var _props$columns = props.columns,
987
991
  columns = _props$columns === void 0 ? [] : _props$columns,
@@ -1045,11 +1049,11 @@ var DataTable = function DataTable(props) {
1045
1049
  if (onSort) onSort(dragged, dropped);
1046
1050
  }
1047
1051
 
1048
- function checkAll() {
1052
+ function checkAll(id, value) {
1049
1053
  var ids = rows.map(function (row) {
1050
1054
  return row.id;
1051
1055
  });
1052
- if (onCheckAll) onCheckAll(ids);
1056
+ if (onCheckAll) onCheckAll(ids, value);
1053
1057
  }
1054
1058
 
1055
1059
  var style = outlined ? "outlined" : "";
@@ -1093,11 +1097,6 @@ var DataTableRow = function DataTableRow(props) {
1093
1097
  toggleInfo = _useState2[1];
1094
1098
 
1095
1099
  var infoIcon = isInfoOpen ? 'expand_more' : 'expand_less';
1096
-
1097
- var isFunction = function isFunction(value) {
1098
- return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
1099
- };
1100
-
1101
1100
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("tr", {
1102
1101
  onClick: function onClick(ev) {
1103
1102
  return onSelect(row, ev);
@@ -1117,7 +1116,7 @@ var DataTableRow = function DataTableRow(props) {
1117
1116
  }
1118
1117
  }) : null), row.info && isInfoOpen ? /*#__PURE__*/React.createElement("tr", {
1119
1118
  className: "table-row-info"
1120
- }, isFunction(row.info) ? row.info() : row.info) : null);
1119
+ }, isFunction$1(row.info) ? row.info() : row.info) : null);
1121
1120
  };
1122
1121
  /**
1123
1122
  * DataTable Cell
@@ -4297,13 +4296,11 @@ var TableFilters = function TableFilters(props) {
4297
4296
 
4298
4297
 
4299
4298
  var TableEditor = function TableEditor(props) {
4300
- var check = function check(ids) {
4301
- if (ids === void 0) {
4302
- ids = [];
4303
- }
4304
-
4299
+ var check = function check(id, value) {
4305
4300
  try {
4306
- console.log("check: ", ids);
4301
+ var ids = Array.isArray(id) ? id : [id];
4302
+ pageContext.check(ids, value);
4303
+ setPageContext(Object.assign({}, pageContext));
4307
4304
  return Promise.resolve();
4308
4305
  } catch (e) {
4309
4306
  return Promise.reject(e);
@@ -4407,11 +4404,14 @@ var TableEditor = function TableEditor(props) {
4407
4404
  id: field.id,
4408
4405
  label: field.label,
4409
4406
  type: field.type,
4410
- onChange: field.editable ? change : null,
4407
+ onChange: field.id === "checked" ? check : field.editable ? change : null,
4408
+
4409
+ /* checked has it´s own handler */
4411
4410
  options: options
4412
4411
  };
4413
4412
  }),
4414
4413
  rows: groups[groupName].map(function (item) {
4414
+ item.checked = pageContext.checked.has(item.id);
4415
4415
  item.actions = actions ? actions.map(function (_action) {
4416
4416
  return _action.filter ? _action.filter(item) ? /*#__PURE__*/React.createElement(Icon, {
4417
4417
  icon: _action.icon,
@@ -4469,6 +4469,7 @@ var TableEditor = function TableEditor(props) {
4469
4469
  });
4470
4470
  }
4471
4471
 
4472
+ console.log('table page checked', pageContext.checked);
4472
4473
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Header, {
4473
4474
  icon: icon,
4474
4475
  title: /*#__PURE__*/React.createElement(Text, null, title)
@@ -4491,6 +4492,7 @@ var TableContext = function TableContext(url, field) {
4491
4492
  var API = TableAPI(url);
4492
4493
  return {
4493
4494
  all: [],
4495
+ checked: new Set(),
4494
4496
  selected: null,
4495
4497
  filters: {},
4496
4498
  load: function load(filter) {
@@ -4515,6 +4517,23 @@ var TableContext = function TableContext(url, field) {
4515
4517
  return Promise.reject(e);
4516
4518
  }
4517
4519
  },
4520
+ check: function check(ids, isChecked) {
4521
+ var _this3 = this;
4522
+
4523
+ if (isChecked === void 0) {
4524
+ isChecked = true;
4525
+ }
4526
+
4527
+ if (isChecked) {
4528
+ ids.forEach(function (id) {
4529
+ return _this3.checked.add(id);
4530
+ });
4531
+ } else {
4532
+ ids.forEach(function (id) {
4533
+ return _this3.checked["delete"](id);
4534
+ });
4535
+ }
4536
+ },
4518
4537
  select: function select(id) {
4519
4538
  var result = this.all.find(function (item) {
4520
4539
  return item.id === id;
@@ -4526,11 +4545,11 @@ var TableContext = function TableContext(url, field) {
4526
4545
  },
4527
4546
  create: function create(form) {
4528
4547
  try {
4529
- var _this4 = this;
4548
+ var _this5 = this;
4530
4549
 
4531
4550
  var _temp4 = _catch(function () {
4532
4551
  return Promise.resolve(API.create(form)).then(function () {
4533
- return Promise.resolve(_this4.load()).then(function () {});
4552
+ return Promise.resolve(_this5.load()).then(function () {});
4534
4553
  });
4535
4554
  }, function (error) {
4536
4555
  console.log(error);
@@ -4543,11 +4562,11 @@ var TableContext = function TableContext(url, field) {
4543
4562
  },
4544
4563
  update: function update(form) {
4545
4564
  try {
4546
- var _this6 = this;
4565
+ var _this7 = this;
4547
4566
 
4548
4567
  var _temp6 = _catch(function () {
4549
4568
  return Promise.resolve(API.update(form)).then(function () {
4550
- return Promise.resolve(_this6.load()).then(function () {});
4569
+ return Promise.resolve(_this7.load()).then(function () {});
4551
4570
  });
4552
4571
  }, function (error) {
4553
4572
  console.log(error);
@@ -4560,11 +4579,11 @@ var TableContext = function TableContext(url, field) {
4560
4579
  },
4561
4580
  remove: function remove(id) {
4562
4581
  try {
4563
- var _this8 = this;
4582
+ var _this9 = this;
4564
4583
 
4565
4584
  var _temp8 = _catch(function () {
4566
4585
  return Promise.resolve(API.remove(id)).then(function () {
4567
- return Promise.resolve(_this8.load()).then(function () {});
4586
+ return Promise.resolve(_this9.load()).then(function () {});
4568
4587
  });
4569
4588
  }, function (error) {
4570
4589
  console.log(error);