ywana-core8 0.0.626 → 0.0.629

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/dist/index.cjs CHANGED
@@ -182,7 +182,8 @@ var Icon = function Icon(_ref) {
182
182
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
183
183
  action = _ref.action,
184
184
  _ref$eventPropagation = _ref.eventPropagation,
185
- eventPropagation = _ref$eventPropagation === void 0 ? false : _ref$eventPropagation;
185
+ eventPropagation = _ref$eventPropagation === void 0 ? false : _ref$eventPropagation,
186
+ className = _ref.className;
186
187
 
187
188
  function click(event) {
188
189
  if (!eventPropagation) {
@@ -195,7 +196,7 @@ var Icon = function Icon(_ref) {
195
196
 
196
197
  var style = disabled ? "disabled" : clickable ? "clickable" : "";
197
198
  return /*#__PURE__*/React__default["default"].createElement("i", {
198
- className: "icon " + size + " " + style + " material-icons",
199
+ className: "icon " + size + " " + style + " " + className + " material-icons",
199
200
  onClick: click
200
201
  }, icon);
201
202
  };
@@ -1448,6 +1449,8 @@ var DropDown = function DropDown(props) {
1448
1449
  readOnly = _props$readOnly3 === void 0 ? false : _props$readOnly3,
1449
1450
  _props$verbose = props.verbose,
1450
1451
  verbose = _props$verbose === void 0 ? true : _props$verbose,
1452
+ _props$editable = props.editable,
1453
+ editable = _props$editable === void 0 ? false : _props$editable,
1451
1454
  onBlur = props.onBlur;
1452
1455
 
1453
1456
  var _useState = React.useState(false),
@@ -1466,7 +1469,8 @@ var DropDown = function DropDown(props) {
1466
1469
 
1467
1470
  var _label = option ? option.label : "";
1468
1471
 
1469
- setLabel(_label);
1472
+ if (editable && _label === "") setLabel(value);
1473
+ if (!editable) setLabel(_label);
1470
1474
  }
1471
1475
  }, [value]);
1472
1476
 
@@ -1474,10 +1478,15 @@ var DropDown = function DropDown(props) {
1474
1478
  if (predictive) {
1475
1479
  setLabel(value);
1476
1480
  } else {
1481
+ console.log('change', id, value);
1477
1482
  if (onChange) onChange(id, value);
1478
1483
  }
1479
1484
  }
1480
1485
 
1486
+ function onFocus() {
1487
+ if (!editable) toggle();
1488
+ }
1489
+
1481
1490
  function toggle() {
1482
1491
  if (site && site.changeFocus) {
1483
1492
  site.changeFocus({
@@ -1528,14 +1537,22 @@ var DropDown = function DropDown(props) {
1528
1537
  }
1529
1538
  }
1530
1539
 
1540
+ var title = editable ? /*#__PURE__*/React__default["default"].createElement("div", {
1541
+ className: "row"
1542
+ }, props.label, /*#__PURE__*/React__default["default"].createElement(Icon, {
1543
+ className: "decorator",
1544
+ icon: "edit",
1545
+ size: "small"
1546
+ })) : props.label;
1531
1547
  return /*#__PURE__*/React__default["default"].createElement("div", {
1532
1548
  className: "dropdown"
1533
1549
  }, /*#__PURE__*/React__default["default"].createElement(TextField, _extends({}, props, {
1534
- onClick: toggle,
1550
+ label: title,
1551
+ onClick: onFocus,
1535
1552
  value: label,
1536
1553
  onChange: change,
1537
1554
  onBlur: blur,
1538
- readOnly: !predictive
1555
+ readOnly: !predictive && !editable
1539
1556
  })), !readOnly ? /*#__PURE__*/React__default["default"].createElement(Icon, {
1540
1557
  icon: "expand_more",
1541
1558
  clickable: true,
@@ -4659,6 +4676,8 @@ var StringEditor = function StringEditor(_ref7) {
4659
4676
  predictive = _field$predictive === void 0 ? false : _field$predictive,
4660
4677
  _field$multivalue = field.multivalue,
4661
4678
  multivalue = _field$multivalue === void 0 ? false : _field$multivalue,
4679
+ _field$freeValue = field.freeValue,
4680
+ freeValue = _field$freeValue === void 0 ? false : _field$freeValue,
4662
4681
  Editor = field.Editor;
4663
4682
 
4664
4683
  function change(id, value) {
@@ -4741,7 +4760,8 @@ var StringEditor = function StringEditor(_ref7) {
4741
4760
  onChange: change,
4742
4761
  options: buildOptions(),
4743
4762
  readOnly: !editable,
4744
- predictive: predictive
4763
+ predictive: predictive,
4764
+ editable: freeValue
4745
4765
  }) : multivalue ? /*#__PURE__*/React__default["default"].createElement(TokenField, {
4746
4766
  id: id,
4747
4767
  label: label,
@@ -5643,6 +5663,8 @@ var CollectionPage = function CollectionPage(props) {
5643
5663
  autosave = _props$autosave === void 0 ? false : _props$autosave,
5644
5664
  _props$delay = props.delay,
5645
5665
  delay = _props$delay === void 0 ? 1000 : _props$delay,
5666
+ _props$patch = props.patch,
5667
+ patch = _props$patch === void 0 ? false : _props$patch,
5646
5668
  groupBy = props.groupBy,
5647
5669
  levels = props.levels,
5648
5670
  sorter = props.sorter,
@@ -5761,7 +5783,8 @@ var CollectionPage = function CollectionPage(props) {
5761
5783
  delay: delay,
5762
5784
  canDelete: canDelete,
5763
5785
  canEdit: canEdit,
5764
- onReload: reloadSelection
5786
+ onReload: reloadSelection,
5787
+ patch: patch
5765
5788
  }), children ? /*#__PURE__*/React__default["default"].createElement("article", null, children) : null, /*#__PURE__*/React__default["default"].createElement("footer", null, footer)));
5766
5789
  };
5767
5790
  var CollectionFilters = function CollectionFilters(props) {
@@ -5868,7 +5891,7 @@ var CollectionList = function CollectionList(props) {
5868
5891
  function search() {
5869
5892
  var items = filter ? all.filter(function (item) {
5870
5893
  var result = searchBy.some(function (fieldName) {
5871
- var value = item[fieldName];
5894
+ var value = item[fieldName] ? item[fieldName].toUpperCase() : "";
5872
5895
  return value ? value.indexOf(filter.toUpperCase()) >= 0 : false;
5873
5896
  });
5874
5897
  return result;
@@ -6043,9 +6066,19 @@ var CollectionTree = function CollectionTree(props) {
6043
6066
  var CollectionEditor = function CollectionEditor(props) {
6044
6067
  var save = function save() {
6045
6068
  try {
6046
- return Promise.resolve(pageContext.update(form)).then(function () {
6069
+ var _temp3 = function _temp3() {
6047
6070
  setPageContext(Object.assign({}, pageContext));
6048
- });
6071
+ };
6072
+
6073
+ var _temp4 = function () {
6074
+ if (patch) {
6075
+ return Promise.resolve(pageContext.patch(form.id, form)).then(function () {});
6076
+ } else {
6077
+ return Promise.resolve(pageContext.update(form)).then(function () {});
6078
+ }
6079
+ }();
6080
+
6081
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
6049
6082
  } catch (e) {
6050
6083
  return Promise.reject(e);
6051
6084
  }
@@ -6075,7 +6108,9 @@ var CollectionEditor = function CollectionEditor(props) {
6075
6108
  _props$delay2 = props.delay,
6076
6109
  delay = _props$delay2 === void 0 ? 1000 : _props$delay2,
6077
6110
  canDelete = props.canDelete,
6078
- onReload = props.onReload;
6111
+ onReload = props.onReload,
6112
+ _props$patch2 = props.patch,
6113
+ patch = _props$patch2 === void 0 ? false : _props$patch2;
6079
6114
  var timer = React.useRef(null);
6080
6115
 
6081
6116
  var _useState5 = React.useState(selected),
@@ -6173,7 +6208,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6173
6208
  try {
6174
6209
  var _this2 = this;
6175
6210
 
6176
- var _temp2 = _catch$3(function () {
6211
+ var _temp6 = _catch$3(function () {
6177
6212
  return Promise.resolve(API.all(null, page)).then(function (data) {
6178
6213
  _this2.all = field ? data[field] : data;
6179
6214
  });
@@ -6181,7 +6216,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6181
6216
  console.log(error);
6182
6217
  });
6183
6218
 
6184
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
6219
+ return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
6185
6220
  } catch (e) {
6186
6221
  return Promise.reject(e);
6187
6222
  }
@@ -6190,7 +6225,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6190
6225
  try {
6191
6226
  var _this4 = this;
6192
6227
 
6193
- var _temp4 = function () {
6228
+ var _temp8 = function () {
6194
6229
  if (fetching) {
6195
6230
  return Promise.resolve(_this4.fetch(id)).then(function (result) {
6196
6231
  _this4.selected = result;
@@ -6204,7 +6239,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6204
6239
  }
6205
6240
  }();
6206
6241
 
6207
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
6242
+ return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
6208
6243
  } catch (e) {
6209
6244
  return Promise.reject(e);
6210
6245
  }
@@ -6238,7 +6273,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6238
6273
  try {
6239
6274
  var _this8 = this;
6240
6275
 
6241
- var _temp6 = _catch$3(function () {
6276
+ var _temp10 = _catch$3(function () {
6242
6277
  return Promise.resolve(API.create(form)).then(function () {
6243
6278
  return Promise.resolve(_this8.load()).then(function () {});
6244
6279
  });
@@ -6246,7 +6281,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6246
6281
  console.log(error);
6247
6282
  });
6248
6283
 
6249
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
6284
+ return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function () {}) : void 0);
6250
6285
  } catch (e) {
6251
6286
  return Promise.reject(e);
6252
6287
  }
@@ -6255,7 +6290,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6255
6290
  try {
6256
6291
  var _this10 = this;
6257
6292
 
6258
- var _temp8 = _catch$3(function () {
6293
+ var _temp12 = _catch$3(function () {
6259
6294
  return Promise.resolve(API.update(form)).then(function () {
6260
6295
  return Promise.resolve(_this10.load()).then(function () {});
6261
6296
  });
@@ -6263,7 +6298,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6263
6298
  console.log(error);
6264
6299
  });
6265
6300
 
6266
- return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
6301
+ return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
6267
6302
  } catch (e) {
6268
6303
  return Promise.reject(e);
6269
6304
  }
@@ -6272,7 +6307,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6272
6307
  try {
6273
6308
  var _this12 = this;
6274
6309
 
6275
- var _temp10 = _catch$3(function () {
6310
+ var _temp14 = _catch$3(function () {
6276
6311
  return Promise.resolve(API.patch(id, form)).then(function () {
6277
6312
  return Promise.resolve(_this12.load()).then(function () {});
6278
6313
  });
@@ -6280,7 +6315,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6280
6315
  console.log(error);
6281
6316
  });
6282
6317
 
6283
- return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(function () {}) : void 0);
6318
+ return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
6284
6319
  } catch (e) {
6285
6320
  return Promise.reject(e);
6286
6321
  }
@@ -6289,7 +6324,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6289
6324
  try {
6290
6325
  var _this14 = this;
6291
6326
 
6292
- var _temp12 = _catch$3(function () {
6327
+ var _temp16 = _catch$3(function () {
6293
6328
  return Promise.resolve(API.updateProperty(id, propertyName, form)).then(function () {
6294
6329
  return Promise.resolve(_this14.load()).then(function () {});
6295
6330
  });
@@ -6297,7 +6332,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6297
6332
  console.log(error);
6298
6333
  });
6299
6334
 
6300
- return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(function () {}) : void 0);
6335
+ return Promise.resolve(_temp16 && _temp16.then ? _temp16.then(function () {}) : void 0);
6301
6336
  } catch (e) {
6302
6337
  return Promise.reject(e);
6303
6338
  }
@@ -6306,7 +6341,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6306
6341
  try {
6307
6342
  var _this16 = this;
6308
6343
 
6309
- var _temp14 = _catch$3(function () {
6344
+ var _temp18 = _catch$3(function () {
6310
6345
  return Promise.resolve(API.remove(id)).then(function () {
6311
6346
  return Promise.resolve(_this16.load()).then(function () {});
6312
6347
  });
@@ -6314,7 +6349,7 @@ var CollectionContext = function CollectionContext(url, field, host, page, fetch
6314
6349
  console.log(error);
6315
6350
  });
6316
6351
 
6317
- return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
6352
+ return Promise.resolve(_temp18 && _temp18.then ? _temp18.then(function () {}) : void 0);
6318
6353
  } catch (e) {
6319
6354
  return Promise.reject(e);
6320
6355
  }