orion-design 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Throne/index.d.ts +2 -10
- package/dist/Throne/index.js.map +1 -1
- package/dist/components/Button/Button.vue.d.ts +15 -1
- package/dist/components/Button/ButtonGroup/ButtonGroup.d.ts +4 -0
- package/dist/components/Button/ButtonGroup/ButtonGroup.js +2 -0
- package/dist/components/Button/ButtonGroup/ButtonGroup.js.map +1 -0
- package/dist/components/Button/ButtonGroup/ButtonGroup.vue.d.ts +17 -0
- package/dist/components/Button/ButtonGroup/index.d.ts +1 -0
- package/dist/components/Button/ButtonGroup/index.js +2 -0
- package/dist/components/Button/ButtonGroup/index.js.map +1 -0
- package/dist/components/Button/index.d.ts +20 -1
- package/dist/components/Button/index.js +36 -18
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Form/Checkbox/Checkbox.d.ts +0 -1
- package/dist/components/Form/DiyItem/DiyItem.d.ts +9 -0
- package/dist/components/Form/DiyItem/DiyItem.js +2 -0
- package/dist/components/Form/DiyItem/DiyItem.js.map +1 -0
- package/dist/components/Form/DiyItem/DiyItem.vue.d.ts +17 -0
- package/dist/components/Form/DiyItem/index.d.ts +1 -0
- package/dist/components/Form/DiyItem/index.js +2 -0
- package/dist/components/Form/DiyItem/index.js.map +1 -0
- package/dist/components/Form/FileInput/FileInput.vue.d.ts +1 -1
- package/dist/components/Form/Form.d.ts +1 -0
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/Form/Switch/Switch.d.ts +0 -1
- package/dist/components/Form/hooks/useForm.d.ts +0 -1
- package/dist/components/Form/hooks/useForm.js +28 -28
- package/dist/components/Form/hooks/useForm.js.map +1 -1
- package/dist/components/Form/index.d.ts +3 -0
- package/dist/components/Form/index.js +287 -241
- package/dist/components/Form/index.js.map +1 -1
- package/dist/components/types.d.ts +11 -0
- package/dist/components/types.js +2 -0
- package/dist/components/types.js.map +1 -0
- package/dist/index.css +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 +6 -3
package/dist/Throne/index.d.ts
CHANGED
@@ -1,17 +1,9 @@
|
|
1
1
|
import { Ref } from 'vue';
|
2
|
-
|
3
|
-
value: string;
|
4
|
-
content: string;
|
5
|
-
}
|
6
|
-
export type CascadeSysCodeItem = {
|
7
|
-
value: string;
|
8
|
-
content: string;
|
9
|
-
parent?: string;
|
10
|
-
};
|
2
|
+
import { CodeData } from '../components/types';
|
11
3
|
export interface ThroneType {
|
12
4
|
hasAuth: (authId: string) => boolean | null;
|
13
5
|
getIcon: (iconId: string) => () => unknown;
|
14
|
-
getCode: (codeName: string) => Ref<
|
6
|
+
getCode: (codeName: string) => Ref<CodeData>;
|
15
7
|
impl: (throne: Partial<ThroneType>) => void;
|
16
8
|
}
|
17
9
|
declare const Throne: ThroneType;
|
package/dist/Throne/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Throne/index.ts"],"sourcesContent":["import OrionError from '../error/OrionError'\r\nimport type { Ref } from 'vue'\r\n\r\
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Throne/index.ts"],"sourcesContent":["import OrionError from '../error/OrionError'\r\nimport type { Ref } from 'vue'\r\n\r\nimport type { CodeData } from '../components/types'\r\n\r\nexport interface ThroneType {\r\n hasAuth: (authId: string) => boolean | null\r\n getIcon: (iconId: string) => () => unknown\r\n getCode: (codeName: string) => Ref<CodeData>\r\n impl: (throne: Partial<ThroneType>) => void\r\n}\r\n\r\nlet hasAuth: ThroneType['hasAuth'] = () => {\r\n throw new OrionError(`Throne.hasAuth not configured!`)\r\n}\r\n\r\nlet getIcon: ThroneType['getIcon'] = (iconId) => {\r\n throw new OrionError(`Throne.getIcon not configured!`)\r\n}\r\n\r\nlet getCode: ThroneType['getCode'] = (codeName) => {\r\n throw new OrionError(`Throne.getCode not configured!`)\r\n}\r\n\r\nconst Throne: ThroneType = {\r\n hasAuth: (authId) => {\r\n return hasAuth(authId)\r\n },\r\n getIcon: (iconId) => {\r\n return getIcon(iconId)\r\n },\r\n getCode: (codeName) => {\r\n return getCode(codeName)\r\n },\r\n impl: (throne) => {\r\n if (throne.hasAuth) {\r\n hasAuth = throne.hasAuth\r\n }\r\n\r\n if (throne.getIcon) {\r\n getIcon = throne.getIcon\r\n }\r\n\r\n if (throne.getCode) {\r\n getCode = throne.getCode\r\n }\r\n },\r\n}\r\n\r\nexport default Throne\r\n"],"names":["hasAuth","OrionError","getIcon","iconId","getCode","codeName","Throne","authId","throne"],"mappings":";AAYA,IAAIA,IAAiC,MAAM;AACnC,QAAA,IAAIC,EAAW,gCAAgC;AACvD,GAEIC,IAAiC,CAACC,MAAW;AACzC,QAAA,IAAIF,EAAW,gCAAgC;AACvD,GAEIG,IAAiC,CAACC,MAAa;AAC3C,QAAA,IAAIJ,EAAW,gCAAgC;AACvD;AAEA,MAAMK,IAAqB;AAAA,EACzB,SAAS,CAACC,MACDP,EAAQO,CAAM;AAAA,EAEvB,SAAS,CAACJ,MACDD,EAAQC,CAAM;AAAA,EAEvB,SAAS,CAACE,MACDD,EAAQC,CAAQ;AAAA,EAEzB,MAAM,CAACG,MAAW;AAChB,IAAIA,EAAO,YACTR,IAAUQ,EAAO,UAGfA,EAAO,YACTN,IAAUM,EAAO,UAGfA,EAAO,YACTJ,IAAUI,EAAO;AAAA,EAErB;AACF;"}
|
@@ -1,2 +1,16 @@
|
|
1
|
-
declare
|
1
|
+
declare function __VLS_template(): {
|
2
|
+
slots: {
|
3
|
+
default?(_: {}): any;
|
4
|
+
};
|
5
|
+
refs: {};
|
6
|
+
attrs: Partial<{}>;
|
7
|
+
};
|
8
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
9
|
+
declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
10
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
2
11
|
export default _default;
|
12
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
13
|
+
new (): {
|
14
|
+
$slots: S;
|
15
|
+
};
|
16
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ButtonGroup.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { ButtonGroupProps } from './ButtonGroup';
|
2
|
+
declare function __VLS_template(): {
|
3
|
+
slots: {
|
4
|
+
default?(_: {}): any;
|
5
|
+
};
|
6
|
+
refs: {};
|
7
|
+
attrs: Partial<{}>;
|
8
|
+
};
|
9
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
10
|
+
declare const __VLS_component: import('vue').DefineComponent<ButtonGroupProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ButtonGroupProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
11
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
12
|
+
export default _default;
|
13
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
14
|
+
new (): {
|
15
|
+
$slots: S;
|
16
|
+
};
|
17
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './ButtonGroup';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -1,2 +1,21 @@
|
|
1
|
-
|
1
|
+
import { default as ButtonGroup } from './ButtonGroup/ButtonGroup.vue';
|
2
|
+
declare const _default: import('../_util').SFCWithInstall<{
|
3
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<{}> & Readonly<{}>, {}, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
4
|
+
P: {};
|
5
|
+
B: {};
|
6
|
+
D: {};
|
7
|
+
C: {};
|
8
|
+
M: {};
|
9
|
+
Defaults: {};
|
10
|
+
}, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, {}>;
|
11
|
+
__isFragment?: never;
|
12
|
+
__isTeleport?: never;
|
13
|
+
__isSuspense?: never;
|
14
|
+
} & import('vue').ComponentOptionsBase<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
15
|
+
$slots: {
|
16
|
+
default?(_: {}): any;
|
17
|
+
};
|
18
|
+
})> & {
|
19
|
+
ButtonGroup: typeof ButtonGroup;
|
20
|
+
};
|
2
21
|
export default _default;
|
@@ -1,27 +1,45 @@
|
|
1
1
|
import "lodash-es";
|
2
|
-
import { defineComponent as
|
3
|
-
import { withInstall as
|
4
|
-
import { ElButton as
|
5
|
-
|
2
|
+
import { defineComponent as r, openBlock as n, createBlock as p, unref as u, withCtx as l, renderSlot as a, computed as m, createElementBlock as s, normalizeStyle as i, createVNode as c } from "vue";
|
3
|
+
import { withInstall as f } from "../_util/vue/install.js";
|
4
|
+
import { ElButton as _ } from "element-plus";
|
5
|
+
import { S as d } from "../../index-BbsXWo7C.js";
|
6
|
+
const g = /* @__PURE__ */ r({
|
6
7
|
name: "OButton",
|
7
8
|
__name: "Button",
|
8
9
|
setup(o) {
|
9
|
-
return
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
])),
|
15
|
-
_: 1
|
10
|
+
return (t, e) => (n(), p(u(_), null, {
|
11
|
+
default: l(() => [
|
12
|
+
a(t.$slots, "default")
|
13
|
+
]),
|
14
|
+
_: 3
|
16
15
|
}));
|
17
16
|
}
|
18
|
-
}),
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
}), B = /* @__PURE__ */ r({
|
18
|
+
name: "OButtongroup",
|
19
|
+
__name: "ButtonGroup",
|
20
|
+
props: {
|
21
|
+
gutter: { type: [Boolean, String] },
|
22
|
+
align: { default: "right" }
|
23
|
+
},
|
24
|
+
setup(o) {
|
25
|
+
const t = m(() => ({
|
26
|
+
textAlign: o.align
|
27
|
+
}));
|
28
|
+
return (e, h) => (n(), s("div", {
|
29
|
+
style: i(t.value)
|
30
|
+
}, [
|
31
|
+
c(u(d), { gutter: e.gutter }, {
|
32
|
+
default: l(() => [
|
33
|
+
a(e.$slots, "default")
|
34
|
+
]),
|
35
|
+
_: 3
|
36
|
+
}, 8, ["gutter"])
|
37
|
+
], 4));
|
38
|
+
}
|
39
|
+
}), v = f(g, {
|
40
|
+
ButtonGroup: B
|
41
|
+
});
|
24
42
|
export {
|
25
|
-
|
43
|
+
v as default
|
26
44
|
};
|
27
45
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Button/
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Button/ButtonGroup/ButtonGroup.vue","../../../src/components/Button/index.ts"],"sourcesContent":["<template>\r\n <div :style=\"style\">\r\n <space :gutter=\"gutter\"> <slot></slot> </space>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { computed, CSSProperties } from 'vue'\r\nimport type { ButtonGroupProps } from './ButtonGroup'\r\nimport Space from '../../Space'\r\n\r\ndefineOptions({ name: 'OButtongroup' })\r\n\r\nconst { gutter, align = 'right' } = defineProps<ButtonGroupProps>()\r\nconst style = computed<CSSProperties>(() => {\r\n return {\r\n textAlign: align\r\n }\r\n})\r\n</script>\r\n","import { withInstall } from '../_util'\r\n\r\nimport Button from './Button.vue'\r\nimport ButtonGroup from './ButtonGroup/ButtonGroup.vue'\r\n\r\nexport default withInstall<typeof Button, { ButtonGroup: typeof ButtonGroup }>(Button, {\r\n ButtonGroup\r\n})\r\n"],"names":["style","computed","__props","index","withInstall","Button","ButtonGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAcM,UAAAA,IAAQC,EAAwB,OAC7B;AAAA,MACL,WAAWC;MAEd;;;;;;;;;;;;ICbcC,IAAAC,EAAgEC,GAAQ;AAAA,EAAA,aACrFC;AACF,CAAC;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"DiyItem.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { DiyItemProps } from './DiyItem';
|
2
|
+
declare function __VLS_template(): {
|
3
|
+
slots: {
|
4
|
+
default?(_: {}): any;
|
5
|
+
};
|
6
|
+
refs: {};
|
7
|
+
attrs: Partial<{}>;
|
8
|
+
};
|
9
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
10
|
+
declare const __VLS_component: import('vue').DefineComponent<DiyItemProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<DiyItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
11
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
12
|
+
export default _default;
|
13
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
14
|
+
new (): {
|
15
|
+
$slots: S;
|
16
|
+
};
|
17
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './DiyItem';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -164,7 +164,7 @@ declare const _default: import('vue').DefineComponent<FileInputProps, {}, {}, {}
|
|
164
164
|
$root: import('vue').ComponentPublicInstance | null;
|
165
165
|
$parent: import('vue').ComponentPublicInstance | null;
|
166
166
|
$host: Element | null;
|
167
|
-
$emit: ((event: "input", value: string) => void) & ((event: "clear") => void) & ((event: "focus", evt: FocusEvent) => void) & ((event: "update:modelValue", value: string) => void) & ((event: "
|
167
|
+
$emit: ((event: "input", value: string) => void) & ((event: "clear") => void) & ((event: "focus", evt: FocusEvent) => void) & ((event: "update:modelValue", value: string) => void) & ((event: "change", value: string) => void) & ((event: "blur", evt: FocusEvent) => void) & ((event: "compositionend", evt: CompositionEvent) => void) & ((event: "compositionstart", evt: CompositionEvent) => void) & ((event: "compositionupdate", evt: CompositionEvent) => void) & ((event: "keydown", evt: Event | KeyboardEvent) => void) & ((event: "mouseenter", evt: MouseEvent) => void) & ((event: "mouseleave", evt: MouseEvent) => void);
|
168
168
|
$el: any;
|
169
169
|
$options: import('vue').ComponentOptionsBase<Readonly<import('vue').ExtractPropTypes<{
|
170
170
|
readonly ariaLabel: StringConstructor;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../../src/components/Form/Form.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\r\nimport type { FormRules as ElFormRules, FormItemRule as ElFormItemRule } from 'element-plus'\r\nimport type { Arrayable as ElArrayable } from 'element-plus/es/utils/typescript'\r\n\r\nexport type FormRules = ElFormRules\r\nexport type FormItemRule = ElFormItemRule\r\nexport type Arrayable<T> = ElArrayable<T>\r\n\r\nexport interface FormProps {\r\n rules?: FormRules\r\n itemSpan?: number\r\n itemLabelWidth?: string | number\r\n disabled?: boolean\r\n}\r\n\r\nexport interface FormExpose {\r\n validate: () => Promise<boolean>\r\n}\r\n\r\nexport interface FormContext {\r\n model: Record<string, any>\r\n rules?: FormRules\r\n itemSpan: number\r\n}\r\n\r\nexport const formContextKey: InjectionKey<FormContext> = Symbol('formContextKey')\r\n"],"names":["formContextKey"],"mappings":"
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../../src/components/Form/Form.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\r\nimport type { FormRules as ElFormRules, FormItemRule as ElFormItemRule } from 'element-plus'\r\nimport type { Arrayable as ElArrayable } from 'element-plus/es/utils/typescript'\r\n\r\nexport type FormRules = ElFormRules\r\nexport type FormItemRule = ElFormItemRule\r\nexport type Arrayable<T> = ElArrayable<T>\r\n\r\nexport interface FormProps {\r\n rules?: FormRules\r\n itemSpan?: number\r\n itemLabelWidth?: string | number\r\n disabled?: boolean\r\n}\r\n\r\nexport interface FormExpose {\r\n validate: () => Promise<boolean>\r\n}\r\n\r\nexport interface FormContext {\r\n model: Record<string, any>\r\n rules?: FormRules\r\n itemSpan: number\r\n disabled?: boolean\r\n}\r\n\r\nexport const formContextKey: InjectionKey<FormContext> = Symbol('formContextKey')\r\n"],"names":["formContextKey"],"mappings":"AA0Ba,MAAAA,IAA4C,OAAO,gBAAgB;"}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { CodeItem } from '../../../Throne';
|
2
1
|
declare const useFormContext: () => import('..').FormContext | undefined;
|
3
2
|
declare const useFormSpan: () => import('vue').ComputedRef<number>;
|
4
3
|
declare const useFormRules: () => import('vue').ComputedRef<import('element-plus').FormItemRule[]>;
|
@@ -1,44 +1,44 @@
|
|
1
|
-
import { inject as
|
1
|
+
import { inject as x, getCurrentInstance as s, computed as n } from "vue";
|
2
2
|
import { formContextKey as C } from "../Form.js";
|
3
3
|
import b from "../../../Throne/index.js";
|
4
|
-
import { castArray as
|
5
|
-
import
|
6
|
-
|
7
|
-
const
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
return n(() => {
|
13
|
-
const
|
4
|
+
import { castArray as d, isString as h, isArray as y } from "lodash-es";
|
5
|
+
import f from "../../../error/OrionError.js";
|
6
|
+
const c = () => x(C), R = () => {
|
7
|
+
const e = c(), { props: t } = s();
|
8
|
+
return n(() => t.span ? t.span : e.itemSpan);
|
9
|
+
}, S = () => {
|
10
|
+
const e = c(), { props: t, type: r } = s(), { name: i, label: m, required: a } = t;
|
11
|
+
let p = "change";
|
12
|
+
return r.extendOptions && r.extendOptions.trigger && (p = r.extendOptions.trigger), n(() => {
|
13
|
+
const o = [];
|
14
14
|
let u = !0;
|
15
|
-
return a && (
|
15
|
+
return a && (t.rules && (o.push(...d(t.rules)), u = !o.some((l) => Object.keys(l).includes("required"))), e.rules && e.rules[i] && (u = !d(e.rules[i]).some((g) => Object.keys(g).includes("required")))), u && o.push({
|
16
16
|
required: !0,
|
17
|
-
message: `必填项[${m ||
|
18
|
-
trigger:
|
19
|
-
}),
|
17
|
+
message: `必填项[${m || i}]不能为空`,
|
18
|
+
trigger: p
|
19
|
+
}), o;
|
20
20
|
});
|
21
|
-
}, S = () => {
|
22
|
-
const e = p(y), { props: o } = s(), { disabled: r } = o;
|
23
|
-
return n(() => e.disabled || r);
|
24
21
|
}, k = () => {
|
22
|
+
const e = c(), { props: t } = s(), { disabled: r } = t;
|
23
|
+
return n(() => e.disabled || r);
|
24
|
+
}, A = () => {
|
25
25
|
let e;
|
26
|
-
const { props:
|
26
|
+
const { props: t } = s(), { code: r } = t;
|
27
27
|
if (r)
|
28
|
-
if (
|
28
|
+
if (h(r))
|
29
29
|
e = b.getCode(r).value;
|
30
|
-
else if (
|
30
|
+
else if (y(r))
|
31
31
|
e = r;
|
32
32
|
else
|
33
|
-
throw new
|
34
|
-
else throw new
|
33
|
+
throw new f("code类型错误");
|
34
|
+
else throw new f("code为空");
|
35
35
|
return n(() => e);
|
36
36
|
};
|
37
37
|
export {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
A as useFormCode,
|
39
|
+
c as useFormContext,
|
40
|
+
k as useFormDisabled,
|
41
|
+
S as useFormRules,
|
42
|
+
R as useFormSpan
|
43
43
|
};
|
44
44
|
//# 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, { CodeItem } from '../../../Throne'\r\nimport { castArray, isArray, isString } from 'lodash-es'\r\nimport
|
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, { CodeItem } from '../../../Throne'\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\nexport { useFormContext, useFormSpan, useFormRules, useFormDisabled, useFormCode }\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"],"mappings":";;;;;AAMA,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,QAAIC,IAAO;AAEX,WAAIH,MACEP,EAAM,UACRS,EAAM,KAAK,GAAGE,EAAUX,EAAM,KAAK,CAAC,GAC7BU,IAAA,CAACD,EAAM,KAAK,CAACG,MAAS,OAAO,KAAKA,CAAI,EAAE,SAAS,UAAU,CAAC,IAEjEb,EAAY,SAASA,EAAY,MAAMM,CAAc,MAEhDK,IAAA,CADWC,EAAUZ,EAAY,MAAMM,CAAc,CAAC,EAC3C,KAAK,CAACO,MAAS,OAAO,KAAKA,CAAI,EAAE,SAAS,UAAU,CAAC,KAIvEF,KACFD,EAAM,KAAK;AAAA,MACT,UAAU;AAAA,MACV,SAAS,OAAOH,KAAgBD,CAAI;AAAA,MACpC,SAAAG;AAAA,IAAA,CACD,GAGIC;AAAA,EAAA,CACR;AACH,GAEMI,IAAkB,MAAM;AAC5B,QAAMd,IAAcJ,KACd,EAAE,OAAAK,MAAUC,KACZ,EAAE,UAAAa,EAAa,IAAAd;AACrB,SAAOE,EAAS,MAAMH,EAAY,YAAae,CAAoB;AACrE,GAEMC,IAAc,MAAM;AACpB,MAAAC;AACE,QAAA,EAAE,OAAAhB,MAAUC,KACZ,EAAE,MAAAgB,EAAS,IAAAjB;AACjB,MAAKiB;AAEL,QAAWC,EAASD,CAAI;AACX,MAAAD,IAAAG,EAAO,QAAQF,CAAI,EAAE;AAAA,aACvBG,EAAkBH,CAAI;AACpB,MAAAD,IAAAC;AAAA;AAEL,YAAA,IAAII,EAAW,UAAU;AAAA,MANzB,OAAA,IAAIA,EAAW,QAAQ;AAQxB,SAAAnB,EAAS,MAAMc,CAAQ;AAChC;"}
|
@@ -10,6 +10,7 @@ import { default as Switch } from './Switch/Switch.vue';
|
|
10
10
|
import { default as DateInput } from './DateInput/DateInput.vue';
|
11
11
|
import { default as FileInput } from './FileInput/FileInput.vue';
|
12
12
|
import { default as ButtonGroup } from './ButtonGroup/ButtonGroup.vue';
|
13
|
+
import { default as DiyItem } from './DiyItem/DiyItem.vue';
|
13
14
|
declare const _default: import('../_util').SFCWithInstall<{
|
14
15
|
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
|
15
16
|
modelValue?: Record<string, any>;
|
@@ -284,6 +285,7 @@ declare const _default: import('../_util').SFCWithInstall<{
|
|
284
285
|
DateInput: typeof DateInput;
|
285
286
|
FileInput: typeof FileInput;
|
286
287
|
ButtonGroup: typeof ButtonGroup;
|
288
|
+
DiyItem: typeof DiyItem;
|
287
289
|
};
|
288
290
|
export default _default;
|
289
291
|
export * from './Form';
|
@@ -299,3 +301,4 @@ export * from './Switch';
|
|
299
301
|
export * from './DateInput';
|
300
302
|
export * from './FileInput';
|
301
303
|
export * from './ButtonGroup';
|
304
|
+
export * from './DiyItem';
|