formiojs-eorion 0.0.9 → 0.1.1
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 +1 -1
- package/components/CustomTabs/Tabs.form.js +22 -0
- package/components/CustomTabs/Tabs.js +355 -0
- package/components/CustomTabs/Tabs.unit.js +43 -0
- package/components/CustomTabs/editForm/Tabs.edit.display.js +112 -0
- package/components/CustomTabs/fixtures/comp1.js +33 -0
- package/components/CustomTabs/fixtures/index.js +13 -0
- package/components/DataChinaGrid/Data.form.js +19 -0
- package/components/DataChinaGrid/Data.js +245 -0
- package/components/DataChinaGrid/editForm/Data.edit.display.js +472 -0
- package/components/DataChinaGridRow/Data.form.js +19 -0
- package/components/DataChinaGridRow/Data.js +245 -0
- package/components/DataChinaGridRow/editForm/Data.edit.display.js +479 -0
- package/components/FileDownload/FileDownload.js +11 -2
- package/components/builder.js +6 -0
- package/components/index.js +7 -1
- package/dist/formio.builder.css +23 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.contrib.js +76 -3
- package/dist/formio.contrib.min.js +1 -1
- package/dist/formio.contrib.min.js.LICENSE.txt +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +178 -6
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.css +23 -0
- package/dist/formio.full.js +178 -6
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +2 -2
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/package.json +1 -1
- package/templates/bootstrap/customTab/flat.ejs.js +19 -0
- package/templates/bootstrap/customTab/form.ejs.js +41 -0
- package/templates/bootstrap/customTab/index.js +14 -0
- package/templates/bootstrap/dataChinaGrid/form.ejs.js +57 -0
- package/templates/bootstrap/dataChinaGrid/index.js +12 -0
- package/templates/bootstrap/dataChinaGridRow/form.ejs.js +59 -0
- package/templates/bootstrap/dataChinaGridRow/index.js +12 -0
- package/templates/bootstrap/index.js +7 -1
- package/utils/utils.js +43 -0
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.
|
|
1727
|
+
Formio.version = '0.1.1';
|
|
1728
1728
|
Formio.pathType = '';
|
|
1729
1729
|
Formio.events = new _EventEmitter.default();
|
|
1730
1730
|
Formio.cdn = new _CDN.default();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _default;
|
|
7
|
+
require("core-js/modules/es.array.concat.js");
|
|
8
|
+
var _NestedComponent = _interopRequireDefault(require("../_classes/nested/NestedComponent.form"));
|
|
9
|
+
var _TabsEdit = _interopRequireDefault(require("./editForm/Tabs.edit.display"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _default() {
|
|
12
|
+
for (var _len = arguments.length, extend = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
|
+
extend[_key] = arguments[_key];
|
|
14
|
+
}
|
|
15
|
+
return _NestedComponent.default.apply(void 0, [[{
|
|
16
|
+
key: 'display',
|
|
17
|
+
components: _TabsEdit.default
|
|
18
|
+
}, {
|
|
19
|
+
key: 'addons',
|
|
20
|
+
ignore: true
|
|
21
|
+
}]].concat(extend));
|
|
22
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
require("core-js/modules/es.reflect.get.js");
|
|
5
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
6
|
+
require("core-js/modules/es.reflect.construct.js");
|
|
7
|
+
require("core-js/modules/es.symbol.to-primitive.js");
|
|
8
|
+
require("core-js/modules/es.date.to-primitive.js");
|
|
9
|
+
require("core-js/modules/es.symbol.js");
|
|
10
|
+
require("core-js/modules/es.symbol.description.js");
|
|
11
|
+
require("core-js/modules/es.number.constructor.js");
|
|
12
|
+
require("core-js/modules/es.symbol.iterator.js");
|
|
13
|
+
require("core-js/modules/es.array.iterator.js");
|
|
14
|
+
require("core-js/modules/es.string.iterator.js");
|
|
15
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
16
|
+
require("core-js/modules/es.array.from.js");
|
|
17
|
+
require("core-js/modules/es.array.slice.js");
|
|
18
|
+
require("core-js/modules/es.function.name.js");
|
|
19
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
20
|
+
Object.defineProperty(exports, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
exports.default = void 0;
|
|
24
|
+
require("core-js/modules/es.array.concat.js");
|
|
25
|
+
require("core-js/modules/es.array.map.js");
|
|
26
|
+
require("core-js/modules/es.object.to-string.js");
|
|
27
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
|
28
|
+
require("core-js/modules/es.array.find-index.js");
|
|
29
|
+
require("core-js/modules/es.array.filter.js");
|
|
30
|
+
require("core-js/modules/es.array.includes.js");
|
|
31
|
+
require("core-js/modules/es.string.includes.js");
|
|
32
|
+
require("core-js/modules/es.object.get-prototype-of.js");
|
|
33
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
34
|
+
var _NestedComponent2 = _interopRequireDefault(require("../_classes/nested/NestedComponent"));
|
|
35
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
37
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
38
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
39
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
40
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
41
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
42
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
43
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
44
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
45
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
46
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
47
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
48
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
49
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
50
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
51
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
52
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
53
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
54
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
55
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
56
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
57
|
+
var CustomTabsComponent = /*#__PURE__*/function (_NestedComponent) {
|
|
58
|
+
_inherits(CustomTabsComponent, _NestedComponent);
|
|
59
|
+
var _super = _createSuper(CustomTabsComponent);
|
|
60
|
+
function CustomTabsComponent() {
|
|
61
|
+
var _this;
|
|
62
|
+
_classCallCheck(this, CustomTabsComponent);
|
|
63
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
64
|
+
args[_key] = arguments[_key];
|
|
65
|
+
}
|
|
66
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
67
|
+
_this.currentTab = 0;
|
|
68
|
+
_this.noField = true;
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
_createClass(CustomTabsComponent, [{
|
|
72
|
+
key: "defaultSchema",
|
|
73
|
+
get: function get() {
|
|
74
|
+
return CustomTabsComponent.schema();
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "schema",
|
|
78
|
+
get: function get() {
|
|
79
|
+
var _this2 = this;
|
|
80
|
+
var schema = _get(_getPrototypeOf(CustomTabsComponent.prototype), "schema", this);
|
|
81
|
+
// We need to clone this because the builder uses the "components" reference and this would reset that reference.
|
|
82
|
+
var components = _lodash.default.cloneDeep(this.component.components);
|
|
83
|
+
schema.components = components.map(function (tab, index) {
|
|
84
|
+
tab.components = _this2.tabs[index].map(function (component) {
|
|
85
|
+
return component.schema;
|
|
86
|
+
});
|
|
87
|
+
return tab;
|
|
88
|
+
});
|
|
89
|
+
return schema;
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "tabKey",
|
|
93
|
+
get: function get() {
|
|
94
|
+
return "tab-".concat(this.key);
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "tabLikey",
|
|
98
|
+
get: function get() {
|
|
99
|
+
return "tabLi-".concat(this.key);
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "tabLinkKey",
|
|
103
|
+
get: function get() {
|
|
104
|
+
return "tabLink-".concat(this.key);
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "init",
|
|
108
|
+
value: function init() {
|
|
109
|
+
var _this3 = this;
|
|
110
|
+
this.components = [];
|
|
111
|
+
this.tabs = [];
|
|
112
|
+
_lodash.default.each(this.component.components, function (tab, index) {
|
|
113
|
+
_this3.tabs[index] = [];
|
|
114
|
+
// Initialize empty tabs.
|
|
115
|
+
tab.components = tab.components || [];
|
|
116
|
+
_lodash.default.each(tab.components, function (comp) {
|
|
117
|
+
var component = _this3.createComponent(comp);
|
|
118
|
+
component.tab = index;
|
|
119
|
+
_this3.tabs[index].push(component);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "render",
|
|
125
|
+
value: function render() {
|
|
126
|
+
var _this4 = this;
|
|
127
|
+
return _get(_getPrototypeOf(CustomTabsComponent.prototype), "render", this).call(this, this.renderTemplate('customTab', {
|
|
128
|
+
tabKey: this.tabKey,
|
|
129
|
+
tabLikey: this.tabLikey,
|
|
130
|
+
tabLinkKey: this.tabLinkKey,
|
|
131
|
+
currentTab: this.currentTab,
|
|
132
|
+
tabComponents: this.tabs.map(function (tab) {
|
|
133
|
+
return _this4.renderComponents(tab);
|
|
134
|
+
})
|
|
135
|
+
}, this.options.flatten || this.options.pdf ? 'flat' : null));
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "attach",
|
|
139
|
+
value: function attach(element) {
|
|
140
|
+
var _this$loadRefs,
|
|
141
|
+
_this5 = this;
|
|
142
|
+
this.loadRefs(element, (_this$loadRefs = {}, _defineProperty(_this$loadRefs, this.tabLinkKey, 'multiple'), _defineProperty(_this$loadRefs, this.tabKey, 'multiple'), _defineProperty(_this$loadRefs, this.tabLikey, 'multiple'), _defineProperty(_this$loadRefs, 'tabLine', 'single'), _this$loadRefs));
|
|
143
|
+
['change', 'error'].forEach(function (event) {
|
|
144
|
+
return _this5.on(event, _this5.handleTabsValidation.bind(_this5));
|
|
145
|
+
});
|
|
146
|
+
var superAttach = _get(_getPrototypeOf(CustomTabsComponent.prototype), "attach", this).call(this, element);
|
|
147
|
+
this.refs[this.tabLinkKey].forEach(function (tabLink, index) {
|
|
148
|
+
_this5.addEventListener(tabLink, 'click', function (event) {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
_this5.setTab(index);
|
|
151
|
+
});
|
|
152
|
+
_this5.addEventListener(tabLink, 'mouseover', function (event) {
|
|
153
|
+
tabLink.style.color = _this5.component["headerHoverColor"];
|
|
154
|
+
});
|
|
155
|
+
_this5.addEventListener(tabLink, 'mouseout', function (event) {
|
|
156
|
+
if (index === _this5.currentTab) {
|
|
157
|
+
tabLink.style.color = _this5.component["headerColor"];
|
|
158
|
+
} else {
|
|
159
|
+
tabLink.style.color = _this5.component["headerNormalColor"];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
this.refs[this.tabKey].forEach(function (tab, index) {
|
|
164
|
+
_this5.attachComponents(tab, _this5.tabs[index], _this5.component.components[index].components);
|
|
165
|
+
});
|
|
166
|
+
this.setTabLine();
|
|
167
|
+
return superAttach;
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
key: "detach",
|
|
171
|
+
value: function detach(all) {
|
|
172
|
+
_get(_getPrototypeOf(CustomTabsComponent.prototype), "detach", this).call(this, all);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 通过childKey来设置tab选中
|
|
177
|
+
* @param childKey
|
|
178
|
+
*/
|
|
179
|
+
}, {
|
|
180
|
+
key: "setTabByKey",
|
|
181
|
+
value: function setTabByKey(childKey) {
|
|
182
|
+
var _this6 = this;
|
|
183
|
+
_lodash.default.each(this.component.components, function (tab, index) {
|
|
184
|
+
if (tab.key === childKey) {
|
|
185
|
+
_this6.setTab(index);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}, {
|
|
190
|
+
key: "setTabLine",
|
|
191
|
+
value: function setTabLine() {
|
|
192
|
+
var _this7 = this;
|
|
193
|
+
_lodash.default.each(this.refs[this.tabLinkKey], function (tabLink, tabIndex) {
|
|
194
|
+
// 设置下划线位置 //设置颜色
|
|
195
|
+
if (tabIndex === _this7.currentTab) {
|
|
196
|
+
_this7.refs.tabLine.style.width = "".concat(tabLink.offsetWidth, "px");
|
|
197
|
+
// 10是容器的padding
|
|
198
|
+
_this7.refs.tabLine.style.transform = "translateX(".concat(tabLink.offsetLeft - 15, "px)");
|
|
199
|
+
tabLink.style.color = _this7.component["headerColor"];
|
|
200
|
+
} else {
|
|
201
|
+
tabLink.style.color = _this7.component["headerNormalColor"];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Set the current tab.
|
|
208
|
+
*
|
|
209
|
+
* @param index
|
|
210
|
+
*/
|
|
211
|
+
}, {
|
|
212
|
+
key: "setTab",
|
|
213
|
+
value: function setTab(index) {
|
|
214
|
+
var _this8 = this;
|
|
215
|
+
if (!this.tabs || !this.tabs[index] || !this.refs[this.tabKey] || !this.refs[this.tabKey][index]) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this.currentTab = index;
|
|
219
|
+
_lodash.default.each(this.refs[this.tabKey], function (tab) {
|
|
220
|
+
_this8.removeClass(tab, 'formio-tab-panel-active');
|
|
221
|
+
tab.style.display = 'none';
|
|
222
|
+
});
|
|
223
|
+
this.addClass(this.refs[this.tabKey][index], 'formio-tab-panel-active');
|
|
224
|
+
this.refs[this.tabKey][index].style.display = 'block';
|
|
225
|
+
_lodash.default.each(this.refs[this.tabLinkKey], function (tabLink, tabIndex) {
|
|
226
|
+
if (_this8.refs[_this8.tabLinkKey][tabIndex]) {
|
|
227
|
+
_this8.removeClass(tabLink, 'formio-tab-link-active');
|
|
228
|
+
}
|
|
229
|
+
if (_this8.refs[_this8.tabLikey][tabIndex]) {
|
|
230
|
+
_this8.removeClass(_this8.refs[_this8.tabLikey][tabIndex], 'formio-tab-link-container-active');
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
if (this.refs[this.tabLikey][index]) {
|
|
234
|
+
this.addClass(this.refs[this.tabLikey][index], 'formio-tab-link-container-active');
|
|
235
|
+
}
|
|
236
|
+
if (this.refs[this.tabLinkKey][index]) {
|
|
237
|
+
this.addClass(this.refs[this.tabLinkKey][index], 'formio-tab-link-active');
|
|
238
|
+
}
|
|
239
|
+
this.setTabLine();
|
|
240
|
+
this.triggerChange();
|
|
241
|
+
}
|
|
242
|
+
}, {
|
|
243
|
+
key: "beforeFocus",
|
|
244
|
+
value: function beforeFocus(component) {
|
|
245
|
+
if ('beforeFocus' in this.parent) {
|
|
246
|
+
this.parent.beforeFocus(this);
|
|
247
|
+
}
|
|
248
|
+
var tabIndex = this.tabs.findIndex(function (tab) {
|
|
249
|
+
return tab.some(function (comp) {
|
|
250
|
+
return comp === component;
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
if (tabIndex !== -1 && this.currentTab !== tabIndex) {
|
|
254
|
+
this.setTab(tabIndex);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}, {
|
|
258
|
+
key: "setErrorClasses",
|
|
259
|
+
value: function setErrorClasses(elements, dirty, hasErrors, hasMessages) {
|
|
260
|
+
var _this9 = this;
|
|
261
|
+
var element = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.element;
|
|
262
|
+
if (this.component.modalEdit) {
|
|
263
|
+
_get(_getPrototypeOf(CustomTabsComponent.prototype), "setErrorClasses", this).call(this, elements, dirty, hasErrors, hasMessages, element);
|
|
264
|
+
}
|
|
265
|
+
elements.forEach(function (element) {
|
|
266
|
+
_this9.addClass(element, 'is-invalid');
|
|
267
|
+
if (element.getAttribute('ref') !== 'openModal') {
|
|
268
|
+
if (_this9.options.highlightErrors) {
|
|
269
|
+
_this9.addClass(element, 'tab-error');
|
|
270
|
+
} else {
|
|
271
|
+
_this9.addClass(element, 'has-error');
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}, {
|
|
277
|
+
key: "clearErrorClasses",
|
|
278
|
+
value: function clearErrorClasses(elements) {
|
|
279
|
+
var _this10 = this;
|
|
280
|
+
if (this.options.server || !this.rendered) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (this.component.modalEdit) {
|
|
284
|
+
var element = Array.isArray(elements) || elements instanceof NodeList ? this.element : elements;
|
|
285
|
+
_get(_getPrototypeOf(CustomTabsComponent.prototype), "clearErrorClasses", this).call(this, element);
|
|
286
|
+
}
|
|
287
|
+
elements = Array.isArray(elements) || elements instanceof NodeList ? elements : [elements];
|
|
288
|
+
elements.forEach(function (element) {
|
|
289
|
+
_this10.removeClass(element, 'is-invalid');
|
|
290
|
+
_this10.removeClass(element, 'tab-error');
|
|
291
|
+
_this10.removeClass(element, 'has-error');
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}, {
|
|
295
|
+
key: "handleTabsValidation",
|
|
296
|
+
value: function handleTabsValidation() {
|
|
297
|
+
if (!this.refs[this.tabLinkKey] || !this.refs[this.tabLinkKey].length || !this.tabs.length) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
// 切换tab时,刷新taskCalendar组件,修复taskCalendar在tab中高度错乱的问题
|
|
301
|
+
if (this.tabs[this.currentTab] && this.tabs[this.currentTab].length > 0 && this.tabs[this.currentTab][0].type === 'taskCalendar') {
|
|
302
|
+
this.tabs[this.currentTab][0].refresh(new Date().getTime());
|
|
303
|
+
}
|
|
304
|
+
this.clearErrorClasses(this.refs[this.tabLinkKey]);
|
|
305
|
+
var invalidTabsIndexes = this.tabs.reduce(function (invalidTabs, tab, tabIndex) {
|
|
306
|
+
var hasComponentWithError = tab.some(function (comp) {
|
|
307
|
+
return !!comp.error;
|
|
308
|
+
});
|
|
309
|
+
return hasComponentWithError ? [].concat(_toConsumableArray(invalidTabs), [tabIndex]) : invalidTabs;
|
|
310
|
+
}, []);
|
|
311
|
+
if (!invalidTabsIndexes.length) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
var invalidTabs = _toConsumableArray(this.refs[this.tabLinkKey]).filter(function (_, tabIndex) {
|
|
315
|
+
return invalidTabsIndexes.includes(tabIndex);
|
|
316
|
+
});
|
|
317
|
+
this.setErrorClasses(invalidTabs);
|
|
318
|
+
}
|
|
319
|
+
}], [{
|
|
320
|
+
key: "schema",
|
|
321
|
+
value: function schema() {
|
|
322
|
+
for (var _len2 = arguments.length, extend = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
323
|
+
extend[_key2] = arguments[_key2];
|
|
324
|
+
}
|
|
325
|
+
return _NestedComponent2.default.schema.apply(_NestedComponent2.default, [{
|
|
326
|
+
label: 'CustomTabs',
|
|
327
|
+
type: 'customTabs',
|
|
328
|
+
input: false,
|
|
329
|
+
key: 'custom_tabs',
|
|
330
|
+
persistent: false,
|
|
331
|
+
tableView: false,
|
|
332
|
+
components: [{
|
|
333
|
+
label: 'Tab 1',
|
|
334
|
+
key: 'tab1',
|
|
335
|
+
components: []
|
|
336
|
+
}],
|
|
337
|
+
verticalLayout: false
|
|
338
|
+
}].concat(extend));
|
|
339
|
+
}
|
|
340
|
+
}, {
|
|
341
|
+
key: "builderInfo",
|
|
342
|
+
get: function get() {
|
|
343
|
+
return {
|
|
344
|
+
title: 'CustomTabs',
|
|
345
|
+
group: 'layout',
|
|
346
|
+
icon: 'folder-o',
|
|
347
|
+
weight: 50,
|
|
348
|
+
documentation: '/userguide/forms/layout-components#custom-tabs',
|
|
349
|
+
schema: CustomTabsComponent.schema()
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}]);
|
|
353
|
+
return CustomTabsComponent;
|
|
354
|
+
}(_NestedComponent2.default);
|
|
355
|
+
exports.default = CustomTabsComponent;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.array.includes.js");
|
|
4
|
+
require("core-js/modules/es.string.includes.js");
|
|
5
|
+
var _powerAssert = _interopRequireDefault(require("power-assert"));
|
|
6
|
+
var _Formio = _interopRequireDefault(require("../../Formio"));
|
|
7
|
+
var _fixtures = require("./fixtures");
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
describe('Tabs Component', function () {
|
|
10
|
+
it('Test setting error classes when set to modalEdit', function (done) {
|
|
11
|
+
var formElement = document.createElement('div');
|
|
12
|
+
_Formio.default.createForm(formElement, {
|
|
13
|
+
display: 'form',
|
|
14
|
+
type: 'form',
|
|
15
|
+
components: [_fixtures.comp1]
|
|
16
|
+
}).then(function (form) {
|
|
17
|
+
var comp = form.components[0];
|
|
18
|
+
var data = {
|
|
19
|
+
textField: ''
|
|
20
|
+
};
|
|
21
|
+
form.checkValidity(data, true, data);
|
|
22
|
+
setTimeout(function () {
|
|
23
|
+
var openModalWrapper = form.element.querySelector('[ref="openModalWrapper"]');
|
|
24
|
+
(0, _powerAssert.default)(openModalWrapper.className.includes('formio-error-wrapper'), 'Should have error class');
|
|
25
|
+
(0, _powerAssert.default)(openModalWrapper.className.includes('has-message'), 'Should have class indicating that the component has a message');
|
|
26
|
+
var openModalButton = comp.element.querySelector('[ref="openModal"]');
|
|
27
|
+
(0, _powerAssert.default)(!openModalButton.className.includes('tab-error'), 'Open modal element should not have a tab-error class');
|
|
28
|
+
var validData = {
|
|
29
|
+
textField: 'Text'
|
|
30
|
+
};
|
|
31
|
+
form.setSubmission({
|
|
32
|
+
data: validData
|
|
33
|
+
});
|
|
34
|
+
setTimeout(function () {
|
|
35
|
+
var openModalWrapper = form.element.querySelector('[ref="openModalWrapper"]');
|
|
36
|
+
(0, _powerAssert.default)(!openModalWrapper.className.includes('formio-error-wrapper'), 'Should not have error class');
|
|
37
|
+
(0, _powerAssert.default)(!openModalWrapper.className.includes('has-message'), 'Should not have class indicating that the component has a message');
|
|
38
|
+
done();
|
|
39
|
+
}, 250);
|
|
40
|
+
}, 200);
|
|
41
|
+
}).catch(done);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = [{
|
|
8
|
+
key: 'labelPosition',
|
|
9
|
+
ignore: true
|
|
10
|
+
}, {
|
|
11
|
+
key: 'placeholder',
|
|
12
|
+
ignore: true
|
|
13
|
+
}, {
|
|
14
|
+
key: 'description',
|
|
15
|
+
ignore: true
|
|
16
|
+
}, {
|
|
17
|
+
key: 'autofocus',
|
|
18
|
+
ignore: true
|
|
19
|
+
}, {
|
|
20
|
+
key: 'tooltip',
|
|
21
|
+
ignore: true
|
|
22
|
+
}, {
|
|
23
|
+
key: 'tabindex',
|
|
24
|
+
ignore: true
|
|
25
|
+
}, {
|
|
26
|
+
key: 'disabled',
|
|
27
|
+
ignore: true
|
|
28
|
+
}, {
|
|
29
|
+
key: 'tableView',
|
|
30
|
+
ignore: true
|
|
31
|
+
}, {
|
|
32
|
+
key: 'components',
|
|
33
|
+
type: 'datagrid',
|
|
34
|
+
input: true,
|
|
35
|
+
label: 'Tabs',
|
|
36
|
+
weight: 50,
|
|
37
|
+
reorder: true,
|
|
38
|
+
components: [{
|
|
39
|
+
type: 'textfield',
|
|
40
|
+
input: true,
|
|
41
|
+
key: 'label',
|
|
42
|
+
label: 'Label'
|
|
43
|
+
}, {
|
|
44
|
+
type: 'textfield',
|
|
45
|
+
input: true,
|
|
46
|
+
key: 'key',
|
|
47
|
+
label: 'Key',
|
|
48
|
+
allowCalculateOverride: true,
|
|
49
|
+
calculateValue: {
|
|
50
|
+
_camelCase: [{
|
|
51
|
+
var: 'row.label'
|
|
52
|
+
}]
|
|
53
|
+
}
|
|
54
|
+
}]
|
|
55
|
+
}, {
|
|
56
|
+
type: 'panel',
|
|
57
|
+
weight: 51,
|
|
58
|
+
label: '头部设置',
|
|
59
|
+
components: [{
|
|
60
|
+
type: 'checkbox',
|
|
61
|
+
key: 'hideHeader',
|
|
62
|
+
label: '隐藏头部',
|
|
63
|
+
input: true
|
|
64
|
+
}, {
|
|
65
|
+
type: 'select',
|
|
66
|
+
label: '对齐方式',
|
|
67
|
+
data: {
|
|
68
|
+
values: [{
|
|
69
|
+
label: '居中',
|
|
70
|
+
value: 'center'
|
|
71
|
+
}, {
|
|
72
|
+
label: '左对齐',
|
|
73
|
+
value: 'start'
|
|
74
|
+
}, {
|
|
75
|
+
label: '右对齐',
|
|
76
|
+
value: 'end'
|
|
77
|
+
}]
|
|
78
|
+
},
|
|
79
|
+
key: 'headerAlign',
|
|
80
|
+
input: true,
|
|
81
|
+
defaultValue: 'center',
|
|
82
|
+
dataSrc: 'values'
|
|
83
|
+
}, {
|
|
84
|
+
type: 'textfield',
|
|
85
|
+
key: 'headerBackgroundColor',
|
|
86
|
+
label: '背景色',
|
|
87
|
+
defaultValue: 'white',
|
|
88
|
+
input: true
|
|
89
|
+
}, {
|
|
90
|
+
type: 'textfield',
|
|
91
|
+
key: 'headerColor',
|
|
92
|
+
tooltip: '文字和下标颜色',
|
|
93
|
+
label: '主题色',
|
|
94
|
+
defaultValue: '#333',
|
|
95
|
+
input: true
|
|
96
|
+
}, {
|
|
97
|
+
type: 'textfield',
|
|
98
|
+
key: 'headerNormalColor',
|
|
99
|
+
tooltip: '未选中tab颜色',
|
|
100
|
+
label: '未选中主题色',
|
|
101
|
+
defaultValue: '#999',
|
|
102
|
+
input: true
|
|
103
|
+
}, {
|
|
104
|
+
type: 'textfield',
|
|
105
|
+
key: 'headerHoverColor',
|
|
106
|
+
tooltip: '鼠标经过时颜色',
|
|
107
|
+
label: 'hover颜色',
|
|
108
|
+
defaultValue: '#999',
|
|
109
|
+
input: true
|
|
110
|
+
}]
|
|
111
|
+
}];
|
|
112
|
+
exports.default = _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
label: 'Tabs',
|
|
9
|
+
components: [{
|
|
10
|
+
label: 'Tab 1',
|
|
11
|
+
key: 'tab1',
|
|
12
|
+
components: []
|
|
13
|
+
}, {
|
|
14
|
+
label: 'Tab 2',
|
|
15
|
+
key: 'tab2',
|
|
16
|
+
components: [{
|
|
17
|
+
label: 'Text Field',
|
|
18
|
+
tableView: true,
|
|
19
|
+
validate: {
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
key: 'textField',
|
|
23
|
+
type: 'textfield',
|
|
24
|
+
input: true
|
|
25
|
+
}]
|
|
26
|
+
}],
|
|
27
|
+
key: 'tabs',
|
|
28
|
+
type: 'tabs',
|
|
29
|
+
input: false,
|
|
30
|
+
tableView: false,
|
|
31
|
+
modalEdit: true
|
|
32
|
+
};
|
|
33
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "comp1", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _comp.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _comp = _interopRequireDefault(require("./comp1"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _default;
|
|
7
|
+
require("core-js/modules/es.array.concat.js");
|
|
8
|
+
var _NestedComponent = _interopRequireDefault(require("../_classes/nested/NestedComponent.form"));
|
|
9
|
+
var _DataEdit = _interopRequireDefault(require("./editForm/Data.edit.display"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _default() {
|
|
12
|
+
for (var _len = arguments.length, extend = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
|
+
extend[_key] = arguments[_key];
|
|
14
|
+
}
|
|
15
|
+
return _NestedComponent.default.apply(void 0, [[{
|
|
16
|
+
key: 'display',
|
|
17
|
+
components: _DataEdit.default
|
|
18
|
+
}]].concat(extend));
|
|
19
|
+
}
|