@blueking/bkui-form 1.0.1-beta.3 → 1.0.1-beta.4

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 (209) hide show
  1. package/dist/adapter/common/FieldGroupWrap.d.ts +209 -0
  2. package/dist/adapter/field/ArrayField.d.ts +147 -0
  3. package/dist/adapter/field/BooleanField.d.ts +145 -0
  4. package/dist/adapter/field/CompositionField.d.ts +151 -0
  5. package/dist/adapter/field/FieldProps.d.ts +70 -0
  6. package/dist/adapter/field/NumberField.d.ts +145 -0
  7. package/dist/adapter/field/ObjectField.d.ts +147 -0
  8. package/dist/adapter/field/SchemaField.d.ts +145 -0
  9. package/dist/adapter/field/StringField.d.ts +4 -0
  10. package/dist/adapter/widget/ArrayWidget.d.ts +154 -0
  11. package/dist/adapter/widget/ButtonWidget.d.ts +16 -0
  12. package/dist/adapter/widget/CheckboxWidget.d.ts +34 -0
  13. package/dist/adapter/widget/CollapseGroupWidget.d.ts +196 -0
  14. package/dist/adapter/widget/ColorPickerWidget.d.ts +8 -0
  15. package/dist/adapter/widget/InputWidget.d.ts +30 -0
  16. package/dist/adapter/widget/KeyValueArrayWidget.d.ts +157 -0
  17. package/dist/adapter/widget/RadioWidget.d.ts +37 -0
  18. package/dist/adapter/widget/SelectWidget.d.ts +37 -0
  19. package/dist/adapter/widget/SwitchWidget.d.ts +10 -0
  20. package/dist/adapter/widget/TabGroupWidget.d.ts +187 -0
  21. package/dist/adapter/widget/TableWidget.d.ts +154 -0
  22. package/dist/adapter/widget/Widget.d.ts +182 -0
  23. package/dist/controller/form.d.ts +141 -0
  24. package/dist/controller/props.d.ts +62 -0
  25. package/dist/core/events.d.ts +10 -0
  26. package/dist/core/expression.d.ts +13 -0
  27. package/dist/core/form.d.ts +5 -0
  28. package/dist/core/lang.d.ts +1 -0
  29. package/dist/core/layout.d.ts +20 -0
  30. package/dist/core/lifecycle.d.ts +0 -0
  31. package/dist/core/path.d.ts +9 -0
  32. package/dist/core/proxy.d.ts +3 -0
  33. package/dist/core/reaction.d.ts +5 -0
  34. package/dist/core/register.d.ts +19 -0
  35. package/dist/core/schema.d.ts +26 -0
  36. package/dist/core/validator.d.ts +35 -0
  37. package/dist/core/widgetTree.d.ts +40 -0
  38. package/dist/index.d.ts +6 -0
  39. package/dist/index.es.js +7443 -0
  40. package/dist/index.umd.js +12 -0
  41. package/dist/style.css +1 -0
  42. package/dist/util/fetch.d.ts +10 -0
  43. package/dist/util/index.d.ts +23 -0
  44. package/package.json +24 -12
  45. package/esm/adapter/common/FieldGroupWrap.tsx.js +0 -199
  46. package/esm/adapter/field/ArrayField.tsx.js +0 -55
  47. package/esm/adapter/field/BooleanField.tsx.js +0 -41
  48. package/esm/adapter/field/CompositionField.tsx.js +0 -113
  49. package/esm/adapter/field/FieldProps.ts.js +0 -85
  50. package/esm/adapter/field/NumberField.tsx.js +0 -19
  51. package/esm/adapter/field/ObjectField.tsx.js +0 -58
  52. package/esm/adapter/field/SchemaField.tsx.js +0 -28
  53. package/esm/adapter/field/StringField.tsx.js +0 -4
  54. package/esm/adapter/widget/ArrayWidget.ts.js +0 -196
  55. package/esm/adapter/widget/ButtonWidget.ts.js +0 -76
  56. package/esm/adapter/widget/CheckboxWidget.ts.js +0 -101
  57. package/esm/adapter/widget/CollapseGroupWidget.ts.js +0 -140
  58. package/esm/adapter/widget/ColorPickerWidget.ts.js +0 -71
  59. package/esm/adapter/widget/InputWidget.ts.js +0 -79
  60. package/esm/adapter/widget/KeyValueArrayWidget.tsx.js +0 -156
  61. package/esm/adapter/widget/RadioWidget.ts.js +0 -98
  62. package/esm/adapter/widget/SelectWidget.ts.js +0 -98
  63. package/esm/adapter/widget/SwitchWidget.ts.js +0 -73
  64. package/esm/adapter/widget/TabGroupWidget.ts.js +0 -145
  65. package/esm/adapter/widget/TableWidget.ts.js +0 -205
  66. package/esm/adapter/widget/Widget.ts.js +0 -497
  67. package/esm/assets/fonts/iconcool.eot +0 -0
  68. package/esm/assets/fonts/iconcool.svg +0 -53
  69. package/esm/assets/fonts/iconcool.ttf +0 -0
  70. package/esm/assets/fonts/iconcool.woff +0 -0
  71. package/esm/assets/style.css +0 -43
  72. package/esm/controller/form.css +0 -164
  73. package/esm/controller/form.tsx.js +0 -159
  74. package/esm/controller/props.ts.js +0 -75
  75. package/esm/core/events.ts.js +0 -74
  76. package/esm/core/expression.ts.js +0 -67
  77. package/esm/core/lang.ts.js +0 -25
  78. package/esm/core/layout.ts.js +0 -149
  79. package/esm/core/path.ts.js +0 -60
  80. package/esm/core/proxy.ts.js +0 -10
  81. package/esm/core/reaction.ts.js +0 -116
  82. package/esm/core/register.ts.js +0 -74
  83. package/esm/core/schema.ts.js +0 -302
  84. package/esm/core/validator.ts.js +0 -248
  85. package/esm/core/widgetTree.ts.js +0 -163
  86. package/esm/index.ts.js +0 -6
  87. package/esm/node_modules/@blueking/cli-service/dist/lib/path.js +0 -35
  88. package/esm/node_modules/@blueking/cli-service/dist/lib/util.js +0 -233
  89. package/esm/node_modules/@blueking/cli-service/dist/tools/rust/helper/path.js +0 -172
  90. package/esm/node_modules/ajv/dist/ajv.js +0 -50
  91. package/esm/node_modules/ajv/dist/compile/codegen/code.js +0 -156
  92. package/esm/node_modules/ajv/dist/compile/codegen/index.js +0 -697
  93. package/esm/node_modules/ajv/dist/compile/codegen/scope.js +0 -143
  94. package/esm/node_modules/ajv/dist/compile/errors.js +0 -123
  95. package/esm/node_modules/ajv/dist/compile/index.js +0 -242
  96. package/esm/node_modules/ajv/dist/compile/names.js +0 -28
  97. package/esm/node_modules/ajv/dist/compile/ref_error.js +0 -12
  98. package/esm/node_modules/ajv/dist/compile/resolve.js +0 -155
  99. package/esm/node_modules/ajv/dist/compile/rules.js +0 -26
  100. package/esm/node_modules/ajv/dist/compile/util.js +0 -178
  101. package/esm/node_modules/ajv/dist/compile/validate/applicability.js +0 -19
  102. package/esm/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -50
  103. package/esm/node_modules/ajv/dist/compile/validate/dataType.js +0 -203
  104. package/esm/node_modules/ajv/dist/compile/validate/defaults.js +0 -35
  105. package/esm/node_modules/ajv/dist/compile/validate/index.js +0 -520
  106. package/esm/node_modules/ajv/dist/compile/validate/keyword.js +0 -124
  107. package/esm/node_modules/ajv/dist/compile/validate/subschema.js +0 -81
  108. package/esm/node_modules/ajv/dist/core.js +0 -618
  109. package/esm/node_modules/ajv/dist/refs/data.json +0 -13
  110. package/esm/node_modules/ajv/dist/refs/json-schema-draft-07.json +0 -151
  111. package/esm/node_modules/ajv/dist/runtime/equal.js +0 -7
  112. package/esm/node_modules/ajv/dist/runtime/ucs2length.js +0 -24
  113. package/esm/node_modules/ajv/dist/runtime/uri.js +0 -6
  114. package/esm/node_modules/ajv/dist/runtime/validation_error.js +0 -11
  115. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -49
  116. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -106
  117. package/esm/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -23
  118. package/esm/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -12
  119. package/esm/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -95
  120. package/esm/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -85
  121. package/esm/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -66
  122. package/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -44
  123. package/esm/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -52
  124. package/esm/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -30
  125. package/esm/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -26
  126. package/esm/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -60
  127. package/esm/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -75
  128. package/esm/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -12
  129. package/esm/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -54
  130. package/esm/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -38
  131. package/esm/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -13
  132. package/esm/node_modules/ajv/dist/vocabularies/code.js +0 -131
  133. package/esm/node_modules/ajv/dist/vocabularies/core/id.js +0 -10
  134. package/esm/node_modules/ajv/dist/vocabularies/core/index.js +0 -16
  135. package/esm/node_modules/ajv/dist/vocabularies/core/ref.js +0 -122
  136. package/esm/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -104
  137. package/esm/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -9
  138. package/esm/node_modules/ajv/dist/vocabularies/draft7.js +0 -17
  139. package/esm/node_modules/ajv/dist/vocabularies/format/format.js +0 -92
  140. package/esm/node_modules/ajv/dist/vocabularies/format/index.js +0 -6
  141. package/esm/node_modules/ajv/dist/vocabularies/metadata.js +0 -18
  142. package/esm/node_modules/ajv/dist/vocabularies/validation/const.js +0 -25
  143. package/esm/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -48
  144. package/esm/node_modules/ajv/dist/vocabularies/validation/index.js +0 -33
  145. package/esm/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -24
  146. package/esm/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -27
  147. package/esm/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -27
  148. package/esm/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -24
  149. package/esm/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -26
  150. package/esm/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -24
  151. package/esm/node_modules/ajv/dist/vocabularies/validation/required.js +0 -79
  152. package/esm/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -64
  153. package/esm/node_modules/ajv-formats/dist/formats.js +0 -173
  154. package/esm/node_modules/ajv-formats/dist/index.js +0 -37
  155. package/esm/node_modules/ajv-formats/dist/limit.js +0 -69
  156. package/esm/node_modules/ajv-i18n/localize/zh/index.js +0 -154
  157. package/esm/node_modules/fast-deep-equal/index.js +0 -46
  158. package/esm/node_modules/fast-uri/index.js +0 -303
  159. package/esm/node_modules/fast-uri/lib/schemes.js +0 -188
  160. package/esm/node_modules/fast-uri/lib/scopedChars.js +0 -30
  161. package/esm/node_modules/fast-uri/lib/utils.js +0 -244
  162. package/esm/node_modules/json-schema-traverse/index.js +0 -89
  163. package/esm/node_modules/semver/classes/comparator.js +0 -143
  164. package/esm/node_modules/semver/classes/range.js +0 -557
  165. package/esm/node_modules/semver/classes/semver.js +0 -333
  166. package/esm/node_modules/semver/functions/clean.js +0 -8
  167. package/esm/node_modules/semver/functions/cmp.js +0 -54
  168. package/esm/node_modules/semver/functions/coerce.js +0 -62
  169. package/esm/node_modules/semver/functions/compare-build.js +0 -9
  170. package/esm/node_modules/semver/functions/compare-loose.js +0 -5
  171. package/esm/node_modules/semver/functions/compare.js +0 -7
  172. package/esm/node_modules/semver/functions/diff.js +0 -60
  173. package/esm/node_modules/semver/functions/eq.js +0 -5
  174. package/esm/node_modules/semver/functions/gt.js +0 -5
  175. package/esm/node_modules/semver/functions/gte.js +0 -5
  176. package/esm/node_modules/semver/functions/inc.js +0 -21
  177. package/esm/node_modules/semver/functions/lt.js +0 -5
  178. package/esm/node_modules/semver/functions/lte.js +0 -5
  179. package/esm/node_modules/semver/functions/major.js +0 -5
  180. package/esm/node_modules/semver/functions/minor.js +0 -5
  181. package/esm/node_modules/semver/functions/neq.js +0 -5
  182. package/esm/node_modules/semver/functions/parse.js +0 -18
  183. package/esm/node_modules/semver/functions/patch.js +0 -5
  184. package/esm/node_modules/semver/functions/prerelease.js +0 -8
  185. package/esm/node_modules/semver/functions/rcompare.js +0 -5
  186. package/esm/node_modules/semver/functions/rsort.js +0 -5
  187. package/esm/node_modules/semver/functions/satisfies.js +0 -12
  188. package/esm/node_modules/semver/functions/sort.js +0 -5
  189. package/esm/node_modules/semver/functions/valid.js +0 -8
  190. package/esm/node_modules/semver/index.js +0 -91
  191. package/esm/node_modules/semver/internal/constants.js +0 -37
  192. package/esm/node_modules/semver/internal/debug.js +0 -11
  193. package/esm/node_modules/semver/internal/identifiers.js +0 -29
  194. package/esm/node_modules/semver/internal/lrucache.js +0 -42
  195. package/esm/node_modules/semver/internal/parse-options.js +0 -17
  196. package/esm/node_modules/semver/internal/re.js +0 -223
  197. package/esm/node_modules/semver/ranges/gtr.js +0 -6
  198. package/esm/node_modules/semver/ranges/intersects.js +0 -9
  199. package/esm/node_modules/semver/ranges/ltr.js +0 -6
  200. package/esm/node_modules/semver/ranges/max-satisfying.js +0 -27
  201. package/esm/node_modules/semver/ranges/min-satisfying.js +0 -26
  202. package/esm/node_modules/semver/ranges/min-version.js +0 -63
  203. package/esm/node_modules/semver/ranges/outside.js +0 -82
  204. package/esm/node_modules/semver/ranges/simplify.js +0 -49
  205. package/esm/node_modules/semver/ranges/subset.js +0 -249
  206. package/esm/node_modules/semver/ranges/to-comparators.js +0 -10
  207. package/esm/node_modules/semver/ranges/valid.js +0 -13
  208. package/esm/util/fetch.ts.js +0 -190
  209. package/esm/util/index.ts.js +0 -276
@@ -1,164 +0,0 @@
1
- .bk-schema-form {
2
- font-size: 12px;
3
- .mb10 {
4
- margin-bottom: 10px;
5
- }
6
- .mb0 {
7
- margin-bottom: 0px;
8
- }
9
- .mt5 {
10
- margin-top: 5px;
11
- }
12
- .mr24 {
13
- margin-right: 24px;
14
- }
15
- .mr5 {
16
- margin-right: 5px;
17
- }
18
- .pr20 {
19
- padding-right: 20px;
20
- }
21
- .bk-form-item {
22
- margin-top: unset !important;
23
- margin-bottom: unset !important;
24
- }
25
- .bk-schema-form-group.normal {
26
- padding: 24px;
27
- position: relative;
28
- }
29
- .bk-schema-form-group.card{
30
- background: #fff;
31
- padding: 0 24px 24px 24px;
32
- border-radius: 2px;
33
- }
34
- .bk-schema-form-group.hide-empty-row .bk-schema-form-group-content {
35
- row-gap: 0 !important;
36
- }
37
- .bk-schema-form-group.hide-empty-row .bk-schema-form-group-content .bk-form-item {
38
- margin-bottom: 20px;
39
- }
40
- .bk-schema-form-group--error {
41
- border-color: #f5222d !important;
42
- }
43
- .bk-schema-form-group__error-tips{
44
- position: relative;
45
- display: block;
46
- width: 10px;
47
- height: 10px;
48
- }
49
- .bk-schema-form-group__error-tips-popover {
50
- position: absolute;
51
- top: -5px;
52
- left: 0;
53
- z-index: 1;
54
- background: #fff;
55
- border: 1px solid #f5222d;
56
- color: #f5222d;
57
- font-size: 12px;
58
- margin-left: 10px;
59
- font-weight: normal;
60
- padding: 5px 10px;
61
- border-radius: 2px;
62
- max-height: 50px;
63
- overflow:hidden;
64
- }
65
- .bk-schema-form-group__error-tips-popover:hover {
66
- max-height: unset;
67
- }
68
-
69
- .bk-schema-form-group__error-tips-popover > p {
70
- padding: 0;
71
- margin: 0;
72
- white-space: nowrap;
73
- }
74
- .bk-schema-form-group .bk-schema-form-group-title {
75
- font-size: 14px;
76
- font-weight: 600;
77
- color: #63656E;
78
- }
79
- .bk-schema-form-group .bk-schema-form-group-title.default {
80
- display: inline-block;
81
- margin-bottom: 10px;
82
- }
83
- .bk-schema-form-group .bk-schema-form-group-title.normal {
84
- position: absolute;
85
- top: -1em;
86
- left: 10px;
87
- line-height: 2em;
88
- padding: 0 0.5em;
89
- background: #fff;
90
- }
91
- .bk-schema-form-group .bk-schema-form-group-title.card{
92
- display: flex;
93
- height: 50px;
94
- align-items: center;
95
- padding: 0 24px;
96
- margin: 0 -24px 8px -24px;
97
- }
98
- .bk-schema-form-group-add {
99
- font-size: 14px;
100
- color: #3a84ff;
101
- cursor: pointer;
102
- display: flex;
103
- align-items: center;
104
- }
105
- .bk-schema-form-group-delete {
106
- display: flex;
107
- align-items: center;
108
- justify-content: center;
109
- position: absolute;
110
- right: 8px;
111
- top: 6px;
112
- cursor: pointer;
113
- color: #979bA5;
114
- font-size: 14px;
115
- }
116
- .bk-schema-form-group-delete:hover {
117
- color: #3a84ff;
118
- }
119
- .bk-schema-form-reset-default {
120
- display: inline-flex;
121
- align-items: center;
122
- justify-content: center;
123
- margin-left: 8px;
124
- cursor: pointer;
125
- color: #979bA5;
126
- font-size: 14px;
127
- }
128
- .bk-schema-form-reset-default:hover {
129
- color: #3a84ff;
130
- }
131
- .bk-schema-form-label-description {
132
- cursor: pointer;
133
- border-bottom: 1px dashed #979ba5;
134
- }
135
- .bk-schema-form-item__error-tips {
136
- color: #f5222d;
137
- font-size: 12px;
138
- margin-top: 5px;
139
- margin: 0;
140
- line-height: 1.5em;
141
- }
142
- .bk-schema-form-item--error .bk-input,
143
- .bk-schema-form-item--error .bk-textarea-wrapper,
144
- .bk-schema-form-item--error .bk-select {
145
- border: 1px solid #f5222d;
146
- box-shadow: none;
147
- }
148
- .bk-schema-form-item-auto-height .bk-form-content {
149
- min-height: auto;
150
- line-height: 1;
151
- }
152
- .table-widget-actions .action-btn {
153
- margin-right: 8px;
154
- font-size: 14px;
155
- cursor: pointer;
156
- }
157
- .table-widget-actions .action-btn:hover {
158
- color: #3a84ff;
159
- }
160
- .is-disabled .action-btn {
161
- color: #dcdee5 !important;
162
- cursor: not-allowed;
163
- }
164
- }
@@ -1,159 +0,0 @@
1
- import { defineComponent, h } from 'vue';
2
- import { merge, deepEquals, mergeDeep, hasOwnProperty } from '../util/index.ts.js';
3
- import registry, { Registry } from '../core/register.ts.js';
4
- import Schema from '../core/schema.ts.js';
5
- import Layout from '../core/layout.ts.js';
6
- import createProxy from '../core/proxy.ts.js';
7
- import Path from '../core/path.ts.js';
8
- import props from './props.ts.js';
9
- import SchemaField from '../adapter/field/SchemaField.tsx.js';
10
- import ObjectField from '../adapter/field/ObjectField.tsx.js';
11
- import NumberField from '../adapter/field/NumberField.tsx.js';
12
- import StringField from '../adapter/field/StringField.tsx.js';
13
- import ArrayField from '../adapter/field/ArrayField.tsx.js';
14
- import BooleanField from '../adapter/field/BooleanField.tsx.js';
15
- import CompositionField from '../adapter/field/CompositionField.tsx.js';
16
- import CheckboxWidget from '../adapter/widget/CheckboxWidget.ts.js';
17
- import SelectWidget from '../adapter/widget/SelectWidget.ts.js';
18
- import RadioWidget from '../adapter/widget/RadioWidget.ts.js';
19
- import ButtonWidget from '../adapter/widget/ButtonWidget.ts.js';
20
- import TableWidget from '../adapter/widget/TableWidget.ts.js';
21
- import FieldGroupWrap from '../adapter/common/FieldGroupWrap.tsx.js';
22
- import KeyValueArrayWidget from '../adapter/widget/KeyValueArrayWidget.tsx.js';
23
- import TabGroupWidget from '../adapter/widget/TabGroupWidget.ts.js';
24
- import CollapseGroupWidget from '../adapter/widget/CollapseGroupWidget.ts.js';
25
- import SwitcherWidget from '../adapter/widget/SwitchWidget.ts.js';
26
- import ColorWidget from '../adapter/widget/ColorPickerWidget.ts.js';
27
- import InputWidget from '../adapter/widget/InputWidget.ts.js';
28
- import './form.css';
29
- import { registryGlobalRules, validateForm, validateFormItem, validateFormWithResult, validateSchema, DEFAULT_RULES } from '../core/validator.ts.js';
30
- const defaultOptions = {
31
- namespace: 'bk',
32
- // 包装组件库组件(添加一些属性方便配置)
33
- components: {
34
- button: ButtonWidget,
35
- select: SelectWidget,
36
- radio: RadioWidget,
37
- checkbox: CheckboxWidget,
38
- table: TableWidget,
39
- group: FieldGroupWrap,
40
- bfArray: KeyValueArrayWidget,
41
- tab: TabGroupWidget,
42
- collapse: CollapseGroupWidget,
43
- switcher: SwitcherWidget,
44
- color: ColorWidget,
45
- bfInput: InputWidget
46
- },
47
- fields: {
48
- object: ObjectField,
49
- string: StringField,
50
- any: '',
51
- array: ArrayField,
52
- boolean: BooleanField,
53
- null: '',
54
- integer: NumberField,
55
- number: NumberField,
56
- composition: CompositionField
57
- }
58
- };
59
- export default function createForm(opts = {}) {
60
- const options = mergeDeep(defaultOptions, opts);
61
- const { namespace, components, fields, baseWidgets = {} } = options;
62
- Registry.namespace = namespace;
63
- registry.addComponentsMap(components);
64
- registry.addFieldsMap(fields);
65
- registry.addBaseWidgets(baseWidgets);
66
- return defineComponent({
67
- name: 'BkuiForm',
68
- props,
69
- data () {
70
- return {
71
- rootData: {},
72
- formKey: 'bk-ui-form'
73
- };
74
- },
75
- watch: {
76
- schema (newSchema, oldSchema) {
77
- if (JSON.stringify(newSchema) === JSON.stringify(oldSchema)) return;
78
- this.validateSchema(this.schema);
79
- this.initFormData();
80
- this.formKey = `bk-ui-form-${new Date().getTime()}`;
81
- },
82
- context: {
83
- handler (ctx) {
84
- Registry.context = ctx;
85
- if (hasOwnProperty(ctx, 'rules')) {
86
- registryGlobalRules(ctx.rules);
87
- }
88
- },
89
- immediate: true
90
- },
91
- rules: {
92
- immediate: true,
93
- handler (value) {
94
- registryGlobalRules(value);
95
- }
96
- },
97
- modelValue () {
98
- this.initFormData();
99
- }
100
- },
101
- beforeCreate () {
102
- registryGlobalRules(DEFAULT_RULES);
103
- },
104
- created () {
105
- this.validateSchema(this.schema);
106
- this.initFormData();
107
- },
108
- methods: {
109
- initFormData () {
110
- this.rootData = merge(Schema.getSchemaDefaultValue(createProxy(this.schema, this)) || {}, this.modelValue);
111
- this.emitFormValueChange(this.rootData, this.modelValue);
112
- },
113
- emitFormValueChange (newValue, oldValue) {
114
- if (!deepEquals(newValue, oldValue)) {
115
- this.rootData = newValue;
116
- this.$emit('update:modelValue', newValue);
117
- this.$emit('change', newValue, oldValue);
118
- }
119
- },
120
- validateForm,
121
- validateFormItem,
122
- validate: validateFormWithResult,
123
- validateSchema
124
- },
125
- render () {
126
- const self = this;
127
- return h(registry.getBaseWidget('form'), {
128
- ref: 'bkui-form',
129
- key: this.formKey,
130
- model: this.modelValue,
131
- formType: this.formType,
132
- labelWidth: this.labelWidth,
133
- class: {
134
- 'bk-schema-form': true
135
- },
136
- style: {
137
- width: typeof this.width === 'number' ? `${this.width}px` : this.width
138
- }
139
- }, {
140
- default: ()=>h(SchemaField, Object.assign(Object.assign({}, this.$props), {
141
- schema: createProxy(this.schema, this),
142
- rootData: this.rootData,
143
- modelValue: this.modelValue,
144
- layout: new Layout(this.layout).layout,
145
- 'onUpdate:modelValue': ({ path = '', value })=>{
146
- if (!path) {
147
- // console.warn('set rootData');
148
- self.emitFormValueChange(value, self.modelValue);
149
- } else {
150
- // 双向绑定逻辑
151
- const newValue = Path.setPathValue(self.rootData, path, value);
152
- self.emitFormValueChange(newValue, self.modelValue);
153
- }
154
- }
155
- }), this.$slots)
156
- });
157
- }
158
- });
159
- }
@@ -1,75 +0,0 @@
1
- import request from '../util/fetch.ts.js';
2
- export default {
3
- // 表单值
4
- modelValue: {
5
- type: Object,
6
- default: ()=>({})
7
- },
8
- rules: {
9
- type: Object,
10
- default: ()=>({})
11
- },
12
- schema: {
13
- type: Object,
14
- default: ()=>({})
15
- },
16
- width: {
17
- type: [
18
- String,
19
- Number
20
- ],
21
- default: '100%'
22
- },
23
- // 表单布局
24
- layout: {
25
- type: [
26
- Array,
27
- Object
28
- ],
29
- default: ()=>[]
30
- },
31
- // 表单类型
32
- formType: {
33
- type: String,
34
- default: 'default'
35
- },
36
- // 表单全局上下文
37
- context: {
38
- type: Object,
39
- default: ()=>({})
40
- },
41
- // http请求适配器
42
- httpAdapter: {
43
- type: Object,
44
- default: ()=>({
45
- request,
46
- responseParse: (res)=>res
47
- })
48
- },
49
- readonly: {
50
- type: Boolean,
51
- default: false
52
- },
53
- // 透传 disabled 属性
54
- disabled: {
55
- type: Boolean,
56
- default: false
57
- },
58
- readonlyMode: {
59
- type: String,
60
- default: 'value',
61
- validator: (value)=>[
62
- 'value',
63
- 'custom'
64
- ].includes(value)
65
- },
66
- labelWidth: {
67
- type: Number,
68
- default: 150
69
- },
70
- // 全局配置:是否显示恢复默认值按钮
71
- showResetDefault: {
72
- type: Boolean,
73
- default: false
74
- }
75
- };
@@ -1,74 +0,0 @@
1
- // 事件订阅器
2
- function _define_property(obj, key, value) {
3
- if (key in obj) {
4
- Object.defineProperty(obj, key, {
5
- value: value,
6
- enumerable: true,
7
- configurable: true,
8
- writable: true
9
- });
10
- } else {
11
- obj[key] = value;
12
- }
13
- return obj;
14
- }
15
- export class FormEvent {
16
- on(path, type, cb) {
17
- if (!(path in this.callbacks)) {
18
- this.callbacks[path] = {};
19
- }
20
- if (!(type in this.callbacks[path])) {
21
- this.callbacks[path][type] = [];
22
- }
23
- this.callbacks[path][type].push(cb);
24
- return this;
25
- }
26
- off(path, type, cb) {
27
- if (!(path && type)) {
28
- // 参数全部为空,清空callbacks
29
- this.callbacks = Object.create(null);
30
- } else if (path && !type) {
31
- // 清空当前path所有事件
32
- delete this.callbacks[path];
33
- } else if (path && type && !cb) {
34
- // 清空当前type的所有事件
35
- delete this.callbacks[path][type];
36
- } else {
37
- // 清空对应事件
38
- const events = this.callbacks[path][type];
39
- // eslint-disable-next-line no-restricted-syntax
40
- for(const index in events){
41
- if (cb === events[index]) {
42
- events.splice(Number(index), 1);
43
- }
44
- }
45
- }
46
- return this;
47
- }
48
- once(path, type, cb) {
49
- const _this = this;
50
- function innerOnce(...arg) {
51
- cb(...arg);
52
- _this.off(path, type, innerOnce);
53
- }
54
- innerOnce.fn = cb;
55
- this.on(path, type, innerOnce);
56
- return this;
57
- }
58
- emit(path, type, ...arg) {
59
- if (!this.callbacks[path]) return;
60
- if (type in this.callbacks[path]) {
61
- const runs = [
62
- ...this.callbacks[path][type]
63
- ];
64
- for (const cb of runs){
65
- cb(...arg);
66
- }
67
- }
68
- }
69
- constructor(){
70
- _define_property(this, "callbacks", void 0);
71
- this.callbacks = Object.create(null);
72
- }
73
- }
74
- export default new FormEvent();
@@ -1,67 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */ import { isObj } from '../util/index.ts.js';
2
- import { Registry } from './register.ts.js';
3
- // 组件对外暴露的上下文
4
- export const getContext = (instance)=>{
5
- const { context, loadDataSource, validate, schema, rootData, widgetNode } = instance;
6
- return {
7
- $self: instance,
8
- $context: context,
9
- $schema: schema,
10
- $rules: schema.rules,
11
- $loadDataSource: loadDataSource,
12
- $validate: validate,
13
- $rootData: rootData,
14
- $widgetNode: widgetNode
15
- };
16
- };
17
- export const executeExpression = (expression, instance, $dep = [])=>{
18
- const { $self, $context, $schema, $rules, $loadDataSource, $validate, $rootData, $widgetNode } = getContext(instance);
19
- const context = {
20
- $self,
21
- $context,
22
- $schema,
23
- $rules,
24
- $loadDataSource,
25
- $validate,
26
- $rootData,
27
- $widgetNode,
28
- $dep
29
- };
30
- if (typeof expression === 'string') {
31
- if (!/^{{.+}}$/.test(expression.trim())) return expression; // 没有上下文时直接返回
32
- const expStr = expression.trim().replace(/(^{{)|(}}$)/g, '') // 去掉{{ }}
33
- .trim();
34
- const innerFuncs = [
35
- '$loadDataSource',
36
- '$validate'
37
- ];
38
- const func = function({ $self, $context, $schema, $rules, $loadDataSource, $validate, $rootData, $widgetNode, $dep }) {
39
- try {
40
- // eslint-disable-next-line no-eval
41
- return innerFuncs.includes(expStr) ? eval(`${expStr}()`) : eval(expStr);
42
- } catch (err) {
43
- console.error(`execute ${expStr} error, please check. \n`, err);
44
- }
45
- };
46
- return func(context);
47
- }
48
- if (isObj(expression)) {
49
- Object.keys(expression).forEach((key)=>{
50
- expression[key] = executeExpression(expression[key], instance);
51
- });
52
- return expression;
53
- }
54
- };
55
- // 解析字符串模板(无上下文时使用,只能解析context内容)
56
- export const parseStrTemplate = (expression)=>{
57
- const $context = Registry.context;
58
- const expStr = expression.trim().replace(/(^{{)|(}}$)/g, '').trim();
59
- try {
60
- // eslint-disable-next-line no-new-func
61
- const func = new Function('$context', `return ${expStr}`);
62
- return func($context);
63
- } catch (err) {
64
- console.error(`parse template ${expression} error`, err);
65
- }
66
- };
67
- export const isExpression = (expression)=>typeof expression === 'string' && /{{.*}}/.test(expression);
@@ -1,25 +0,0 @@
1
- import { getCookie } from '../util/index.ts.js';
2
- const messages = {
3
- 'zh-CN': {
4
- add: '添加'
5
- },
6
- 'en-US': {
7
- add: 'Add'
8
- }
9
- };
10
- export default function locale(item) {
11
- var _messages_curLang;
12
- let curLang = getCookie('blueking_language') || 'zh-CN';
13
- if ([
14
- 'en-US',
15
- 'enUS',
16
- 'enus',
17
- 'en-us',
18
- 'en'
19
- ].includes(curLang)) {
20
- curLang = 'en-US';
21
- } else {
22
- curLang = 'zh-CN';
23
- }
24
- return ((_messages_curLang = messages[curLang]) === null || _messages_curLang === void 0 ? void 0 : _messages_curLang[item]) || '';
25
- }