ywana-core8 0.0.578 → 0.0.581

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.
@@ -1,5 +1,5 @@
1
1
  import 'material-design-icons-iconfont/dist/material-design-icons.css';
2
- import React, { useState, useContext, useEffect, Fragment, useRef, useMemo, Children } from 'react';
2
+ import React, { useState, useEffect, useContext, Fragment, useRef, useMemo, Children } from 'react';
3
3
  import RSwitch from 'react-switch';
4
4
  import moment$1 from 'moment';
5
5
  import { extendMoment } from 'moment-range';
@@ -198,18 +198,25 @@ var Accordion = function Accordion(props) {
198
198
  sections = _props$sections === void 0 ? [] : _props$sections,
199
199
  onCheck = props.onCheck;
200
200
 
201
- var _useState = useState(sections.map(function (section) {
202
- return section.open;
203
- })),
201
+ var _useState = useState([]),
204
202
  openSections = _useState[0],
205
203
  setOpenSections = _useState[1];
206
204
 
207
- var _useState2 = useState(sections.map(function (section) {
208
- return section.checked;
209
- })),
205
+ var _useState2 = useState([]),
210
206
  checkedSections = _useState2[0],
211
207
  setCheckedSections = _useState2[1];
212
208
 
209
+ useEffect(function () {
210
+ var openSections = sections.map(function (section) {
211
+ return section.open;
212
+ });
213
+ var checkedSections = sections.map(function (section) {
214
+ return section.checked;
215
+ });
216
+ setOpenSections(openSections);
217
+ setCheckedSections(checkedSections);
218
+ }, [sections]);
219
+
213
220
  function toggle(index) {
214
221
  var next = openSections.map(function (open, i) {
215
222
  return i === index ? !open : open;
@@ -8454,27 +8461,32 @@ var TabbedTablePage = function TabbedTablePage(props) {
8454
8461
 
8455
8462
  useEffect(function () {
8456
8463
  try {
8457
- var _field = Object.values(schema).find(function (field) {
8458
- return field.tab && field.tab === true;
8459
- });
8460
-
8461
- var _tabs = _field.options.map(function (option) {
8462
- return Object.assign({}, option, {
8463
- field: _field.id
8464
+ var _temp3 = function _temp3() {
8465
+ var field = Object.values(schema).find(function (field) {
8466
+ return field.tab && field.tab === true;
8464
8467
  });
8465
- });
8468
+ var tabs = field.options.map(function (option) {
8469
+ return Object.assign({}, option, {
8470
+ field: field.id
8471
+ });
8472
+ });
8473
+ setTabs(tabs);
8474
+ context.changeTab(tabs[0]);
8475
+ setPageContext(context);
8476
+ };
8466
8477
 
8467
- setTabs(_tabs);
8468
- context.changeTab(_tabs[0]);
8469
- setPageContext(context);
8470
- return Promise.resolve();
8478
+ var _temp4 = function () {
8479
+ if (canQuery) return Promise.resolve(context.loadQueries(user)).then(function () {});
8480
+ }();
8481
+
8482
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
8471
8483
  } catch (e) {
8472
8484
  return Promise.reject(e);
8473
8485
  }
8474
8486
  }, []);
8475
8487
  useEffect(function () {
8476
8488
  try {
8477
- var _temp2 = function () {
8489
+ var _temp6 = function () {
8478
8490
  if (tab) {
8479
8491
  var _filter;
8480
8492
 
@@ -8485,7 +8497,7 @@ var TabbedTablePage = function TabbedTablePage(props) {
8485
8497
  }
8486
8498
  }();
8487
8499
 
8488
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
8500
+ return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(function () {}) : void 0);
8489
8501
  } catch (e) {
8490
8502
  return Promise.reject(e);
8491
8503
  }
@@ -8815,6 +8827,16 @@ var TableQueries = function TableQueries(props) {
8815
8827
 
8816
8828
 
8817
8829
  var TableFilters = function TableFilters(props) {
8830
+ var reload = function reload() {
8831
+ try {
8832
+ return Promise.resolve(pageContext.load(form, likes)).then(function () {
8833
+ setPageContext(Object.assign({}, pageContext));
8834
+ });
8835
+ } catch (e) {
8836
+ return Promise.reject(e);
8837
+ }
8838
+ };
8839
+
8818
8840
  var change = function change(next) {
8819
8841
  try {
8820
8842
  setForm(next);
@@ -8857,7 +8879,7 @@ var TableFilters = function TableFilters(props) {
8857
8879
  delete filterSchema.flows;
8858
8880
  return filterSchema;
8859
8881
  }, [schema]);
8860
- useMemo(function () {
8882
+ var likes = useMemo(function () {
8861
8883
  var fields = Object.values(schema);
8862
8884
  return fields.reduce(function (likes, field) {
8863
8885
  if (field.like === true) likes.push(field.id);
@@ -8865,13 +8887,10 @@ var TableFilters = function TableFilters(props) {
8865
8887
  }, []);
8866
8888
  }, [schema]);
8867
8889
  useEffect(function () {
8868
- if (filters && !equal(filters, form)) setForm(filters);
8890
+ if (filters) setForm(filters);
8869
8891
  }, [filters]);
8870
8892
  useEffect(function () {
8871
- if (pageContext.changeFilters && !equal(filters, form)) {
8872
- pageContext.changeFilters(form);
8873
- setPageContext(Object.assign({}, pageContext));
8874
- }
8893
+ reload();
8875
8894
  }, [form]);
8876
8895
 
8877
8896
  function clear() {
@@ -8940,7 +8959,7 @@ var TableEditor = function TableEditor(props) {
8940
8959
  var remove = function remove(id) {
8941
8960
  try {
8942
8961
  return Promise.resolve(site.confirm("Are you sure ?")).then(function (confirm) {
8943
- var _temp5 = function () {
8962
+ var _temp7 = function () {
8944
8963
  if (confirm) {
8945
8964
  return Promise.resolve(pageContext.remove(id)).then(function () {
8946
8965
  pageContext.clear();
@@ -8949,7 +8968,7 @@ var TableEditor = function TableEditor(props) {
8949
8968
  }
8950
8969
  }();
8951
8970
 
8952
- if (_temp5 && _temp5.then) return _temp5.then(function () {});
8971
+ if (_temp7 && _temp7.then) return _temp7.then(function () {});
8953
8972
  });
8954
8973
  } catch (e) {
8955
8974
  return Promise.reject(e);
@@ -8963,8 +8982,7 @@ var TableEditor = function TableEditor(props) {
8963
8982
  setPageContext = _useContext5[1];
8964
8983
 
8965
8984
  var _pageContext$all = pageContext.all,
8966
- all = _pageContext$all === void 0 ? [] : _pageContext$all,
8967
- filters = pageContext.filters;
8985
+ all = _pageContext$all === void 0 ? [] : _pageContext$all;
8968
8986
  var icon = props.icon,
8969
8987
  title = props.title,
8970
8988
  schema = props.schema,
@@ -8979,22 +8997,6 @@ var TableEditor = function TableEditor(props) {
8979
8997
  groupBy = _useState5[0],
8980
8998
  setGroupBy = _useState5[1];
8981
8999
 
8982
- useEffect(function () {
8983
- try {
8984
- var _temp4 = function () {
8985
- if (filters) {
8986
- return Promise.resolve(pageContext.load(filters)).then(function () {
8987
- setPageContext(Object.assign({}, pageContext));
8988
- });
8989
- }
8990
- }();
8991
-
8992
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
8993
- } catch (e) {
8994
- return Promise.reject(e);
8995
- }
8996
- }, [filters]);
8997
-
8998
9000
  function changeGroup(id, value) {
8999
9001
  setGroupBy(value);
9000
9002
  }
@@ -9177,7 +9179,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9177
9179
  try {
9178
9180
  var _this2 = this;
9179
9181
 
9180
- var _temp7 = _catch(function () {
9182
+ var _temp9 = _catch(function () {
9181
9183
  var filters = filter ? Object.keys(filter).reduce(function (filters, key) {
9182
9184
  var field = filter[key];
9183
9185
 
@@ -9206,7 +9208,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9206
9208
  console.log(error);
9207
9209
  });
9208
9210
 
9209
- return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(function () {}) : void 0);
9211
+ return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
9210
9212
  } catch (e) {
9211
9213
  return Promise.reject(e);
9212
9214
  }
@@ -9244,7 +9246,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9244
9246
  try {
9245
9247
  var _this5 = this;
9246
9248
 
9247
- var _temp9 = _catch(function () {
9249
+ var _temp11 = _catch(function () {
9248
9250
  return Promise.resolve(API.create(form)).then(function () {
9249
9251
  return Promise.resolve(_this5.load({}, [])).then(function () {});
9250
9252
  });
@@ -9252,7 +9254,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9252
9254
  console.log(error);
9253
9255
  });
9254
9256
 
9255
- return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function () {}) : void 0);
9257
+ return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(function () {}) : void 0);
9256
9258
  } catch (e) {
9257
9259
  return Promise.reject(e);
9258
9260
  }
@@ -9261,7 +9263,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9261
9263
  try {
9262
9264
  var _this7 = this;
9263
9265
 
9264
- var _temp11 = _catch(function () {
9266
+ var _temp13 = _catch(function () {
9265
9267
  return Promise.resolve(API.update(form)).then(function () {
9266
9268
  return Promise.resolve(_this7.load()).then(function () {});
9267
9269
  });
@@ -9269,7 +9271,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9269
9271
  console.log(error);
9270
9272
  });
9271
9273
 
9272
- return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(function () {}) : void 0);
9274
+ return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(function () {}) : void 0);
9273
9275
  } catch (e) {
9274
9276
  return Promise.reject(e);
9275
9277
  }
@@ -9278,7 +9280,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9278
9280
  try {
9279
9281
  var _this9 = this;
9280
9282
 
9281
- var _temp13 = _catch(function () {
9283
+ var _temp15 = _catch(function () {
9282
9284
  return Promise.resolve(API.remove(id)).then(function () {
9283
9285
  return Promise.resolve(_this9.load()).then(function () {});
9284
9286
  });
@@ -9286,7 +9288,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9286
9288
  console.log(error);
9287
9289
  });
9288
9290
 
9289
- return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(function () {}) : void 0);
9291
+ return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(function () {}) : void 0);
9290
9292
  } catch (e) {
9291
9293
  return Promise.reject(e);
9292
9294
  }
@@ -9298,7 +9300,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9298
9300
  try {
9299
9301
  var _this11 = this;
9300
9302
 
9301
- var _temp15 = _catch(function () {
9303
+ var _temp17 = _catch(function () {
9302
9304
  return Promise.resolve(API.queries(user, urlQuery)).then(function (_API$queries) {
9303
9305
  _this11.queries = _API$queries;
9304
9306
  });
@@ -9306,7 +9308,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9306
9308
  console.log(error);
9307
9309
  });
9308
9310
 
9309
- return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(function () {}) : void 0);
9311
+ return Promise.resolve(_temp17 && _temp17.then ? _temp17.then(function () {}) : void 0);
9310
9312
  } catch (e) {
9311
9313
  return Promise.reject(e);
9312
9314
  }
@@ -9315,7 +9317,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9315
9317
  try {
9316
9318
  var _this13 = this;
9317
9319
 
9318
- var _temp17 = _catch(function () {
9320
+ var _temp19 = _catch(function () {
9319
9321
  return Promise.resolve(API.createQuery(query, urlQuery)).then(function () {
9320
9322
  return Promise.resolve(_this13.loadQueries(user)).then(function () {});
9321
9323
  });
@@ -9323,7 +9325,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9323
9325
  console.log(error);
9324
9326
  });
9325
9327
 
9326
- return Promise.resolve(_temp17 && _temp17.then ? _temp17.then(function () {}) : void 0);
9328
+ return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(function () {}) : void 0);
9327
9329
  } catch (e) {
9328
9330
  return Promise.reject(e);
9329
9331
  }
@@ -9332,7 +9334,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9332
9334
  try {
9333
9335
  var _this15 = this;
9334
9336
 
9335
- var _temp19 = _catch(function () {
9337
+ var _temp21 = _catch(function () {
9336
9338
  return Promise.resolve(API.removeQuery(id, urlQuery)).then(function () {
9337
9339
  return Promise.resolve(_this15.loadQueries(user)).then(function () {});
9338
9340
  });
@@ -9340,7 +9342,7 @@ var TableContext = function TableContext(url, field, host, urlQuery) {
9340
9342
  console.log(error);
9341
9343
  });
9342
9344
 
9343
- return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(function () {}) : void 0);
9345
+ return Promise.resolve(_temp21 && _temp21.then ? _temp21.then(function () {}) : void 0);
9344
9346
  } catch (e) {
9345
9347
  return Promise.reject(e);
9346
9348
  }