@opentiny/vue-renderless 3.1.0-alpha.0 → 3.5.0-alpha.0

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.
Files changed (178) hide show
  1. package/action-menu/index.js +10 -0
  2. package/action-menu/vue.js +26 -0
  3. package/amount/index.js +334 -0
  4. package/amount/vue.js +206 -0
  5. package/area/index.js +162 -0
  6. package/area/vue.js +68 -0
  7. package/autonavi-map/index.js +28 -0
  8. package/avatar/index.js +5 -1
  9. package/avatar/vue.js +2 -1
  10. package/baidu-map/index.js +28 -0
  11. package/breadcrumb/index.js +9 -0
  12. package/breadcrumb/vue.js +25 -3
  13. package/breadcrumb-item/index.js +26 -0
  14. package/breadcrumb-item/vue.js +20 -11
  15. package/bulletin-board/index.js +4 -1
  16. package/button-group/vue.js +1 -1
  17. package/calendar/index.js +14 -14
  18. package/card-template/index.js +1 -1
  19. package/cascader/index.js +21 -7
  20. package/cascader/vue.js +1 -2
  21. package/cascader-node/index.js +3 -1
  22. package/cascader-panel/index.js +12 -4
  23. package/cascader-panel/vue.js +1 -2
  24. package/chart-bar/index.js +533 -0
  25. package/chart-boxplot/index.js +270 -0
  26. package/chart-candle/index.js +428 -0
  27. package/chart-core/deps/constants.js +65 -0
  28. package/chart-core/deps/numerify.js +286 -0
  29. package/chart-core/deps/utils.js +205 -0
  30. package/chart-core/index.js +541 -0
  31. package/chart-core/modules/animation.js +10 -0
  32. package/chart-core/modules/extend.js +36 -0
  33. package/chart-core/modules/mark.js +7 -0
  34. package/chart-core/vue.js +128 -0
  35. package/chart-funnel/index.js +155 -0
  36. package/chart-gauge/index.js +153 -0
  37. package/chart-graph/index.js +38 -0
  38. package/chart-heatmap/index.js +407 -0
  39. package/chart-line/index.js +358 -0
  40. package/chart-liquidfill/index.js +119 -0
  41. package/chart-map/index.js +261 -0
  42. package/chart-pie/index.js +327 -0
  43. package/chart-radar/index.js +181 -0
  44. package/chart-sankey/index.js +166 -0
  45. package/chart-scatter/index.js +360 -0
  46. package/chart-sunburst/index.js +36 -0
  47. package/chart-tree/index.js +107 -0
  48. package/chart-waterfall/index.js +231 -0
  49. package/chart-wordcloud/index.js +109 -0
  50. package/checkbox/index.js +4 -4
  51. package/checkbox-button/index.js +3 -1
  52. package/common/bigInt.js +5 -2
  53. package/common/date.js +17 -17
  54. package/common/deps/date-util.js +15 -5
  55. package/common/deps/date.js +6 -6
  56. package/common/deps/dom.js +18 -6
  57. package/common/deps/eSpaceCtrl.js +286 -0
  58. package/common/deps/fullscreen/apis.js +22 -22
  59. package/common/deps/memorize.js +3 -3
  60. package/common/deps/modal-queue.js +2 -0
  61. package/common/deps/popper.js +12 -10
  62. package/common/deps/popup-manager.js +16 -5
  63. package/common/deps/resize-event.js +6 -2
  64. package/common/deps/scrollbar-width.js +6 -2
  65. package/common/deps/tree-model/node.js +30 -10
  66. package/common/deps/tree-model/tree-store.js +33 -21
  67. package/common/deps/tree-model/util.js +6 -2
  68. package/common/deps/upload-ajax.js +7 -1
  69. package/common/deps/vue-popper.js +2 -2
  70. package/common/string.js +1 -1
  71. package/company/index.js +56 -0
  72. package/company/vue.js +35 -0
  73. package/country/index.js +54 -0
  74. package/country/vue.js +35 -0
  75. package/credit-card-form/index.js +1 -0
  76. package/currency/index.js +78 -0
  77. package/currency/vue.js +39 -0
  78. package/date-panel/index.js +16 -6
  79. package/date-picker/index.js +9 -5
  80. package/date-range/index.js +28 -9
  81. package/date-table/index.js +3 -1
  82. package/dept/index.js +318 -0
  83. package/dept/vue.js +163 -0
  84. package/detail-page/index.js +4 -1
  85. package/dialog-box/index.js +14 -4
  86. package/dialog-box/vue.js +7 -3
  87. package/drop-roles/index.js +73 -0
  88. package/drop-roles/vue.js +38 -0
  89. package/dropdown/index.js +5 -4
  90. package/dropdown/vue.js +5 -3
  91. package/dropdown-item/index.js +15 -0
  92. package/dropdown-item/vue.js +27 -13
  93. package/espace/index.js +129 -0
  94. package/espace/vue.js +52 -0
  95. package/exception/index.js +1 -1
  96. package/file-upload/index.js +336 -291
  97. package/form/index.js +3 -1
  98. package/form/vue.js +15 -0
  99. package/form-item/index.js +15 -5
  100. package/fullscreen/index.js +4 -4
  101. package/fullscreen/vue.js +3 -3
  102. package/grid/core/interceptor.js +4 -7
  103. package/grid/plugins/export.js +2 -2
  104. package/grid/plugins/exportExcel.js +28 -10
  105. package/grid/static/array/findTree.js +1 -1
  106. package/grid/static/base/helperCreateGetObjects.js +1 -1
  107. package/grid/static/base/helperEqualCompare.js +2 -2
  108. package/grid/static/base/helperGetHGSKeys.js +1 -1
  109. package/grid/static/base/uniqueId.js +1 -1
  110. package/grid/static/object/assign.js +3 -3
  111. package/grid/static/string/toString.js +3 -3
  112. package/hrapprover/index.js +118 -0
  113. package/hrapprover/vue.js +102 -0
  114. package/locales/index.js +116 -0
  115. package/locales/vue.js +46 -0
  116. package/logon-user/index.js +23 -0
  117. package/logon-user/vue.js +22 -0
  118. package/logout/index.js +118 -0
  119. package/logout/vue.js +22 -0
  120. package/milestone/index.js +2 -1
  121. package/mini-picker/index.js +1 -1
  122. package/mini-picker/vue.js +1 -1
  123. package/modal/index.js +4 -2
  124. package/month-table/index.js +2 -2
  125. package/nav-menu/index.js +2 -2
  126. package/numeric/index.js +5 -2
  127. package/package.json +33 -136
  128. package/pager-item/vue.js +6 -2
  129. package/picker/index.js +43 -17
  130. package/picker/timezone.js +2 -2
  131. package/picker-column/index.js +7 -3
  132. package/pop-upload/index.js +5 -3
  133. package/popeditor/index.js +15 -7
  134. package/popover/index.js +87 -54
  135. package/popover/vue.js +13 -9
  136. package/rate/index.js +2 -2
  137. package/rich-text/clipboard.js +77 -0
  138. package/rich-text/index.js +176 -0
  139. package/rich-text/module/file-upload.js +118 -0
  140. package/rich-text/module/image-drop.js +54 -0
  141. package/rich-text/module/image-upload.js +84 -0
  142. package/rich-text/options.js +187 -0
  143. package/rich-text/table-module.js +557 -0
  144. package/rich-text/vue.js +149 -0
  145. package/roles/index.js +87 -0
  146. package/roles/vue.js +39 -0
  147. package/search/index.js +32 -27
  148. package/search/vue.js +7 -2
  149. package/select/index.js +328 -304
  150. package/select/vue.js +19 -9
  151. package/select-dropdown/index.js +1 -1
  152. package/slider/index.js +9 -11
  153. package/slider/vue.js +3 -3
  154. package/split/vue.js +1 -1
  155. package/tab-nav/index.js +0 -6
  156. package/tab-nav/vue.js +0 -14
  157. package/table/index.js +1 -1
  158. package/text-popup/index.js +6 -4
  159. package/time/index.js +3 -1
  160. package/time-range/index.js +6 -2
  161. package/time-spinner/index.js +15 -5
  162. package/toggle-menu/index.js +11 -0
  163. package/toggle-menu/vue.js +2 -1
  164. package/tooltip/index.js +46 -35
  165. package/tooltip/vue.js +5 -1
  166. package/tree/index.js +57 -21
  167. package/tree-menu/index.js +3 -1
  168. package/tree-node/index.js +7 -3
  169. package/upload/index.js +14 -5
  170. package/user/index.js +634 -0
  171. package/user/vue.js +113 -0
  172. package/user-account/index.js +23 -0
  173. package/user-account/vue.js +25 -0
  174. package/user-contact/index.js +1 -4
  175. package/user-head/index.js +33 -11
  176. package/user-head/vue.js +10 -7
  177. package/user-link/index.js +43 -0
  178. package/user-link/vue.js +60 -0
@@ -1,8 +1,12 @@
1
1
  var scrollBarWidth;
2
2
  var isServer = typeof window === 'undefined';
3
3
  export default function () {
4
- if (isServer) return 0;
5
- if (scrollBarWidth !== undefined) return scrollBarWidth;
4
+ if (isServer) {
5
+ return 0;
6
+ }
7
+ if (scrollBarWidth !== undefined) {
8
+ return scrollBarWidth;
9
+ }
6
10
  var container = document.createElement('div');
7
11
  container.className = 'tiny-scrollbar';
8
12
  container.style.visibility = 'hidden';
@@ -48,7 +48,9 @@ export var getChildState = function getChildState(node) {
48
48
  };
49
49
  var reInitChecked = function reInitChecked(node) {
50
50
  var childNodes = node.childNodes;
51
- if (childNodes.length === 0) return;
51
+ if (childNodes.length === 0) {
52
+ return;
53
+ }
52
54
  var _getChildState = getChildState(childNodes),
53
55
  all = _getChildState.all,
54
56
  none = _getChildState.none,
@@ -70,7 +72,9 @@ var reInitChecked = function reInitChecked(node) {
70
72
  });
71
73
  }
72
74
  var parent = node.parent;
73
- if (!parent || parent.level === 0) return;
75
+ if (!parent || parent.level === 0) {
76
+ return;
77
+ }
74
78
  !node.store.checkStrictly && reInitChecked(parent);
75
79
  };
76
80
  var nodeIdSeed = 0;
@@ -97,7 +101,9 @@ var Node = function () {
97
101
  if (!Array.isArray(this.data)) {
98
102
  markNodeData(this, this.data);
99
103
  }
100
- if (!this.data) return;
104
+ if (!this.data) {
105
+ return;
106
+ }
101
107
  this.expandByDefaultKeys();
102
108
  var key = store.key,
103
109
  lazy = store.lazy,
@@ -189,7 +195,9 @@ var Node = function () {
189
195
  var store = this.store,
190
196
  data = this.data;
191
197
  var nodeKey = store.key;
192
- if (data) return data[nodeKey];
198
+ if (data) {
199
+ return data[nodeKey];
200
+ }
193
201
  return null;
194
202
  }
195
203
  }, {
@@ -255,7 +263,9 @@ var Node = function () {
255
263
  }, {
256
264
  key: "insertChild",
257
265
  value: function insertChild(child, index, batch) {
258
- if (!child) throw new Error('[TINY-Tree] insertChild error: child is required.');
266
+ if (!child) {
267
+ throw new Error('[TINY-Tree] insertChild error: child is required.');
268
+ }
259
269
  var insertNode = function insertNode(_ref) {
260
270
  var arr = _ref.arr,
261
271
  index = _ref.index,
@@ -416,8 +426,12 @@ var Node = function () {
416
426
  var forceInit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
417
427
  var level = this.level,
418
428
  data = this.data;
419
- if (level === 0) return data;
420
- if (!data) return null;
429
+ if (level === 0) {
430
+ return data;
431
+ }
432
+ if (!data) {
433
+ return null;
434
+ }
421
435
  var props = this.store.props;
422
436
  var childrenKey = defaultChildrenKey;
423
437
  if (props) {
@@ -439,7 +453,9 @@ var Node = function () {
439
453
  var _this$store2 = this.store,
440
454
  checkStrictly = _this$store2.checkStrictly,
441
455
  checkDescendants = _this$store2.checkDescendants;
442
- if (checkStrictly) return;
456
+ if (checkStrictly) {
457
+ return;
458
+ }
443
459
  var ret = this.setCheckedInner({
444
460
  checkDescendants: checkDescendants,
445
461
  value: value,
@@ -453,7 +469,9 @@ var Node = function () {
453
469
  return;
454
470
  }
455
471
  var parentNode = this.parent;
456
- if (!parentNode || parentNode.level === 0) return;
472
+ if (!parentNode || parentNode.level === 0) {
473
+ return;
474
+ }
457
475
  if (!recursion) {
458
476
  this.store.lazy ? lazyInitChecked(parentNode) : reInitChecked(parentNode);
459
477
  }
@@ -546,7 +564,9 @@ var Node = function () {
546
564
  });
547
565
  if (!this.store.lazy) {
548
566
  oldChildren.forEach(function (item) {
549
- if (!newChildrenMap[item[NODE_KEY]]) _this5.removeChildByData(item);
567
+ if (!newChildrenMap[item[NODE_KEY]]) {
568
+ _this5.removeChildByData(item);
569
+ }
550
570
  });
551
571
  }
552
572
  newChildren.forEach(function (_ref3) {
@@ -54,8 +54,12 @@ var TreeStore = function () {
54
54
  node.visible = allHidden === false;
55
55
  }
56
56
  }
57
- if (!value) return;
58
- if (node.visible && !node.isLeaf && !lazy) node.expand();
57
+ if (!value) {
58
+ return;
59
+ }
60
+ if (node.visible && !node.isLeaf && !lazy) {
61
+ node.expand();
62
+ }
59
63
  };
60
64
  walkTree(this);
61
65
  }
@@ -172,7 +176,9 @@ var TreeStore = function () {
172
176
  value: function deregisterNode(node) {
173
177
  var _this6 = this;
174
178
  var key = this.key;
175
- if (!key || !node || !node.data) return;
179
+ if (!key || !node || !node.data) {
180
+ return;
181
+ }
176
182
  node.childNodes.forEach(function (child) {
177
183
  _this6.deregisterNode(child);
178
184
  });
@@ -182,7 +188,9 @@ var TreeStore = function () {
182
188
  key: "registerNode",
183
189
  value: function registerNode(node) {
184
190
  var key = this.key;
185
- if (!key || !node || !node.data) return;
191
+ if (!key || !node || !node.data) {
192
+ return;
193
+ }
186
194
  var nodeKey = node.key;
187
195
  if (nodeKey !== undefined) {
188
196
  this.nodesMap[nodeKey] = node;
@@ -240,7 +248,9 @@ var TreeStore = function () {
240
248
  key: "updateChildren",
241
249
  value: function updateChildren(key, data) {
242
250
  var node = this.nodesMap[key];
243
- if (!node) return;
251
+ if (!node) {
252
+ return;
253
+ }
244
254
  var childNodes = node.childNodes;
245
255
  for (var i = childNodes.length - 1; i >= 0; i--) {
246
256
  this.remove(childNodes[i].data);
@@ -253,6 +263,7 @@ var TreeStore = function () {
253
263
  }, {
254
264
  key: "_setCheckedKeys",
255
265
  value: function _setCheckedKeys(key) {
266
+ var _this7 = this;
256
267
  var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
257
268
  var checkedKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
258
269
  var nodes = this._getAllNodes().sort(function (prevNode, nextNode) {
@@ -263,7 +274,7 @@ var TreeStore = function () {
263
274
  nodes.forEach(function (node) {
264
275
  node.setChecked(false, false);
265
276
  });
266
- for (var i = 0, len = nodes.length; i < len; i++) {
277
+ var _loop = function _loop() {
267
278
  var node = nodes[i];
268
279
  var nodeKey = node.data[key].toString();
269
280
  var checked = ~keys.indexOf(nodeKey);
@@ -277,35 +288,36 @@ var TreeStore = function () {
277
288
  cache[parentNode.data[key]] = true;
278
289
  parentNode = parentNode.parent;
279
290
  }
280
- if (node.isLeaf || this.checkStrictly) {
291
+ if (node.isLeaf || _this7.checkStrictly) {
281
292
  node.setChecked(true, false);
282
293
  } else if (leafOnly) {
283
- (function () {
284
- node.setChecked(false, false);
285
- var walkTree = function walkTree(node) {
286
- var childNodes = node.childNodes;
287
- childNodes.forEach(function (child) {
288
- !child.isLeaf && child.setChecked(false, false);
289
- walkTree(child);
290
- });
291
- };
292
- walkTree(node);
293
- })();
294
+ node.setChecked(false, false);
295
+ var walkTree = function walkTree(node) {
296
+ var childNodes = node.childNodes;
297
+ childNodes.forEach(function (child) {
298
+ !child.isLeaf && child.setChecked(false, false);
299
+ walkTree(child);
300
+ });
301
+ };
302
+ walkTree(node);
294
303
  } else {
295
304
  node.setChecked(true, true);
296
305
  }
297
306
  }
307
+ };
308
+ for (var i = 0, len = nodes.length; i < len; i++) {
309
+ _loop();
298
310
  }
299
311
  }
300
312
  }, {
301
313
  key: "setDefaultExpandedKeys",
302
314
  value: function setDefaultExpandedKeys(keys) {
303
- var _this7 = this;
315
+ var _this8 = this;
304
316
  keys = keys || [];
305
317
  this.defaultExpandedKeys = keys;
306
318
  keys.forEach(function (key) {
307
- var node = _this7.getNode(key);
308
- node && node.expand(null, _this7.autoExpandParent);
319
+ var node = _this8.getNode(key);
320
+ node && node.expand(null, _this8.autoExpandParent);
309
321
  });
310
322
  }
311
323
  }, {
@@ -1,10 +1,14 @@
1
1
  export var NODE_KEY = '$treeNodeId';
2
2
  export var getNodeKey = function getNodeKey(key, data) {
3
- if (!key) return data[NODE_KEY];
3
+ if (!key) {
4
+ return data[NODE_KEY];
5
+ }
4
6
  return data[key];
5
7
  };
6
8
  export var markNodeData = function markNodeData(node, data) {
7
- if (!data || data[NODE_KEY]) return;
9
+ if (!data || data[NODE_KEY]) {
10
+ return;
11
+ }
8
12
  Object.defineProperty(data, NODE_KEY, {
9
13
  value: node.id,
10
14
  enumerable: false,
@@ -46,7 +46,13 @@ export default (function (option) {
46
46
  formData.append(key, option.data[key]);
47
47
  });
48
48
  }
49
- formData.append(option.filename, option.file, option.file.name);
49
+ if (Array.isArray(option.file)) {
50
+ option.file.forEach(function (file) {
51
+ formData.append(option.filename, file, file.name);
52
+ });
53
+ } else {
54
+ formData.append(option.filename, option.file, option.file.name);
55
+ }
50
56
  xhr.onerror = function (event) {
51
57
  option.onError(event);
52
58
  };
@@ -30,10 +30,11 @@ var getReferMaxZIndex = function getReferMaxZIndex(reference) {
30
30
  var max = getZIndex(reference);
31
31
  var z;
32
32
  do {
33
+ var _reference, _reference$parentNode;
33
34
  reference = reference.parentNode;
34
35
  z = getZIndex(reference);
35
36
  max = z > max ? z : max;
36
- } while (reference !== document.body);
37
+ } while (reference !== document.body && ((_reference = reference) === null || _reference === void 0 ? void 0 : (_reference$parentNode = _reference.parentNode) === null || _reference$parentNode === void 0 ? void 0 : _reference$parentNode.nodeType) !== 11);
37
38
  return "".concat(max + 1);
38
39
  };
39
40
  var appendPopper = function appendPopper(_ref2) {
@@ -147,7 +148,6 @@ var createPopperFn = function createPopperFn(_ref4) {
147
148
  state.popperJS.onCreate(function () {
148
149
  emit('created', state);
149
150
  resetTransformOrigin();
150
- nextTick(updatePopper);
151
151
  });
152
152
  if (typeof options.onUpdate === 'function') {
153
153
  state.popperJS.onUpdate(options.onUpdate);
package/common/string.js CHANGED
@@ -13,7 +13,7 @@ export var escapeChars = {
13
13
  '<': '&#60;',
14
14
  '>': '&#62;',
15
15
  '"': '&#34;',
16
- "'": '&#x27;',
16
+ '\'': '&#x27;',
17
17
  '[': '&#91;',
18
18
  ']': '&#93;'
19
19
  };
@@ -0,0 +1,56 @@
1
+ export var init = function init(_ref) {
2
+ var state = _ref.state,
3
+ props = _ref.props,
4
+ service = _ref.service;
5
+ return function () {
6
+ var _service$fields = service.fields,
7
+ textField = _service$fields.textField,
8
+ valueField = _service$fields.valueField;
9
+ if (state.source) {
10
+ state.options = state.source.map(function (item) {
11
+ return {
12
+ label: item[textField],
13
+ value: item[valueField]
14
+ };
15
+ });
16
+ } else {
17
+ service.fetchCompany().then(function (data) {
18
+ var list = data || [];
19
+ state.source = props.max ? list.slice(0, props.max) : list;
20
+ state.options = state.source.map(function (item) {
21
+ return {
22
+ label: item[textField],
23
+ value: item[valueField]
24
+ };
25
+ });
26
+ });
27
+ }
28
+ };
29
+ };
30
+ export var change = function change(emit) {
31
+ return function (value) {
32
+ emit('update:modelValue', value);
33
+ emit('change', value);
34
+ };
35
+ };
36
+ export var initService = function initService(_ref2) {
37
+ var props = _ref2.props,
38
+ service = _ref2.service;
39
+ var _ref3 = service || {},
40
+ _ref3$setting = _ref3.setting,
41
+ setting = _ref3$setting === void 0 ? {} : _ref3$setting,
42
+ fetchCompany = _ref3.fetchCompany;
43
+ var _setting$options = setting.options,
44
+ options = _setting$options === void 0 ? {} : _setting$options;
45
+ var defaultCompanySetting = {
46
+ textField: 'tx_corporation_cn',
47
+ valueField: 'tx_coa'
48
+ };
49
+ var fetchCompanyNoop = function fetchCompanyNoop() {
50
+ return Promise.resolve([]);
51
+ };
52
+ return {
53
+ fetchCompany: props.fetchCompany || fetchCompany || fetchCompanyNoop,
54
+ fields: props.fields || options.Company || defaultCompanySetting
55
+ };
56
+ };
package/company/vue.js ADDED
@@ -0,0 +1,35 @@
1
+ import { init, change, initService } from './index';
2
+ export var api = ['state', 'change', 'clear', 'visibleChange'];
3
+ export var renderless = function renderless(props, _ref, _ref2) {
4
+ var watch = _ref.watch,
5
+ reactive = _ref.reactive;
6
+ var emit = _ref2.emit,
7
+ service = _ref2.service;
8
+ var $service = initService({
9
+ props: props,
10
+ service: service
11
+ });
12
+ var state = reactive({
13
+ options: [],
14
+ source: null,
15
+ selectedValue: props.modelValue
16
+ });
17
+ var api = {
18
+ state: state,
19
+ change: change(emit),
20
+ init: init({
21
+ state: state,
22
+ props: props,
23
+ service: $service
24
+ })
25
+ };
26
+ watch(function () {
27
+ return props.modelValue;
28
+ }, function (propsValue) {
29
+ state.selectedValue = propsValue;
30
+ }, {
31
+ immediate: true
32
+ });
33
+ api.init();
34
+ return api;
35
+ };
@@ -0,0 +1,54 @@
1
+ export var change = function change(emit) {
2
+ return function (value) {
3
+ emit('update:modelValue', value);
4
+ emit('change', value);
5
+ };
6
+ };
7
+ export var init = function init(_ref) {
8
+ var state = _ref.state,
9
+ service = _ref.service;
10
+ return function () {
11
+ var _service$fields = service.fields,
12
+ textField = _service$fields.textField,
13
+ valueField = _service$fields.valueField;
14
+ if (state.source) {
15
+ state.options = state.source.map(function (item) {
16
+ return {
17
+ label: item[textField],
18
+ value: item[valueField]
19
+ };
20
+ });
21
+ } else {
22
+ service.fetchCountry().then(function (data) {
23
+ state.source = data || [];
24
+ state.options = state.source.map(function (item) {
25
+ return {
26
+ value: item[valueField],
27
+ label: item[textField]
28
+ };
29
+ });
30
+ });
31
+ }
32
+ };
33
+ };
34
+ export var initService = function initService(_ref2) {
35
+ var props = _ref2.props,
36
+ service = _ref2.service;
37
+ var _ref3 = service || {},
38
+ fetchCountry = _ref3.fetchCountry,
39
+ _ref3$setting = _ref3.setting,
40
+ setting = _ref3$setting === void 0 ? {} : _ref3$setting;
41
+ var _setting$options = setting.options,
42
+ options = _setting$options === void 0 ? {} : _setting$options;
43
+ var defaultCountrySetting = {
44
+ textField: 'territory_short_name',
45
+ valueField: 'territory_code'
46
+ };
47
+ var fetchCountryNoop = function fetchCountryNoop() {
48
+ return Promise.resolve([]);
49
+ };
50
+ return {
51
+ fetchCountry: props.fetchCountry || fetchCountry || fetchCountryNoop,
52
+ fields: props.fields || options.Country || defaultCountrySetting
53
+ };
54
+ };
package/country/vue.js ADDED
@@ -0,0 +1,35 @@
1
+ import { init, change, initService } from './index';
2
+ export var api = ['state', 'change', 'emit'];
3
+ export var renderless = function renderless(props, _ref, _ref2) {
4
+ var watch = _ref.watch,
5
+ reactive = _ref.reactive;
6
+ var service = _ref2.service,
7
+ emit = _ref2.emit;
8
+ var $service = initService({
9
+ props: props,
10
+ service: service
11
+ });
12
+ var state = reactive({
13
+ source: null,
14
+ options: [],
15
+ selectedValue: props.modelValue
16
+ });
17
+ var api = {
18
+ state: state,
19
+ emit: emit,
20
+ change: change(emit),
21
+ init: init({
22
+ state: state,
23
+ service: $service
24
+ })
25
+ };
26
+ watch(function () {
27
+ return props.modelValue;
28
+ }, function (newValue) {
29
+ state.selectedValue = newValue;
30
+ }, {
31
+ immediate: true
32
+ });
33
+ api.init();
34
+ return api;
35
+ };
@@ -17,6 +17,7 @@ export var changeNumber = function changeNumber(_ref2) {
17
17
  state = _ref2.state;
18
18
  return function (event) {
19
19
  state.formData.cardNumber = event.target.value;
20
+ state.mainCardNumber = event.target.value;
20
21
  var value = state.formData.cardNumber.replace(/\D/g, '');
21
22
  if (/^3[47]\d{0,13}$/.test(value)) {
22
23
  state.formData.cardNumber = value.replace(/^(\d{4})(?=\d)/, '$1 ').replace(/^(\d{4}) (\d{6})(?=\d)/, '$1 $2 ');
@@ -0,0 +1,78 @@
1
+ import { isUndefined, isNull } from '@opentiny/vue-renderless/grid/static';
2
+ import { log } from '@opentiny/vue-renderless/common';
3
+ export var init = function init(_ref) {
4
+ var state = _ref.state,
5
+ service = _ref.service,
6
+ api = _ref.api;
7
+ return function () {
8
+ var _service$fields = service.fields,
9
+ textField = _service$fields.textField,
10
+ valueField = _service$fields.valueField;
11
+ service.fetchCurrency().then(function (data) {
12
+ api.fixServiceData(data).then(function (result) {
13
+ state.options = result.map(function (item) {
14
+ return {
15
+ label: item[textField],
16
+ value: item[valueField]
17
+ };
18
+ });
19
+ });
20
+ });
21
+ };
22
+ };
23
+ export var change = function change(emit) {
24
+ return function (value) {
25
+ emit('update:modelValue', value);
26
+ emit('change', value);
27
+ };
28
+ };
29
+ export var initService = function initService(_ref2) {
30
+ var props = _ref2.props,
31
+ service = _ref2.service;
32
+ var defaultCurrencySetting = {
33
+ textField: 'currency_code',
34
+ valueField: 'currency_code'
35
+ };
36
+ var _ref3 = service || {},
37
+ _ref3$setting = _ref3.setting,
38
+ setting = _ref3$setting === void 0 ? {} : _ref3$setting,
39
+ fetchCurrency = _ref3.fetchCurrency;
40
+ var _setting$options = setting.options,
41
+ options = _setting$options === void 0 ? {} : _setting$options;
42
+ var fetchCurrencyNoop = function fetchCurrencyNoop() {
43
+ return Promise.resolve([]);
44
+ };
45
+ return {
46
+ fetchCurrency: props.fetchCurrency || fetchCurrency || fetchCurrencyNoop,
47
+ fields: props.fields || options.Currency || defaultCurrencySetting
48
+ };
49
+ };
50
+ export var fixServiceData = function fixServiceData(_ref4) {
51
+ var props = _ref4.props,
52
+ service = _ref4.service;
53
+ return function (data) {
54
+ var _service$fields2 = service.fields,
55
+ textField = _service$fields2.textField,
56
+ valueField = _service$fields2.valueField;
57
+ return new Promise(function (resolve) {
58
+ data = data || [];
59
+ data = Array.isArray(data) ? data : [];
60
+ var result = [];
61
+ data.forEach(function (option) {
62
+ option = option || {};
63
+ var value = option[valueField];
64
+ var text = option[textField];
65
+ if (isUndefined(value) || isNull(value)) {
66
+ if (text) {
67
+ option[valueField] = text;
68
+ } else {
69
+ log('data error. set it to the default value.', 'warn');
70
+ option[textField] = option[valueField] = props.currency;
71
+ }
72
+ }
73
+ result.push(option);
74
+ });
75
+ resolve(result);
76
+ });
77
+ };
78
+ };
@@ -0,0 +1,39 @@
1
+ import { init, fixServiceData, change, initService } from './index';
2
+ export var api = ['state', 'change'];
3
+ export var renderless = function renderless(props, _ref, _ref2) {
4
+ var watch = _ref.watch,
5
+ reactive = _ref.reactive;
6
+ var service = _ref2.service,
7
+ emit = _ref2.emit;
8
+ var api = {};
9
+ var $service = initService({
10
+ props: props,
11
+ service: service
12
+ });
13
+ var state = reactive({
14
+ options: [],
15
+ selectedValue: props.modelValue
16
+ });
17
+ Object.assign(api, {
18
+ state: state,
19
+ change: change(emit),
20
+ fixServiceData: fixServiceData({
21
+ props: props,
22
+ service: $service
23
+ }),
24
+ init: init({
25
+ state: state,
26
+ service: $service,
27
+ api: api
28
+ })
29
+ });
30
+ watch(function () {
31
+ return props.modelValue;
32
+ }, function (param) {
33
+ state.selectedValue = param;
34
+ }, {
35
+ immediate: true
36
+ });
37
+ api.init();
38
+ return api;
39
+ };
@@ -27,7 +27,9 @@ export var watchValue = function watchValue(_ref2) {
27
27
  var api = _ref2.api,
28
28
  state = _ref2.state;
29
29
  return function (value) {
30
- if (state.selectionMode === DATEPICKER.Dates && state.value) return;
30
+ if (state.selectionMode === DATEPICKER.Dates && state.value) {
31
+ return;
32
+ }
31
33
  if (isDate(value)) {
32
34
  state.date = state.selectionMode === 'week' ? getWeekData(value) : new Date(value);
33
35
  } else {
@@ -74,7 +76,9 @@ export var proxyTimePickerDataProperties = function proxyTimePickerDataPropertie
74
76
  watch = _ref6.watch;
75
77
  return function () {
76
78
  var format = function format(timeFormat) {
77
- if (refs.timepicker) refs.timepicker.state.format = timeFormat;
79
+ if (refs.timepicker) {
80
+ refs.timepicker.state.format = timeFormat;
81
+ }
78
82
  };
79
83
  var value = function value(_value) {
80
84
  if (refs.timepicker) {
@@ -417,7 +421,9 @@ export var handleVisibleTimeChange = function handleVisibleTimeChange(_ref25) {
417
421
  if (time && api.checkDateWithinRange(time)) {
418
422
  state.date = modifyDate(time, state.year, state.month, state.monthDate);
419
423
  state.userInputTime = null;
420
- if (refs.timepicker) refs.timepicker.state.value = state.date;
424
+ if (refs.timepicker) {
425
+ refs.timepicker.state.value = state.date;
426
+ }
421
427
  state.timePickerVisible = false;
422
428
  api.cusEmit(state.date, true);
423
429
  }
@@ -462,7 +468,9 @@ export var selectTz = function selectTz(_ref29) {
462
468
  var emit = _ref29.emit,
463
469
  state = _ref29.state;
464
470
  return function (tz) {
465
- if (state.timezone.isServiceTimezone) return;
471
+ if (state.timezone.isServiceTimezone) {
472
+ return;
473
+ }
466
474
  state.tz = tz.name;
467
475
  state.selectedTz = tz;
468
476
  state.showpopup = false;
@@ -507,7 +515,9 @@ export var debounceChange = debounce(500, function (state, input) {
507
515
  });
508
516
  export var toggleTz = function toggleTz(state) {
509
517
  return function () {
510
- if (state.timezone.isServiceTimezone) return;
518
+ if (state.timezone.isServiceTimezone) {
519
+ return;
520
+ }
511
521
  state.renderTzdata = state.renderTzdata && state.renderTzdata.map(function (item) {
512
522
  item.visible = false;
513
523
  return item;
@@ -538,7 +548,7 @@ export var getRenderTz = function getRenderTz(_ref31) {
538
548
  findTimezoneKey = '';
539
549
  } else {
540
550
  findTimezoneKey = to > 0 ? '+' : '-';
541
- findTimezoneKey = findTimezoneKey + fillChar(Math.abs(to) + '', 2) + ':00';
551
+ findTimezoneKey = findTimezoneKey + fillChar(String(Math.abs(to)), 2) + ':00';
542
552
  }
543
553
  findTimezoneKey = "(UTC".concat(findTimezoneKey, ")");
544
554
  state.renderTzdata.some(function (item) {