orion-design 0.1.31 → 0.1.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. package/README.md +5 -5
  2. package/dist/Throne/index.js +14 -30
  3. package/dist/Throne/index.js.map +1 -1
  4. package/dist/components/Button/index.js +33 -40
  5. package/dist/components/Button/index.js.map +1 -1
  6. package/dist/components/Flex/index.js +89 -122
  7. package/dist/components/Flex/index.js.map +1 -1
  8. package/dist/components/Form/Form.js +2 -2
  9. package/dist/components/Form/Form.js.map +1 -1
  10. package/dist/components/Form/LovInput/LovInput.js +2 -2
  11. package/dist/components/Form/LovInput/LovInput.js.map +1 -1
  12. package/dist/components/Form/LovInput/hooks/useLov.js +5 -5
  13. package/dist/components/Form/LovInput/hooks/useLov.js.map +1 -1
  14. package/dist/components/Form/LovInput/index.js +4 -4
  15. package/dist/components/Form/hooks/FormItemValidateTrigger.js +2 -2
  16. package/dist/components/Form/hooks/FormItemValidateTrigger.js.map +1 -1
  17. package/dist/components/Form/hooks/index.js +68 -127
  18. package/dist/components/Form/hooks/index.js.map +1 -1
  19. package/dist/components/Form/index.js +656 -836
  20. package/dist/components/Form/index.js.map +1 -1
  21. package/dist/components/Form/utils/index.js +18 -30
  22. package/dist/components/Form/utils/index.js.map +1 -1
  23. package/dist/components/LovTable/LovPagetable.vue.d.ts +492 -0
  24. package/dist/components/LovTable/index.d.ts +246 -0
  25. package/dist/components/LovTable/index.js +106 -179
  26. package/dist/components/LovTable/index.js.map +1 -1
  27. package/dist/components/Modal/index.js +56 -111
  28. package/dist/components/Modal/index.js.map +1 -1
  29. package/dist/components/Modal/types.d.ts +1 -1
  30. package/dist/components/Modal/types.js +3 -4
  31. package/dist/components/Modal/types.js.map +1 -1
  32. package/dist/components/Modal/useModal.js +5 -5
  33. package/dist/components/Modal/useModal.js.map +1 -1
  34. package/dist/components/Pagetable/Pagetable.d.ts +92 -1
  35. package/dist/components/Pagetable/columns/PagetableColumnButtongroup.d.ts +13 -0
  36. package/dist/components/Pagetable/columns/PagetableColumnDate.d.ts +13 -0
  37. package/dist/components/Pagetable/columns/PagetableColumnLink.d.ts +13 -0
  38. package/dist/components/Pagetable/columns/PagetableColumnMultiselect.d.ts +13 -0
  39. package/dist/components/Pagetable/columns/PagetableColumnNumber.d.ts +13 -0
  40. package/dist/components/Pagetable/columns/PagetableColumnSingleselect.d.ts +13 -0
  41. package/dist/components/Pagetable/columns/PagetableColumnString.d.ts +13 -0
  42. package/dist/components/Pagetable/hooks/useColumns.js +85 -88
  43. package/dist/components/Pagetable/hooks/useColumns.js.map +1 -1
  44. package/dist/components/Pagetable/index.d.ts +155 -0
  45. package/dist/components/Pagetable/index.js +596 -683
  46. package/dist/components/Pagetable/index.js.map +1 -1
  47. package/dist/components/Pagetable/utils/index.js +54 -92
  48. package/dist/components/Pagetable/utils/index.js.map +1 -1
  49. package/dist/components/Querytable/hooks/useColumns.js +74 -82
  50. package/dist/components/Querytable/hooks/useColumns.js.map +1 -1
  51. package/dist/components/Querytable/index.js +469 -579
  52. package/dist/components/Querytable/index.js.map +1 -1
  53. package/dist/components/Querytable/utils/index.js +54 -92
  54. package/dist/components/Querytable/utils/index.js.map +1 -1
  55. package/dist/components/RichTextEditor/index.js +74 -100
  56. package/dist/components/RichTextEditor/index.js.map +1 -1
  57. package/dist/components/Tabs/constants.js +2 -2
  58. package/dist/components/Tabs/constants.js.map +1 -1
  59. package/dist/components/Tabs/index.js +358 -603
  60. package/dist/components/Tabs/index.js.map +1 -1
  61. package/dist/components/Tabs/tab-bar.js +6 -6
  62. package/dist/components/Tabs/tab-bar.js.map +1 -1
  63. package/dist/components/Tabs/tab-pane.js +3 -3
  64. package/dist/components/Tabs/tab-pane.js.map +1 -1
  65. package/dist/components/_constants/aria.js +2 -2
  66. package/dist/components/_constants/aria.js.map +1 -1
  67. package/dist/components/_constants/event.js +4 -6
  68. package/dist/components/_constants/event.js.map +1 -1
  69. package/dist/components/_constants/index.js +6 -6
  70. package/dist/components/_hooks/index.js +7 -7
  71. package/dist/components/_hooks/use-namespace/index.js +39 -74
  72. package/dist/components/_hooks/use-namespace/index.js.map +1 -1
  73. package/dist/components/_hooks/use-ordered-children/index.js +19 -29
  74. package/dist/components/_hooks/use-ordered-children/index.js.map +1 -1
  75. package/dist/components/_util/arrays.js +5 -9
  76. package/dist/components/_util/arrays.js.map +1 -1
  77. package/dist/components/_util/browser.js +6 -6
  78. package/dist/components/_util/browser.js.map +1 -1
  79. package/dist/components/_util/classNames.js +17 -22
  80. package/dist/components/_util/classNames.js.map +1 -1
  81. package/dist/components/_util/dom/aria.js +39 -74
  82. package/dist/components/_util/dom/aria.js.map +1 -1
  83. package/dist/components/_util/dom/element.js +8 -9
  84. package/dist/components/_util/dom/element.js.map +1 -1
  85. package/dist/components/_util/dom/event.js +7 -14
  86. package/dist/components/_util/dom/event.js.map +1 -1
  87. package/dist/components/_util/dom/index.js +36 -36
  88. package/dist/components/_util/dom/position.js +25 -49
  89. package/dist/components/_util/dom/position.js.map +1 -1
  90. package/dist/components/_util/dom/scroll.js +61 -103
  91. package/dist/components/_util/dom/scroll.js.map +1 -1
  92. package/dist/components/_util/dom/style.js +50 -65
  93. package/dist/components/_util/dom/style.js.map +1 -1
  94. package/dist/components/_util/easings.js +4 -8
  95. package/dist/components/_util/easings.js.map +1 -1
  96. package/dist/components/_util/error.js +11 -12
  97. package/dist/components/_util/error.js.map +1 -1
  98. package/dist/components/_util/functions.js +3 -3
  99. package/dist/components/_util/i18n.js +2 -2
  100. package/dist/components/_util/i18n.js.map +1 -1
  101. package/dist/components/_util/index.js +137 -137
  102. package/dist/components/_util/isValid.js +2 -4
  103. package/dist/components/_util/isValid.js.map +1 -1
  104. package/dist/components/_util/objects.js +14 -18
  105. package/dist/components/_util/objects.js.map +1 -1
  106. package/dist/components/_util/props-util/index.js +20 -46
  107. package/dist/components/_util/props-util/index.js.map +1 -1
  108. package/dist/components/_util/props-util/initDefaultProps.js +10 -18
  109. package/dist/components/_util/props-util/initDefaultProps.js.map +1 -1
  110. package/dist/components/_util/raf.js +4 -5
  111. package/dist/components/_util/raf.js.map +1 -1
  112. package/dist/components/_util/rand.js +3 -4
  113. package/dist/components/_util/rand.js.map +1 -1
  114. package/dist/components/_util/strings.js +8 -9
  115. package/dist/components/_util/strings.js.map +1 -1
  116. package/dist/components/_util/throttleByRaf.js +10 -16
  117. package/dist/components/_util/throttleByRaf.js.map +1 -1
  118. package/dist/components/_util/type.js +38 -41
  119. package/dist/components/_util/type.js.map +1 -1
  120. package/dist/components/_util/types.js +22 -41
  121. package/dist/components/_util/types.js.map +1 -1
  122. package/dist/components/_util/typescript.js +2 -2
  123. package/dist/components/_util/typescript.js.map +1 -1
  124. package/dist/components/_util/util.js +43 -85
  125. package/dist/components/_util/util.js.map +1 -1
  126. package/dist/components/_util/vue/global-node.js +15 -27
  127. package/dist/components/_util/vue/global-node.js.map +1 -1
  128. package/dist/components/_util/vue/icon.js +25 -29
  129. package/dist/components/_util/vue/icon.js.map +1 -1
  130. package/dist/components/_util/vue/index.js +41 -41
  131. package/dist/components/_util/vue/install.js +18 -35
  132. package/dist/components/_util/vue/install.js.map +1 -1
  133. package/dist/components/_util/vue/props/index.js +6 -6
  134. package/dist/components/_util/vue/props/runtime.js +30 -46
  135. package/dist/components/_util/vue/props/runtime.js.map +1 -1
  136. package/dist/components/_util/vue/refs.js +6 -12
  137. package/dist/components/_util/vue/refs.js.map +1 -1
  138. package/dist/components/_util/vue/size.js +3 -5
  139. package/dist/components/_util/vue/size.js.map +1 -1
  140. package/dist/components/_util/vue/validator.js +4 -5
  141. package/dist/components/_util/vue/validator.js.map +1 -1
  142. package/dist/components/_util/vue/vnode.js +54 -100
  143. package/dist/components/_util/vue/vnode.js.map +1 -1
  144. package/dist/components/_util/vue-types/index.js +220 -231
  145. package/dist/components/_util/vue-types/index.js.map +1 -1
  146. package/dist/components/components.js +20 -20
  147. package/dist/components/index.js +35 -38
  148. package/dist/components/index.js.map +1 -1
  149. package/dist/error/OrionError.js +4 -8
  150. package/dist/error/OrionError.js.map +1 -1
  151. package/dist/index.css +1 -797
  152. package/dist/index.js +36 -36
  153. package/dist/print/LodopFuncs.js +43 -101
  154. package/dist/print/LodopFuncs.js.map +1 -1
  155. package/dist/print/index.js +108 -200
  156. package/dist/print/index.js.map +1 -1
  157. package/dist/request/ErrorHandlerChain.js +14 -17
  158. package/dist/request/ErrorHandlerChain.js.map +1 -1
  159. package/dist/request/RequestFilterChain.js +13 -16
  160. package/dist/request/RequestFilterChain.js.map +1 -1
  161. package/dist/request/ResponseParserChain.js +14 -17
  162. package/dist/request/ResponseParserChain.js.map +1 -1
  163. package/dist/request/disivion/DateSerializer.js +22 -47
  164. package/dist/request/disivion/DateSerializer.js.map +1 -1
  165. package/dist/request/disivion/DivisionErrorHandler.js +25 -40
  166. package/dist/request/disivion/DivisionErrorHandler.js.map +1 -1
  167. package/dist/request/disivion/DivisionResponseParser.js +10 -16
  168. package/dist/request/disivion/DivisionResponseParser.js.map +1 -1
  169. package/dist/request/disivion/index.js +201 -305
  170. package/dist/request/disivion/index.js.map +1 -1
  171. package/dist/request/error/BizExceptionResponseError.js +5 -11
  172. package/dist/request/error/BizExceptionResponseError.js.map +1 -1
  173. package/dist/request/error/ExceptionResponseError.js +5 -11
  174. package/dist/request/error/ExceptionResponseError.js.map +1 -1
  175. package/dist/request/error/ResponseError.js +4 -9
  176. package/dist/request/error/ResponseError.js.map +1 -1
  177. package/dist/request/error/SessionExceptionResponseError.js +5 -11
  178. package/dist/request/error/SessionExceptionResponseError.js.map +1 -1
  179. package/dist/request/index.js +11 -11
  180. package/dist/utils/DateUtil.js +33 -48
  181. package/dist/utils/DateUtil.js.map +1 -1
  182. package/dist/utils/NumberUtil.js +6 -6
  183. package/dist/utils/NumberUtil.js.map +1 -1
  184. package/dist/utils/cloneDeep.js +2 -2
  185. package/dist/utils/delay.js +3 -3
  186. package/dist/utils/delay.js.map +1 -1
  187. package/dist/utils/functions.js +3 -3
  188. package/dist/utils/index.js +12 -12
  189. package/dist/utils/md5.js +93 -191
  190. package/dist/utils/md5.js.map +1 -1
  191. package/dist/utils/uuid.js +25 -35
  192. package/dist/utils/uuid.js.map +1 -1
  193. package/dist/version/index.js +2 -2
  194. package/dist/version/version.d.ts +1 -1
  195. package/dist/version/version.js +2 -2
  196. package/dist/version/version.js.map +1 -1
  197. package/package.json +1 -1
  198. package/dist/_commonjsHelpers-DWwsNxpa.js +0 -9
  199. package/dist/_commonjsHelpers-DWwsNxpa.js.map +0 -1
  200. package/dist/components-B3d9m_tn.js +0 -27
  201. package/dist/components-B3d9m_tn.js.map +0 -1
  202. package/dist/functions-BeMkokbY.js +0 -63
  203. package/dist/functions-BeMkokbY.js.map +0 -1
  204. package/dist/index-BOKLZnqH.js +0 -54
  205. package/dist/index-BOKLZnqH.js.map +0 -1
  206. package/dist/index-D1m0KTpK.js +0 -69
  207. package/dist/index-D1m0KTpK.js.map +0 -1
  208. package/dist/index-DR5ZP7mD.js +0 -160
  209. package/dist/index-DR5ZP7mD.js.map +0 -1
  210. package/dist/index-DkwIULcN.js +0 -200
  211. package/dist/index-DkwIULcN.js.map +0 -1
@@ -1,145 +1,86 @@
1
- import { inject, getCurrentInstance, computed } from "vue";
2
- import { formContextKey } from "../Form.js";
3
- import Throne from "../../../Throne/index.js";
4
- import { castArray, isString, isArray } from "lodash-es";
5
- import OrionError from "../../../error/OrionError.js";
6
- import formItemValidateTrigger from "./FormItemValidateTrigger.js";
7
- const useFormContext = () => {
8
- return inject(formContextKey);
9
- };
10
- const useFormItemSpan = () => {
11
- const formContext = useFormContext();
12
- const { props } = getCurrentInstance();
13
- return computed(() => props.span ? props.span : formContext.itemSpan);
14
- };
15
- const useFormItemRules = () => {
16
- const formContext = useFormContext();
17
- const { props, type } = getCurrentInstance();
18
- const { name, label, required } = props;
19
- let trigger = formItemValidateTrigger[type.name];
20
- if (!trigger) {
21
- trigger = "change";
22
- }
23
- return computed(() => {
24
- const rules = [];
25
- let flag = true;
26
- if (required) {
27
- if (props.rules) {
28
- rules.push(...castArray(props.rules));
29
- flag = !rules.some((rule) => Object.keys(rule).includes("required"));
30
- }
31
- if (formContext.rules && formContext.rules[name]) {
32
- const formRules = castArray(formContext.rules[name]);
33
- flag = !formRules.some((rule) => Object.keys(rule).includes("required"));
34
- }
35
- }
36
- if (flag) {
37
- rules.push({
38
- required: true,
39
- message: `必填项[${label ? label : name}]不能为空`,
40
- trigger
41
- });
42
- }
43
- return rules;
1
+ import { inject as C, getCurrentInstance as s, computed as n } from "vue";
2
+ import { formContextKey as M } from "../Form.js";
3
+ import V from "../../../Throne/index.js";
4
+ import { castArray as p, isString as x, isArray as I } from "lodash-es";
5
+ import f from "../../../error/OrionError.js";
6
+ import F from "./FormItemValidateTrigger.js";
7
+ const u = () => C(M), S = () => {
8
+ const e = u(), { props: r } = s();
9
+ return n(() => r.span ? r.span : e.itemSpan);
10
+ }, O = () => {
11
+ const e = u(), { props: r, type: o } = s(), { name: t, label: l, required: m } = r;
12
+ let a = F[o.name];
13
+ return a || (a = "change"), n(() => {
14
+ const c = [];
15
+ let i = !0;
16
+ return m && (r.rules && (c.push(...p(r.rules)), i = !c.some((d) => Object.keys(d).includes("required"))), e.rules && e.rules[t] && (i = !p(e.rules[t]).some((g) => Object.keys(g).includes("required")))), i && c.push({
17
+ required: !0,
18
+ message: `必填项[${l || t}]不能为空`,
19
+ trigger: a
20
+ }), c;
44
21
  });
45
- };
46
- const useFormItemDisabled = () => {
47
- const formContext = useFormContext();
48
- const { props } = getCurrentInstance();
49
- return computed(() => formContext.disabled || props.disabled);
50
- };
51
- const useFormItemCode = () => {
52
- const { props } = getCurrentInstance();
53
- return computed(() => {
54
- let codeData;
55
- const { code } = props;
56
- if (!code) {
57
- throw new OrionError("code为空");
58
- } else if (isString(code)) {
59
- codeData = Throne.getCode(code).value;
60
- } else if (isArray(code)) {
61
- codeData = code;
62
- } else {
63
- throw new OrionError("code类型错误");
64
- }
65
- return codeData;
22
+ }, R = () => {
23
+ const e = u(), { props: r } = s();
24
+ return n(() => e.disabled || r.disabled);
25
+ }, k = () => {
26
+ const { props: e } = s();
27
+ return n(() => {
28
+ let r;
29
+ const { code: o } = e;
30
+ if (o)
31
+ if (x(o))
32
+ r = V.getCode(o).value;
33
+ else if (I(o))
34
+ r = o;
35
+ else
36
+ throw new f("code类型错误");
37
+ else throw new f("code为空");
38
+ return r;
66
39
  });
67
- };
68
- const useFormItemStringModel = () => {
69
- const formContext = useFormContext();
70
- const { props } = getCurrentInstance();
71
- const { name } = props;
72
- return computed({
40
+ }, w = () => {
41
+ const e = u(), { props: r } = s(), { name: o } = r;
42
+ return n({
73
43
  get: () => {
74
- const value = formContext.modelValue[name];
75
- if (!value) {
76
- return "";
77
- }
78
- return value;
44
+ const t = e.modelValue[o];
45
+ return t || "";
79
46
  },
80
- set: (newValue) => {
81
- if (!newValue) {
82
- formContext.updateModelValue(name, "");
83
- } else {
84
- formContext.updateModelValue(name, newValue);
85
- }
47
+ set: (t) => {
48
+ t ? e.updateModelValue(o, t) : e.updateModelValue(o, "");
86
49
  }
87
50
  });
88
- };
89
- const useFormItemMultiModel = () => {
90
- const formContext = useFormContext();
91
- const { props } = getCurrentInstance();
92
- const { name } = props;
93
- return computed({
51
+ }, A = () => {
52
+ const e = u(), { props: r } = s(), { name: o } = r;
53
+ return n({
94
54
  get: () => {
95
- const value = formContext.modelValue[name];
96
- if (!value) {
97
- return void 0;
98
- }
99
- return value.split(",");
55
+ const t = e.modelValue[o];
56
+ if (t)
57
+ return t.split(",");
100
58
  },
101
- set: (newValue) => {
102
- if (!newValue) {
103
- formContext.updateModelValue(name, "");
104
- } else {
105
- formContext.updateModelValue(name, newValue.join(","));
106
- }
59
+ set: (t) => {
60
+ t ? e.updateModelValue(o, t.join(",")) : e.updateModelValue(o, "");
107
61
  }
108
62
  });
109
- };
110
- const useFormItemBooleanModel = () => {
111
- const formContext = useFormContext();
112
- const { props } = getCurrentInstance();
113
- const { name } = props;
114
- return computed({
63
+ }, D = () => {
64
+ const e = u(), { props: r } = s(), { name: o } = r;
65
+ return n({
115
66
  get: () => {
116
- const value = formContext.modelValue[name];
117
- if (!value) {
118
- return false;
119
- }
120
- return value == "1";
67
+ const t = e.modelValue[o];
68
+ return t ? t == "1" : !1;
121
69
  },
122
- set: (_newValue) => {
123
- const oldValue = formContext.modelValue[name];
124
- const newValue = _newValue ? "1" : "0";
125
- if (oldValue) {
126
- formContext.updateModelValue(name, newValue);
127
- } else {
128
- if (_newValue) {
129
- formContext.updateModelValue(name, newValue);
130
- }
131
- }
70
+ set: (t) => {
71
+ const l = e.modelValue[o], m = t ? "1" : "0";
72
+ (l || t) && e.updateModelValue(o, m);
132
73
  }
133
74
  });
134
75
  };
135
76
  export {
136
- useFormContext,
137
- useFormItemBooleanModel,
138
- useFormItemCode,
139
- useFormItemDisabled,
140
- useFormItemMultiModel,
141
- useFormItemRules,
142
- useFormItemSpan,
143
- useFormItemStringModel
77
+ u as useFormContext,
78
+ D as useFormItemBooleanModel,
79
+ k as useFormItemCode,
80
+ R as useFormItemDisabled,
81
+ A as useFormItemMultiModel,
82
+ O as useFormItemRules,
83
+ S as useFormItemSpan,
84
+ w as useFormItemStringModel
144
85
  };
145
86
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Form/hooks/index.ts"],"sourcesContent":["import { inject, getCurrentInstance, computed } from 'vue'\r\nimport { formContextKey, FormItemRule } from '../Form'\r\nimport Throne from '../../../Throne'\r\nimport { CodeItem } from '../../types'\r\nimport { castArray, isArray, isString } from 'lodash-es'\r\nimport OrionError from '../../../error/OrionError'\r\nimport formItemValidateTrigger from './FormItemValidateTrigger'\r\n\r\nconst useFormContext = () => {\r\n return inject(formContextKey)\r\n}\r\n\r\nconst useFormItemSpan = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n\r\n return computed(() => (props.span ? (props.span as number) : formContext.itemSpan))\r\n}\r\n\r\nconst useFormItemRules = () => {\r\n const formContext = useFormContext()!\r\n const { props, type } = getCurrentInstance()!\r\n const { name, label, required } = props\r\n let trigger = formItemValidateTrigger[type.name!]\r\n if (!trigger) {\r\n trigger = 'change'\r\n }\r\n\r\n return computed(() => {\r\n const rules: FormItemRule[] = []\r\n let flag = true\r\n\r\n if (required) {\r\n if (props.rules) {\r\n rules.push(...castArray(props.rules))\r\n flag = !rules.some((rule) => Object.keys(rule).includes('required'))\r\n }\r\n if (formContext.rules && formContext.rules[name as string]) {\r\n const formRules = castArray(formContext.rules[name as string])\r\n flag = !formRules.some((rule) => Object.keys(rule).includes('required'))\r\n }\r\n }\r\n\r\n if (flag) {\r\n rules.push({\r\n required: true,\r\n message: `必填项[${label ? label : name}]不能为空`,\r\n trigger: trigger,\r\n })\r\n }\r\n\r\n return rules\r\n })\r\n}\r\n\r\nconst useFormItemDisabled = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n return computed(() => formContext.disabled || (props.disabled as boolean))\r\n}\r\n\r\nconst useFormItemCode = () => {\r\n const { props } = getCurrentInstance()!\r\n\r\n return computed(() => {\r\n let codeData: Array<CodeItem>\r\n const { code } = props\r\n if (!code) {\r\n throw new OrionError('code为空')\r\n } else if (isString(code)) {\r\n codeData = Throne.getCode(code).value\r\n } else if (isArray<CodeItem>(code)) {\r\n codeData = code\r\n } else {\r\n throw new OrionError('code类型错误')\r\n }\r\n\r\n return codeData\r\n })\r\n}\r\n\r\nconst useFormItemStringModel = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { name } = props\r\n\r\n return computed<string>({\r\n get: () => {\r\n const value = formContext.modelValue[name as string]\r\n if (!value) {\r\n return ''\r\n }\r\n return value as string\r\n },\r\n set: (newValue) => {\r\n if (!newValue) {\r\n formContext.updateModelValue(name as string, '')\r\n } else {\r\n formContext.updateModelValue(name as string, newValue)\r\n }\r\n },\r\n })\r\n}\r\n\r\nconst useFormItemMultiModel = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { name } = props\r\n\r\n return computed<string[] | undefined>({\r\n get: () => {\r\n const value = formContext.modelValue[name as string]\r\n if (!value) {\r\n return undefined\r\n }\r\n return (value as string).split(',')\r\n },\r\n set: (newValue) => {\r\n if (!newValue) {\r\n formContext.updateModelValue(name as string, '')\r\n } else {\r\n formContext.updateModelValue(name as string, newValue.join(','))\r\n }\r\n },\r\n })\r\n}\r\n\r\nconst useFormItemBooleanModel = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { name } = props\r\n\r\n return computed<boolean>({\r\n get: () => {\r\n const value = formContext.modelValue[name as string]\r\n if (!value) {\r\n return false\r\n }\r\n return (value as string) == '1'\r\n },\r\n set: (_newValue) => {\r\n const oldValue = formContext.modelValue[name as string]\r\n const newValue = _newValue ? '1' : '0'\r\n if (oldValue) {\r\n formContext.updateModelValue(name as string, newValue)\r\n } else {\r\n if (_newValue) {\r\n formContext.updateModelValue(name as string, newValue)\r\n }\r\n }\r\n },\r\n })\r\n}\r\n\r\nexport {\r\n useFormContext,\r\n useFormItemSpan,\r\n useFormItemRules,\r\n useFormItemDisabled,\r\n useFormItemCode,\r\n useFormItemStringModel,\r\n useFormItemMultiModel,\r\n useFormItemBooleanModel,\r\n}\r\n"],"names":[],"mappings":";;;;;;AAQA,MAAM,iBAAiB,MAAM;AAC3B,SAAO,OAAO,cAAc;AAC9B;AAEA,MAAM,kBAAkB,MAAM;AAC5B,QAAM,cAAc;AACd,QAAA,EAAE,UAAU;AAElB,SAAO,SAAS,MAAO,MAAM,OAAQ,MAAM,OAAkB,YAAY,QAAS;AACpF;AAEA,MAAM,mBAAmB,MAAM;AAC7B,QAAM,cAAc;AACpB,QAAM,EAAE,OAAO,KAAK,IAAI,mBAAmB;AAC3C,QAAM,EAAE,MAAM,OAAO,SAAA,IAAa;AAC9B,MAAA,UAAU,wBAAwB,KAAK,IAAK;AAChD,MAAI,CAAC,SAAS;AACF,cAAA;AAAA,EACZ;AAEA,SAAO,SAAS,MAAM;AACpB,UAAM,QAA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AAQ;AAAA,QACvD;AAAA,MACF;AAAA,IACF;AAAA,EAAA,CACD;AACH;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Form/hooks/index.ts"],"sourcesContent":["import { inject, getCurrentInstance, computed } from 'vue'\r\nimport { formContextKey, FormItemRule } from '../Form'\r\nimport Throne from '../../../Throne'\r\nimport { CodeItem } from '../../types'\r\nimport { castArray, isArray, isString } from 'lodash-es'\r\nimport OrionError from '../../../error/OrionError'\r\nimport formItemValidateTrigger from './FormItemValidateTrigger'\r\n\r\nconst useFormContext = () => {\r\n return inject(formContextKey)\r\n}\r\n\r\nconst useFormItemSpan = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n\r\n return computed(() => (props.span ? (props.span as number) : formContext.itemSpan))\r\n}\r\n\r\nconst useFormItemRules = () => {\r\n const formContext = useFormContext()!\r\n const { props, type } = getCurrentInstance()!\r\n const { name, label, required } = props\r\n let trigger = formItemValidateTrigger[type.name!]\r\n if (!trigger) {\r\n trigger = 'change'\r\n }\r\n\r\n return computed(() => {\r\n const rules: FormItemRule[] = []\r\n let flag = true\r\n\r\n if (required) {\r\n if (props.rules) {\r\n rules.push(...castArray(props.rules))\r\n flag = !rules.some((rule) => Object.keys(rule).includes('required'))\r\n }\r\n if (formContext.rules && formContext.rules[name as string]) {\r\n const formRules = castArray(formContext.rules[name as string])\r\n flag = !formRules.some((rule) => Object.keys(rule).includes('required'))\r\n }\r\n }\r\n\r\n if (flag) {\r\n rules.push({\r\n required: true,\r\n message: `必填项[${label ? label : name}]不能为空`,\r\n trigger: trigger,\r\n })\r\n }\r\n\r\n return rules\r\n })\r\n}\r\n\r\nconst useFormItemDisabled = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n return computed(() => formContext.disabled || (props.disabled as boolean))\r\n}\r\n\r\nconst useFormItemCode = () => {\r\n const { props } = getCurrentInstance()!\r\n\r\n return computed(() => {\r\n let codeData: Array<CodeItem>\r\n const { code } = props\r\n if (!code) {\r\n throw new OrionError('code为空')\r\n } else if (isString(code)) {\r\n codeData = Throne.getCode(code).value\r\n } else if (isArray<CodeItem>(code)) {\r\n codeData = code\r\n } else {\r\n throw new OrionError('code类型错误')\r\n }\r\n\r\n return codeData\r\n })\r\n}\r\n\r\nconst useFormItemStringModel = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { name } = props\r\n\r\n return computed<string>({\r\n get: () => {\r\n const value = formContext.modelValue[name as string]\r\n if (!value) {\r\n return ''\r\n }\r\n return value as string\r\n },\r\n set: (newValue) => {\r\n if (!newValue) {\r\n formContext.updateModelValue(name as string, '')\r\n } else {\r\n formContext.updateModelValue(name as string, newValue)\r\n }\r\n },\r\n })\r\n}\r\n\r\nconst useFormItemMultiModel = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { name } = props\r\n\r\n return computed<string[] | undefined>({\r\n get: () => {\r\n const value = formContext.modelValue[name as string]\r\n if (!value) {\r\n return undefined\r\n }\r\n return (value as string).split(',')\r\n },\r\n set: (newValue) => {\r\n if (!newValue) {\r\n formContext.updateModelValue(name as string, '')\r\n } else {\r\n formContext.updateModelValue(name as string, newValue.join(','))\r\n }\r\n },\r\n })\r\n}\r\n\r\nconst useFormItemBooleanModel = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { name } = props\r\n\r\n return computed<boolean>({\r\n get: () => {\r\n const value = formContext.modelValue[name as string]\r\n if (!value) {\r\n return false\r\n }\r\n return (value as string) == '1'\r\n },\r\n set: (_newValue) => {\r\n const oldValue = formContext.modelValue[name as string]\r\n const newValue = _newValue ? '1' : '0'\r\n if (oldValue) {\r\n formContext.updateModelValue(name as string, newValue)\r\n } else {\r\n if (_newValue) {\r\n formContext.updateModelValue(name as string, newValue)\r\n }\r\n }\r\n },\r\n })\r\n}\r\n\r\nexport {\r\n useFormContext,\r\n useFormItemSpan,\r\n useFormItemRules,\r\n useFormItemDisabled,\r\n useFormItemCode,\r\n useFormItemStringModel,\r\n useFormItemMultiModel,\r\n useFormItemBooleanModel,\r\n}\r\n"],"names":["useFormContext","inject","formContextKey","useFormItemSpan","formContext","props","getCurrentInstance","computed","useFormItemRules","type","name","label","required","trigger","formItemValidateTrigger","rules","flag","castArray","rule","useFormItemDisabled","useFormItemCode","codeData","code","isString","Throne","isArray","OrionError","useFormItemStringModel","value","newValue","useFormItemMultiModel","useFormItemBooleanModel","_newValue","oldValue"],"mappings":";;;;;;AAQA,MAAMA,IAAiB,MACdC,EAAOC,CAAc,GAGxBC,IAAkB,MAAM;AAC5B,QAAMC,IAAcJ,KACd,EAAE,OAAAK,MAAUC;AAElB,SAAOC,EAAS,MAAOF,EAAM,OAAQA,EAAM,OAAkBD,EAAY,QAAS;AACpF,GAEMI,IAAmB,MAAM;AAC7B,QAAMJ,IAAcJ,KACd,EAAE,OAAAK,GAAO,MAAAI,EAAK,IAAIH,EAAmB,GACrC,EAAE,MAAAI,GAAM,OAAAC,GAAO,UAAAC,EAAA,IAAaP;AAC9B,MAAAQ,IAAUC,EAAwBL,EAAK,IAAK;AAChD,SAAKI,MACOA,IAAA,WAGLN,EAAS,MAAM;AACpB,UAAMQ,IAAwB,CAAA;AAC9B,QAAIC,IAAO;AAEX,WAAIJ,MACEP,EAAM,UACRU,EAAM,KAAK,GAAGE,EAAUZ,EAAM,KAAK,CAAC,GAC7BW,IAAA,CAACD,EAAM,KAAK,CAACG,MAAS,OAAO,KAAKA,CAAI,EAAE,SAAS,UAAU,CAAC,IAEjEd,EAAY,SAASA,EAAY,MAAMM,CAAc,MAEhDM,IAAA,CADWC,EAAUb,EAAY,MAAMM,CAAc,CAAC,EAC3C,KAAK,CAACQ,MAAS,OAAO,KAAKA,CAAI,EAAE,SAAS,UAAU,CAAC,KAIvEF,KACFD,EAAM,KAAK;AAAA,MACT,UAAU;AAAA,MACV,SAAS,OAAOJ,KAAgBD,CAAI;AAAA,MACpC,SAAAG;AAAA,IAAA,C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