ywana-core8 0.0.95 → 0.0.99

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.
@@ -476,10 +476,6 @@ function _extends() {
476
476
  return _extends.apply(this, arguments);
477
477
  }
478
478
 
479
- function _readOnlyError(name) {
480
- throw new TypeError("\"" + name + "\" is read-only");
481
- }
482
-
483
479
  /**
484
480
  * List
485
481
  */
@@ -993,6 +989,7 @@ var DataTable = function DataTable(props) {
993
989
  rows = _props$rows === void 0 ? [] : _props$rows,
994
990
  onRowSelection = props.onRowSelection,
995
991
  onSort = props.onSort,
992
+ onCheckAll = props.onCheckAll,
996
993
  editable = props.editable,
997
994
  outlined = props.outlined;
998
995
 
@@ -1048,13 +1045,23 @@ var DataTable = function DataTable(props) {
1048
1045
  if (onSort) onSort(dragged, dropped);
1049
1046
  }
1050
1047
 
1048
+ function checkAll() {
1049
+ var ids = rows.map(function (row) {
1050
+ return row.id;
1051
+ });
1052
+ if (onCheckAll) onCheckAll(ids);
1053
+ }
1054
+
1051
1055
  var style = outlined ? "outlined" : "";
1052
1056
  return /*#__PURE__*/React.createElement("div", {
1053
1057
  className: "datatable8 " + style
1054
1058
  }, /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, columns.map(function (_ref) {
1055
- var label = _ref.label,
1059
+ var id = _ref.id,
1060
+ label = _ref.label,
1056
1061
  sortable = _ref.sortable;
1057
- return /*#__PURE__*/React.createElement("th", null, /*#__PURE__*/React.createElement(Text, null, label), sortable ? /*#__PURE__*/React.createElement(Icon, {
1062
+ return /*#__PURE__*/React.createElement("th", null, id === "checked" ? /*#__PURE__*/React.createElement(CheckBox, {
1063
+ action: checkAll
1064
+ }) : /*#__PURE__*/React.createElement(Text, null, label), sortable ? /*#__PURE__*/React.createElement(Icon, {
1058
1065
  icon: "arrow_up",
1059
1066
  size: "small",
1060
1067
  clickable: true
@@ -1132,7 +1139,15 @@ var DataTableCell = function DataTableCell(_ref2) {
1132
1139
  _onChange = column.onChange,
1133
1140
  options = column.options;
1134
1141
 
1135
- if (_readOnlyError("id")) ; else if (editable && _onChange) {
1142
+ if (id === "checked") {
1143
+ return /*#__PURE__*/React.createElement(CheckBox, {
1144
+ id: id,
1145
+ value: cell,
1146
+ onChange: function onChange(id, value) {
1147
+ return _onChange(row.id, id, value);
1148
+ }
1149
+ });
1150
+ } else if (editable && _onChange) {
1136
1151
  switch (type) {
1137
1152
  case "ICON":
1138
1153
  return /*#__PURE__*/React.createElement(Icon, {
@@ -4282,6 +4297,19 @@ var TableFilters = function TableFilters(props) {
4282
4297
 
4283
4298
 
4284
4299
  var TableEditor = function TableEditor(props) {
4300
+ var check = function check(ids) {
4301
+ if (ids === void 0) {
4302
+ ids = [];
4303
+ }
4304
+
4305
+ try {
4306
+ console.log("check: ", ids);
4307
+ return Promise.resolve();
4308
+ } catch (e) {
4309
+ return Promise.reject(e);
4310
+ }
4311
+ };
4312
+
4285
4313
  var select = function select(row, event) {
4286
4314
  try {
4287
4315
  clear();
@@ -4424,7 +4452,8 @@ var TableEditor = function TableEditor(props) {
4424
4452
  className: "size"
4425
4453
  }, groupSize)), /*#__PURE__*/React.createElement(DataTable, _extends({}, table, {
4426
4454
  onRowSelection: select,
4427
- editable: editable
4455
+ editable: editable,
4456
+ onCheckAll: check
4428
4457
  })));
4429
4458
  });
4430
4459
  }