@cicctencent/formily 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/.eslintrc.js +40 -0
  2. package/.prettierrc.js +28 -0
  3. package/.vscode/launch.json +23 -0
  4. package/CHANGELOG.md +8 -0
  5. package/README.md +22 -2
  6. package/babel.config.js +3 -0
  7. package/build/build.js +96 -0
  8. package/build/rollup.config.bundle.js +63 -0
  9. package/build/update.version.js +35 -0
  10. package/dist/index.css +2516 -0
  11. package/dist/index.js +8377 -0
  12. package/dist/schema-field/index.css +2466 -0
  13. package/dist/schema-field/index.js +8213 -0
  14. package/dist/transform/index.js +551 -0
  15. package/dist/validate/index.js +1104 -0
  16. package/dist/vue-form/index.css +2516 -0
  17. package/dist/vue-form/index.js +8359 -0
  18. package/docs/.vuepress/client.ts +15 -0
  19. package/docs/.vuepress/components/code-preview.vue +203 -0
  20. package/docs/.vuepress/components/highlight.ts +53 -0
  21. package/docs/.vuepress/config.ts +39 -0
  22. package/docs/.vuepress/util.ts +7 -0
  23. package/docs/README.md +30 -0
  24. package/docs/components/anyOf.md +26 -0
  25. package/docs/components/array-cards.md +12 -0
  26. package/docs/components/array-collapse.md +12 -0
  27. package/docs/components/array-items.md +12 -0
  28. package/docs/components/array-table.md +12 -0
  29. package/docs/components/array-tabs.md +16 -0
  30. package/docs/components/cascader.md +12 -0
  31. package/docs/components/checkbox.md +12 -0
  32. package/docs/components/event.md +27 -0
  33. package/docs/components/hotArea.md +25 -0
  34. package/docs/components/index.md +4 -0
  35. package/docs/components/input.md +30 -0
  36. package/docs/components/layout-group.md +19 -0
  37. package/docs/components/link.md +22 -0
  38. package/docs/components/oneOf.md +8 -0
  39. package/docs/components/radio.md +12 -0
  40. package/docs/components/rich-editor.md +21 -0
  41. package/docs/components/select.md +34 -0
  42. package/docs/components/space.md +11 -0
  43. package/docs/components/switch.md +20 -0
  44. package/docs/components/text.md +21 -0
  45. package/docs/components/time-picker.md +11 -0
  46. package/docs/components/transfer.md +14 -0
  47. package/docs/components/upload-button.md +28 -0
  48. package/docs/demos/any-of/index.vue +66 -0
  49. package/docs/demos/array-cards/index.vue +105 -0
  50. package/docs/demos/array-collapse/index.vue +155 -0
  51. package/docs/demos/array-items/index.vue +171 -0
  52. package/docs/demos/array-table/index.vue +115 -0
  53. package/docs/demos/array-tabs/index.vue +56 -0
  54. package/docs/demos/cascader/index.vue +297 -0
  55. package/docs/demos/checkbox/index.vue +39 -0
  56. package/docs/demos/event/index.vue +436 -0
  57. package/docs/demos/hotArea/index.vue +240 -0
  58. package/docs/demos/index.vue +36 -0
  59. package/docs/demos/input/index.vue +46 -0
  60. package/docs/demos/layout-group/index.vue +51 -0
  61. package/docs/demos/link/index.vue +32 -0
  62. package/docs/demos/radio/index.vue +36 -0
  63. package/docs/demos/rich-editor/index.vue +22 -0
  64. package/docs/demos/select/index.vue +76 -0
  65. package/docs/demos/space/index.vue +93 -0
  66. package/docs/demos/switch/index.vue +31 -0
  67. package/docs/demos/text/index.vue +38 -0
  68. package/docs/demos/time-picker/index.vue +39 -0
  69. package/docs/demos/transfer/index.vue +26 -0
  70. package/docs/demos/upload-button/index.vue +27 -0
  71. package/docs/demos/x-data/add-button-title.vue +101 -0
  72. package/docs/demos/x-data/send-message.vue +33 -0
  73. package/docs/demos/x-reactions/any-of.vue +40 -0
  74. package/docs/demos/x-reactions/x-reactions.vue +39 -0
  75. package/docs/guide/component-extend.md +23 -0
  76. package/docs/guide/extra-bury-report.md +64 -0
  77. package/docs/guide/schema.md +22 -0
  78. package/docs/guide/x-data.md +41 -0
  79. package/docs/guide/x-reactions.md +20 -0
  80. package/example/.browserslistrc +4 -0
  81. package/example/.eslintrc.js +20 -0
  82. package/example/README.md +24 -0
  83. package/example/index.html +15 -0
  84. package/example/jest.config.js +26 -0
  85. package/example/package.json +50 -0
  86. package/example/public/favicon.ico +0 -0
  87. package/example/public/index.html +17 -0
  88. package/example/src/App.vue +25 -0
  89. package/example/src/assets/logo.png +0 -0
  90. package/example/src/components/HelloWorld.vue +148 -0
  91. package/example/src/components/group/index.vue +16 -0
  92. package/example/src/components/uploadBtn/index.vue +44 -0
  93. package/example/src/components/uploadBtn/upload-icon.svg +6 -0
  94. package/example/src/layout/component/Aside.vue +39 -0
  95. package/example/src/layout/component/Main.vue +9 -0
  96. package/example/src/layout/index.vue +15 -0
  97. package/example/src/main.ts +17 -0
  98. package/example/src/router/index.ts +99 -0
  99. package/example/src/shims-vue.d.ts +6 -0
  100. package/example/src/store/index.ts +9 -0
  101. package/example/src/views/demo/any-of/data.ts +38 -0
  102. package/example/src/views/demo/any-of/index.vue +35 -0
  103. package/example/src/views/demo/array-cards/data.ts +65 -0
  104. package/example/src/views/demo/array-cards/index.vue +33 -0
  105. package/example/src/views/demo/array-items/data.ts +29 -0
  106. package/example/src/views/demo/array-items/index.vue +33 -0
  107. package/example/src/views/demo/cloud-button/data.ts +14 -0
  108. package/example/src/views/demo/cloud-button/index.vue +22 -0
  109. package/example/src/views/demo/color-group/data.ts +15 -0
  110. package/example/src/views/demo/color-group/index.vue +22 -0
  111. package/example/src/views/demo/color-picker/data.ts +21 -0
  112. package/example/src/views/demo/color-picker/index.vue +33 -0
  113. package/example/src/views/demo/datatime/data.ts +62 -0
  114. package/example/src/views/demo/datatime/index.vue +22 -0
  115. package/example/src/views/demo/event/data.ts +184 -0
  116. package/example/src/views/demo/event/index.vue +33 -0
  117. package/example/src/views/demo/hot-area/data.ts +196 -0
  118. package/example/src/views/demo/hot-area/index.vue +33 -0
  119. package/example/src/views/demo/input/data.ts +39 -0
  120. package/example/src/views/demo/input/index.vue +33 -0
  121. package/example/src/views/demo/link/data.ts +23 -0
  122. package/example/src/views/demo/link/index.vue +22 -0
  123. package/example/src/views/demo/one-of/data.ts +139 -0
  124. package/example/src/views/demo/one-of/index.vue +33 -0
  125. package/example/src/views/demo/rich-editor/data.ts +12 -0
  126. package/example/src/views/demo/rich-editor/index.vue +24 -0
  127. package/example/src/views/demo/select/data.ts +38 -0
  128. package/example/src/views/demo/select/index.vue +33 -0
  129. package/example/src/views/demo/upload-button/data1.ts +11 -0
  130. package/example/src/views/demo/upload-button/data2.ts +12 -0
  131. package/example/src/views/demo/upload-button/index.vue +42 -0
  132. package/example/tsconfig.json +32 -0
  133. package/example/vite.config.ts +12 -0
  134. package/jest.config.js +4 -0
  135. package/package.json +92 -4
  136. package/src/components/__builtins__/configs/index.ts +1 -0
  137. package/src/components/__builtins__/index.ts +2 -0
  138. package/src/components/__builtins__/shared/create-context.ts +54 -0
  139. package/src/components/__builtins__/shared/index.ts +7 -0
  140. package/src/components/__builtins__/shared/loading.ts +20 -0
  141. package/src/components/__builtins__/shared/portal.ts +43 -0
  142. package/src/components/__builtins__/shared/resolve-component.ts +22 -0
  143. package/src/components/__builtins__/shared/transform-component.ts +33 -0
  144. package/src/components/__builtins__/shared/types.ts +8 -0
  145. package/src/components/__builtins__/shared/utils.ts +35 -0
  146. package/src/components/__builtins__/styles/common.scss +22 -0
  147. package/src/components/__builtins__/styles/element-plus.scss +1094 -0
  148. package/src/components/any-of/index.ts +20 -0
  149. package/src/components/array-base/index.ts +413 -0
  150. package/src/components/array-base/style.scss +53 -0
  151. package/src/components/array-base/style.ts +2 -0
  152. package/src/components/array-cards/index.ts +253 -0
  153. package/src/components/array-cards/style.scss +33 -0
  154. package/src/components/array-cards/style.ts +7 -0
  155. package/src/components/array-collapse/index.ts +381 -0
  156. package/src/components/array-collapse/style.scss +38 -0
  157. package/src/components/array-collapse/style.ts +10 -0
  158. package/src/components/array-items/index.ts +213 -0
  159. package/src/components/array-items/style.scss +82 -0
  160. package/src/components/array-items/style.ts +4 -0
  161. package/src/components/array-table/index.ts +567 -0
  162. package/src/components/array-table/style.scss +84 -0
  163. package/src/components/array-table/style.ts +11 -0
  164. package/src/components/array-tabs/index.ts +141 -0
  165. package/src/components/array-tabs/style.scss +16 -0
  166. package/src/components/array-tabs/style.ts +5 -0
  167. package/src/components/base/AnyOf/index.ts +155 -0
  168. package/src/components/base/AnyOf/index.vue +111 -0
  169. package/src/components/base/CloudButton/index.ts +46 -0
  170. package/src/components/base/CloudButton/index.vue +128 -0
  171. package/src/components/base/ColorGroup/index.ts +57 -0
  172. package/src/components/base/ColorGroup/index.vue +30 -0
  173. package/src/components/base/ColorPicker/index.ts +45 -0
  174. package/src/components/base/ColorPicker/index.vue +50 -0
  175. package/src/components/base/Container/index.vue +39 -0
  176. package/src/components/base/HotArea/index.ts +698 -0
  177. package/src/components/base/HotArea/index.vue +565 -0
  178. package/src/components/base/HotArea/type.ts +18 -0
  179. package/src/components/base/Input/index.vue +150 -0
  180. package/src/components/base/LayoutGroup/index.vue +40 -0
  181. package/src/components/base/Link/index.vue +43 -0
  182. package/src/components/base/Middleware/index.ts +235 -0
  183. package/src/components/base/Middleware/index.vue +169 -0
  184. package/src/components/base/OneOf/index.ts +105 -0
  185. package/src/components/base/OneOf/index.vue +85 -0
  186. package/src/components/base/RichEditor/index.ts +13 -0
  187. package/src/components/base/RichEditor/index.vue +120 -0
  188. package/src/components/base/RichEditor/options.ts +24 -0
  189. package/src/components/base/Select/index.ts +106 -0
  190. package/src/components/base/Select/index.vue +161 -0
  191. package/src/components/base/Switch/index.vue +42 -0
  192. package/src/components/base/Text/index.vue +47 -0
  193. package/src/components/base/event/index.ts +226 -0
  194. package/src/components/base/event/index.vue +356 -0
  195. package/src/components/cascader/index.ts +48 -0
  196. package/src/components/cascader/style.ts +5 -0
  197. package/src/components/checkbox/index.ts +166 -0
  198. package/src/components/checkbox/style.ts +5 -0
  199. package/src/components/cloud-button/index.ts +21 -0
  200. package/src/components/color-group/index.ts +18 -0
  201. package/src/components/color-picker/index.ts +18 -0
  202. package/src/components/container/index.ts +18 -0
  203. package/src/components/data-time/index.ts +24 -0
  204. package/src/components/date-picker/index.ts +51 -0
  205. package/src/components/date-picker/style.ts +4 -0
  206. package/src/components/editable/index.ts +261 -0
  207. package/src/components/editable/style.scss +55 -0
  208. package/src/components/editable/style.ts +5 -0
  209. package/src/components/el-form-item/index.ts +21 -0
  210. package/src/components/el-form-item/style.ts +3 -0
  211. package/src/components/event/index.ts +16 -0
  212. package/src/components/form/index.ts +94 -0
  213. package/src/components/form/style.scss +0 -0
  214. package/src/components/form/style.ts +3 -0
  215. package/src/components/form-button-group/index.ts +74 -0
  216. package/src/components/form-button-group/style.scss +0 -0
  217. package/src/components/form-button-group/style.ts +4 -0
  218. package/src/components/form-collapse/index.ts +215 -0
  219. package/src/components/form-collapse/style.scss +6 -0
  220. package/src/components/form-collapse/style.ts +4 -0
  221. package/src/components/form-dialog/index.ts +433 -0
  222. package/src/components/form-dialog/style.ts +4 -0
  223. package/src/components/form-drawer/index.ts +424 -0
  224. package/src/components/form-drawer/style.scss +21 -0
  225. package/src/components/form-drawer/style.ts +4 -0
  226. package/src/components/form-grid/index.ts +181 -0
  227. package/src/components/form-grid/style.scss +5 -0
  228. package/src/components/form-grid/style.ts +1 -0
  229. package/src/components/form-item/animation.scss +72 -0
  230. package/src/components/form-item/grid.scss +171 -0
  231. package/src/components/form-item/index.ts +642 -0
  232. package/src/components/form-item/style.scss +521 -0
  233. package/src/components/form-item/style.ts +2 -0
  234. package/src/components/form-item/var.scss +17 -0
  235. package/src/components/form-layout/index.ts +161 -0
  236. package/src/components/form-layout/style.scss +6 -0
  237. package/src/components/form-layout/style.ts +1 -0
  238. package/src/components/form-layout/useResponsiveFormLayout.ts +118 -0
  239. package/src/components/form-step/index.ts +210 -0
  240. package/src/components/form-step/style.ts +2 -0
  241. package/src/components/form-tab/index.ts +172 -0
  242. package/src/components/form-tab/style.scss +6 -0
  243. package/src/components/form-tab/style.ts +4 -0
  244. package/src/components/hot-area/index.ts +20 -0
  245. package/src/components/index.ts +49 -0
  246. package/src/components/input/index.ts +35 -0
  247. package/src/components/input/style.ts +4 -0
  248. package/src/components/input-number/index.ts +36 -0
  249. package/src/components/input-number/style.ts +3 -0
  250. package/src/components/layout-group/index.ts +18 -0
  251. package/src/components/link/index.ts +18 -0
  252. package/src/components/middleware/index.ts +21 -0
  253. package/src/components/one-of/index.ts +20 -0
  254. package/src/components/placeholder-input/index.ts +21 -0
  255. package/src/components/placeholder-input/index.vue +87 -0
  256. package/src/components/preview-text/index.ts +303 -0
  257. package/src/components/preview-text/style.ts +9 -0
  258. package/src/components/radio/index.ts +109 -0
  259. package/src/components/radio/style.ts +3 -0
  260. package/src/components/reset/index.ts +52 -0
  261. package/src/components/reset/style.ts +1 -0
  262. package/src/components/rich-editor/index.ts +18 -0
  263. package/src/components/row/index.ts +20 -0
  264. package/src/components/row/index.vue +53 -0
  265. package/src/components/select/index.ts +19 -0
  266. package/src/components/select/style.ts +5 -0
  267. package/src/components/space/index.ts +98 -0
  268. package/src/components/space/style.scss +24 -0
  269. package/src/components/space/style.ts +1 -0
  270. package/src/components/submit/index.ts +59 -0
  271. package/src/components/submit/style.ts +1 -0
  272. package/src/components/switch/index.ts +9 -0
  273. package/src/components/switch/style.ts +1 -0
  274. package/src/components/text/index.ts +21 -0
  275. package/src/components/time-picker/index.ts +21 -0
  276. package/src/components/time-picker/style.ts +4 -0
  277. package/src/components/transfer/index.ts +12 -0
  278. package/src/components/transfer/style.ts +1 -0
  279. package/src/components/upload/index.ts +136 -0
  280. package/src/components/upload/style.ts +2 -0
  281. package/src/components/upload-button/index.ts +21 -0
  282. package/src/components/upload-button/index.vue +199 -0
  283. package/src/createScemaField.ts +14 -0
  284. package/src/index.ts +41 -0
  285. package/src/schema-field/index.ts +11 -0
  286. package/src/scope.ts +29 -0
  287. package/src/transform/core.ts +404 -0
  288. package/src/transform/index.ts +11 -0
  289. package/src/transform/transform.ts +59 -0
  290. package/src/transform/utils/constant.ts +79 -0
  291. package/src/transform/utils/func.ts +145 -0
  292. package/src/typings/common.ts +37 -0
  293. package/src/typings/vue-shim.d.ts +7 -0
  294. package/src/typings/vue-test-utils.d.ts +11 -0
  295. package/src/utils/anyof_utils.ts +95 -0
  296. package/src/utils/common.ts +15 -0
  297. package/src/validate/index.ts +648 -0
  298. package/src/validate/utils/constant.ts +2 -0
  299. package/src/vue-form/index.ts +18 -0
  300. package/src/vue-form/index.vue +106 -0
  301. package/src/vue-form/useForm.ts +112 -0
  302. package/tests/data/anyof.ts +40 -0
  303. package/tests/data/image.ts +472 -0
  304. package/tests/fixtures/validate.ts +63 -0
  305. package/tests/unit/transform.spec.ts +253 -0
  306. package/tests/unit/utils.spec.ts +10 -0
  307. package/tests/unit/validate.spec.ts +256 -0
  308. package/tsconfig.json +23 -0
@@ -0,0 +1,18 @@
1
+ import { transformComponent } from '../__builtins__';
2
+ import { connect, mapProps } from '@formily/vue';
3
+
4
+ import JtLink from '../base/Link/index.vue';
5
+
6
+ export type LinkProps = typeof JtLink;
7
+
8
+ const TransformLink = transformComponent<LinkProps>(JtLink);
9
+
10
+ export const Link = connect(
11
+ TransformLink,
12
+ mapProps({
13
+ value: 'modelValue',
14
+ readOnly: 'readonly',
15
+ })
16
+ );
17
+
18
+ export default Link;
@@ -0,0 +1,21 @@
1
+ import { transformComponent } from '../__builtins__';
2
+ import { connect, mapProps } from '@formily/vue';
3
+
4
+ import _Middleware from '../base/Middleware/index.vue';
5
+
6
+ export type MiddlewareProps = typeof _Middleware;
7
+
8
+ const TransformMiddleware = transformComponent<MiddlewareProps>(
9
+ _Middleware,
10
+ { change: 'update:modelValue' }
11
+ );
12
+
13
+ export const Middleware = connect(
14
+ TransformMiddleware,
15
+ mapProps({
16
+ value: 'modelValue',
17
+ readOnly: 'readonly',
18
+ })
19
+ );
20
+
21
+ export default Middleware;
@@ -0,0 +1,20 @@
1
+ import { transformComponent } from '../__builtins__';
2
+ import { mapProps, connect } from '@formily/vue';
3
+
4
+ import JtOneOf from '../base/OneOf/index.vue';
5
+
6
+ export type JtOneOfProps = typeof JtOneOf;
7
+
8
+ const TransformJtOneAny = transformComponent<JtOneOfProps>(JtOneOf, {
9
+ change: 'update:modelValue',
10
+ });
11
+
12
+ export const OneOf = connect(
13
+ TransformJtOneAny,
14
+ mapProps({
15
+ value: 'modelValue',
16
+ readOnly: 'readonly',
17
+ })
18
+ );
19
+
20
+ export default OneOf;
@@ -0,0 +1,21 @@
1
+ import { transformComponent } from '../__builtins__';
2
+ import { connect, mapProps } from '@formily/vue';
3
+
4
+ import FormilyPlaceholderInput from './index.vue';
5
+
6
+ export type FormilyPlaceholderInputProps = typeof FormilyPlaceholderInput;
7
+
8
+ const TransformFormilyPlaceholderInput = transformComponent<FormilyPlaceholderInputProps>(
9
+ FormilyPlaceholderInput,
10
+ { change: 'update:modelValue' }
11
+ );
12
+
13
+ export const PlaceholderInput = connect(
14
+ TransformFormilyPlaceholderInput,
15
+ mapProps({
16
+ value: 'modelValue',
17
+ readOnly: 'readonly',
18
+ })
19
+ );
20
+
21
+ export default PlaceholderInput;
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <div>
3
+ <el-input
4
+ :rows="4"
5
+ type="textarea"
6
+ :model-Value="modelValue"
7
+ @blur="handleBlur"
8
+ @input="handleInput"
9
+ ></el-input>
10
+ <div class="placeholder-group">
11
+ <div
12
+ v-for="item in placeholderList"
13
+ :key="item"
14
+ class="placeholder-group--item"
15
+ @click="insertPlaceholder(item)"
16
+ >
17
+ {{ item.text }} {{ item.description }}
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </template>
22
+
23
+ <script lang="ts">
24
+ import { computed, defineComponent, ref } from 'vue';
25
+
26
+ export default defineComponent({
27
+ name: 'PlaceholderInput',
28
+ emits: ['change'],
29
+ props: {
30
+ modelValue: String,
31
+ placeholderList: {
32
+ type: Array,
33
+ default: () => {
34
+ return [];
35
+ },
36
+ },
37
+ },
38
+ setup(props, ctx) {
39
+ // 光标位置
40
+ const cursorPosition = ref<number>(0);
41
+
42
+ // 失焦记录光标位置
43
+ function handleBlur(e) {
44
+ cursorPosition.value = e.target.selectionStart;
45
+ }
46
+
47
+ function handleInput(e) {
48
+ emitValue(e);
49
+ }
50
+
51
+ let time = null;
52
+ function emitValue(value) {
53
+ if (time) clearTimeout(time);
54
+
55
+ time = setTimeout(() => {
56
+ ctx.emit('change', value);
57
+ }, 100);
58
+ }
59
+
60
+ function insertPlaceholder(data) {
61
+ emitValue(
62
+ props.modelValue.slice(0, cursorPosition.value) +
63
+ data.text +
64
+ props.modelValue.slice(cursorPosition.value)
65
+ );
66
+ }
67
+ return { handleBlur, insertPlaceholder, handleInput };
68
+ },
69
+ });
70
+ </script>
71
+
72
+ <style scoped lang="scss">
73
+ .placeholder-group {
74
+ display: flex;
75
+ flex-wrap: wrap;
76
+ &--item {
77
+ border: 1px solid #999;
78
+ padding: 0px 4px;
79
+ border-radius: 4px;
80
+ margin-top: 10px;
81
+ margin-right: 10px;
82
+ font-size: 12px;
83
+ line-height: 24px;
84
+ cursor: pointer;
85
+ }
86
+ }
87
+ </style>
@@ -0,0 +1,303 @@
1
+ import { defineComponent, computed, toRef, Ref, h } from 'vue';
2
+ import {
3
+ createContext,
4
+ resolveComponent,
5
+ useContext,
6
+ composeExport,
7
+ } from '../__builtins__/shared';
8
+ import { Field } from '@formily/core';
9
+ import { observer } from '@formily/reactive-vue';
10
+ import { useField } from '@formily/vue';
11
+ import { isArr, isValid } from '@formily/shared';
12
+ import { stylePrefix } from '../__builtins__/configs';
13
+ import { InputProps } from '../input';
14
+ import type { SelectProps } from '../select';
15
+ import type { CascaderProps } from '../cascader';
16
+ import type { DatePickerProps } from '../date-picker';
17
+ import type { TimePickerProps } from '../time-picker';
18
+ import { Space } from '../space';
19
+ import { ElTag } from '@cicctencent/jtui';
20
+
21
+ const prefixCls = `${stylePrefix}-preview-text`;
22
+ const PlaceholderContext = createContext('N/A');
23
+
24
+ export const usePlaceholder = (value?: Ref<any>) => {
25
+ const placeholderCtx = useContext(PlaceholderContext);
26
+ const placeholder = computed(() => {
27
+ return isValid(value?.value) && value?.value !== ''
28
+ ? value?.value
29
+ : resolveComponent(placeholderCtx.value) || 'N/A';
30
+ });
31
+ return placeholder;
32
+ };
33
+
34
+ const Input = defineComponent({
35
+ name: 'FPreviewTextInput',
36
+ props: ['value'],
37
+ setup(props, { attrs, slots }) {
38
+ const value = toRef(props, 'value');
39
+ const placeholder = usePlaceholder(value);
40
+ return () => {
41
+ return h(
42
+ Space,
43
+ {
44
+ class: [prefixCls],
45
+ style: attrs.style,
46
+ },
47
+ {
48
+ default: () =>
49
+ [
50
+ slots?.prepend?.(),
51
+ slots?.prefix?.(),
52
+ placeholder.value,
53
+ slots?.suffix?.(),
54
+ slots?.append?.(),
55
+ ].filter(child => !!child),
56
+ }
57
+ );
58
+ };
59
+ },
60
+ });
61
+
62
+ const Select = observer(
63
+ defineComponent<SelectProps>({
64
+ name: 'FPreviewTextSelect',
65
+ setup(_props, { attrs }) {
66
+ const fieldRef = useField<Field>();
67
+ const field = fieldRef.value;
68
+ const props = attrs as unknown as SelectProps;
69
+ const dataSource: any[] = field?.dataSource?.length
70
+ ? field.dataSource
71
+ : props?.options?.length
72
+ ? props.options
73
+ : [];
74
+ const placeholder = usePlaceholder();
75
+ const getSelected = () => {
76
+ const value = props.value;
77
+ if (props.multiple) {
78
+ return isArr(value)
79
+ ? value.map(val => ({ label: val, value: val }))
80
+ : [];
81
+ } else {
82
+ return isValid(value) ? [{ label: value, value }] : [];
83
+ }
84
+ };
85
+
86
+ const getLabels = () => {
87
+ const selected = getSelected();
88
+ if (!selected.length) {
89
+ return h(
90
+ ElTag,
91
+ {},
92
+ {
93
+ default: () => placeholder.value,
94
+ }
95
+ );
96
+ }
97
+ return selected.map(({ value, label }, key) => {
98
+ const text =
99
+ dataSource?.find(item => item.value == value)?.label ||
100
+ label;
101
+ return h(
102
+ ElTag,
103
+ {
104
+ key,
105
+ type: 'info',
106
+ effect: 'light',
107
+ },
108
+ {
109
+ default: () => text || placeholder.value,
110
+ }
111
+ );
112
+ });
113
+ };
114
+
115
+ return () => {
116
+ return h(
117
+ Space,
118
+ {
119
+ class: [prefixCls],
120
+ style: attrs.style,
121
+ },
122
+ {
123
+ default: () => getLabels(),
124
+ }
125
+ );
126
+ };
127
+ },
128
+ })
129
+ );
130
+
131
+ const Cascader = observer(
132
+ defineComponent<CascaderProps>({
133
+ name: 'FPreviewTextCascader',
134
+ setup(_props, { attrs }) {
135
+ const fieldRef = useField<Field>();
136
+ const field = fieldRef.value;
137
+ const props = attrs as unknown as CascaderProps;
138
+ const dataSource: any[] = field?.dataSource?.length
139
+ ? field.dataSource
140
+ : props?.options?.length
141
+ ? props.options
142
+ : [];
143
+ const placeholder = usePlaceholder();
144
+ const valueKey = props.props?.value || 'value';
145
+ const labelKey = props.props?.label || 'label';
146
+ const getSelected = () => {
147
+ return isArr(props.value) ? props.value : [];
148
+ };
149
+
150
+ const findLabel: (value: any, dataSource: any) => any = (
151
+ value,
152
+ dataSource
153
+ ) => {
154
+ for (let i = 0; i < dataSource?.length; i++) {
155
+ const item = dataSource[i];
156
+ if (item?.[valueKey] === value) {
157
+ return item?.[labelKey];
158
+ } else {
159
+ const childLabel = findLabel(value, item?.children);
160
+ if (childLabel) return childLabel;
161
+ }
162
+ }
163
+ };
164
+
165
+ const getLabels = () => {
166
+ const selected = getSelected();
167
+ if (!selected?.length) {
168
+ return h(
169
+ ElTag,
170
+ {},
171
+ {
172
+ default: () => placeholder.value,
173
+ }
174
+ );
175
+ }
176
+ return selected.map((value, key) => {
177
+ const text = findLabel(value, dataSource);
178
+ return h(
179
+ ElTag,
180
+ {
181
+ key,
182
+ type: 'info',
183
+ effect: 'light',
184
+ },
185
+ {
186
+ default: () => text || placeholder.value,
187
+ }
188
+ );
189
+ });
190
+ };
191
+
192
+ return () => {
193
+ return h(
194
+ Space,
195
+ {
196
+ class: [prefixCls],
197
+ style: attrs.style,
198
+ },
199
+ {
200
+ default: () => getLabels(),
201
+ }
202
+ );
203
+ };
204
+ },
205
+ })
206
+ );
207
+
208
+ const DatePicker = defineComponent<DatePickerProps>({
209
+ name: 'FPreviewTextDatePicker',
210
+ setup(_props, { attrs }) {
211
+ const props = attrs as unknown as DatePickerProps;
212
+ const placeholder = usePlaceholder();
213
+ const getLabels = () => {
214
+ if (isArr(props.value)) {
215
+ const labels = (props.value as any[]).map(
216
+ (value: string | Date) => value || placeholder.value
217
+ );
218
+
219
+ return labels.join('~');
220
+ } else {
221
+ return props.value || placeholder.value;
222
+ }
223
+ };
224
+
225
+ return () => {
226
+ return h(
227
+ 'div',
228
+ {
229
+ class: [prefixCls],
230
+ style: attrs.style,
231
+ },
232
+ {
233
+ default: () => getLabels(),
234
+ }
235
+ );
236
+ };
237
+ },
238
+ });
239
+
240
+ const TimePicker = defineComponent<TimePickerProps>({
241
+ name: 'FPreviewTextTimePicker',
242
+ setup(_props, { attrs }) {
243
+ const props = attrs as unknown as TimePickerProps;
244
+ // const format = props.pickerOptions?.format || 'HH:mm:ss'
245
+ const placeholder = usePlaceholder();
246
+ const getLabels = () => {
247
+ if (isArr(props.value)) {
248
+ const labels = props.value.map(
249
+ (value: string | Date) => value || placeholder.value
250
+ );
251
+
252
+ return labels.join('~');
253
+ } else {
254
+ return props.value || placeholder.value;
255
+ }
256
+ };
257
+
258
+ return () => {
259
+ return h(
260
+ 'div',
261
+ {
262
+ class: [prefixCls],
263
+ style: attrs.style,
264
+ },
265
+ {
266
+ default: () => getLabels(),
267
+ }
268
+ );
269
+ };
270
+ },
271
+ });
272
+
273
+ const Text = defineComponent<any>({
274
+ name: 'FPreviewText',
275
+ setup(_props, { attrs }) {
276
+ const placeholder = usePlaceholder();
277
+
278
+ return () => {
279
+ return h(
280
+ 'div',
281
+ {
282
+ class: [prefixCls],
283
+ style: attrs.style,
284
+ },
285
+ {
286
+ default: () => placeholder.value,
287
+ }
288
+ );
289
+ };
290
+ },
291
+ });
292
+
293
+ export const PreviewText = composeExport(Text, {
294
+ Input,
295
+ Select,
296
+ Cascader,
297
+ DatePicker,
298
+ TimePicker,
299
+ Placeholder: PlaceholderContext.Provider,
300
+ usePlaceholder,
301
+ }) as any;
302
+
303
+ export default PreviewText;
@@ -0,0 +1,9 @@
1
+ import '@cicctencent/jtui/theme-chalk/src/tag.scss'
2
+
3
+ // 依赖
4
+ import '../input/style'
5
+ import '../select/style'
6
+ import '../cascader/style'
7
+ import '../time-picker/style'
8
+ import '../date-picker/style'
9
+ import '../space/style'
@@ -0,0 +1,109 @@
1
+ import { connect, mapProps, mapReadPretty } from '@formily/vue';
2
+ import { defineComponent, PropType, h } from 'vue';
3
+ import {
4
+ composeExport,
5
+ transformComponent,
6
+ resolveComponent,
7
+ SlotTypes,
8
+ } from '../__builtins__/shared';
9
+ import { PreviewText } from '../preview-text';
10
+
11
+ import { ElRadio, ElRadioGroup, ElRadioButton } from '@cicctencent/jtui';
12
+
13
+ export type ElRadioProps = typeof ElRadio;
14
+ export type RadioGroupProps = typeof ElRadioGroup & {
15
+ value: any;
16
+ options?: (
17
+ | (Omit<ElRadioProps, 'value'> & {
18
+ value: ElRadioProps['label'];
19
+ label: SlotTypes;
20
+ })
21
+ | string
22
+ )[];
23
+ optionType: 'defalt' | 'button';
24
+ };
25
+
26
+ const TransformElRadioGroup = transformComponent(ElRadioGroup, {
27
+ change: 'input',
28
+ });
29
+
30
+ const RadioGroupOption = defineComponent({
31
+ name: 'FRadioGroup',
32
+ props: {
33
+ options: {
34
+ type: Array as PropType<RadioGroupProps['options']>,
35
+ default: () => [],
36
+ },
37
+ optionType: {
38
+ type: String as PropType<RadioGroupProps['optionType']>,
39
+ default: 'default',
40
+ },
41
+ },
42
+ setup(customProps, { attrs, slots }) {
43
+ return () => {
44
+ const options = customProps.options || [];
45
+ const OptionType =
46
+ customProps.optionType === 'button' ? ElRadioButton : ElRadio;
47
+ const children =
48
+ options.length !== 0
49
+ ? {
50
+ default: () =>
51
+ options.map(option => {
52
+ if (typeof option === 'string') {
53
+ return h(
54
+ OptionType,
55
+ { label: option },
56
+ {
57
+ default: () => [
58
+ resolveComponent(
59
+ slots?.option ?? option,
60
+ { option }
61
+ ),
62
+ ],
63
+ }
64
+ );
65
+ } else {
66
+ return h(
67
+ OptionType,
68
+ {
69
+ ...option,
70
+ value: undefined,
71
+ label: option.value,
72
+ },
73
+ {
74
+ default: () => [
75
+ resolveComponent(
76
+ slots?.option ??
77
+ option.label,
78
+ {
79
+ option,
80
+ }
81
+ ),
82
+ ],
83
+ }
84
+ );
85
+ }
86
+ }),
87
+ }
88
+ : slots;
89
+ return h(
90
+ TransformElRadioGroup,
91
+ {
92
+ ...attrs,
93
+ },
94
+ children
95
+ );
96
+ };
97
+ },
98
+ });
99
+
100
+ const RadioGroup = connect(
101
+ RadioGroupOption,
102
+ mapProps({ dataSource: 'options', value: 'modelValue' }),
103
+ mapReadPretty(PreviewText.Select)
104
+ );
105
+ export const Radio = composeExport(ElRadio, {
106
+ Group: RadioGroup,
107
+ });
108
+
109
+ export default Radio;
@@ -0,0 +1,3 @@
1
+ import '@cicctencent/jtui/theme-chalk/src/radio.scss'
2
+ import '@cicctencent/jtui/theme-chalk/src/radio-group.scss'
3
+ import '@cicctencent/jtui/theme-chalk/src/radio-button.scss'
@@ -0,0 +1,52 @@
1
+ import { IFieldResetOptions } from '@formily/core'
2
+ import { h, useParentForm } from '@formily/vue'
3
+ import { observer } from '@formily/reactive-vue'
4
+ import { defineComponent } from 'vue'
5
+
6
+ import type { ElButton as ElButtonProps } from '@cicctencent/jtui'
7
+ import { ElButton } from '@cicctencent/jtui'
8
+
9
+ export type ResetProps = IFieldResetOptions & typeof ElButtonProps
10
+
11
+ export const Reset = observer(
12
+ defineComponent({
13
+ name: 'FReset',
14
+ props: {
15
+ forceClear: {
16
+ type: Boolean,
17
+ default: false,
18
+ },
19
+ validate: {
20
+ type: Boolean,
21
+ default: false,
22
+ },
23
+ },
24
+ setup(props, { attrs, slots }: any) {
25
+ const formRef = useParentForm()
26
+ return () => {
27
+ const form = formRef?.value
28
+ return h(
29
+ ElButton,
30
+ {
31
+ ...attrs,
32
+ onClick: (e: MouseEvent) => {
33
+ if (attrs?.click) {
34
+ if (attrs.click(e) === false) return
35
+ }
36
+ form
37
+ ?.reset('*', {
38
+ forceClear: props.forceClear,
39
+ validate: props.validate,
40
+ })
41
+ .then(attrs.resetValidateSuccess as (e: any) => void)
42
+ .catch(attrs.resetValidateFailed as (e: any) => void)
43
+ },
44
+ },
45
+ slots
46
+ )
47
+ }
48
+ },
49
+ })
50
+ )
51
+
52
+ export default Reset
@@ -0,0 +1 @@
1
+ import '@cicctencent/jtui/theme-chalk/src/button.scss'
@@ -0,0 +1,18 @@
1
+ import { transformComponent } from '../__builtins__';
2
+ import JtRichEditor from '../base/RichEditor/index.vue';
3
+ import { connect, mapProps } from '@formily/vue';
4
+
5
+ export type JtRichEditorProps = typeof JtRichEditor;
6
+
7
+ const TransformJtRichEditor =
8
+ transformComponent<JtRichEditorProps>(JtRichEditor);
9
+
10
+ export const RichEditor = connect(
11
+ TransformJtRichEditor,
12
+ mapProps({
13
+ value: 'modelValue',
14
+ readOnly: 'readonly',
15
+ })
16
+ );
17
+
18
+ export default RichEditor;
@@ -0,0 +1,20 @@
1
+ import { transformComponent } from '../__builtins__';
2
+ import { connect, mapProps } from '@formily/vue';
3
+
4
+ import FormilyRow from './index.vue';
5
+
6
+ export type FormilyRowProps = typeof FormilyRow;
7
+
8
+ const TransformFormilyRow = transformComponent<FormilyRowProps>(FormilyRow, {
9
+ change: 'update:modelValue',
10
+ });
11
+
12
+ export const Row = connect(
13
+ TransformFormilyRow,
14
+ mapProps({
15
+ value: 'modelValue',
16
+ readOnly: 'readonly',
17
+ })
18
+ );
19
+
20
+ export default Row;