orion-design 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Form/hooks/useForm.d.ts +2 -1
- package/dist/components/Form/hooks/useForm.js +6 -5
- package/dist/components/Form/hooks/useForm.js.map +1 -1
- package/dist/version/version.d.ts +1 -1
- package/dist/version/version.js +1 -1
- package/dist/version/version.js.map +1 -1
- package/package.json +1 -1
@@ -1,9 +1,10 @@
|
|
1
|
+
import { CodeItem } from '../../types';
|
1
2
|
declare const useFormContext: () => import('..').FormContext | undefined;
|
2
3
|
declare const useFormSpan: () => import('vue').ComputedRef<number>;
|
3
4
|
declare const useFormRules: () => import('vue').ComputedRef<import('element-plus').FormItemRule[]>;
|
4
5
|
declare const useFormDisabled: () => import('vue').ComputedRef<boolean>;
|
5
6
|
declare const useFormCode: () => import('vue').ComputedRef<CodeItem[]>;
|
6
7
|
declare const useFormDirectModel: () => import('vue').WritableComputedRef<string, string>;
|
7
|
-
declare const useFormMultiModel: () => import('vue').WritableComputedRef<string[], string[]>;
|
8
|
+
declare const useFormMultiModel: () => import('vue').WritableComputedRef<string[] | undefined, string[] | undefined>;
|
8
9
|
declare const useFormBooleanModel: () => import('vue').WritableComputedRef<boolean, boolean>;
|
9
10
|
export { useFormContext, useFormSpan, useFormRules, useFormDisabled, useFormCode, useFormDirectModel, useFormMultiModel, useFormBooleanModel };
|
@@ -3,10 +3,10 @@ import { formContextKey as C } from "../Form.js";
|
|
3
3
|
import M from "../../../Throne/index.js";
|
4
4
|
import { castArray as p, isString as V, isArray as F } from "lodash-es";
|
5
5
|
import f from "../../../error/OrionError.js";
|
6
|
-
const u = () => x(C),
|
6
|
+
const u = () => x(C), j = () => {
|
7
7
|
const e = u(), { props: r } = s();
|
8
8
|
return n(() => r.span ? r.span : e.itemSpan);
|
9
|
-
},
|
9
|
+
}, q = () => {
|
10
10
|
const e = u(), { props: r, type: t } = s(), { name: o, label: l, required: c } = r;
|
11
11
|
let d = "change";
|
12
12
|
return t.extendOptions && t.extendOptions.trigger && (d = t.extendOptions.trigger), n(() => {
|
@@ -49,7 +49,8 @@ const u = () => x(C), q = () => {
|
|
49
49
|
return n({
|
50
50
|
get: () => {
|
51
51
|
const o = e.modelValue[t];
|
52
|
-
|
52
|
+
if (o)
|
53
|
+
return o.split(",");
|
53
54
|
},
|
54
55
|
set: (o) => {
|
55
56
|
o ? e.updateModelValue(t, o.join(",")) : e.updateModelValue(t, "");
|
@@ -75,7 +76,7 @@ export {
|
|
75
76
|
S as useFormDirectModel,
|
76
77
|
D as useFormDisabled,
|
77
78
|
k as useFormMultiModel,
|
78
|
-
|
79
|
-
|
79
|
+
q as useFormRules,
|
80
|
+
j as useFormSpan
|
80
81
|
};
|
81
82
|
//# sourceMappingURL=useForm.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useForm.js","sources":["../../../../src/components/Form/hooks/useForm.ts"],"sourcesContent":["import { inject, getCurrentInstance, computed } from 'vue'\r\nimport { formContextKey, FormItemRule } from '../Form'\r\nimport Throne
|
1
|
+
{"version":3,"file":"useForm.js","sources":["../../../../src/components/Form/hooks/useForm.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\n\r\nconst useFormContext = () => {\r\n return inject(formContextKey)\r\n}\r\n\r\nconst useFormSpan = () => {\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 useFormRules = () => {\r\n const formContext = useFormContext()!\r\n const { props, type } = getCurrentInstance()!\r\n const { name, label, required } = props\r\n let trigger = 'change'\r\n if (type['extendOptions'] && type['extendOptions']['trigger']) {\r\n trigger = type['extendOptions']['trigger']\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 useFormDisabled = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { disabled } = props\r\n return computed(() => formContext.disabled || (disabled as boolean))\r\n}\r\n\r\nconst useFormCode = () => {\r\n let codeData: Array<CodeItem>\r\n const { props } = getCurrentInstance()!\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 return computed(() => codeData)\r\n}\r\n\r\nconst useFormDirectModel = () => {\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 useFormMultiModel = () => {\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 useFormBooleanModel = () => {\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 { useFormContext, useFormSpan, useFormRules, useFormDisabled, useFormCode, useFormDirectModel, useFormMultiModel, useFormBooleanModel }\r\n"],"names":["useFormContext","inject","formContextKey","useFormSpan","formContext","props","getCurrentInstance","computed","useFormRules","type","name","label","required","trigger","rules","flag","castArray","rule","useFormDisabled","disabled","useFormCode","codeData","code","isString","Throne","isArray","OrionError","useFormDirectModel","value","newValue","useFormMultiModel","useFormBooleanModel","_newValue","oldValue"],"mappings":";;;;;AAOA,MAAMA,IAAiB,MACdC,EAAOC,CAAc,GAGxBC,IAAc,MAAM;AACxB,QAAMC,IAAcJ,KACd,EAAE,OAAAK,MAAUC;AAElB,SAAOC,EAAS,MAAOF,EAAM,OAAQA,EAAM,OAAkBD,EAAY,QAAS;AACpF,GAEMI,IAAe,MAAM;AACzB,QAAMJ,IAAcJ,KACd,EAAE,OAAAK,GAAO,MAAAI,EAAK,IAAIH,EAAmB,GACrC,EAAE,MAAAI,GAAM,OAAAC,GAAO,UAAAC,EAAA,IAAaP;AAClC,MAAIQ,IAAU;AACd,SAAIJ,EAAK,iBAAoBA,EAAK,cAAiB,YACvCI,IAAAJ,EAAK,cAAiB,UAG3BF,EAAS,MAAM;AACpB,UAAMO,IAAwB,CAAA;AAC9B,QA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a;AACjB,MAAKA,IAGSzB,EAAA,iBAAiBM,GAAgBmB,CAAQ,IAFzCzB,EAAA,iBAAiBM,GAAgB,EAAE;AAAA,IAInD;AAAA,EAAA,CACD;AACH,GAEMoB,IAAoB,MAAM;AAC9B,QAAM1B,IAAcJ,KACd,EAAE,OAAAK,MAAUC,KACZ,EAAE,MAAAI,EAAS,IAAAL;AAEjB,SAAOE,EAA+B;AAAA,IACpC,KAAK,MAAM;AACH,YAAAqB,IAAQxB,EAAY,WAAWM,CAAc;AACnD,UAAKkB;AAGG,eAAAA,EAAiB,MAAM,GAAG;AAAA,IACpC;AAAA,IACA,KAAK,CAACC,MAAa;AACjB,MAAKA,IAGHzB,EAAY,iBAAiBM,GAAgBmB,EAAS,KAAK,GAAG,CAAC,IAFnDzB,EAAA,iBAAiBM,GAAgB,EAAE;AAAA,IAInD;AAAA,EAAA,CACD;AACH,GAEMqB,IAAsB,MAAM;AAChC,QAAM3B,IAAcJ,KACd,EAAE,OAAAK,MAAUC,KACZ,EAAE,MAAAI,EAAS,IAAAL;AAEjB,SAAOE,EAAkB;AAAA,IACvB,KAAK,MAAM;AACH,YAAAqB,IAAQxB,EAAY,WAAWM,CAAc;AACnD,aAAKkB,IAGGA,KAAoB,MAFnB;AAAA,IAGX;AAAA,IACA,KAAK,CAACI,MAAc;AACZ,YAAAC,IAAW7B,EAAY,WAAWM,CAAc,GAChDmB,IAAWG,IAAY,MAAM;AACnC,OAAIC,KAGED,MACU5B,EAAA,iBAAiBM,GAAgBmB,CAAQ;AAAA,IAG3D;AAAA,EAAA,CACD;AACH;"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const _default: "0.1.
|
1
|
+
declare const _default: "0.1.9";
|
2
2
|
export default _default;
|
package/dist/version/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../src/version/version.ts"],"sourcesContent":["export default '0.1.
|
1
|
+
{"version":3,"file":"version.js","sources":["../../src/version/version.ts"],"sourcesContent":["export default '0.1.9';"],"names":["version"],"mappings":"AAAA,MAAAA,IAAe;"}
|