bkui-vue 0.0.1-beta.468 → 0.0.1-beta.469

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 (168) hide show
  1. package/lib/affix/index.js +1 -335
  2. package/lib/alert/index.js +1 -276
  3. package/lib/animate-number/index.js +1 -219
  4. package/lib/backtop/index.js +1 -252
  5. package/lib/badge/index.js +1 -293
  6. package/lib/breadcrumb/index.js +1 -311
  7. package/lib/button/index.js +1 -388
  8. package/lib/card/index.js +1 -356
  9. package/lib/cascader/index.js +2 -2075
  10. package/lib/cascader/index.js.LICENSE.txt +1 -0
  11. package/lib/checkbox/index.js +1 -536
  12. package/lib/code-diff/index.js +1 -5535
  13. package/lib/collapse/index.js +1 -589
  14. package/lib/collapse-transition/index.js +1 -234
  15. package/lib/color-picker/index.js +1 -2701
  16. package/lib/components.js +1 -781
  17. package/lib/config-provider/index.js +1 -377
  18. package/lib/container/index.js +1 -390
  19. package/lib/date-picker/index.js +1 -5537
  20. package/lib/dialog/index.js +2 -1322
  21. package/lib/dialog/index.js.LICENSE.txt +1 -0
  22. package/lib/directives/index.js +2 -1357
  23. package/lib/directives/index.js.LICENSE.txt +14 -0
  24. package/lib/dist.index.js +1 -179
  25. package/lib/divider/index.js +1 -226
  26. package/lib/dropdown/index.js +1 -392
  27. package/lib/exception/index.js +1 -423
  28. package/lib/fixed-navbar/index.js +1 -210
  29. package/lib/form/index.js +1 -995
  30. package/lib/hooks.js +1 -133
  31. package/lib/icon/angle-double-down-line.js +1 -541
  32. package/lib/icon/angle-double-left-line.js +1 -541
  33. package/lib/icon/angle-double-left.js +1 -541
  34. package/lib/icon/angle-double-right-line.js +1 -541
  35. package/lib/icon/angle-double-right.js +1 -541
  36. package/lib/icon/angle-double-up-line.js +1 -541
  37. package/lib/icon/angle-down-fill.js +1 -541
  38. package/lib/icon/angle-down-line.js +1 -541
  39. package/lib/icon/angle-down.js +1 -541
  40. package/lib/icon/angle-left.js +1 -541
  41. package/lib/icon/angle-right.js +1 -541
  42. package/lib/icon/angle-up-fill.js +1 -541
  43. package/lib/icon/angle-up.js +1 -541
  44. package/lib/icon/archive-fill.js +1 -541
  45. package/lib/icon/arrows-left.js +1 -541
  46. package/lib/icon/arrows-right.js +1 -541
  47. package/lib/icon/audio-fill.js +1 -541
  48. package/lib/icon/bk.js +1 -541
  49. package/lib/icon/circle.js +1 -541
  50. package/lib/icon/close-line.js +1 -541
  51. package/lib/icon/close.js +1 -541
  52. package/lib/icon/code.js +1 -541
  53. package/lib/icon/cog-shape.js +1 -541
  54. package/lib/icon/collapse-left.js +1 -541
  55. package/lib/icon/copy-shape.js +1 -541
  56. package/lib/icon/copy.js +1 -541
  57. package/lib/icon/data-shape.js +1 -541
  58. package/lib/icon/del.js +1 -541
  59. package/lib/icon/doc-fill.js +1 -541
  60. package/lib/icon/done.js +1 -541
  61. package/lib/icon/down-shape.js +1 -541
  62. package/lib/icon/down-small.js +1 -541
  63. package/lib/icon/edit-line.js +1 -541
  64. package/lib/icon/ellipsis.js +1 -541
  65. package/lib/icon/enlarge-line.js +1 -541
  66. package/lib/icon/error.js +1 -541
  67. package/lib/icon/excel-fill.js +1 -541
  68. package/lib/icon/exclamation-circle-shape.js +1 -541
  69. package/lib/icon/eye.js +1 -541
  70. package/lib/icon/filliscreen-line.js +1 -541
  71. package/lib/icon/fix-line.js +1 -541
  72. package/lib/icon/fix-shape.js +1 -541
  73. package/lib/icon/folder-open.js +1 -541
  74. package/lib/icon/folder-shape-open.js +1 -541
  75. package/lib/icon/folder-shape.js +1 -541
  76. package/lib/icon/folder.js +1 -541
  77. package/lib/icon/funnel.js +1 -541
  78. package/lib/icon/help-document-fill.js +1 -541
  79. package/lib/icon/help-fill.js +1 -541
  80. package/lib/icon/help.js +1 -541
  81. package/lib/icon/image-fill.js +1 -563
  82. package/lib/icon/img-error.js +1 -563
  83. package/lib/icon/img-placehoulder.js +1 -563
  84. package/lib/icon/index.js +1 -2337
  85. package/lib/icon/info-line.js +1 -563
  86. package/lib/icon/info.js +1 -563
  87. package/lib/icon/left-shape.js +1 -563
  88. package/lib/icon/left-turn-line.js +1 -563
  89. package/lib/icon/narrow-line.js +1 -563
  90. package/lib/icon/original.js +1 -563
  91. package/lib/icon/pdf-fill.js +1 -563
  92. package/lib/icon/play-shape.js +1 -563
  93. package/lib/icon/plus.js +1 -563
  94. package/lib/icon/ppt-fill.js +1 -563
  95. package/lib/icon/qq.js +1 -563
  96. package/lib/icon/right-shape.js +1 -563
  97. package/lib/icon/right-turn-line.js +1 -563
  98. package/lib/icon/search.js +1 -563
  99. package/lib/icon/share.js +1 -563
  100. package/lib/icon/spinner.js +1 -563
  101. package/lib/icon/success.js +1 -563
  102. package/lib/icon/switcher-loading.js +1 -563
  103. package/lib/icon/text-file.js +1 -563
  104. package/lib/icon/text-fill.js +1 -563
  105. package/lib/icon/transfer.js +1 -563
  106. package/lib/icon/tree-application-shape.js +1 -563
  107. package/lib/icon/unfull-screen.js +1 -563
  108. package/lib/icon/unvisible.js +1 -563
  109. package/lib/icon/up-shape.js +1 -563
  110. package/lib/icon/upload.js +1 -563
  111. package/lib/icon/video-fill.js +1 -563
  112. package/lib/icon/warn.js +1 -563
  113. package/lib/icon/weixin-pro.js +1 -563
  114. package/lib/icon/weixin.js +1 -563
  115. package/lib/image/index.js +1 -944
  116. package/lib/index.js +1 -195
  117. package/lib/info-box/index.js +2 -1508
  118. package/lib/info-box/index.js.LICENSE.txt +1 -0
  119. package/lib/input/index.js +1 -963
  120. package/lib/link/index.js +1 -219
  121. package/lib/loading/index.js +1 -434
  122. package/lib/locale/index.js +1 -489
  123. package/lib/menu/index.js +1 -776
  124. package/lib/message/index.js +2 -1744
  125. package/lib/message/index.js.LICENSE.txt +6 -0
  126. package/lib/modal/index.js +1 -397
  127. package/lib/navigation/index.js +1 -423
  128. package/lib/notify/index.js +1 -437
  129. package/lib/overflow-title/index.js +1 -547
  130. package/lib/pagination/index.js +1 -987
  131. package/lib/plugin-popover/index.js +1 -4022
  132. package/lib/plugins/index.js +1 -130
  133. package/lib/pop-confirm/index.js +1 -365
  134. package/lib/popover/index.js +1 -4028
  135. package/lib/popover2/index.js +1 -171
  136. package/lib/preset.js +1 -164
  137. package/lib/process/index.js +2 -1143
  138. package/lib/process/index.js.LICENSE.txt +1 -0
  139. package/lib/progress/index.js +1 -476
  140. package/lib/radio/index.js +1 -611
  141. package/lib/rate/index.js +1 -348
  142. package/lib/resize-layout/index.js +1 -482
  143. package/lib/search-select/index.js +2 -2999
  144. package/lib/search-select/index.js.LICENSE.txt +1 -0
  145. package/lib/select/index.js +2 -2531
  146. package/lib/select/index.js.LICENSE.txt +1 -0
  147. package/lib/shared/index.js +1 -2713
  148. package/lib/sideslider/index.js +2 -1043
  149. package/lib/sideslider/index.js.LICENSE.txt +1 -0
  150. package/lib/slider/index.js +2 -1667
  151. package/lib/slider/index.js.LICENSE.txt +1 -0
  152. package/lib/steps/index.js +2 -1212
  153. package/lib/steps/index.js.LICENSE.txt +1 -0
  154. package/lib/swiper/index.js +1 -350
  155. package/lib/switcher/index.js +1 -323
  156. package/lib/tab/index.js +1 -918
  157. package/lib/table/index.js +1 -6388
  158. package/lib/table-column/index.js +1 -801
  159. package/lib/tag/index.js +1 -300
  160. package/lib/tag-input/index.js +1 -1757
  161. package/lib/time-picker/index.js +1 -142
  162. package/lib/timeline/index.js +1 -297
  163. package/lib/transfer/index.js +1 -764
  164. package/lib/tree/index.js +1 -2608
  165. package/lib/upload/index.js +2 -3257
  166. package/lib/upload/index.js.LICENSE.txt +1 -0
  167. package/lib/virtual-render/index.js +1 -790
  168. package/package.json +1 -1
package/lib/form/index.js CHANGED
@@ -1,995 +1 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory(require("../shared"), require("vue"), require("lodash"), require("../config-provider"), require("../directives"), require("../icon"));
4
- else if(typeof define === 'function' && define.amd)
5
- define(["../shared", "vue", "lodash", "../config-provider", "../directives", "../icon"], factory);
6
- else {
7
- var a = typeof exports === 'object' ? factory(require("../shared"), require("vue"), require("lodash"), require("../config-provider"), require("../directives"), require("../icon")) : factory(root["../shared"], root["vue"], root["lodash"], root["../config-provider"], root["../directives"], root["../icon"]);
8
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
- }
10
- })(self, (__WEBPACK_EXTERNAL_MODULE__4212__, __WEBPACK_EXTERNAL_MODULE__748__, __WEBPACK_EXTERNAL_MODULE__467__, __WEBPACK_EXTERNAL_MODULE__2717__, __WEBPACK_EXTERNAL_MODULE__4061__, __WEBPACK_EXTERNAL_MODULE__6870__) => {
11
- return /******/ (() => { // webpackBootstrap
12
- /******/ "use strict";
13
- /******/ var __webpack_modules__ = ({
14
-
15
- /***/ 2717:
16
- /***/ ((module) => {
17
-
18
- module.exports = __WEBPACK_EXTERNAL_MODULE__2717__;
19
-
20
- /***/ }),
21
-
22
- /***/ 4061:
23
- /***/ ((module) => {
24
-
25
- module.exports = __WEBPACK_EXTERNAL_MODULE__4061__;
26
-
27
- /***/ }),
28
-
29
- /***/ 6870:
30
- /***/ ((module) => {
31
-
32
- module.exports = __WEBPACK_EXTERNAL_MODULE__6870__;
33
-
34
- /***/ }),
35
-
36
- /***/ 4212:
37
- /***/ ((module) => {
38
-
39
- module.exports = __WEBPACK_EXTERNAL_MODULE__4212__;
40
-
41
- /***/ }),
42
-
43
- /***/ 467:
44
- /***/ ((module) => {
45
-
46
- module.exports = __WEBPACK_EXTERNAL_MODULE__467__;
47
-
48
- /***/ }),
49
-
50
- /***/ 748:
51
- /***/ ((module) => {
52
-
53
- module.exports = __WEBPACK_EXTERNAL_MODULE__748__;
54
-
55
- /***/ })
56
-
57
- /******/ });
58
- /************************************************************************/
59
- /******/ // The module cache
60
- /******/ var __webpack_module_cache__ = {};
61
- /******/
62
- /******/ // The require function
63
- /******/ function __webpack_require__(moduleId) {
64
- /******/ // Check if module is in cache
65
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
66
- /******/ if (cachedModule !== undefined) {
67
- /******/ return cachedModule.exports;
68
- /******/ }
69
- /******/ // Create a new module (and put it into the cache)
70
- /******/ var module = __webpack_module_cache__[moduleId] = {
71
- /******/ // no module.id needed
72
- /******/ // no module.loaded needed
73
- /******/ exports: {}
74
- /******/ };
75
- /******/
76
- /******/ // Execute the module function
77
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
78
- /******/
79
- /******/ // Return the exports of the module
80
- /******/ return module.exports;
81
- /******/ }
82
- /******/
83
- /************************************************************************/
84
- /******/ /* webpack/runtime/compat get default export */
85
- /******/ (() => {
86
- /******/ // getDefaultExport function for compatibility with non-harmony modules
87
- /******/ __webpack_require__.n = (module) => {
88
- /******/ var getter = module && module.__esModule ?
89
- /******/ () => (module['default']) :
90
- /******/ () => (module);
91
- /******/ __webpack_require__.d(getter, { a: getter });
92
- /******/ return getter;
93
- /******/ };
94
- /******/ })();
95
- /******/
96
- /******/ /* webpack/runtime/define property getters */
97
- /******/ (() => {
98
- /******/ // define getter functions for harmony exports
99
- /******/ __webpack_require__.d = (exports, definition) => {
100
- /******/ for(var key in definition) {
101
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
102
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
103
- /******/ }
104
- /******/ }
105
- /******/ };
106
- /******/ })();
107
- /******/
108
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
109
- /******/ (() => {
110
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
111
- /******/ })();
112
- /******/
113
- /******/ /* webpack/runtime/make namespace object */
114
- /******/ (() => {
115
- /******/ // define __esModule on exports
116
- /******/ __webpack_require__.r = (exports) => {
117
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
118
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
119
- /******/ }
120
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
121
- /******/ };
122
- /******/ })();
123
- /******/
124
- /************************************************************************/
125
- var __webpack_exports__ = {};
126
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
127
- (() => {
128
- // ESM COMPAT FLAG
129
- __webpack_require__.r(__webpack_exports__);
130
-
131
- // EXPORTS
132
- __webpack_require__.d(__webpack_exports__, {
133
- BkComposeFormItem: () => (/* reexport */ compose_form_item),
134
- BkForm: () => (/* binding */ BkForm),
135
- BkFormItem: () => (/* reexport */ form_item),
136
- "default": () => (/* binding */ src),
137
- formItemKey: () => (/* reexport */ external_shared_.formItemKey),
138
- formKey: () => (/* reexport */ external_shared_.formKey),
139
- useFormItem: () => (/* reexport */ external_shared_.useFormItem)
140
- });
141
-
142
- // EXTERNAL MODULE: external "../shared"
143
- var external_shared_ = __webpack_require__(4212);
144
- // EXTERNAL MODULE: external "vue"
145
- var external_vue_ = __webpack_require__(748);
146
- ;// CONCATENATED MODULE: ../../packages/form/src/compose-form-item.tsx
147
- /*
148
- * Tencent is pleased to support the open source community by making
149
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
150
- *
151
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
152
- *
153
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
154
- *
155
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
156
- *
157
- * ---------------------------------------------------
158
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
159
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
160
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
161
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
162
- *
163
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
164
- * the Software.
165
- *
166
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
167
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
168
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
169
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
170
- * IN THE SOFTWARE.
171
- */
172
-
173
- var isCustomComponent = function isCustomComponent(node) {
174
- return node.__v_isVNode;
175
- };
176
- /* harmony default export */ const compose_form_item = ((0,external_vue_.defineComponent)({
177
- name: 'ComposeFormItem',
178
- props: {
179
- headBackgroundColor: {
180
- type: String,
181
- "default": '#FAFBFD'
182
- },
183
- tailBackgroundColor: String
184
- },
185
- render: function render() {
186
- if (!this.$slots["default"]) {
187
- return null;
188
- }
189
- var childrenArr = this.$slots["default"]();
190
- if (childrenArr.length > 1) {
191
- var childrenLength = childrenArr.length;
192
- var startIndex = 0;
193
- var headChildren = null;
194
- while (startIndex < childrenLength) {
195
- if (isCustomComponent(childrenArr[startIndex])) {
196
- headChildren = childrenArr[startIndex];
197
- break;
198
- }
199
- startIndex = startIndex + 1;
200
- }
201
- var tailIndex = childrenLength - 1;
202
- var tailChildren = null;
203
- while (tailIndex >= 0 && tailIndex > startIndex) {
204
- if (isCustomComponent(childrenArr[tailIndex])) {
205
- tailChildren = childrenArr[tailIndex];
206
- break;
207
- }
208
- tailIndex = tailIndex - 1;
209
- }
210
- if (headChildren && tailChildren) {
211
- if (!headChildren.props) {
212
- headChildren.props = {};
213
- }
214
- var headChildClass = 'bk-compose-form-item-head';
215
- if (headChildren.props["class"]) {
216
- headChildClass += " ".concat(headChildren.props["class"]);
217
- }
218
- if (this.headBackgroundColor) {
219
- headChildren.props.style = Object.assign(headChildren.props.style || {}, {
220
- 'background-color': this.headBackgroundColor
221
- });
222
- }
223
- headChildren.props["class"] = headChildClass;
224
- if (!tailChildren.props) {
225
- tailChildren.props = {};
226
- }
227
- var tailChildStaticClass = 'bk-compose-form-item-tail';
228
- if (tailChildren.props["class"]) {
229
- tailChildStaticClass += " ".concat(tailChildren.props["class"]);
230
- }
231
- if (this.tailBackgroundColor) {
232
- tailChildren.props.style = Object.assign(tailChildren.props.style || {}, {
233
- 'background-color': this.tailBackgroundColor
234
- });
235
- }
236
- tailChildren.props["class"] = tailChildStaticClass;
237
- }
238
- }
239
- return (0,external_vue_.h)('div', {
240
- "class": 'bk-compose-form-item'
241
- }, childrenArr);
242
- }
243
- }));
244
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/typeof.js
245
- function _typeof(obj) {
246
- "@babel/helpers - typeof";
247
-
248
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
249
- return typeof obj;
250
- } : function (obj) {
251
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
252
- }, _typeof(obj);
253
- }
254
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
255
-
256
- function _toPrimitive(input, hint) {
257
- if (_typeof(input) !== "object" || input === null) return input;
258
- var prim = input[Symbol.toPrimitive];
259
- if (prim !== undefined) {
260
- var res = prim.call(input, hint || "default");
261
- if (_typeof(res) !== "object") return res;
262
- throw new TypeError("@@toPrimitive must return a primitive value.");
263
- }
264
- return (hint === "string" ? String : Number)(input);
265
- }
266
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
267
-
268
-
269
- function _toPropertyKey(arg) {
270
- var key = _toPrimitive(arg, "string");
271
- return _typeof(key) === "symbol" ? key : String(key);
272
- }
273
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
274
-
275
- function _defineProperty(obj, key, value) {
276
- key = _toPropertyKey(key);
277
- if (key in obj) {
278
- Object.defineProperty(obj, key, {
279
- value: value,
280
- enumerable: true,
281
- configurable: true,
282
- writable: true
283
- });
284
- } else {
285
- obj[key] = value;
286
- }
287
- return obj;
288
- }
289
- // EXTERNAL MODULE: external "lodash"
290
- var external_lodash_ = __webpack_require__(467);
291
- var external_lodash_default = /*#__PURE__*/__webpack_require__.n(external_lodash_);
292
- ;// CONCATENATED MODULE: ../../packages/form/src/form.tsx
293
-
294
-
295
- /*
296
- * Tencent is pleased to support the open source community by making
297
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
298
- *
299
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
300
- *
301
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
302
- *
303
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
304
- *
305
- * ---------------------------------------------------
306
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
307
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
308
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
309
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
310
- *
311
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
312
- * the Software.
313
- *
314
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
315
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
316
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
317
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
318
- * IN THE SOFTWARE.
319
- */
320
-
321
-
322
-
323
- var formProps = {
324
- formType: external_shared_.PropTypes.oneOf(['default', 'vertical']).def('default'),
325
- labelWidth: external_shared_.PropTypes.oneOfType([Number, String]).def(150),
326
- labelPosition: external_shared_.PropTypes.oneOf(['left', 'center', 'right']),
327
- model: external_shared_.PropTypes.object,
328
- rules: external_shared_.PropTypes.object
329
- };
330
- var formEvents = {
331
- submit: null,
332
- validate: function validate(property, result, message) {
333
- return (0,external_lodash_.isString)(property) && (0,external_lodash_.isBoolean)(result) && (0,external_lodash_.isString)(message);
334
- }
335
- };
336
- /* harmony default export */ const src_form = ((0,external_vue_.defineComponent)({
337
- name: 'Form',
338
- props: formProps,
339
- emits: formEvents,
340
- setup: function setup(props, context) {
341
- // form-item 列表
342
- var formItemInstanceList = [];
343
- /**
344
- * @desc 注册 form-item
345
- * @param { IFormItemContext } formItemInstance
346
- */
347
- var register = function register(formItemInstance) {
348
- formItemInstanceList.push(formItemInstance);
349
- };
350
- /**
351
- * @desc 卸载 form-item
352
- * @param { IFormItemContext } formItemInstance
353
- */
354
- var unregister = function unregister(formItemInstance) {
355
- formItemInstanceList = formItemInstanceList.reduce(function (result, item) {
356
- if (item !== formItemInstance) {
357
- result.push(item);
358
- }
359
- return result;
360
- }, []);
361
- };
362
- (0,external_vue_.provide)(external_shared_.formKey, {
363
- props: props,
364
- emit: context.emit,
365
- register: register,
366
- unregister: unregister
367
- });
368
- var handleSubmit = function handleSubmit(event) {
369
- event.preventDefault();
370
- context.emit('submit');
371
- };
372
- /**
373
- * @desc 验证表单
374
- * @param { string | Array<string> } fields 指定表单字段
375
- * @returns { Promise<[]> }
376
- */
377
- var validate = function validate(fields) {
378
- var fieldMap = {};
379
- if (fields) {
380
- var fieldList = typeof fields === 'string' ? [fields] : fields;
381
- fieldMap = fieldList.reduce(function (result, item) {
382
- return Object.assign(Object.assign({}, result), _defineProperty({}, item, true));
383
- }, {});
384
- } else {
385
- fieldMap = formItemInstanceList.reduce(function (result, item) {
386
- if (item.property) {
387
- return Object.assign(Object.assign({}, result), _defineProperty({}, item.property, true));
388
- }
389
- return result;
390
- }, {});
391
- }
392
- return Promise.all(formItemInstanceList.reduce(function (result, formItem) {
393
- if (fieldMap[formItem.property]) {
394
- result.push(formItem.validate());
395
- }
396
- return result;
397
- }, [])).then(function () {
398
- return Promise.resolve(props.model);
399
- });
400
- };
401
- /**
402
- * @desc 获取表单的验证的结果(所有表单项验证成功返回 true)
403
- * @returns { Promise<Boolean> }
404
- */
405
- var getValidateResult = function getValidateResult() {
406
- return Promise.all(formItemInstanceList.map(function (formItem) {
407
- return formItem.validate(undefined, false);
408
- })).then(function () {
409
- return true;
410
- })["catch"](function () {
411
- return false;
412
- });
413
- };
414
- /**
415
- * @desc 清除表单验证错误信息
416
- * @param { string | Array<string> } fields 指定表单字段
417
- */
418
- var clearValidate = function clearValidate(fields) {
419
- var fieldMap = {};
420
- if (fields) {
421
- var fieldList = typeof fields === 'string' ? [fields] : fields;
422
- fieldMap = fieldList.reduce(function (result, item) {
423
- return Object.assign(Object.assign({}, result), _defineProperty({}, item, true));
424
- }, {});
425
- } else {
426
- fieldMap = formItemInstanceList.reduce(function (result, item) {
427
- return Object.assign(Object.assign({}, result), _defineProperty({}, item.property, true));
428
- }, {});
429
- }
430
- formItemInstanceList.forEach(function (formItem) {
431
- return fieldMap[formItem.property] && formItem.clearValidate();
432
- });
433
- };
434
- return {
435
- handleSubmit: handleSubmit,
436
- validate: validate,
437
- getValidateResult: getValidateResult,
438
- clearValidate: clearValidate
439
- };
440
- },
441
- render: function render() {
442
- var _a, _b;
443
- var formClasses = (0,external_shared_.classes)(_defineProperty({
444
- 'bk-form': true
445
- }, "bk-form--".concat(this.formType), true));
446
- return (0,external_vue_.createVNode)("form", {
447
- "class": formClasses,
448
- "onSubmit": this.handleSubmit
449
- }, [(_b = (_a = this.$slots)["default"]) === null || _b === void 0 ? void 0 : _b.call(_a)]);
450
- }
451
- }));
452
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
453
- function _arrayLikeToArray(arr, len) {
454
- if (len == null || len > arr.length) len = arr.length;
455
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
456
- return arr2;
457
- }
458
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
459
-
460
- function _arrayWithoutHoles(arr) {
461
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
462
- }
463
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/iterableToArray.js
464
- function _iterableToArray(iter) {
465
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
466
- }
467
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
468
-
469
- function _unsupportedIterableToArray(o, minLen) {
470
- if (!o) return;
471
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
472
- var n = Object.prototype.toString.call(o).slice(8, -1);
473
- if (n === "Object" && o.constructor) n = o.constructor.name;
474
- if (n === "Map" || n === "Set") return Array.from(o);
475
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
476
- }
477
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
478
- function _nonIterableSpread() {
479
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
480
- }
481
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
482
-
483
-
484
-
485
-
486
- function _toConsumableArray(arr) {
487
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
488
- }
489
- // EXTERNAL MODULE: external "../config-provider"
490
- var external_config_provider_ = __webpack_require__(2717);
491
- // EXTERNAL MODULE: external "../directives"
492
- var external_directives_ = __webpack_require__(4061);
493
- // EXTERNAL MODULE: external "../icon"
494
- var external_icon_ = __webpack_require__(6870);
495
- ;// CONCATENATED MODULE: ../../packages/form/src/utils.ts
496
- /*
497
- * Tencent is pleased to support the open source community by making
498
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
499
- *
500
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
501
- *
502
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
503
- *
504
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
505
- *
506
- * ---------------------------------------------------
507
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
508
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
509
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
510
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
511
- *
512
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
513
- * the Software.
514
- *
515
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
516
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
517
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
518
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
519
- * IN THE SOFTWARE.
520
- */
521
- var getRuleMessage = function getRuleMessage(rule) {
522
- if (typeof rule.message === 'function') {
523
- return rule.message();
524
- }
525
- return rule.message;
526
- };
527
- ;// CONCATENATED MODULE: ../../packages/form/src/validator.ts
528
- /*
529
- * Tencent is pleased to support the open source community by making
530
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
531
- *
532
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
533
- *
534
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
535
- *
536
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
537
- *
538
- * ---------------------------------------------------
539
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
540
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
541
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
542
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
543
- *
544
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
545
- * the Software.
546
- *
547
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
548
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
549
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
550
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
551
- * IN THE SOFTWARE.
552
- */
553
-
554
- /* harmony default export */ const src_validator = ({
555
- required: function required(value) {
556
- if (typeof value === 'number' || typeof value === 'boolean' || external_lodash_default().isDate(value)) {
557
- return true;
558
- }
559
- return !external_lodash_default().isEmpty(value);
560
- },
561
- min: function min(value, _min) {
562
- return value >= _min;
563
- },
564
- max: function max(value, _max) {
565
- return _max >= value;
566
- },
567
- email: function email(value) {
568
- return /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(value);
569
- },
570
- maxlength: function maxlength(value, _maxlength) {
571
- return value.length <= _maxlength;
572
- },
573
- pattern: function pattern(value, _pattern) {
574
- return _pattern.test(value);
575
- }
576
- });
577
- ;// CONCATENATED MODULE: ../../packages/form/src/form-item.tsx
578
-
579
-
580
-
581
- /*
582
- * Tencent is pleased to support the open source community by making
583
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
584
- *
585
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
586
- *
587
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
588
- *
589
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
590
- *
591
- * ---------------------------------------------------
592
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
593
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
594
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
595
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
596
- *
597
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
598
- * the Software.
599
- *
600
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
601
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
602
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
603
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
604
- * IN THE SOFTWARE.
605
- */
606
-
607
-
608
-
609
-
610
-
611
-
612
-
613
-
614
- var formItemProps = {
615
- label: external_shared_.PropTypes.string,
616
- labelWidth: external_shared_.PropTypes.oneOfType([Number, String]),
617
- labelPosition: external_shared_.PropTypes.oneOf(['left', 'center', 'right']),
618
- property: external_shared_.PropTypes.string.def(''),
619
- required: external_shared_.PropTypes.bool.def(false),
620
- email: external_shared_.PropTypes.bool.def(false),
621
- max: external_shared_.PropTypes.number,
622
- min: external_shared_.PropTypes.number,
623
- maxlength: external_shared_.PropTypes.number,
624
- rules: external_shared_.PropTypes.array,
625
- autoCheck: external_shared_.PropTypes.bool.def(false),
626
- description: external_shared_.PropTypes.string,
627
- errorDisplayType: external_shared_.PropTypes.oneOf(['tooltips', 'normal']).def('normal')
628
- };
629
- var hasOwn = function hasOwn(obj, key) {
630
- return Object.prototype.hasOwnProperty.call(obj, key);
631
- };
632
- var getRulesFromProps = function getRulesFromProps(props, t) {
633
- var rules = [];
634
- var label = props.label || '';
635
- if (props.required) {
636
- rules.push({
637
- required: true,
638
- validator: src_validator.required,
639
- message: "".concat(label, " ").concat(t.value.notBeEmpty),
640
- trigger: 'change'
641
- });
642
- }
643
- if (props.email) {
644
- rules.push({
645
- email: true,
646
- validator: src_validator.email,
647
- message: "".concat(label, " ").concat(t.value.incorrectFormat),
648
- trigger: 'change'
649
- });
650
- }
651
- if (Number(props.max) > -1) {
652
- rules.push({
653
- validator: function validator(value) {
654
- return src_validator.max(value, props.max);
655
- },
656
- message: "".concat(label, " ").concat(t.value.max, " ").concat(props.max),
657
- trigger: 'change'
658
- });
659
- }
660
- if (Number(props.min) > -1) {
661
- rules.push({
662
- validator: function validator(value) {
663
- return src_validator.min(value, props.min);
664
- },
665
- message: "".concat(label, " ").concat(t.value.min, " ").concat(props.min),
666
- trigger: 'change'
667
- });
668
- }
669
- if (Number(props.maxlength) > -1) {
670
- rules.push({
671
- validator: function validator(value) {
672
- return src_validator.maxlength(value, props.maxlength);
673
- },
674
- message: "".concat(label, " ").concat(t.value.maxLen, " ").concat(props.maxlength),
675
- trigger: 'change'
676
- });
677
- }
678
- return rules;
679
- };
680
- var mergeRules = function mergeRules(configRules, propRules, t) {
681
- var customRequired = false;
682
- var customEmail = false;
683
- var formatConfigRules = configRules.reduce(function (result, rule) {
684
- var rulevalidator;
685
- if (rule.required) {
686
- rulevalidator = (0,external_lodash_.isFunction)(rule.validator) ? rule.validator : src_validator.required;
687
- customRequired = true;
688
- } else if (rule.email) {
689
- rulevalidator = (0,external_lodash_.isFunction)(rule.validator) ? rule.validator : src_validator.email;
690
- customEmail = true;
691
- } else if (Number(rule.max) > -1) {
692
- rulevalidator = function rulevalidator(value) {
693
- return src_validator.max(value, rule.max);
694
- };
695
- } else if (Number(rule.min) > -1) {
696
- rulevalidator = function rulevalidator(value) {
697
- return src_validator.min(value, rule.max);
698
- };
699
- } else if (Number(rule.maxlength) > -1) {
700
- rulevalidator = function rulevalidator(value) {
701
- return src_validator.min(value, rule.max);
702
- };
703
- } else if (Object.prototype.toString.call(rule.pattern) === '[object RegExp]') {
704
- rulevalidator = function rulevalidator(value) {
705
- return src_validator.pattern(value, rule.pattern);
706
- };
707
- } else if ((0,external_lodash_.isFunction)(rule.validator)) {
708
- rulevalidator = rule.validator;
709
- } else {
710
- // 不支持的配置规则
711
- return result;
712
- }
713
- result.push({
714
- validator: rulevalidator,
715
- message: rule.message || t.value.verifyError,
716
- trigger: rule.trigger || 'blur'
717
- });
718
- return result;
719
- }, []);
720
- // 自定义配置验证规则覆盖内置验证规则
721
- var filterPropRules = propRules.reduce(function (result, ruleItem) {
722
- if (ruleItem.required && customRequired) {
723
- return result;
724
- }
725
- if (ruleItem.email && customEmail) {
726
- return result;
727
- }
728
- result.push(ruleItem);
729
- return result;
730
- }, []);
731
- return [].concat(_toConsumableArray(filterPropRules), _toConsumableArray(formatConfigRules));
732
- };
733
- var getTriggerRules = function getTriggerRules(trigger, rules) {
734
- return rules.reduce(function (result, rule) {
735
- if (!rule.trigger || !trigger) {
736
- result.push(rule);
737
- return result;
738
- }
739
- var ruleTriggerList = Array.isArray(rule.trigger) ? rule.trigger : [rule.trigger];
740
- if (ruleTriggerList.includes(trigger)) {
741
- result.push(rule);
742
- }
743
- return result;
744
- }, []);
745
- };
746
- var isValid = function isValid(value) {
747
- return value !== undefined;
748
- };
749
- /* harmony default export */ const form_item = ((0,external_vue_.defineComponent)({
750
- name: 'FormItem',
751
- directives: {
752
- bkTooltips: external_directives_.bkTooltips
753
- },
754
- props: formItemProps,
755
- setup: function setup(props, context) {
756
- var t = (0,external_config_provider_.useLocale)('form');
757
- var form = (0,external_shared_.useForm)();
758
- var isForm = Boolean(form);
759
- var parentFormItem = (0,external_shared_.useFormItem)();
760
- var isNested = Boolean(parentFormItem);
761
- var currentInstance = (0,external_vue_.getCurrentInstance)();
762
- var state = (0,external_vue_.reactive)({
763
- isError: false,
764
- errorMessage: ''
765
- });
766
- var isFormTypeVertical = (0,external_vue_.computed)(function () {
767
- if (!isForm) {
768
- return false;
769
- }
770
- return form.props.formType === 'vertical';
771
- });
772
- var isShowLabel = (0,external_vue_.computed)(function () {
773
- if (props.label || context.slots.label) {
774
- return true;
775
- }
776
- return false;
777
- });
778
- var labelStyles = (0,external_vue_.computed)(function () {
779
- var styles = {
780
- width: '',
781
- paddingRight: '',
782
- textAlign: ''
783
- };
784
- var labelPosition = props.labelPosition || isForm && form.props.labelPosition;
785
- if (labelPosition) {
786
- styles['text-align'] = labelPosition;
787
- }
788
- if (form.props.formType === 'vertical' || !props.label && isNested) {
789
- return styles;
790
- }
791
- var labelWidth = isValid(props.labelWidth) ? props.labelWidth : isForm && form.props.labelWidth;
792
- if (isValid(labelWidth)) {
793
- styles.width = "".concat(labelWidth, "px");
794
- styles.paddingRight = labelWidth ? '' : '0px';
795
- }
796
- return styles;
797
- });
798
- var contentStyles = (0,external_vue_.computed)(function () {
799
- return _defineProperty({}, 'margin-left', labelStyles.value.width);
800
- });
801
- /**
802
- * @desc 验证字段
803
- *
804
- * @param { undefined | string } trigger 验证触发方式
805
- * @param { boolean } showError 是否展示错误信息
806
- */
807
- var validate = function validate(trigger) {
808
- var showError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
809
- // 没有设置 property 不进行验证
810
- if (!props.property || isForm && !form.props.model) {
811
- return Promise.resolve(true);
812
- }
813
- var rules = [];
814
- // 继承 form 的验证规则
815
- if (isForm && form.props.rules && hasOwn(form.props.rules, props.property)) {
816
- rules = form.props.rules[props.property];
817
- }
818
- // form-item 自己的 rules 规则优先级更高
819
- if (props.rules) {
820
- rules = props.rules;
821
- }
822
- // 合并规则属性配置
823
- rules = getTriggerRules(trigger, mergeRules(rules, getRulesFromProps(props, t), t));
824
- // 重新触发验证重置上次的验证状态
825
- if (rules.length > 0 && showError) {
826
- state.isError = false;
827
- state.errorMessage = '';
828
- }
829
- var value = (0,external_lodash_.get)(form.props.model, props.property);
830
- var doValidate = function () {
831
- var stepIndex = -1;
832
- return function () {
833
- stepIndex = stepIndex + 1;
834
- // form-item 验证通过
835
- if (stepIndex >= rules.length) {
836
- form.emit('validate', props.property, true, '');
837
- return Promise.resolve(true);
838
- }
839
- var rule = rules[stepIndex];
840
- return Promise.resolve().then(function () {
841
- var result = rule.validator(value);
842
- var errorMessage = getRuleMessage(rule);
843
- // 异步验证(validator 返回一个 Promise)
844
- if (typeof result !== 'boolean' && typeof result.then === 'function') {
845
- return result.then(function (data) {
846
- // 异步验证结果为 false
847
- if (data === false) {
848
- return Promise.reject(errorMessage);
849
- }
850
- }).then(function () {
851
- return doValidate();
852
- }, function () {
853
- if (showError) {
854
- state.isError = true;
855
- state.errorMessage = errorMessage;
856
- }
857
- form.emit('validate', props.property, false, errorMessage);
858
- return Promise.reject(state.errorMessage);
859
- });
860
- }
861
- // 同步验证失败
862
- if (!result) {
863
- if (showError) {
864
- state.isError = true;
865
- // 验证结果返回的是 String 表示验证失败,返回结果作为错误信息
866
- state.errorMessage = typeof result === 'string' ? result : errorMessage;
867
- }
868
- form.emit('validate', props.property, false, errorMessage);
869
- return Promise.reject(state.errorMessage);
870
- }
871
- // 下一步
872
- return doValidate();
873
- });
874
- };
875
- }();
876
- return doValidate();
877
- };
878
- /**
879
- * @desc 清除验证状态
880
- */
881
- var clearValidate = function clearValidate() {
882
- state.isError = false;
883
- state.errorMessage = '';
884
- };
885
- (0,external_vue_.provide)(external_shared_.formItemKey, Object.assign(Object.assign({}, props), {
886
- validate: validate,
887
- clearValidate: clearValidate
888
- }));
889
- (0,external_vue_.onMounted)(function () {
890
- if (isForm) {
891
- form.register(currentInstance.proxy);
892
- }
893
- });
894
- (0,external_vue_.onBeforeUnmount)(function () {
895
- if (isForm) {
896
- form.unregister(currentInstance.proxy);
897
- }
898
- });
899
- return Object.assign(Object.assign({}, (0,external_vue_.toRefs)(state)), {
900
- isShowLabel: isShowLabel,
901
- labelStyles: labelStyles,
902
- contentStyles: contentStyles,
903
- isFormTypeVertical: isFormTypeVertical,
904
- validate: validate,
905
- clearValidate: clearValidate
906
- });
907
- },
908
- render: function render() {
909
- var _this = this;
910
- var _a, _b, _c, _d;
911
- var itemClassees = (0,external_shared_.classes)({
912
- 'bk-form-item': true,
913
- 'is-error': this.isError,
914
- 'is-required': this.required
915
- });
916
- var renderLabel = function renderLabel() {
917
- if (_this.$slots.label) {
918
- return _this.$slots.label();
919
- }
920
- if (_this.description) {
921
- return (0,external_vue_.withDirectives)((0,external_vue_.createVNode)("span", {
922
- "class": {
923
- 'bk-form-label-description': Boolean(_this.description)
924
- }
925
- }, [_this.label]), [[(0,external_vue_.resolveDirective)("bk-tooltips"), _this.description]]);
926
- }
927
- return _this.label;
928
- };
929
- var renderError = function renderError() {
930
- if (!_this.isError) {
931
- return null;
932
- }
933
- if (_this.errorDisplayType === 'tooltips') {
934
- return (0,external_vue_.withDirectives)((0,external_vue_.createVNode)("div", {
935
- "class": "bk-form-error-tips"
936
- }, [(0,external_vue_.createVNode)(external_icon_.ExclamationCircleShape, null, null)]), [[(0,external_vue_.resolveDirective)("bk-tooltips"), _this.errorMessage]]);
937
- }
938
- return (0,external_vue_.createVNode)("div", {
939
- "class": "bk-form-error"
940
- }, [_this.$slots.error ? _this.$slots.error(_this.errorMessage) : _this.errorMessage]);
941
- };
942
- return (0,external_vue_.createVNode)("div", {
943
- "class": itemClassees
944
- }, [this.isShowLabel && (0,external_vue_.createVNode)("div", {
945
- "class": "bk-form-label",
946
- "style": this.labelStyles
947
- }, [renderLabel(), this.isFormTypeVertical && ((_b = (_a = this.$slots).labelAppend) === null || _b === void 0 ? void 0 : _b.call(_a))]), (0,external_vue_.createVNode)("div", {
948
- "class": "bk-form-content",
949
- "style": this.contentStyles
950
- }, [(_d = (_c = this.$slots)["default"]) === null || _d === void 0 ? void 0 : _d.call(_c), renderError()])]);
951
- }
952
- }));
953
- ;// CONCATENATED MODULE: ../../packages/form/src/index.ts
954
- /*
955
- * Tencent is pleased to support the open source community by making
956
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
957
- *
958
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
959
- *
960
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
961
- *
962
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
963
- *
964
- * ---------------------------------------------------
965
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
966
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
967
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
968
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
969
- *
970
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
971
- * the Software.
972
- *
973
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
974
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
975
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
976
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
977
- * IN THE SOFTWARE.
978
- */
979
-
980
-
981
-
982
-
983
-
984
- var BkForm = (0,external_shared_.withInstallProps)(src_form, {
985
- FormItem: form_item,
986
- ComposeFormItem: compose_form_item
987
- });
988
- /* harmony default export */ const src = (BkForm);
989
-
990
- })();
991
-
992
- /******/ return __webpack_exports__;
993
- /******/ })()
994
- ;
995
- });
1
+ !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("../shared"),require("vue"),require("lodash"),require("../config-provider"),require("../directives"),require("../icon"));else if("function"==typeof define&&define.amd)define(["../shared","vue","lodash","../config-provider","../directives","../icon"],r);else{var t="object"==typeof exports?r(require("../shared"),require("vue"),require("lodash"),require("../config-provider"),require("../directives"),require("../icon")):r(e["../shared"],e.vue,e.lodash,e["../config-provider"],e["../directives"],e["../icon"]);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(self,((e,r,t,o,n,i)=>(()=>{"use strict";var a={2717:e=>{e.exports=o},4061:e=>{e.exports=n},6870:e=>{e.exports=i},4212:r=>{r.exports=e},467:e=>{e.exports=t},748:e=>{e.exports=r}},s={};function l(e){var r=s[e];if(void 0!==r)return r.exports;var t=s[e]={exports:{}};return a[e](t,t.exports,l),t.exports}l.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return l.d(r,{a:r}),r},l.d=(e,r)=>{for(var t in r)l.o(r,t)&&!l.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},l.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};return(()=>{l.r(u),l.d(u,{BkComposeFormItem:()=>o,BkForm:()=>j,BkFormItem:()=>P,default:()=>S,formItemKey:()=>e.formItemKey,formKey:()=>e.formKey,useFormItem:()=>e.useFormItem});var e=l(4212),r=l(748),t=function(e){return e.__v_isVNode};const o=(0,r.defineComponent)({name:"ComposeFormItem",props:{headBackgroundColor:{type:String,default:"#FAFBFD"},tailBackgroundColor:String},render:function(){if(!this.$slots.default)return null;var e=this.$slots.default();if(e.length>1){for(var o=e.length,n=0,i=null;n<o;){if(t(e[n])){i=e[n];break}n+=1}for(var a=o-1,s=null;a>=0&&a>n;){if(t(e[a])){s=e[a];break}a-=1}if(i&&s){i.props||(i.props={});var l="bk-compose-form-item-head";i.props.class&&(l+=" ".concat(i.props.class)),this.headBackgroundColor&&(i.props.style=Object.assign(i.props.style||{},{"background-color":this.headBackgroundColor})),i.props.class=l,s.props||(s.props={});var u="bk-compose-form-item-tail";s.props.class&&(u+=" ".concat(s.props.class)),this.tailBackgroundColor&&(s.props.style=Object.assign(s.props.style||{},{"background-color":this.tailBackgroundColor})),s.props.class=u}}return(0,r.h)("div",{class:"bk-compose-form-item"},e)}});function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function i(e,r,t){return(r=function(e){var r=function(e,r){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===n(r)?r:String(r)}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var a=l(467),s=l.n(a),c={formType:e.PropTypes.oneOf(["default","vertical"]).def("default"),labelWidth:e.PropTypes.oneOfType([Number,String]).def(150),labelPosition:e.PropTypes.oneOf(["left","center","right"]),model:e.PropTypes.object,rules:e.PropTypes.object},p={submit:null,validate:function(e,r,t){return(0,a.isString)(e)&&(0,a.isBoolean)(r)&&(0,a.isString)(t)}};const f=(0,r.defineComponent)({name:"Form",props:c,emits:p,setup:function(t,o){var n=[];return(0,r.provide)(e.formKey,{props:t,emit:o.emit,register:function(e){n.push(e)},unregister:function(e){n=n.reduce((function(r,t){return t!==e&&r.push(t),r}),[])}}),{handleSubmit:function(e){e.preventDefault(),o.emit("submit")},validate:function(e){var r={};return r=e?("string"==typeof e?[e]:e).reduce((function(e,r){return Object.assign(Object.assign({},e),i({},r,!0))}),{}):n.reduce((function(e,r){return r.property?Object.assign(Object.assign({},e),i({},r.property,!0)):e}),{}),Promise.all(n.reduce((function(e,t){return r[t.property]&&e.push(t.validate()),e}),[])).then((function(){return Promise.resolve(t.model)}))},getValidateResult:function(){return Promise.all(n.map((function(e){return e.validate(void 0,!1)}))).then((function(){return!0})).catch((function(){return!1}))},clearValidate:function(e){var r={};r=e?("string"==typeof e?[e]:e).reduce((function(e,r){return Object.assign(Object.assign({},e),i({},r,!0))}),{}):n.reduce((function(e,r){return Object.assign(Object.assign({},e),i({},r.property,!0))}),{}),n.forEach((function(e){return r[e.property]&&e.clearValidate()}))}}},render:function(){var t,o,n=(0,e.classes)(i({"bk-form":!0},"bk-form--".concat(this.formType),!0));return(0,r.createVNode)("form",{class:n,onSubmit:this.handleSubmit},[null===(o=(t=this.$slots).default)||void 0===o?void 0:o.call(t)])}});function m(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}function d(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(e){if("string"==typeof e)return m(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?m(e,r):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var g=l(2717),v=l(4061),y=l(6870);const b={required:function(e){return!("number"!=typeof e&&"boolean"!=typeof e&&!s().isDate(e)&&s().isEmpty(e))},min:function(e,r){return e>=r},max:function(e,r){return r>=e},email:function(e){return/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(e)},maxlength:function(e,r){return e.length<=r},pattern:function(e,r){return r.test(e)}};var h={label:e.PropTypes.string,labelWidth:e.PropTypes.oneOfType([Number,String]),labelPosition:e.PropTypes.oneOf(["left","center","right"]),property:e.PropTypes.string.def(""),required:e.PropTypes.bool.def(!1),email:e.PropTypes.bool.def(!1),max:e.PropTypes.number,min:e.PropTypes.number,maxlength:e.PropTypes.number,rules:e.PropTypes.array,autoCheck:e.PropTypes.bool.def(!1),description:e.PropTypes.string,errorDisplayType:e.PropTypes.oneOf(["tooltips","normal"]).def("normal")},x=function(e){return void 0!==e};const P=(0,r.defineComponent)({name:"FormItem",directives:{bkTooltips:v.bkTooltips},props:h,setup:function(t,o){var n=(0,g.useLocale)("form"),s=(0,e.useForm)(),l=Boolean(s),u=(0,e.useFormItem)(),c=Boolean(u),p=(0,r.getCurrentInstance)(),f=(0,r.reactive)({isError:!1,errorMessage:""}),m=(0,r.computed)((function(){return!!l&&"vertical"===s.props.formType})),v=(0,r.computed)((function(){return!(!t.label&&!o.slots.label)})),y=(0,r.computed)((function(){var e={width:"",paddingRight:"",textAlign:""},r=t.labelPosition||l&&s.props.labelPosition;if(r&&(e["text-align"]=r),"vertical"===s.props.formType||!t.label&&c)return e;var o=x(t.labelWidth)?t.labelWidth:l&&s.props.labelWidth;return x(o)&&(e.width="".concat(o,"px"),e.paddingRight=o?"":"0px"),e})),h=(0,r.computed)((function(){return i({},"margin-left",y.value.width)})),P=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t.property||l&&!s.props.model)return Promise.resolve(!0);var o,i,u=[];l&&s.props.rules&&(o=s.props.rules,i=t.property,Object.prototype.hasOwnProperty.call(o,i))&&(u=s.props.rules[t.property]),t.rules&&(u=t.rules),u=function(e,r){return r.reduce((function(r,t){return t.trigger&&e?((Array.isArray(t.trigger)?t.trigger:[t.trigger]).includes(e)&&r.push(t),r):(r.push(t),r)}),[])}(e,function(e,r,t){var o=!1,n=!1,i=e.reduce((function(e,r){var i;if(r.required)i=(0,a.isFunction)(r.validator)?r.validator:b.required,o=!0;else if(r.email)i=(0,a.isFunction)(r.validator)?r.validator:b.email,n=!0;else if(Number(r.max)>-1)i=function(e){return b.max(e,r.max)};else if(Number(r.min)>-1)i=function(e){return b.min(e,r.max)};else if(Number(r.maxlength)>-1)i=function(e){return b.min(e,r.max)};else if("[object RegExp]"===Object.prototype.toString.call(r.pattern))i=function(e){return b.pattern(e,r.pattern)};else{if(!(0,a.isFunction)(r.validator))return e;i=r.validator}return e.push({validator:i,message:r.message||t.value.verifyError,trigger:r.trigger||"blur"}),e}),[]),s=r.reduce((function(e,r){return r.required&&o||r.email&&n||e.push(r),e}),[]);return[].concat(d(s),d(i))}(u,function(e,r){var t=[],o=e.label||"";return e.required&&t.push({required:!0,validator:b.required,message:"".concat(o," ").concat(r.value.notBeEmpty),trigger:"change"}),e.email&&t.push({email:!0,validator:b.email,message:"".concat(o," ").concat(r.value.incorrectFormat),trigger:"change"}),Number(e.max)>-1&&t.push({validator:function(r){return b.max(r,e.max)},message:"".concat(o," ").concat(r.value.max," ").concat(e.max),trigger:"change"}),Number(e.min)>-1&&t.push({validator:function(r){return b.min(r,e.min)},message:"".concat(o," ").concat(r.value.min," ").concat(e.min),trigger:"change"}),Number(e.maxlength)>-1&&t.push({validator:function(r){return b.maxlength(r,e.maxlength)},message:"".concat(o," ").concat(r.value.maxLen," ").concat(e.maxlength),trigger:"change"}),t}(t,n),n)),u.length>0&&r&&(f.isError=!1,f.errorMessage="");var c,p=(0,a.get)(s.props.model,t.property),m=(c=-1,function(){if((c+=1)>=u.length)return s.emit("validate",t.property,!0,""),Promise.resolve(!0);var e=u[c];return Promise.resolve().then((function(){var o=e.validator(p),n=function(e){return"function"==typeof e.message?e.message():e.message}(e);return"boolean"!=typeof o&&"function"==typeof o.then?o.then((function(e){if(!1===e)return Promise.reject(n)})).then((function(){return m()}),(function(){return r&&(f.isError=!0,f.errorMessage=n),s.emit("validate",t.property,!1,n),Promise.reject(f.errorMessage)})):o?m():(r&&(f.isError=!0,f.errorMessage="string"==typeof o?o:n),s.emit("validate",t.property,!1,n),Promise.reject(f.errorMessage))}))});return m()},j=function(){f.isError=!1,f.errorMessage=""};return(0,r.provide)(e.formItemKey,Object.assign(Object.assign({},t),{validate:P,clearValidate:j})),(0,r.onMounted)((function(){l&&s.register(p.proxy)})),(0,r.onBeforeUnmount)((function(){l&&s.unregister(p.proxy)})),Object.assign(Object.assign({},(0,r.toRefs)(f)),{isShowLabel:v,labelStyles:y,contentStyles:h,isFormTypeVertical:m,validate:P,clearValidate:j})},render:function(){var t,o,n,i,a=this,s=(0,e.classes)({"bk-form-item":!0,"is-error":this.isError,"is-required":this.required});return(0,r.createVNode)("div",{class:s},[this.isShowLabel&&(0,r.createVNode)("div",{class:"bk-form-label",style:this.labelStyles},[a.$slots.label?a.$slots.label():a.description?(0,r.withDirectives)((0,r.createVNode)("span",{class:{"bk-form-label-description":Boolean(a.description)}},[a.label]),[[(0,r.resolveDirective)("bk-tooltips"),a.description]]):a.label,this.isFormTypeVertical&&(null===(o=(t=this.$slots).labelAppend)||void 0===o?void 0:o.call(t))]),(0,r.createVNode)("div",{class:"bk-form-content",style:this.contentStyles},[null===(i=(n=this.$slots).default)||void 0===i?void 0:i.call(n),a.isError?"tooltips"===a.errorDisplayType?(0,r.withDirectives)((0,r.createVNode)("div",{class:"bk-form-error-tips"},[(0,r.createVNode)(y.ExclamationCircleShape,null,null)]),[[(0,r.resolveDirective)("bk-tooltips"),a.errorMessage]]):(0,r.createVNode)("div",{class:"bk-form-error"},[a.$slots.error?a.$slots.error(a.errorMessage):a.errorMessage]):null])])}});var j=(0,e.withInstallProps)(f,{FormItem:P,ComposeFormItem:o});const S=j})(),u})()));