@vunk/form 2.18.2 → 2.19.0

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 (323) hide show
  1. package/components/_plugin-vue_export-helper.cjs +1 -11
  2. package/components/api-tables-select/index.cjs +1 -467
  3. package/components/api-tables-select/index.mjs +56 -413
  4. package/components/api-tables-select/src/ctx.d.ts +152 -172
  5. package/components/api-tables-select/src/index.vue.d.ts +394 -983
  6. package/components/button/index.cjs +1 -112
  7. package/components/button/index.mjs +57 -85
  8. package/components/button/src/ctx.d.ts +28 -113
  9. package/components/button/src/index.vue.d.ts +317 -625
  10. package/components/card-input-collection/index.cjs +1 -370
  11. package/components/card-input-collection/index.mjs +175 -277
  12. package/components/card-input-collection/src/core.vue.d.ts +54 -951
  13. package/components/card-input-collection/src/ctx.d.ts +19 -49
  14. package/components/card-input-collection/src/index.vue.d.ts +46 -110
  15. package/components/cascader/index.cjs +1 -150
  16. package/components/cascader/index.mjs +88 -116
  17. package/components/cascader/src/ctx.d.ts +140 -207
  18. package/components/cascader/src/index.vue.d.ts +315 -522
  19. package/components/cascader/src/use.d.ts +1 -1
  20. package/components/checkbox/index.cjs +1 -152
  21. package/components/checkbox/index.mjs +75 -119
  22. package/components/checkbox/src/ctx.d.ts +46 -69
  23. package/components/checkbox/src/index.vue.d.ts +448 -1016
  24. package/components/cloneDeep.cjs +1 -2106
  25. package/components/color-picker/index.cjs +1 -80
  26. package/components/color-picker/index.mjs +46 -69
  27. package/components/color-picker/src/ctx.d.ts +130 -107
  28. package/components/color-picker/src/index.vue.d.ts +285 -255
  29. package/components/date-picker/index.cjs +1 -119
  30. package/components/date-picker/index.mjs +63 -97
  31. package/components/date-picker/src/ctx.d.ts +123 -206
  32. package/components/date-picker/src/index.vue.d.ts +269 -1358
  33. package/components/date-picker/src/types.d.ts +7 -7
  34. package/components/date-picker-range/index.cjs +1 -177
  35. package/components/date-picker-range/index.mjs +62 -113
  36. package/components/date-picker-range/src/ctx.d.ts +130 -206
  37. package/components/date-picker-range/src/index.vue.d.ts +861 -448
  38. package/components/debounce.cjs +1 -0
  39. package/components/dialog/index.cjs +1 -126
  40. package/components/dialog/index.mjs +65 -99
  41. package/components/dialog/src/ctx.d.ts +17 -108
  42. package/components/dialog/src/index.vue.d.ts +77 -1072
  43. package/components/dialog-input-collection/index.cjs +1 -624
  44. package/components/dialog-input-collection/index.mjs +276 -498
  45. package/components/dialog-input-collection/src/ctx.d.ts +21 -52
  46. package/components/dialog-input-collection/src/dialog-form.vue.d.ts +29 -6371
  47. package/components/dialog-input-collection/src/index.vue.d.ts +65 -7630
  48. package/components/dialog-input-collection/src/layout.vue.d.ts +13 -73
  49. package/components/download-plus/index.cjs +1 -456
  50. package/components/download-plus/index.mjs +215 -358
  51. package/components/download-plus/src/api.d.ts +1 -1
  52. package/components/download-plus/src/ctx.d.ts +21 -52
  53. package/components/download-plus/src/index.vue.d.ts +437 -1177
  54. package/components/editable-text/index.cjs +1 -295
  55. package/components/editable-text/index.mjs +113 -239
  56. package/components/editable-text/src/ctx.d.ts +24 -50
  57. package/components/editable-text/src/index.vue.d.ts +59 -3258
  58. package/components/el-slider/index.cjs +1 -0
  59. package/components/el-slider/index.d.ts +5 -0
  60. package/components/el-slider/index.mjs +475 -0
  61. package/components/el-slider/src/button.d.ts +36 -0
  62. package/components/el-slider/src/button.vue.d.ts +41 -0
  63. package/components/el-slider/src/composables/index.cjs +1 -0
  64. package/components/el-slider/src/composables/index.d.ts +6 -0
  65. package/components/el-slider/src/composables/index.mjs +9 -0
  66. package/components/el-slider/src/composables/use-lifecycle.d.ts +4 -0
  67. package/components/el-slider/src/composables/use-marks.d.ts +7 -0
  68. package/components/el-slider/src/composables/use-slide.d.ts +23 -0
  69. package/components/el-slider/src/composables/use-slider-button.d.ts +18 -0
  70. package/components/el-slider/src/composables/use-stops.d.ts +8 -0
  71. package/components/el-slider/src/composables/use-watch.d.ts +4 -0
  72. package/components/el-slider/src/constants.d.ts +14 -0
  73. package/components/el-slider/src/marker.d.ts +37 -0
  74. package/components/el-slider/src/slider-core.vue.d.ts +218 -0
  75. package/components/el-slider/src/slider.d.ts +174 -0
  76. package/components/esri-input-geojson/index.cjs +2 -1604
  77. package/components/esri-input-geojson/index.mjs +682 -1290
  78. package/components/esri-input-geojson/src/append.vue.d.ts +239 -1099
  79. package/components/esri-input-geojson/src/const.d.ts +1 -1
  80. package/components/esri-input-geojson/src/ctx.d.ts +66 -161
  81. package/components/esri-input-geojson/src/default-view.vue.d.ts +8 -132
  82. package/components/esri-input-geojson/src/index.vue.d.ts +982 -708
  83. package/components/esri-input-geojson/src/types.d.ts +1 -0
  84. package/components/esri-input-geojson/src/viewer.vue.d.ts +53 -282
  85. package/components/fieldset/index.cjs +1 -110
  86. package/components/fieldset/index.mjs +63 -76
  87. package/components/fieldset/src/ctx.d.ts +4 -4
  88. package/components/fieldset/src/index.vue.d.ts +7 -7
  89. package/components/form/index.cjs +1 -248
  90. package/components/form/index.mjs +107 -161
  91. package/components/form/src/ctx.d.ts +15 -64
  92. package/components/form/src/index.vue.d.ts +374 -2431
  93. package/components/form-item/index.cjs +1 -294
  94. package/components/form-item/index.mjs +140 -229
  95. package/components/form-item/src/core.vue.d.ts +32 -1854
  96. package/components/form-item/src/ctx.d.ts +19 -51
  97. package/components/form-item/src/index.vue.d.ts +38 -101
  98. package/components/form-item-renderer/index.cjs +1 -193
  99. package/components/form-item-renderer/index.mjs +103 -162
  100. package/components/form-item-renderer/src/core.vue.d.ts +9 -9
  101. package/components/form-item-renderer/src/ctx.d.ts +3 -3
  102. package/components/form-item-renderer/src/index.vue.d.ts +24 -74
  103. package/components/form-item-renderer-template/index.cjs +1 -47
  104. package/components/form-item-renderer-template/index.mjs +20 -33
  105. package/components/form-item-renderer-template/src/index.vue.d.ts +1 -1
  106. package/components/forms-provider/index.cjs +1 -99
  107. package/components/forms-provider/index.mjs +44 -73
  108. package/components/forms-provider/src/core.d.ts +3 -2
  109. package/components/forms-provider/src/segment.vue.d.ts +8 -8
  110. package/components/forms-provider/src/view.vue.d.ts +14 -4
  111. package/components/index.cjs +1 -399
  112. package/components/index2.cjs +1 -17
  113. package/components/information/index.cjs +1 -65
  114. package/components/information/index.mjs +28 -38
  115. package/components/information/src/ctx.d.ts +2 -2
  116. package/components/information/src/index.vue.d.ts +4 -4
  117. package/components/information-collection/index.cjs +1 -81
  118. package/components/information-collection/index.mjs +44 -48
  119. package/components/information-collection/src/ctx.d.ts +29 -65
  120. package/components/information-collection/src/index.vue.d.ts +64 -136
  121. package/components/information-renderer/index.cjs +1 -16
  122. package/components/information-renderer/index.d.ts +9 -9
  123. package/components/information-renderer/index.mjs +9 -10
  124. package/components/information-tag/index.cjs +1 -101
  125. package/components/information-tag/index.mjs +44 -54
  126. package/components/information-tag/src/ctx.d.ts +6 -21
  127. package/components/information-tag/src/index.vue.d.ts +23 -51
  128. package/components/information-templates-default/index.cjs +1 -101
  129. package/components/information-templates-default/index.mjs +63 -73
  130. package/components/information-templates-default/src/index.vue.d.ts +1 -1
  131. package/components/input/index.cjs +1 -115
  132. package/components/input/index.mjs +60 -83
  133. package/components/input/src/ctx.d.ts +51 -152
  134. package/components/input/src/index.vue.d.ts +392 -951
  135. package/components/input-array/index.cjs +1 -310
  136. package/components/input-array/index.mjs +114 -244
  137. package/components/input-array/src/ctx.d.ts +19 -49
  138. package/components/input-array/src/form-template.vue.d.ts +1 -901
  139. package/components/input-array/src/index.vue.d.ts +43 -730
  140. package/components/input-collection/index.cjs +1 -452
  141. package/components/input-collection/index.mjs +195 -355
  142. package/components/input-collection/src/core.vue.d.ts +64 -1026
  143. package/components/input-collection/src/ctx.d.ts +21 -51
  144. package/components/input-collection/src/index.vue.d.ts +50 -114
  145. package/components/input-file/index.cjs +1 -142
  146. package/components/input-file/index.mjs +68 -100
  147. package/components/input-file/src/ctx.d.ts +8 -29
  148. package/components/input-file/src/index.vue.d.ts +444 -74
  149. package/components/input-file/src/template.vue.d.ts +1 -124
  150. package/components/input-link/index.cjs +1 -167
  151. package/components/input-link/index.mjs +60 -83
  152. package/components/input-link/src/ctx.d.ts +52 -137
  153. package/components/input-link/src/index.vue.d.ts +833 -311
  154. package/components/input-number/index.cjs +1 -119
  155. package/components/input-number/index.mjs +73 -87
  156. package/components/input-number/src/ctx.d.ts +38 -131
  157. package/components/input-number/src/index.vue.d.ts +321 -683
  158. package/components/input-tag/index.cjs +1 -100
  159. package/components/input-tag/index.mjs +51 -78
  160. package/components/input-tag/src/ctx.d.ts +43 -145
  161. package/components/input-tag/src/index.vue.d.ts +324 -778
  162. package/components/isObject.cjs +1 -165
  163. package/components/monaco-editor/index.cjs +1 -83
  164. package/components/monaco-editor/index.mjs +40 -59
  165. package/components/monaco-editor/src/ctx.d.ts +19 -44
  166. package/components/monaco-editor/src/index.vue.d.ts +209 -109
  167. package/components/radio/index.cjs +1 -267
  168. package/components/radio/index.mjs +110 -209
  169. package/components/radio/src/ctx.d.ts +27 -91
  170. package/components/radio/src/index.vue.d.ts +298 -1279
  171. package/components/radio/src/option.vue.d.ts +29 -881
  172. package/components/radio/src/wraper.vue.d.ts +64 -196
  173. package/components/renderer-data/index.cjs +1 -41
  174. package/components/renderer-data/index.mjs +19 -26
  175. package/components/renderer-data/src/ctx.d.ts +1 -1
  176. package/components/renderer-data/src/index.vue.d.ts +2 -2
  177. package/components/select/index.cjs +1 -311
  178. package/components/select/index.mjs +156 -214
  179. package/components/select/src/core.vue.d.ts +638 -1080
  180. package/components/select/src/ctx.d.ts +140 -223
  181. package/components/select/src/index.vue.d.ts +334 -610
  182. package/components/select/src/options.vue.d.ts +1 -1
  183. package/components/slider/index.cjs +1 -88
  184. package/components/slider/index.mjs +41 -70
  185. package/components/slider/src/ctx.d.ts +63 -174
  186. package/components/slider/src/index.vue.d.ts +151 -420
  187. package/components/style.css +1 -0
  188. package/components/switch/index.cjs +1 -88
  189. package/components/switch/index.mjs +37 -69
  190. package/components/switch/src/ctx.d.ts +34 -113
  191. package/components/switch/src/index.vue.d.ts +88 -699
  192. package/components/switch/src/types.d.ts +2 -2
  193. package/components/tables-select/index.cjs +1 -263
  194. package/components/tables-select/index.mjs +102 -172
  195. package/components/tables-select/src/ctx.d.ts +76 -91
  196. package/components/tables-select/src/index.vue.d.ts +228 -4969
  197. package/components/template-instances-provider/index.cjs +1 -31
  198. package/components/template-instances-provider/index.mjs +18 -22
  199. package/components/template-instances-provider/src/index.vue.d.ts +2 -2
  200. package/components/templates-default/index.cjs +1 -235
  201. package/components/templates-default/index.mjs +152 -211
  202. package/components/templates-default/src/ctx.d.ts +5 -3
  203. package/components/templates-default/src/index.vue.d.ts +7298 -157
  204. package/components/templates-element-plus/index.cjs +1 -112
  205. package/components/templates-element-plus/index.mjs +49 -91
  206. package/components/templates-element-plus/src/ctx.d.ts +1 -1
  207. package/components/templates-element-plus/src/index.vue.d.ts +65 -258
  208. package/components/templates-esri/index.cjs +1 -65
  209. package/components/templates-esri/index.mjs +29 -39
  210. package/components/templates-esri/src/ctx.d.ts +1 -1
  211. package/components/templates-esri/src/index.vue.d.ts +1776 -24
  212. package/components/templates-layout/index.cjs +1 -137
  213. package/components/templates-layout/index.mjs +78 -116
  214. package/components/templates-layout/src/ctx.d.ts +1 -1
  215. package/components/templates-layout/src/index.vue.d.ts +79 -411
  216. package/components/templates-variant/index.cjs +1 -70
  217. package/components/templates-variant/index.mjs +33 -43
  218. package/components/templates-variant/src/ctx.d.ts +1 -1
  219. package/components/templates-variant/src/index.vue.d.ts +1238 -24
  220. package/components/time-picker/index.cjs +1 -104
  221. package/components/time-picker/index.mjs +57 -87
  222. package/components/time-picker/src/ctx.d.ts +121 -211
  223. package/components/time-picker/src/index.vue.d.ts +263 -1368
  224. package/components/upload/index.cjs +1 -663
  225. package/components/upload/index.mjs +343 -537
  226. package/components/upload/src/ctx.d.ts +108 -195
  227. package/components/upload/src/file.vue.d.ts +197 -776
  228. package/components/upload/src/index.vue.d.ts +689 -1931
  229. package/components/upload/src/types.d.ts +1 -1
  230. package/components/upload/src/wraper.vue.d.ts +232 -407
  231. package/components/upload-plus/index.cjs +21 -18673
  232. package/components/upload-plus/index.mjs +4598 -18372
  233. package/components/upload-plus/src/api.d.ts +2 -2
  234. package/components/upload-plus/src/ctx.d.ts +24 -51
  235. package/components/upload-plus/src/index.vue.d.ts +51 -1656
  236. package/components/use-watch.cjs +1 -0
  237. package/components/van-cascader/index.cjs +1 -125
  238. package/components/van-cascader/index.mjs +51 -96
  239. package/components/van-cascader/src/ctx.d.ts +135 -203
  240. package/components/van-cascader/src/index.vue.d.ts +312 -985
  241. package/components/var-datetime-picker/index.cjs +1 -333
  242. package/components/var-datetime-picker/index.mjs +175 -254
  243. package/components/var-datetime-picker/src/ctx.d.ts +19 -50
  244. package/components/var-datetime-picker/src/index.vue.d.ts +688 -1115
  245. package/components/vditor/index.cjs +1 -86
  246. package/components/vditor/index.mjs +40 -66
  247. package/components/vditor/src/ctx.d.ts +16 -45
  248. package/components/vditor/src/index.vue.d.ts +195 -120
  249. package/composables/element-plus/index.cjs +1 -23
  250. package/composables/element-plus/index.mjs +14 -18
  251. package/composables/index.cjs +1 -161
  252. package/composables/index.d.ts +1 -0
  253. package/composables/index.mjs +102 -135
  254. package/composables/useForm.d.ts +2 -2
  255. package/composables/useRtl.d.ts +18 -0
  256. package/composables/useSourceManager.d.ts +2 -2
  257. package/composables/useTemplateInstances.d.ts +3 -3
  258. package/index.css +1 -562
  259. package/index.d.ts +0 -3
  260. package/index.esm.js +23 -48
  261. package/locale/index.cjs +1 -102
  262. package/locale/index.mjs +34 -34
  263. package/locale/lang/index.cjs +1 -2
  264. package/locale/lang/index.d.ts +1 -0
  265. package/package.json +14 -85
  266. package/shared/const/index.cjs +1 -59
  267. package/shared/const/index.d.ts +1 -1
  268. package/shared/const/index.mjs +18 -20
  269. package/shared/element-plus/ctx.d.ts +40 -37
  270. package/shared/element-plus/index.cjs +1 -211
  271. package/shared/element-plus/index.mjs +93 -161
  272. package/shared/element-plus/instances.d.ts +207 -321
  273. package/shared/form/index.cjs +1 -33
  274. package/shared/form/index.mjs +23 -25
  275. package/shared/helper/index.cjs +1 -11
  276. package/shared/helper/index.mjs +7 -8
  277. package/shared/index.cjs +1 -8
  278. package/shared/index.mjs +5 -1
  279. package/shared/infer-prop/index.cjs +1 -36
  280. package/shared/infer-prop/index.mjs +22 -28
  281. package/shared/progress-it/index.cjs +1 -42
  282. package/shared/progress-it/index.mjs +15 -31
  283. package/shared/rules/index.cjs +1 -56
  284. package/shared/rules/index.mjs +19 -18
  285. package/shared/types/form/index.cjs +1 -2
  286. package/shared/types/index.cjs +1 -2
  287. package/shared/types/source/index.cjs +1 -2
  288. package/shared/types/source-manager/index.cjs +1 -2
  289. package/shared/upload/index.cjs +1 -774
  290. package/shared/upload/index.mjs +180 -764
  291. package/component.d.ts +0 -3
  292. package/components/_plugin-vue_export-helper.mjs +0 -9
  293. package/components/card-input-collection/index.css +0 -21
  294. package/components/cascader/index.css +0 -9
  295. package/components/checkbox/index.css +0 -30
  296. package/components/cloneDeep.mjs +0 -2104
  297. package/components/date-picker-range/index.css +0 -18
  298. package/components/dialog-input-collection/index.css +0 -21
  299. package/components/download-plus/index.css +0 -68
  300. package/components/editable-text/index.css +0 -9
  301. package/components/esri-input-geojson/index.css +0 -32
  302. package/components/fieldset/index.css +0 -5
  303. package/components/form-item/index.css +0 -35
  304. package/components/index.mjs +0 -378
  305. package/components/index2.mjs +0 -14
  306. package/components/information-tag/index.css +0 -6
  307. package/components/information-templates-default/index.css +0 -16
  308. package/components/input-array/index.css +0 -14
  309. package/components/input-collection/index.css +0 -20
  310. package/components/input-link/index.css +0 -4
  311. package/components/input-number/index.css +0 -13
  312. package/components/isObject.mjs +0 -158
  313. package/components/monaco-editor/index.css +0 -4
  314. package/components/radio/index.css +0 -40
  315. package/components/select/index.css +0 -15
  316. package/components/switch/index.css +0 -10
  317. package/components/tables-select/index.css +0 -3
  318. package/components/templates-layout/index.css +0 -3
  319. package/components/upload/index.css +0 -34
  320. package/components/upload-plus/index.css +0 -84
  321. package/components/van-cascader/index.css +0 -6
  322. package/components/var-datetime-picker/index.css +0 -17
  323. package/defaults.d.ts +0 -5
@@ -1,161 +1 @@
1
- 'use strict';
2
-
3
- var vue = require('vue');
4
- var core = require('@vunk/core');
5
-
6
- const useSourceManager = (source, opts = {}) => {
7
- if (!vue.isRef(source)) {
8
- source = vue.ref(source);
9
- }
10
- const op = {
11
- ...opts,
12
- slotsChildren: ["default"]
13
- };
14
- opts.slotsChildren && op.slotsChildren.push(...opts.slotsChildren);
15
- const manager = vue.computed(() => {
16
- const keyRecord = {};
17
- const propRecord = {};
18
- const idRecord = {};
19
- function intoData(list, k = []) {
20
- list.forEach((item, index) => {
21
- const currentK = [...k, index];
22
- const managerInfo = {
23
- source: item,
24
- key: currentK,
25
- nextKey: [...k, index + 1],
26
- prop: item.prop,
27
- id: item.id
28
- };
29
- keyRecord[currentK.join()] = managerInfo;
30
- if (item.prop) {
31
- propRecord[item.prop] = managerInfo;
32
- }
33
- if (item.id) {
34
- idRecord[item.id] = managerInfo;
35
- }
36
- if (item.templateSlots) {
37
- if (Array.isArray(item.templateSlots)) {
38
- currentK.push("templateSlots");
39
- intoData(item.templateSlots, currentK);
40
- }
41
- op.slotsChildren.forEach((filed) => {
42
- if (Array.isArray(item.templateSlots[filed])) {
43
- currentK.push("templateSlots", filed);
44
- intoData(item.templateSlots[filed], currentK);
45
- }
46
- });
47
- }
48
- });
49
- }
50
- intoData(vue.unref(source));
51
- return {
52
- keyRecord,
53
- propRecord,
54
- idRecord
55
- };
56
- });
57
- const getManagerInfoByProp = (prop) => {
58
- return manager.value.propRecord[prop];
59
- };
60
- const getManagerInfoByKey = (key) => {
61
- return manager.value.keyRecord[key.join()];
62
- };
63
- const getManagerInfoById = (id) => {
64
- return manager.value.idRecord[id];
65
- };
66
- return [
67
- source,
68
- {
69
- manager,
70
- getManagerInfoByProp,
71
- getManagerInfoByKey,
72
- getManagerInfoById
73
- }
74
- ];
75
- };
76
-
77
- const useForm = () => {
78
- return vue.inject("vkfFormVm", null);
79
- };
80
-
81
- const useComputedReadonly = (props) => {
82
- const form = useForm();
83
- const readonly = vue.computed(() => {
84
- return props.readonly ?? form?.props.readonly ?? false;
85
- });
86
- return readonly;
87
- };
88
-
89
- const PARENT_KEY = Symbol("PARENT_KEY");
90
- const useTemplateInstances = () => {
91
- const templateInstances = vue.inject(
92
- "vkTemplateInstances",
93
- null
94
- );
95
- return templateInstances;
96
- };
97
- const useTemplateInstancesContext = () => {
98
- const templateInstances = useTemplateInstances();
99
- const getParent = (ins) => {
100
- return ins?.[PARENT_KEY];
101
- };
102
- const getTemplateInstance = (key) => {
103
- let instance = templateInstances?.[key];
104
- if (instance) return instance;
105
- let parent = getParent(templateInstances);
106
- while (parent) {
107
- instance = parent?.[key];
108
- if (instance) return instance;
109
- parent = getParent(parent);
110
- }
111
- return null;
112
- };
113
- return {
114
- templateInstances,
115
- getTemplateInstance,
116
- getParent
117
- };
118
- };
119
- const initTemplateInstances = () => {
120
- const perent = useTemplateInstances();
121
- const templateInstances = vue.shallowReactive({});
122
- templateInstances[PARENT_KEY] = perent;
123
- vue.provide("vkTemplateInstances", templateInstances);
124
- return templateInstances;
125
- };
126
-
127
- const initRendererData = (props, ctx) => {
128
- const data = vue.computed(() => props.data);
129
- const emitSetData = (e) => {
130
- ctx.emit("setData", {
131
- intoUndefined: core.defaultIntoUndefined,
132
- ...e
133
- });
134
- };
135
- const getDataValue = (key) => {
136
- return core.getValue(data.value, key, core.defaultIntoUndefined, true);
137
- };
138
- const rendererData = {
139
- data,
140
- emitSetData,
141
- getDataValue
142
- };
143
- vue.provide("vkRendererData", rendererData);
144
- return rendererData;
145
- };
146
- const useRendererData = () => {
147
- const rendererData = vue.inject(
148
- "vkRendererData",
149
- {}
150
- );
151
- return rendererData;
152
- };
153
-
154
- exports.initRendererData = initRendererData;
155
- exports.initTemplateInstances = initTemplateInstances;
156
- exports.useComputedReadonly = useComputedReadonly;
157
- exports.useForm = useForm;
158
- exports.useRendererData = useRendererData;
159
- exports.useSourceManager = useSourceManager;
160
- exports.useTemplateInstances = useTemplateInstances;
161
- exports.useTemplateInstancesContext = useTemplateInstancesContext;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),m=require("@vunk/core"),T=(t,n={})=>{a.isRef(t)||(t=a.ref(t));const s={...n,slotsChildren:["default"]};n.slotsChildren&&s.slotsChildren.push(...n.slotsChildren);const e=a.computed(()=>{const u={},g={},I={};function i(S,R=[]){S.forEach((o,h)=>{const d=[...R,h],p={source:o,key:d,nextKey:[...R,h+1],prop:o.prop,id:o.id};u[d.join()]=p,o.prop&&(g[o.prop]=p),o.id&&(I[o.id]=p),o.templateSlots&&(Array.isArray(o.templateSlots)&&(d.push("templateSlots"),i(o.templateSlots,d)),s.slotsChildren.forEach(f=>{Array.isArray(o.templateSlots[f])&&(d.push("templateSlots",f),i(o.templateSlots[f],d))}))})}return i(a.unref(t)),{keyRecord:u,propRecord:g,idRecord:I}});return[t,{manager:e,getManagerInfoByProp:u=>e.value.propRecord[u],getManagerInfoByKey:u=>e.value.keyRecord[u.join()],getManagerInfoById:u=>e.value.idRecord[u]}]},v=()=>a.inject("vkfFormVm",null),C=t=>{const n=v();return a.computed(()=>t.readonly??(n==null?void 0:n.props.readonly)??!1)},M=t=>{const n=a.ref(0),s=a.computed(()=>{n.value;const r=t.value;return r?r.matches(":dir(rtl)")||getComputedStyle(r).direction==="rtl":!1});let e=null;const l=r=>{e==null||e.disconnect(),e=new MutationObserver(()=>{n.value++});let c=r.parentElement;for(;c;)e.observe(c,{attributes:!0,attributeFilter:["dir","style","class"]}),c=c.parentElement};return a.watch(t,r=>{r?l(r):e==null||e.disconnect()},{immediate:!0,flush:"post"}),a.onBeforeUnmount(()=>e==null?void 0:e.disconnect()),s},D=Symbol("PARENT_KEY"),y=()=>a.inject("vkTemplateInstances",null),E=()=>{const t=y(),n=e=>e==null?void 0:e[D];return{templateInstances:t,getTemplateInstance:e=>{let l=t==null?void 0:t[e];if(l)return l;let r=n(t);for(;r;){if(l=r==null?void 0:r[e],l)return l;r=n(r)}return null},getParent:n}},k=()=>{const t=y(),n=a.shallowReactive({});return n[D]=t,a.provide("vkTemplateInstances",n),n},A=(t,n)=>{const s=a.computed(()=>t.data),r={data:s,emitSetData:c=>{n.emit("setData",{intoUndefined:m.defaultIntoUndefined,...c})},getDataValue:c=>m.getValue(s.value,c,m.defaultIntoUndefined,!0)};return a.provide("vkRendererData",r),r},B=()=>a.inject("vkRendererData",{});exports.initRendererData=A;exports.initTemplateInstances=k;exports.useComputedReadonly=C;exports.useForm=v;exports.useRendererData=B;exports.useRtl=M;exports.useSourceManager=T;exports.useTemplateInstances=y;exports.useTemplateInstancesContext=E;
@@ -1,5 +1,6 @@
1
1
  export * from './useSourceManager';
2
2
  export * from './useForm';
3
3
  export * from './useComputedReadonly';
4
+ export * from './useRtl';
4
5
  export * from './useTemplateInstances';
5
6
  export * from './useRendererData';
@@ -1,152 +1,119 @@
1
- import { isRef, ref, computed, unref, inject, shallowReactive, provide } from 'vue';
2
- import { defaultIntoUndefined, getValue } from '@vunk/core';
3
-
4
- const useSourceManager = (source, opts = {}) => {
5
- if (!isRef(source)) {
6
- source = ref(source);
7
- }
8
- const op = {
9
- ...opts,
1
+ import { isRef as E, ref as D, computed as d, unref as M, inject as m, watch as k, onBeforeUnmount as A, shallowReactive as B, provide as v } from "vue";
2
+ import { defaultIntoUndefined as R, getValue as w } from "@vunk/core";
3
+ const j = (t, n = {}) => {
4
+ E(t) || (t = D(t));
5
+ const o = {
6
+ ...n,
10
7
  slotsChildren: ["default"]
11
8
  };
12
- opts.slotsChildren && op.slotsChildren.push(...opts.slotsChildren);
13
- const manager = computed(() => {
14
- const keyRecord = {};
15
- const propRecord = {};
16
- const idRecord = {};
17
- function intoData(list, k = []) {
18
- list.forEach((item, index) => {
19
- const currentK = [...k, index];
20
- const managerInfo = {
21
- source: item,
22
- key: currentK,
23
- nextKey: [...k, index + 1],
24
- prop: item.prop,
25
- id: item.id
9
+ n.slotsChildren && o.slotsChildren.push(...n.slotsChildren);
10
+ const e = d(() => {
11
+ const c = {}, y = {}, g = {};
12
+ function i(C, I = []) {
13
+ C.forEach((a, h) => {
14
+ const u = [...I, h], p = {
15
+ source: a,
16
+ key: u,
17
+ nextKey: [...I, h + 1],
18
+ prop: a.prop,
19
+ id: a.id
26
20
  };
27
- keyRecord[currentK.join()] = managerInfo;
28
- if (item.prop) {
29
- propRecord[item.prop] = managerInfo;
30
- }
31
- if (item.id) {
32
- idRecord[item.id] = managerInfo;
33
- }
34
- if (item.templateSlots) {
35
- if (Array.isArray(item.templateSlots)) {
36
- currentK.push("templateSlots");
37
- intoData(item.templateSlots, currentK);
38
- }
39
- op.slotsChildren.forEach((filed) => {
40
- if (Array.isArray(item.templateSlots[filed])) {
41
- currentK.push("templateSlots", filed);
42
- intoData(item.templateSlots[filed], currentK);
43
- }
44
- });
45
- }
21
+ c[u.join()] = p, a.prop && (y[a.prop] = p), a.id && (g[a.id] = p), a.templateSlots && (Array.isArray(a.templateSlots) && (u.push("templateSlots"), i(a.templateSlots, u)), o.slotsChildren.forEach((f) => {
22
+ Array.isArray(a.templateSlots[f]) && (u.push("templateSlots", f), i(a.templateSlots[f], u));
23
+ }));
46
24
  });
47
25
  }
48
- intoData(unref(source));
49
- return {
50
- keyRecord,
51
- propRecord,
52
- idRecord
26
+ return i(M(t)), {
27
+ keyRecord: c,
28
+ propRecord: y,
29
+ idRecord: g
53
30
  };
54
31
  });
55
- const getManagerInfoByProp = (prop) => {
56
- return manager.value.propRecord[prop];
57
- };
58
- const getManagerInfoByKey = (key) => {
59
- return manager.value.keyRecord[key.join()];
60
- };
61
- const getManagerInfoById = (id) => {
62
- return manager.value.idRecord[id];
63
- };
64
32
  return [
65
- source,
33
+ t,
66
34
  {
67
- manager,
68
- getManagerInfoByProp,
69
- getManagerInfoByKey,
70
- getManagerInfoById
35
+ manager: e,
36
+ getManagerInfoByProp: (c) => e.value.propRecord[c],
37
+ getManagerInfoByKey: (c) => e.value.keyRecord[c.join()],
38
+ getManagerInfoById: (c) => e.value.idRecord[c]
71
39
  }
72
40
  ];
73
- };
74
-
75
- const useForm = () => {
76
- return inject("vkfFormVm", null);
77
- };
78
-
79
- const useComputedReadonly = (props) => {
80
- const form = useForm();
81
- const readonly = computed(() => {
82
- return props.readonly ?? form?.props.readonly ?? false;
41
+ }, K = () => m("vkfFormVm", null), F = (t) => {
42
+ const n = K();
43
+ return d(() => t.readonly ?? (n == null ? void 0 : n.props.readonly) ?? !1);
44
+ }, U = (t) => {
45
+ const n = D(0), o = d(() => {
46
+ n.value;
47
+ const r = t.value;
48
+ return r ? r.matches(":dir(rtl)") || getComputedStyle(r).direction === "rtl" : !1;
83
49
  });
84
- return readonly;
85
- };
86
-
87
- const PARENT_KEY = Symbol("PARENT_KEY");
88
- const useTemplateInstances = () => {
89
- const templateInstances = inject(
90
- "vkTemplateInstances",
91
- null
92
- );
93
- return templateInstances;
94
- };
95
- const useTemplateInstancesContext = () => {
96
- const templateInstances = useTemplateInstances();
97
- const getParent = (ins) => {
98
- return ins?.[PARENT_KEY];
99
- };
100
- const getTemplateInstance = (key) => {
101
- let instance = templateInstances?.[key];
102
- if (instance) return instance;
103
- let parent = getParent(templateInstances);
104
- while (parent) {
105
- instance = parent?.[key];
106
- if (instance) return instance;
107
- parent = getParent(parent);
108
- }
109
- return null;
110
- };
111
- return {
112
- templateInstances,
113
- getTemplateInstance,
114
- getParent
115
- };
116
- };
117
- const initTemplateInstances = () => {
118
- const perent = useTemplateInstances();
119
- const templateInstances = shallowReactive({});
120
- templateInstances[PARENT_KEY] = perent;
121
- provide("vkTemplateInstances", templateInstances);
122
- return templateInstances;
123
- };
124
-
125
- const initRendererData = (props, ctx) => {
126
- const data = computed(() => props.data);
127
- const emitSetData = (e) => {
128
- ctx.emit("setData", {
129
- intoUndefined: defaultIntoUndefined,
130
- ...e
50
+ let e = null;
51
+ const s = (r) => {
52
+ e == null || e.disconnect(), e = new MutationObserver(() => {
53
+ n.value++;
131
54
  });
55
+ let l = r.parentElement;
56
+ for (; l; )
57
+ e.observe(l, {
58
+ attributes: !0,
59
+ attributeFilter: ["dir", "style", "class"]
60
+ }), l = l.parentElement;
132
61
  };
133
- const getDataValue = (key) => {
134
- return getValue(data.value, key, defaultIntoUndefined, true);
62
+ return k(
63
+ t,
64
+ (r) => {
65
+ r ? s(r) : e == null || e.disconnect();
66
+ },
67
+ { immediate: !0, flush: "post" }
68
+ ), A(() => e == null ? void 0 : e.disconnect()), o;
69
+ }, S = Symbol("PARENT_KEY"), T = () => m(
70
+ "vkTemplateInstances",
71
+ null
72
+ ), x = () => {
73
+ const t = T(), n = (e) => e == null ? void 0 : e[S];
74
+ return {
75
+ templateInstances: t,
76
+ getTemplateInstance: (e) => {
77
+ let s = t == null ? void 0 : t[e];
78
+ if (s)
79
+ return s;
80
+ let r = n(t);
81
+ for (; r; ) {
82
+ if (s = r == null ? void 0 : r[e], s)
83
+ return s;
84
+ r = n(r);
85
+ }
86
+ return null;
87
+ },
88
+ getParent: n
135
89
  };
136
- const rendererData = {
137
- data,
138
- emitSetData,
139
- getDataValue
90
+ }, N = () => {
91
+ const t = T(), n = B({});
92
+ return n[S] = t, v("vkTemplateInstances", n), n;
93
+ }, Y = (t, n) => {
94
+ const o = d(() => t.data), r = {
95
+ data: o,
96
+ emitSetData: (l) => {
97
+ n.emit("setData", {
98
+ intoUndefined: R,
99
+ ...l
100
+ });
101
+ },
102
+ getDataValue: (l) => w(o.value, l, R, !0)
140
103
  };
141
- provide("vkRendererData", rendererData);
142
- return rendererData;
143
- };
144
- const useRendererData = () => {
145
- const rendererData = inject(
146
- "vkRendererData",
147
- {}
148
- );
149
- return rendererData;
104
+ return v("vkRendererData", r), r;
105
+ }, _ = () => m(
106
+ "vkRendererData",
107
+ {}
108
+ );
109
+ export {
110
+ Y as initRendererData,
111
+ N as initTemplateInstances,
112
+ F as useComputedReadonly,
113
+ K as useForm,
114
+ _ as useRendererData,
115
+ U as useRtl,
116
+ j as useSourceManager,
117
+ T as useTemplateInstances,
118
+ x as useTemplateInstancesContext
150
119
  };
151
-
152
- export { initRendererData, initTemplateInstances, useComputedReadonly, useForm, useRendererData, useSourceManager, useTemplateInstances, useTemplateInstancesContext };
@@ -1,6 +1,6 @@
1
1
  import { ComponentInternalInstance } from 'vue';
2
2
  import { VkfForm } from '@vunk/form/components/form';
3
3
  import { VueComponentPropsType } from '@vunk/core';
4
- export declare const useForm: () => ComponentInternalInstance & {
4
+ export declare const useForm: () => (ComponentInternalInstance & {
5
5
  props: VueComponentPropsType<typeof VkfForm>;
6
- };
6
+ }) | null;
@@ -0,0 +1,18 @@
1
+ import { type ComputedRef, type Ref } from 'vue';
2
+ /**
3
+ * Detect whether the given element is rendered in an RTL context.
4
+ *
5
+ * The check delegates to the browser's CSS engine via
6
+ * `Element.matches(':dir(rtl)')` — the same code path the selector uses
7
+ * for actual style matching. This means it covers every edge case the
8
+ * browser covers: `dir="auto"` resolved by content sniffing, CSS
9
+ * `direction` overrides via stylesheet, inline `style="..."`, etc.
10
+ *
11
+ * Falls back to `getComputedStyle(el).direction === 'rtl'` for browsers
12
+ * without `:dir()` support (Safari < 16.4).
13
+ *
14
+ * Reactivity: a `MutationObserver` watches `dir` / `style` / `class`
15
+ * changes on every ancestor up to the document root, so flipping
16
+ * `dir="rtl"` on a parent at runtime re-evaluates the result.
17
+ */
18
+ export declare const useRtl: (target: Ref<HTMLElement | null | undefined>) => ComputedRef<boolean>;
@@ -10,6 +10,6 @@ export declare const useSourceManager: <T = FormItemRendererSource>(source: Mayb
10
10
  idRecord: Record<string, ManagerInfo<T>>;
11
11
  }>;
12
12
  readonly getManagerInfoByProp: <I = T>(prop: string) => ManagerInfo<I>;
13
- readonly getManagerInfoByKey: <I = T>(key: (string | number)[]) => ManagerInfo<I>;
14
- readonly getManagerInfoById: <I = T>(id: string) => ManagerInfo<I>;
13
+ readonly getManagerInfoByKey: <I_1 = T>(key: (string | number)[]) => ManagerInfo<I_1>;
14
+ readonly getManagerInfoById: <I_2 = T>(id: string) => ManagerInfo<I_2>;
15
15
  }];
@@ -1,8 +1,8 @@
1
1
  import { TemplateInstances } from '@vunk/form/shared';
2
- export declare const useTemplateInstances: () => TemplateInstances;
2
+ export declare const useTemplateInstances: () => TemplateInstances | null;
3
3
  export declare const useTemplateInstancesContext: () => {
4
- templateInstances: TemplateInstances;
5
- getTemplateInstance: (key: string) => import("vue").ComponentInternalInstance;
4
+ templateInstances: TemplateInstances | null;
5
+ getTemplateInstance: (key: string) => import("vue").ComponentInternalInstance | null;
6
6
  getParent: (ins: TemplateInstances | null) => any;
7
7
  };
8
8
  export declare const initTemplateInstances: () => import("vue").ShallowReactive<TemplateInstances>;