bkui-vue 0.0.2-beta.75 → 0.0.2-beta.77

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