formiojs-eorion 0.1.7 → 0.1.9

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/Formio.js CHANGED
@@ -1724,7 +1724,7 @@ Formio.projectUrlSet = false;
1724
1724
  Formio.plugins = [];
1725
1725
  Formio.cache = {};
1726
1726
  Formio.Providers = _providers.default;
1727
- Formio.version = '0.1.7';
1727
+ Formio.version = '0.1.9';
1728
1728
  Formio.pathType = '';
1729
1729
  Formio.events = new _EventEmitter.default();
1730
1730
  Formio.cdn = new _CDN.default();
@@ -304,6 +304,9 @@ var CustomTabsComponent = /*#__PURE__*/function (_NestedComponent) {
304
304
  if (['echarts', 'taskCalendar'].includes(item.type)) {
305
305
  _this11.tabs[_this11.currentTab][index].refresh(new Date().getTime());
306
306
  }
307
+ if (['data_china_grid_row', 'data_china_grid'].includes(item.type)) {
308
+ _this11.tabs[_this11.currentTab][index].resetSparkLine();
309
+ }
307
310
  });
308
311
  }
309
312
  this.clearErrorClasses(this.refs[this.tabLinkKey]);
@@ -20,9 +20,9 @@ exports.default = void 0;
20
20
  require("core-js/modules/es.regexp.exec.js");
21
21
  require("core-js/modules/es.string.replace.js");
22
22
  require("core-js/modules/es.string.trim.js");
23
+ require("core-js/modules/es.array.find.js");
23
24
  require("core-js/modules/es.object.to-string.js");
24
25
  require("core-js/modules/web.dom-collections.for-each.js");
25
- require("core-js/modules/es.array.find.js");
26
26
  require("core-js/modules/es.array.concat.js");
27
27
  require("core-js/modules/es.object.get-prototype-of.js");
28
28
  var _Field = _interopRequireDefault(require("../_classes/field/Field"));
@@ -135,6 +135,62 @@ var DataChinaGrid = /*#__PURE__*/function (_Component) {
135
135
  value: function getValue() {
136
136
  return this.component.field;
137
137
  }
138
+ }, {
139
+ key: "resetSparkLine",
140
+ value: function resetSparkLine() {
141
+ var self = this;
142
+ var container = this.element.querySelector('.data-container');
143
+ if (self.component['enable-sparkline']) {
144
+ if (self.isLoadingSparkLine) {
145
+ return true;
146
+ }
147
+ self.isLoadingSparkLine = true;
148
+ var sparkLineType = this.component['sparkLine-type'] || 'line';
149
+ var fillColor;
150
+ if (self.component['sparkLine-fill-color']) {
151
+ switch (sparkLineType) {
152
+ case 'line':
153
+ fillColor = self.component['sparkLine-fill-color'].split(',')[0];
154
+ break;
155
+ case 'pie':
156
+ case 'donut':
157
+ case 'bar':
158
+ fillColor = self.component['sparkLine-fill-color'].split(',');
159
+ break;
160
+ }
161
+ }
162
+ // values
163
+ container.querySelector('.sparkline-container').innerHTML = "<span class=\"line\">".concat(self.parseTpl(self.component['sparkLine-value'], {
164
+ data: self.rootValue
165
+ }), "</span>");
166
+ try {
167
+ // @ts-ignore
168
+ $(container).find('.line').peity(sparkLineType, {
169
+ fill: fillColor,
170
+ height: self.component['sparkLine-height'],
171
+ max: self.component['sparkLine-max-value-count'],
172
+ min: 0,
173
+ stroke: self.component['sparkLine-stroke-color'],
174
+ strokeWidth: 2,
175
+ width: self.component['sparkLine-width']
176
+ });
177
+ self.isLoadingSparkLine = false;
178
+ } catch (e) {
179
+ container.querySelectorAll(".line").forEach(function (e) {
180
+ return peity(e, sparkLineType, {
181
+ fill: fillColor,
182
+ height: self.component['sparkLine-height'],
183
+ max: self.component['sparkLine-max-value-count'],
184
+ min: 0,
185
+ stroke: self.component['sparkLine-stroke-color'],
186
+ strokeWidth: 2,
187
+ width: self.component['sparkLine-width']
188
+ });
189
+ });
190
+ self.isLoadingSparkLine = false;
191
+ }
192
+ }
193
+ }
138
194
 
139
195
  /**
140
196
  * Set the value of the component into the dom elements.
@@ -179,56 +235,7 @@ var DataChinaGrid = /*#__PURE__*/function (_Component) {
179
235
  });
180
236
  }
181
237
  // 图标
182
- if (self.component['enable-sparkline']) {
183
- if (self.isLoadingSparkLine) {
184
- return true;
185
- }
186
- self.isLoadingSparkLine = true;
187
- var sparkLineType = this.component['sparkLine-type'] || 'line';
188
- var fillColor;
189
- if (self.component['sparkLine-fill-color']) {
190
- switch (sparkLineType) {
191
- case 'line':
192
- fillColor = self.component['sparkLine-fill-color'].split(',')[0];
193
- break;
194
- case 'pie':
195
- case 'donut':
196
- case 'bar':
197
- fillColor = self.component['sparkLine-fill-color'].split(',');
198
- break;
199
- }
200
- }
201
- // values
202
- container.querySelector('.sparkline-container').innerHTML = "<span class=\"line\">".concat(self.parseTpl(self.component['sparkLine-value'], {
203
- data: self.rootValue
204
- }), "</span>");
205
- try {
206
- // @ts-ignore
207
- $(container).find('.line').peity(sparkLineType, {
208
- fill: fillColor,
209
- height: self.component['sparkLine-height'],
210
- max: self.component['sparkLine-max-value-count'],
211
- min: 0,
212
- stroke: self.component['sparkLine-stroke-color'],
213
- strokeWidth: 2,
214
- width: self.component['sparkLine-width']
215
- });
216
- self.isLoadingSparkLine = false;
217
- } catch (e) {
218
- container.querySelectorAll(".line").forEach(function (e) {
219
- return peity(e, sparkLineType, {
220
- fill: fillColor,
221
- height: self.component['sparkLine-height'],
222
- max: self.component['sparkLine-max-value-count'],
223
- min: 0,
224
- stroke: self.component['sparkLine-stroke-color'],
225
- strokeWidth: 2,
226
- width: self.component['sparkLine-width']
227
- });
228
- });
229
- self.isLoadingSparkLine = false;
230
- }
231
- }
238
+ self.resetSparkLine();
232
239
  } catch (e) {
233
240
  console.log(e);
234
241
  }
@@ -20,9 +20,9 @@ exports.default = void 0;
20
20
  require("core-js/modules/es.regexp.exec.js");
21
21
  require("core-js/modules/es.string.replace.js");
22
22
  require("core-js/modules/es.string.trim.js");
23
+ require("core-js/modules/es.array.find.js");
23
24
  require("core-js/modules/es.object.to-string.js");
24
25
  require("core-js/modules/web.dom-collections.for-each.js");
25
- require("core-js/modules/es.array.find.js");
26
26
  require("core-js/modules/es.array.concat.js");
27
27
  require("core-js/modules/es.object.get-prototype-of.js");
28
28
  var _Field = _interopRequireDefault(require("../_classes/field/Field"));
@@ -136,6 +136,65 @@ var DataChinaGridRow = /*#__PURE__*/function (_Component) {
136
136
  value: function getValue() {
137
137
  return this.component.field;
138
138
  }
139
+ }, {
140
+ key: "resetSparkLine",
141
+ value: function resetSparkLine() {
142
+ var self = this;
143
+ var container = this.element.querySelector('.data-container');
144
+ if (self.component['enable-sparkline']) {
145
+ if (self.isLoadingSparkLine) {
146
+ return true;
147
+ }
148
+ self.isLoadingSparkLine = true;
149
+ var sparkLineType = this.component['sparkLine-type'] || 'line';
150
+ var fillColor;
151
+ if (self.component['sparkLine-fill-color']) {
152
+ switch (sparkLineType) {
153
+ case 'line':
154
+ fillColor = self.component['sparkLine-fill-color'].split(',')[0];
155
+ break;
156
+ case 'pie':
157
+ case 'donut':
158
+ case 'bar':
159
+ fillColor = self.component['sparkLine-fill-color'].split(',');
160
+ break;
161
+ }
162
+ }
163
+ // values
164
+ container.querySelector('.sparkline-container').innerHTML = "<span class=\"line\">".concat(self.parseTpl(self.component['sparkLine-value'], {
165
+ data: self.rootValue
166
+ }), "</span>");
167
+ // 宽度计算
168
+ var parentWidth = container.querySelector('#sparkline-container-parent').offsetWidth;
169
+ parentWidth = parentWidth * self.component['sparkLine-width'];
170
+ try {
171
+ // @ts-ignore
172
+ (0, _jquery.default)(container).find('.line').peity(sparkLineType, {
173
+ fill: fillColor,
174
+ height: self.component['sparkLine-height'],
175
+ max: self.component['sparkLine-max-value-count'],
176
+ min: 0,
177
+ stroke: self.component['sparkLine-stroke-color'],
178
+ strokeWidth: 2,
179
+ width: parentWidth
180
+ });
181
+ self.isLoadingSparkLine = false;
182
+ } catch (e) {
183
+ container.querySelectorAll(".line").forEach(function (e) {
184
+ return peity(e, sparkLineType, {
185
+ fill: fillColor,
186
+ height: self.component['sparkLine-height'],
187
+ max: self.component['sparkLine-max-value-count'],
188
+ min: 0,
189
+ stroke: self.component['sparkLine-stroke-color'],
190
+ strokeWidth: 2,
191
+ width: parentWidth
192
+ });
193
+ });
194
+ self.isLoadingSparkLine = false;
195
+ }
196
+ }
197
+ }
139
198
 
140
199
  /**
141
200
  * Set the value of the component into the dom elements.
@@ -180,59 +239,7 @@ var DataChinaGridRow = /*#__PURE__*/function (_Component) {
180
239
  });
181
240
  }
182
241
  // 图标
183
- if (self.component['enable-sparkline']) {
184
- if (self.isLoadingSparkLine) {
185
- return true;
186
- }
187
- self.isLoadingSparkLine = true;
188
- var sparkLineType = this.component['sparkLine-type'] || 'line';
189
- var fillColor;
190
- if (self.component['sparkLine-fill-color']) {
191
- switch (sparkLineType) {
192
- case 'line':
193
- fillColor = self.component['sparkLine-fill-color'].split(',')[0];
194
- break;
195
- case 'pie':
196
- case 'donut':
197
- case 'bar':
198
- fillColor = self.component['sparkLine-fill-color'].split(',');
199
- break;
200
- }
201
- }
202
- // values
203
- container.querySelector('.sparkline-container').innerHTML = "<span class=\"line\">".concat(self.parseTpl(self.component['sparkLine-value'], {
204
- data: self.rootValue
205
- }), "</span>");
206
- // 宽度计算
207
- var parentWidth = container.querySelector('#sparkline-container-parent').offsetWidth;
208
- parentWidth = parentWidth * self.component['sparkLine-width'];
209
- try {
210
- // @ts-ignore
211
- (0, _jquery.default)(container).find('.line').peity(sparkLineType, {
212
- fill: fillColor,
213
- height: self.component['sparkLine-height'],
214
- max: self.component['sparkLine-max-value-count'],
215
- min: 0,
216
- stroke: self.component['sparkLine-stroke-color'],
217
- strokeWidth: 2,
218
- width: parentWidth
219
- });
220
- self.isLoadingSparkLine = false;
221
- } catch (e) {
222
- container.querySelectorAll(".line").forEach(function (e) {
223
- return peity(e, sparkLineType, {
224
- fill: fillColor,
225
- height: self.component['sparkLine-height'],
226
- max: self.component['sparkLine-max-value-count'],
227
- min: 0,
228
- stroke: self.component['sparkLine-stroke-color'],
229
- strokeWidth: 2,
230
- width: parentWidth
231
- });
232
- });
233
- self.isLoadingSparkLine = false;
234
- }
235
- }
242
+ self.resetSparkLine();
236
243
  } catch (e) {
237
244
  console.log(e);
238
245
  }
@@ -119,7 +119,7 @@ var ECharts = /*#__PURE__*/function (_FieldComponent) {
119
119
  // 初始化 ECharts 实例
120
120
  chartInstance = echarts.init(canvas);
121
121
  }
122
- var optionsStr = this.component["option-value"];
122
+ var optionsStr = this.component['option-value'];
123
123
  optionsStr = this.parseTpl(optionsStr, {
124
124
  data: this.rootValue
125
125
  });
@@ -161,6 +161,7 @@ var _default = {
161
161
  data_china_grid: _Data2.default,
162
162
  data_china_grid_row: _Data3.default,
163
163
  customTabs: _Tabs2.default,
164
- echarts: _ECharts.default
164
+ echarts: _ECharts.default,
165
+ progress: _Progress.default
165
166
  };
166
167
  exports.default = _default;
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = _default;
7
7
  require("core-js/modules/es.array.concat.js");
8
- var _NestedComponent = _interopRequireDefault(require("../_classes/nested/NestedComponent.form"));
8
+ var _Component = _interopRequireDefault(require("../_classes/component/Component.form"));
9
9
  var _ProgressEdit = _interopRequireDefault(require("./editForm/Progress.edit.display"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  function _default() {
12
12
  for (var _len = arguments.length, extend = new Array(_len), _key = 0; _key < _len; _key++) {
13
13
  extend[_key] = arguments[_key];
14
14
  }
15
- return _NestedComponent.default.apply(void 0, [[{
15
+ return _Component.default.apply(void 0, [[{
16
16
  key: 'display',
17
17
  components: _ProgressEdit.default
18
18
  }]].concat(extend));
@@ -15,12 +15,13 @@ exports.default = void 0;
15
15
  require("core-js/modules/es.regexp.exec.js");
16
16
  require("core-js/modules/es.string.replace.js");
17
17
  require("core-js/modules/es.string.trim.js");
18
+ require("core-js/modules/es.object.to-string.js");
19
+ require("core-js/modules/web.dom-collections.for-each.js");
18
20
  require("core-js/modules/es.array.concat.js");
19
21
  require("core-js/modules/es.symbol.to-primitive.js");
20
22
  require("core-js/modules/es.date.to-primitive.js");
21
23
  require("core-js/modules/es.symbol.js");
22
24
  require("core-js/modules/es.symbol.description.js");
23
- require("core-js/modules/es.object.to-string.js");
24
25
  require("core-js/modules/es.number.constructor.js");
25
26
  var _Field = _interopRequireDefault(require("../_classes/field/Field"));
26
27
  var _Progress = _interopRequireDefault(require("./Progress.form"));
@@ -65,9 +66,15 @@ var Progress = /*#__PURE__*/function (_FieldComponent) {
65
66
  }, {
66
67
  key: "attach",
67
68
  value: function attach(element) {
68
- var refs = {};
69
+ var _this = this;
70
+ var refs = {
71
+ titleContainer: 'single',
72
+ progressContainer: 'single'
73
+ };
69
74
  this.loadRefs(element, refs);
70
-
75
+ setTimeout(function () {
76
+ _this.setValue();
77
+ }, 100);
71
78
  // Allow basic component functionality to attach like field logic and tooltips.
72
79
  return _get(_getPrototypeOf(Progress.prototype), "attach", this).call(this, element);
73
80
  }
@@ -87,7 +94,15 @@ var Progress = /*#__PURE__*/function (_FieldComponent) {
87
94
  value: function parseTpl(template, map) {
88
95
  return template.replace(/\$\{.+?}/g, function (match) {
89
96
  var path = match.substr(2, match.length - 3).trim();
90
- return _lodash.default.get(map, path);
97
+ var strTmp = _lodash.default.get(map, path);
98
+ if (strTmp === undefined) {
99
+ strTmp = null;
100
+ } else {
101
+ if (_lodash.default.isArray(strTmp) || _lodash.default.isObject(strTmp)) {
102
+ strTmp = JSON.stringify(strTmp);
103
+ }
104
+ }
105
+ return strTmp;
91
106
  });
92
107
  }
93
108
 
@@ -100,6 +115,29 @@ var Progress = /*#__PURE__*/function (_FieldComponent) {
100
115
  }, {
101
116
  key: "setValue",
102
117
  value: function setValue(value) {
118
+ var _this2 = this;
119
+ this.refs.titleContainer.innerHTML = "";
120
+ this.refs.progressContainer.innerHTML = "";
121
+ var optionsStr = this.component['option-value'];
122
+ try {
123
+ optionsStr = this.parseTpl(optionsStr, {
124
+ data: this.rootValue
125
+ });
126
+ optionsStr = JSON.parse(optionsStr);
127
+ var sum = _lodash.default.sumBy(optionsStr, 'value');
128
+ if (this.component['max-value'] && this.component['max-value'].trim().length > 0) {
129
+ sum = _lodash.default.toNumber(this.parseTpl(this.component['max-value'], {
130
+ data: this.rootValue
131
+ }));
132
+ }
133
+ optionsStr.forEach(function (item) {
134
+ var percent = _lodash.default.floor(_lodash.default.divide(item.value, sum) * 100, 1);
135
+ _this2.refs.titleContainer.insertAdjacentHTML('beforeend', "<div class=\"progress-title-container\" style=\"display: flex;flex-direction: row;align-items: center;font-size: ".concat(_this2.component['font-size'], "\">\n <div class=\"progress-title-item-indicator\" style=\"width: 5px;height: 5px;background-color: ").concat(item.color, ";margin-right: 10px\"></div>\n <div class=\"progress-title-item-title\" style=\"color: ").concat(item.color, "\">").concat(item.title, "</div>\n <div class=\"progress-title-item-value\" style=\"font-weight: bold;margin-left: 5px;margin-right: 5px;color: black\">").concat(item.value, "</div>\n <div class=\"progress-title-item-unit\" style=\"color: grey\">").concat(item.unit, "</div>\n <div class=\"progress-title-item-percent\" style=\"margin-left: 10px;color: grey\">").concat(percent, "%</div>\n </div>"));
136
+ _this2.refs.progressContainer.insertAdjacentHTML('beforeend', "<div class=\"progress-bar\" role=\"progressbar\" style=\"width: ".concat(percent, "%;background-color: ").concat(item.color, "\" aria-valuenow=\"").concat(item.value, "\" aria-valuemin=\"0\" aria-valuemax=\"").concat(sum, "\"></div>"));
137
+ });
138
+ } catch (e) {
139
+ console.log('json转换失败', e);
140
+ }
103
141
  return true;
104
142
  }
105
143
  }], [{
@@ -121,7 +159,7 @@ exports.default = Progress;
121
159
  _defineProperty(Progress, "builderInfo", {
122
160
  title: 'Progress',
123
161
  group: 'advanced',
124
- icon: 'qrcode',
162
+ icon: 'bar-progress',
125
163
  weight: 70,
126
164
  documentation: 'http://help.form.io/userguide/#progress',
127
165
  schema: Progress.schema()
@@ -5,40 +5,59 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _default = [{
8
- type: 'number',
9
- label: 'Size',
8
+ type: 'textfield',
9
+ label: '宽度',
10
10
  key: 'width',
11
11
  input: true,
12
12
  weight: 1,
13
- defaultValue: 128,
14
- placeholder: 'Size of Qr Code',
15
- tooltip: 'Enter the size that should be displayed by this Qr Code.'
16
- }, {
17
- type: 'select',
18
- label: '对齐方式',
19
- key: 'align',
20
- weight: 2,
21
- defaultValue: "start",
22
- data: {
23
- values: [{
24
- label: 'left',
25
- value: 'start'
26
- }, {
27
- label: 'right',
28
- value: 'end'
29
- }, {
30
- label: 'mid',
31
- value: 'center'
32
- }]
13
+ defaultValue: "100%",
14
+ validate: {
15
+ required: true
33
16
  }
34
17
  }, {
35
- type: 'input',
36
- label: 'Value',
37
- key: 'value',
18
+ type: 'textfield',
19
+ label: '高度',
20
+ key: 'height',
38
21
  input: true,
39
- placeholder: "https://${data.name}-hh.com",
40
- tooltip: 'Value',
41
- weight: 3
22
+ weight: 1,
23
+ defaultValue: "50px",
24
+ validate: {
25
+ required: true
26
+ }
27
+ }, {
28
+ type: 'textarea',
29
+ label: '配置项',
30
+ key: 'option-value',
31
+ editor: 'ace',
32
+ input: true,
33
+ tooltip: '配置项(json格式)',
34
+ placeholder: "[{\"value\":10,\"title\":\"demo\",\"color\":\"black\",\"unit\":\"\u4E2A\"}]",
35
+ weight: 1,
36
+ validate: {
37
+ required: true
38
+ }
39
+ }, {
40
+ type: 'textfield',
41
+ label: '最大值',
42
+ key: 'max-value',
43
+ input: true,
44
+ weight: 1,
45
+ tooltip: '进度条最大值,若该值为空,则根据所有选项自动计算百分比',
46
+ defaultValue: null
47
+ }, {
48
+ type: 'textfield',
49
+ label: '字体大小',
50
+ key: 'font-size',
51
+ input: true,
52
+ weight: 1,
53
+ defaultValue: "20px"
54
+ }, {
55
+ type: 'textfield',
56
+ label: '进度条背景颜色',
57
+ key: 'progress-color',
58
+ input: true,
59
+ weight: 1,
60
+ defaultValue: "white"
42
61
  }, {
43
62
  key: 'labelPosition',
44
63
  ignore: true