react-hook-core 0.1.2 → 0.1.5

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/README.md CHANGED
@@ -1 +1 @@
1
- # react-xone
1
+ # react
package/lib/components.js CHANGED
@@ -25,15 +25,15 @@ var __assign = (this && this.__assign) || function () {
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  var React = require("react");
28
- var reflectx_1 = require("reflectx");
29
- var search_core_1 = require("search-core");
30
28
  var core_1 = require("./core");
31
29
  var core_2 = require("./core");
32
30
  var diff_1 = require("./diff");
33
31
  var edit_1 = require("./edit");
34
32
  var formutil_1 = require("./formutil");
35
33
  var input_1 = require("./input");
34
+ var reflect_1 = require("./reflect");
36
35
  var route_1 = require("./route");
36
+ var search_1 = require("./search");
37
37
  var state_1 = require("./state");
38
38
  var ViewComponent = (function (_super) {
39
39
  __extends(ViewComponent, _super);
@@ -62,7 +62,6 @@ var ViewComponent = (function (_super) {
62
62
  }
63
63
  }
64
64
  }
65
- _this.back = _this.back.bind(_this);
66
65
  _this.getModelName = _this.getModelName.bind(_this);
67
66
  _this.load = _this.load.bind(_this);
68
67
  _this.getModel = _this.getModel.bind(_this);
@@ -70,12 +69,6 @@ var ViewComponent = (function (_super) {
70
69
  _this.ref = React.createRef();
71
70
  return _this;
72
71
  }
73
- ViewComponent.prototype.back = function (event) {
74
- if (event) {
75
- event.preventDefault();
76
- }
77
- this.props.history.goBack();
78
- };
79
72
  ViewComponent.prototype.getModelName = function () {
80
73
  if (this.name && this.name.length > 0) {
81
74
  return this.name;
@@ -88,13 +81,6 @@ var ViewComponent = (function (_super) {
88
81
  return n;
89
82
  }
90
83
  };
91
- ViewComponent.prototype.componentDidMount = function () {
92
- this.form = this.ref.current;
93
- var id = core_2.buildId(this.props, this.keys);
94
- if (id) {
95
- this.load(id);
96
- }
97
- };
98
84
  ViewComponent.prototype.load = function (_id, callback) {
99
85
  var id = _id;
100
86
  if (id != null && id !== '' && this.loadData) {
@@ -305,15 +291,15 @@ var BaseSearchComponent = (function (_super) {
305
291
  _this.ui = ui;
306
292
  _this.loading = loading;
307
293
  _this.listFormId = listFormId;
308
- _this.initPageSize = 20;
309
- _this.pageSize = 20;
294
+ _this.initPageSize = 24;
295
+ _this.pageSize = 24;
310
296
  _this.pageIndex = 1;
311
- _this.itemTotal = 0;
312
- _this.pageTotal = 0;
297
+ _this.total = 0;
298
+ _this.pages = 0;
313
299
  _this.sequenceNo = 'sequenceNo';
314
300
  _this.tmpPageIndex = 1;
315
301
  _this.pageMaxSize = 7;
316
- _this.pageSizes = [10, 20, 40, 60, 100, 200, 400, 800];
302
+ _this.pageSizes = core_2.pageSizes;
317
303
  _this.viewable = true;
318
304
  _this.addable = true;
319
305
  _this.editable = true;
@@ -322,11 +308,12 @@ var BaseSearchComponent = (function (_super) {
322
308
  };
323
309
  _this.pageSizeChanged = function (event) {
324
310
  var size = parseInt(event.currentTarget.value, 10);
325
- search_core_1.changePageSize(_this, size);
311
+ search_1.changePageSize(_this, size);
326
312
  _this.tmpPageIndex = 1;
327
313
  _this.doSearch();
328
314
  };
329
315
  _this.resource = resourceService.resource();
316
+ _this.hideFilter = true;
330
317
  _this.getModelName = _this.getModelName.bind(_this);
331
318
  _this.showMessage = _this.showMessage.bind(_this);
332
319
  _this.toggleFilter = _this.toggleFilter.bind(_this);
@@ -338,7 +325,7 @@ var BaseSearchComponent = (function (_super) {
338
325
  _this.getFields = _this.getFields.bind(_this);
339
326
  _this.pageSizeChanged = _this.pageSizeChanged.bind(_this);
340
327
  _this.clearQ = _this.clearQ.bind(_this);
341
- _this.searchOnClick = _this.searchOnClick.bind(_this);
328
+ _this.search = _this.search.bind(_this);
342
329
  _this.resetAndSearch = _this.resetAndSearch.bind(_this);
343
330
  _this.doSearch = _this.doSearch.bind(_this);
344
331
  _this.call = _this.call.bind(_this);
@@ -357,10 +344,12 @@ var BaseSearchComponent = (function (_super) {
357
344
  return 'filter';
358
345
  };
359
346
  BaseSearchComponent.prototype.toggleFilter = function (event) {
360
- this.hideFilter = !this.hideFilter;
347
+ var x = !this.hideFilter;
348
+ core_1.handleToggle(event.target, !x);
349
+ this.hideFilter = x;
361
350
  };
362
351
  BaseSearchComponent.prototype.load = function (s, autoSearch) {
363
- var obj2 = search_core_1.initFilter(s, this);
352
+ var obj2 = search_1.initFilter(s, this);
364
353
  this.setFilter(obj2);
365
354
  var com = this;
366
355
  if (autoSearch) {
@@ -401,11 +390,11 @@ var BaseSearchComponent = (function (_super) {
401
390
  var l = this.getList();
402
391
  var f = this.getSearchForm();
403
392
  var dc = (this.ui ? this.ui.decodeFromForm : undefined);
404
- var obj3 = search_core_1.getModel(this.state, name, this, fields, this.excluding, this.keys, l, f, dc, lc, cc);
393
+ var obj3 = search_1.getModel(this.state, name, this, fields, this.excluding, this.keys, l, f, dc, lc, cc);
405
394
  return obj3;
406
395
  };
407
396
  BaseSearchComponent.prototype.getFields = function () {
408
- var fs = search_core_1.getFieldsFromForm(this.fields, this.initFields, this.form);
397
+ var fs = search_1.getFieldsFromForm(this.fields, this.initFields, this.form);
409
398
  this.initFields = true;
410
399
  return fs;
411
400
  };
@@ -421,7 +410,7 @@ var BaseSearchComponent = (function (_super) {
421
410
  });
422
411
  }
423
412
  };
424
- BaseSearchComponent.prototype.searchOnClick = function (event) {
413
+ BaseSearchComponent.prototype.search = function (event) {
425
414
  if (event) {
426
415
  event.preventDefault();
427
416
  if (!this.getSearchForm()) {
@@ -439,7 +428,7 @@ var BaseSearchComponent = (function (_super) {
439
428
  this.triggerSearch = true;
440
429
  return;
441
430
  }
442
- search_core_1.reset(this);
431
+ search_1.reset(this);
443
432
  this.tmpPageIndex = 1;
444
433
  this.doSearch();
445
434
  };
@@ -458,7 +447,7 @@ var BaseSearchComponent = (function (_super) {
458
447
  com.running = true;
459
448
  core_1.showLoading(_this.loading);
460
449
  if (!_this.ignoreUrlParam) {
461
- search_core_1.addParametersIntoUrl(s, isFirstLoad);
450
+ search_1.addParametersIntoUrl(s, isFirstLoad);
462
451
  }
463
452
  com.call(s);
464
453
  });
@@ -468,19 +457,19 @@ var BaseSearchComponent = (function (_super) {
468
457
  BaseSearchComponent.prototype.validateSearch = function (se, callback) {
469
458
  var u = this.ui;
470
459
  var vl = (u ? u.validateForm : undefined);
471
- search_core_1.validate(se, callback, this.getSearchForm(), state_1.localeOf(undefined, this.getLocale), vl);
460
+ search_1.validate(se, callback, this.getSearchForm(), state_1.localeOf(undefined, this.getLocale), vl);
472
461
  };
473
462
  BaseSearchComponent.prototype.showResults = function (s, sr) {
474
463
  var com = this;
475
464
  var results = sr.list;
476
465
  if (results && results.length > 0) {
477
466
  var lc = state_1.localeOf(undefined, this.getLocale);
478
- search_core_1.formatResultsByComponent(results, com, lc);
467
+ search_1.formatResults(results, com.pageIndex, com.pageSize, com.pageSize, com.sequenceNo, com.format, lc);
479
468
  }
480
469
  var am = com.appendMode;
481
470
  com.pageIndex = (s.page && s.page >= 1 ? s.page : 1);
482
471
  if (sr.total) {
483
- com.itemTotal = sr.total;
472
+ com.total = sr.total;
484
473
  }
485
474
  if (am) {
486
475
  var limit = s.limit;
@@ -488,7 +477,7 @@ var BaseSearchComponent = (function (_super) {
488
477
  limit = s.firstLimit;
489
478
  }
490
479
  com.nextPageToken = sr.nextPageToken;
491
- search_core_1.handleAppend(com, sr.list, limit, sr.nextPageToken);
480
+ search_1.handleAppend(com, sr.list, limit, sr.nextPageToken);
492
481
  if (com.append && (s.page && s.page > 1)) {
493
482
  com.appendList(results);
494
483
  }
@@ -497,11 +486,11 @@ var BaseSearchComponent = (function (_super) {
497
486
  }
498
487
  }
499
488
  else {
500
- search_core_1.showPaging(com, sr.list, s.limit, sr.total);
489
+ search_1.showPaging(com, sr.list, s.limit, sr.total);
501
490
  com.setList(results);
502
491
  com.tmpPageIndex = s.page;
503
492
  if (s.limit) {
504
- this.showMessage(search_core_1.buildMessage(this.resourceService, s.page, s.limit, sr.list, sr.total));
493
+ this.showMessage(search_1.buildMessage(this.resourceService, s.page, s.limit, sr.list, sr.total));
505
494
  }
506
495
  }
507
496
  com.running = undefined;
@@ -514,7 +503,7 @@ var BaseSearchComponent = (function (_super) {
514
503
  BaseSearchComponent.prototype.appendList = function (results) {
515
504
  var _a;
516
505
  var list = this.state.list;
517
- var arr = search_core_1.append(list, results);
506
+ var arr = search_1.append(list, results);
518
507
  var listForm = this.getSearchForm();
519
508
  var props = this.props;
520
509
  var setGlobalState = props.props.setGlobalState;
@@ -543,7 +532,7 @@ var BaseSearchComponent = (function (_super) {
543
532
  };
544
533
  BaseSearchComponent.prototype.sort = function (event) {
545
534
  event.preventDefault();
546
- search_core_1.handleSortEvent(event, this);
535
+ search_1.handleSortEvent(event, this);
547
536
  if (!this.appendMode) {
548
537
  this.doSearch();
549
538
  }
@@ -554,12 +543,12 @@ var BaseSearchComponent = (function (_super) {
554
543
  BaseSearchComponent.prototype.showMore = function (event) {
555
544
  event.preventDefault();
556
545
  this.tmpPageIndex = this.pageIndex;
557
- search_core_1.more(this);
546
+ search_1.more(this);
558
547
  this.doSearch();
559
548
  };
560
549
  BaseSearchComponent.prototype.pageChanged = function (data) {
561
- var currentPage = data.currentPage, itemsPerPage = data.itemsPerPage;
562
- search_core_1.changePage(this, currentPage, itemsPerPage);
550
+ var page = data.page, size = data.size;
551
+ search_1.changePage(this, page, size);
563
552
  this.doSearch();
564
553
  };
565
554
  return BaseSearchComponent;
@@ -569,25 +558,19 @@ var SearchComponent = (function (_super) {
569
558
  __extends(SearchComponent, _super);
570
559
  function SearchComponent(props, sv, param, showMessage, showError, getLocale, uis, loading, listFormId) {
571
560
  var _this = _super.call(this, props, input_1.getResource(param), input_1.getMsgFunc(param, showMessage), input_1.getLocaleFunc(param, getLocale), input_1.getUIService(param, uis), input_1.getLoadingFunc(param, loading), listFormId) || this;
572
- _this.add = function (event) {
573
- event.preventDefault();
574
- var url = _this.url + '/add';
575
- _this.props.history.push(url);
576
- };
577
561
  _this.autoSearch = input_1.getAutoSearch(param);
578
562
  if (sv) {
579
563
  if (typeof sv === 'function') {
580
564
  var x = sv;
581
- _this.search = x;
565
+ _this.service = x;
582
566
  }
583
567
  else {
584
- _this.search = sv.search;
568
+ _this.service = sv.search;
585
569
  if (sv.keys) {
586
570
  _this.keys = sv.keys();
587
571
  }
588
572
  }
589
573
  }
590
- _this.add = _this.add.bind(_this);
591
574
  _this.call = _this.call.bind(_this);
592
575
  _this.showError = input_1.getErrorFunc(param, showError);
593
576
  _this.componentDidMount = _this.componentDidMount.bind(_this);
@@ -603,7 +586,7 @@ var SearchComponent = (function (_super) {
603
586
  this.load(s, this.autoSearch);
604
587
  };
605
588
  SearchComponent.prototype.mergeFilter = function (obj, b, arrs) {
606
- return search_core_1.mergeFilter(obj, b, this.pageSizes, arrs);
589
+ return search_1.mergeFilter(obj, b, this.pageSizes, arrs);
607
590
  };
608
591
  SearchComponent.prototype.createFilter = function () {
609
592
  var s = {};
@@ -611,7 +594,7 @@ var SearchComponent = (function (_super) {
611
594
  };
612
595
  SearchComponent.prototype.call = function (se) {
613
596
  this.running = true;
614
- var s = reflectx_1.clone(se);
597
+ var s = reflect_1.clone(se);
615
598
  var page = this.pageIndex;
616
599
  if (!page || page < 1) {
617
600
  page = 1;
@@ -634,8 +617,8 @@ var SearchComponent = (function (_super) {
634
617
  delete se['firstLimit'];
635
618
  core_1.showLoading(this.loading);
636
619
  var com = this;
637
- if (this.search) {
638
- this.search(s, limit, next, fields).then(function (sr) {
620
+ if (this.service) {
621
+ this.service(s, limit, next, fields).then(function (sr) {
639
622
  com.showResults(s, sr);
640
623
  com.running = undefined;
641
624
  core_1.hideLoading(com.loading);
@@ -663,7 +646,7 @@ var BaseEditComponent = (function (_super) {
663
646
  _this.backOnSuccess = true;
664
647
  _this.patchable = true;
665
648
  _this.addable = true;
666
- _this.newOnClick = function (event) {
649
+ _this.create = function (event) {
667
650
  if (event) {
668
651
  event.preventDefault();
669
652
  }
@@ -680,7 +663,7 @@ var BaseEditComponent = (function (_super) {
680
663
  }, 100);
681
664
  }
682
665
  };
683
- _this.saveOnClick = function (event) {
666
+ _this.save = function (event) {
684
667
  event.preventDefault();
685
668
  event.persist();
686
669
  if (!_this.form && event && event.target) {
@@ -708,11 +691,11 @@ var BaseEditComponent = (function (_super) {
708
691
  _this.showModel = _this.showModel.bind(_this);
709
692
  _this.getModel = _this.getModel.bind(_this);
710
693
  _this.createModel = _this.createModel.bind(_this);
711
- _this.newOnClick = _this.newOnClick.bind(_this);
712
- _this.saveOnClick = _this.saveOnClick.bind(_this);
694
+ _this.create = _this.create.bind(_this);
695
+ _this.save = _this.save.bind(_this);
713
696
  _this.onSave = _this.onSave.bind(_this);
714
697
  _this.validate = _this.validate.bind(_this);
715
- _this.save = _this.save.bind(_this);
698
+ _this.doSave = _this.doSave.bind(_this);
716
699
  _this.succeed = _this.succeed.bind(_this);
717
700
  _this.fail = _this.fail.bind(_this);
718
701
  _this.postSave = _this.postSave.bind(_this);
@@ -723,7 +706,6 @@ var BaseEditComponent = (function (_super) {
723
706
  if (event) {
724
707
  event.preventDefault();
725
708
  }
726
- this.props.history.goBack();
727
709
  };
728
710
  BaseEditComponent.prototype.resetState = function (newMod, model, originalModel) {
729
711
  this.newMode = newMod;
@@ -792,12 +774,12 @@ var BaseEditComponent = (function (_super) {
792
774
  com_2.validate(obj_1, function () {
793
775
  var msg = core_2.message(r.value, 'msg_confirm_save', 'confirm', 'yes', 'no');
794
776
  _this.confirm(msg.message, msg.title, function () {
795
- com_2.save(obj_1, obj_1, isBack);
777
+ com_2.doSave(obj_1, obj_1, isBack);
796
778
  }, msg.no, msg.yes);
797
779
  });
798
780
  }
799
781
  else {
800
- var diffObj_1 = reflectx_1.makeDiff(edit_1.initPropertyNullInModel(this.orginalModel, this.metadata), obj_1, this.keys, this.version);
782
+ var diffObj_1 = reflect_1.makeDiff(edit_1.initPropertyNullInModel(this.orginalModel, this.metadata), obj_1, this.keys, this.version);
801
783
  var keys = Object.keys(diffObj_1);
802
784
  if (keys.length === 0) {
803
785
  this.showMessage(r.value('msg_no_change'));
@@ -806,7 +788,7 @@ var BaseEditComponent = (function (_super) {
806
788
  com_2.validate(obj_1, function () {
807
789
  var msg = core_2.message(r.value, 'msg_confirm_save', 'confirm', 'yes', 'no');
808
790
  _this.confirm(msg.message, msg.title, function () {
809
- com_2.save(obj_1, diffObj_1, isBack);
791
+ com_2.doSave(obj_1, diffObj_1, isBack);
810
792
  }, msg.no, msg.yes);
811
793
  });
812
794
  }
@@ -824,14 +806,14 @@ var BaseEditComponent = (function (_super) {
824
806
  callback(obj);
825
807
  }
826
808
  };
827
- BaseEditComponent.prototype.save = function (obj, dif, isBack) {
809
+ BaseEditComponent.prototype.doSave = function (obj, dif, isBack) {
828
810
  };
829
811
  BaseEditComponent.prototype.succeed = function (msg, isBack, result) {
830
812
  if (result) {
831
813
  var model = result.value;
832
814
  this.newMode = false;
833
815
  if (model && this.setBack) {
834
- this.resetState(false, model, reflectx_1.clone(model));
816
+ this.resetState(false, model, reflect_1.clone(model));
835
817
  }
836
818
  else {
837
819
  edit_1.handleVersion(this.getModel(), this.version);
@@ -947,19 +929,10 @@ var EditComponent = (function (_super) {
947
929
  _this.keys = [];
948
930
  }
949
931
  _this.load = _this.load.bind(_this);
950
- _this.save = _this.save.bind(_this);
951
- _this.componentDidMount = _this.componentDidMount.bind(_this);
932
+ _this.doSave = _this.doSave.bind(_this);
952
933
  _this.ref = React.createRef();
953
934
  return _this;
954
935
  }
955
- EditComponent.prototype.componentDidMount = function () {
956
- var k = (this.ui ? this.ui.registerEvents : undefined);
957
- this.form = core_2.initForm(this.ref.current, k);
958
- var id = core_2.buildId(this.props, this.keys);
959
- if (id) {
960
- this.load(id);
961
- }
962
- };
963
936
  EditComponent.prototype.load = function (_id, callback) {
964
937
  var _this = this;
965
938
  var id = _id;
@@ -973,7 +946,7 @@ var EditComponent = (function (_super) {
973
946
  }
974
947
  else {
975
948
  com_3.newMode = false;
976
- com_3.orginalModel = reflectx_1.clone(obj);
949
+ com_3.orginalModel = reflect_1.clone(obj);
977
950
  if (!callback) {
978
951
  com_3.showModel(obj);
979
952
  }
@@ -1017,7 +990,7 @@ var EditComponent = (function (_super) {
1017
990
  }
1018
991
  }
1019
992
  };
1020
- EditComponent.prototype.save = function (obj, body, isBack) {
993
+ EditComponent.prototype.doSave = function (obj, body, isBack) {
1021
994
  this.running = true;
1022
995
  core_1.showLoading(this.loading);
1023
996
  var isBackO = (isBack == null || isBack === undefined ? this.backOnSuccess : isBack);
@@ -1055,7 +1028,6 @@ var BaseDiffApprComponent = (function (_super) {
1055
1028
  _this.resource = resourceService.resource();
1056
1029
  _this.showMessage = _this.showMessage.bind(_this);
1057
1030
  _this.showError = _this.showError.bind(_this);
1058
- _this.back = _this.back.bind(_this);
1059
1031
  _this.initModel = _this.initModel.bind(_this);
1060
1032
  _this.postApprove = _this.postApprove.bind(_this);
1061
1033
  _this.postReject = _this.postReject.bind(_this);
@@ -1067,12 +1039,6 @@ var BaseDiffApprComponent = (function (_super) {
1067
1039
  };
1068
1040
  return _this;
1069
1041
  }
1070
- BaseDiffApprComponent.prototype.back = function (event) {
1071
- if (event) {
1072
- event.preventDefault();
1073
- }
1074
- this.props.history.goBack();
1075
- };
1076
1042
  BaseDiffApprComponent.prototype.initModel = function () {
1077
1043
  var x = {};
1078
1044
  return x;
@@ -1117,7 +1083,7 @@ var BaseDiffApprComponent = (function (_super) {
1117
1083
  var p = this.props;
1118
1084
  var diffModel = p['diffModel'];
1119
1085
  if (diffModel) {
1120
- var differentKeys_1 = reflectx_1.diff(diffModel.origin, diffModel.value);
1086
+ var differentKeys_1 = reflect_1.diff(diffModel.origin, diffModel.value);
1121
1087
  var dataFields = diff_1.getDataFields(this.form);
1122
1088
  dataFields.forEach(function (e) {
1123
1089
  var x = e.getAttribute('data-field');
@@ -1136,7 +1102,7 @@ var BaseDiffApprComponent = (function (_super) {
1136
1102
  }
1137
1103
  else {
1138
1104
  var _a = this.state, origin_1 = _a.origin, value = _a.value;
1139
- var differentKeys_2 = reflectx_1.diff(origin_1, value);
1105
+ var differentKeys_2 = reflect_1.diff(origin_1, value);
1140
1106
  var dataFields = diff_1.getDataFields(this.form);
1141
1107
  dataFields.forEach(function (e) {
1142
1108
  var x = e.getAttribute('data-field');
@@ -1178,13 +1144,6 @@ var DiffApprComponent = (function (_super) {
1178
1144
  };
1179
1145
  return _this;
1180
1146
  }
1181
- DiffApprComponent.prototype.componentDidMount = function () {
1182
- this.form = this.ref.current;
1183
- var id = core_2.buildId(this.props, this.keys);
1184
- if (id) {
1185
- this.load(id);
1186
- }
1187
- };
1188
1147
  DiffApprComponent.prototype.formatFields = function (value) {
1189
1148
  return value;
1190
1149
  };
package/lib/core.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var formutil_1 = require("./formutil");
4
+ exports.pageSizes = [12, 24, 60, 100, 120, 180, 300, 600];
4
5
  function createEditStatus(status) {
5
6
  if (status) {
6
7
  return status;
@@ -32,7 +33,7 @@ exports.createDiffStatus = createDiffStatus;
32
33
  var resource = (function () {
33
34
  function resource() {
34
35
  }
35
- resource.phone = / |\-|\.|\(|\)/g;
36
+ resource.phone = / |-|\.|\(|\)/g;
36
37
  resource._cache = {};
37
38
  resource.cache = true;
38
39
  return resource;
@@ -106,26 +107,21 @@ function buildKeys(attributes) {
106
107
  return ps;
107
108
  }
108
109
  exports.buildKeys = buildKeys;
109
- function buildId(props, keys) {
110
- if (!props) {
111
- return null;
112
- }
113
- var sp = (props.match ? props : props['props']);
110
+ function buildId(p, keys) {
114
111
  if (!keys || keys.length === 0 || keys.length === 1) {
115
112
  if (keys && keys.length === 1) {
116
- var x = sp.match.params[keys[0]];
117
- if (x && x !== '') {
118
- return x;
113
+ if (p[keys[0]]) {
114
+ return p[keys[0]];
119
115
  }
120
116
  }
121
- return sp.match.params['id'];
117
+ return p['id'];
122
118
  }
123
119
  var id = {};
124
120
  for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
125
121
  var key = keys_1[_i];
126
- var v = sp.match.params[key];
122
+ var v = p[key];
127
123
  if (!v) {
128
- v = sp[key];
124
+ v = p[key];
129
125
  if (!v) {
130
126
  return null;
131
127
  }
@@ -268,3 +264,16 @@ function getDecodeFromForm(u, d) {
268
264
  return (u && u.ui ? u.ui.decodeFromForm : undefined);
269
265
  }
270
266
  exports.getDecodeFromForm = getDecodeFromForm;
267
+ function handleToggle(target, on) {
268
+ if (target) {
269
+ if (on) {
270
+ if (!target.classList.contains('on')) {
271
+ target.classList.add('on');
272
+ }
273
+ }
274
+ else {
275
+ target.classList.remove('on');
276
+ }
277
+ }
278
+ }
279
+ exports.handleToggle = handleToggle;
package/lib/diff.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var reflectx_1 = require("reflectx");
3
+ var reflect_1 = require("./reflect");
4
4
  function formatDiffModel(obj, formatFields) {
5
5
  if (!obj) {
6
6
  return obj;
7
7
  }
8
- var obj2 = reflectx_1.clone(obj);
8
+ var obj2 = reflect_1.clone(obj);
9
9
  if (!obj2.origin) {
10
10
  obj2.origin = {};
11
11
  }
package/lib/formutil.js CHANGED
@@ -80,7 +80,7 @@ function focusFirstError(form, className) {
80
80
  var ctrl = form[i];
81
81
  var parent_1 = ctrl.parentElement;
82
82
  if (ctrl.classList.contains(className)
83
- || parent_1 && parent_1.classList.contains(className)) {
83
+ || (parent_1 && parent_1.classList.contains(className))) {
84
84
  ctrl.focus();
85
85
  ctrl.scrollIntoView();
86
86
  return;
@@ -93,7 +93,7 @@ function focusFirstError(form, className) {
93
93
  var parent_2 = ctrl.parentElement;
94
94
  if (ctrl.classList.contains('invalid')
95
95
  || ctrl.classList.contains('.ng-invalid')
96
- || parent_2 && parent_2.classList.contains('invalid')) {
96
+ || (parent_2 && parent_2.classList.contains('invalid'))) {
97
97
  ctrl.focus();
98
98
  ctrl.scrollIntoView();
99
99
  return;
package/lib/index.js CHANGED
@@ -2,12 +2,40 @@
2
2
  function __export(m) {
3
3
  for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
4
  }
5
- Object.defineProperty(exports, "__esModule", { value: true });var React = require("react");__export(require("./formutil"));__export(require("./util"));__export(require("./core"));__export(require("./state"));__export(require("./edit"));__export(require("./route"));__export(require("./components"));__export(require("./diff"));__export(require("./router"));__export(require("./merge"));__export(require("./update"));__export(require("./useView"));__export(require("./useEdit"));__export(require("./useSearch"));__export(require("./useMessage"));
6
- exports.withDefaultProps = function (Component) {
7
- return function (props) {
8
- return React.createElement(Component, { props: props, history: props.history });
9
- };
10
- };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var React = require("react");
7
+ __export(require("./formutil"));
8
+ __export(require("./util"));
9
+ __export(require("./core"));
10
+ __export(require("./state"));
11
+ __export(require("./edit"));
12
+ __export(require("./route"));
13
+ __export(require("./diff"));
14
+ __export(require("./merge"));
15
+ __export(require("./update"));
16
+ __export(require("./useSearch"));
17
+ __export(require("./useMessage"));
18
+ __export(require("./useEdit"));
19
+ __export(require("./components"));
20
+ __export(require("./search"));
21
+ __export(require("./reflect"));
22
+ var core_1 = require("./core");
23
+ function checked(s, v) {
24
+ if (s) {
25
+ if (Array.isArray(s)) {
26
+ return s.includes(v);
27
+ }
28
+ else {
29
+ return s === v;
30
+ }
31
+ }
32
+ return false;
33
+ }
34
+ exports.checked = checked;
35
+ function value(obj) {
36
+ return (obj ? obj : {});
37
+ }
38
+ exports.value = value;
11
39
  exports.Loading = function (props) {
12
40
  var loadingStyle = {
13
41
  top: '30%',
@@ -17,9 +45,17 @@ exports.Loading = function (props) {
17
45
  'boxShadow': 'none'
18
46
  };
19
47
  if (props.error) {
20
- return React.createElement("div", null, "Error Load Module!");
48
+ return React.createElement('div', null, 'Error Load Module!');
21
49
  }
22
50
  else {
23
- return (React.createElement("div", { className: 'loader-wrapper' }, React.createElement("div", { className: 'loader-sign', style: loadingStyle }, React.createElement("div", { className: 'loader' }))));
51
+ return (React.createElement('div', { className: 'loader-wrapper' }, React.createElement('div', { className: 'loader-sign', style: loadingStyle }, React.createElement('div', { className: 'loader' }))));
24
52
  }
25
53
  };
54
+ function PageSizeSelect(p) {
55
+ var g = p.sizes;
56
+ var s = (!g || g.length === 0 ? core_1.pageSizes : g);
57
+ var opts = s.map(function (pgSize) { return React.createElement('option', { key: pgSize, value: pgSize }, pgSize); });
58
+ return React.createElement('select', { id: p.id, name: p.name, defaultValue: p.size, onChange: p.onChange }, opts);
59
+ }
60
+ exports.PageSizeSelect = PageSizeSelect;
61
+ exports.default = PageSizeSelect;