@vunk/form 2.19.19 → 2.19.21
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.
- package/components/ai-provider/index.cjs +1 -0
- package/components/ai-provider/index.d.ts +7 -0
- package/components/ai-provider/index.mjs +61 -0
- package/components/ai-provider/src/ctx.d.ts +8 -0
- package/components/ai-provider/src/index.vue.d.ts +23 -0
- package/components/ai-provider/src/types.d.ts +56 -0
- package/components/ai-provider/src/use.d.ts +3 -0
- package/components/api-tables-select/index.cjs +1 -1
- package/components/api-tables-select/index.mjs +1 -1
- package/components/api-tables-select/src/ctx.d.ts +57 -57
- package/components/api-tables-select/src/index.vue.d.ts +46 -419
- package/components/button/index.cjs +1 -1
- package/components/button/index.mjs +12 -12
- package/components/button/src/ctx.d.ts +7 -2
- package/components/button/src/index.vue.d.ts +36 -14
- package/components/card-input-collection/index.cjs +1 -1
- package/components/card-input-collection/index.mjs +136 -141
- package/components/card-input-collection/src/core.vue.d.ts +18 -7
- package/components/card-input-collection/src/ctx.d.ts +7 -2
- package/components/card-input-collection/src/index.vue.d.ts +18 -7
- package/components/cascader/index.cjs +1 -1
- package/components/cascader/index.mjs +38 -39
- package/components/cascader/src/ctx.d.ts +8 -3
- package/components/cascader/src/index.vue.d.ts +19 -8
- package/components/checkbox/src/ctx.d.ts +8 -3
- package/components/checkbox/src/index.vue.d.ts +43 -21
- package/components/{cloneDeep-DE0l40hv.mjs → cloneDeep-2YeQ7w2t.mjs} +10 -10
- package/components/cloneDeep-Btpy0oPF.js +1 -0
- package/components/collapse/index.cjs +1 -1
- package/components/collapse/index.mjs +19 -22
- package/components/collapse-item/index.cjs +1 -1
- package/components/collapse-item/index.mjs +21 -21
- package/components/collapse-item/src/index.vue.d.ts +2 -2
- package/components/color-picker/index.cjs +1 -1
- package/components/color-picker/index.mjs +26 -27
- package/components/color-picker/src/ctx.d.ts +7 -2
- package/components/color-picker/src/index.vue.d.ts +17 -6
- package/components/{style.css → components.css} +1 -1
- package/components/date-picker/index.cjs +1 -1
- package/components/date-picker/index.mjs +40 -41
- package/components/date-picker/src/ctx.d.ts +8 -3
- package/components/date-picker/src/index.vue.d.ts +17 -6
- package/components/date-picker-range/index.cjs +1 -1
- package/components/date-picker-range/index.mjs +17 -17
- package/components/date-picker-range/src/ctx.d.ts +14 -9
- package/components/date-picker-range/src/index.vue.d.ts +48 -26
- package/components/dialog/index.cjs +1 -1
- package/components/dialog/index.mjs +41 -52
- package/components/dialog/src/ctx.d.ts +1 -1
- package/components/dialog/src/index.vue.d.ts +1 -1
- package/components/dialog-input-collection/index.cjs +1 -1
- package/components/dialog-input-collection/index.mjs +124 -122
- package/components/dialog-input-collection/src/ctx.d.ts +7 -2
- package/components/dialog-input-collection/src/dialog-form.vue.d.ts +1 -1
- package/components/dialog-input-collection/src/index.vue.d.ts +17 -6
- package/components/download-plus/index.cjs +1 -1
- package/components/download-plus/index.mjs +193 -202
- package/components/download-plus/src/ctx.d.ts +7 -2
- package/components/download-plus/src/index.vue.d.ts +32 -10
- package/components/editable-text/index.cjs +1 -1
- package/components/editable-text/index.mjs +72 -75
- package/components/editable-text/src/ctx.d.ts +7 -2
- package/components/editable-text/src/index.vue.d.ts +18 -7
- package/components/el-slider/index.cjs +1 -1
- package/components/el-slider/index.mjs +230 -233
- package/components/el-slider/src/composables/index.cjs +1 -1
- package/components/el-slider/src/composables/index.mjs +1 -1
- package/components/el-slider/src/slider-core.vue.d.ts +3 -3
- package/components/esri-input-geojson/index.cjs +1 -5
- package/components/esri-input-geojson/index.mjs +59 -68
- package/components/esri-input-geojson/src/append.vue.d.ts +2 -2
- package/components/esri-input-geojson/src/ctx.d.ts +9 -4
- package/components/esri-input-geojson/src/index.vue.d.ts +65 -30
- package/components/fieldset/src/index.vue.d.ts +1 -1
- package/components/form/index.cjs +1 -1
- package/components/form/index.mjs +96 -101
- package/components/form/src/ctx.d.ts +2 -2
- package/components/form/src/index.vue.d.ts +4 -4
- package/components/form/src/use.d.ts +2 -2
- package/components/form-item/index.cjs +1 -1
- package/components/form-item/index.mjs +179 -107
- package/components/form-item/src/core.vue.d.ts +7 -3
- package/components/form-item/src/ctx.d.ts +7 -1
- package/components/form-item/src/index.vue.d.ts +13 -2
- package/components/form-item/src/use.d.ts +11 -0
- package/components/form-item-renderer/index.cjs +1 -1
- package/components/form-item-renderer/index.d.ts +1 -0
- package/components/form-item-renderer/index.mjs +85 -78
- package/components/form-item-renderer/src/use.d.ts +3 -0
- package/components/forms-provider/index.cjs +1 -1
- package/components/forms-provider/index.mjs +18 -21
- package/components/index-BIo_4rr_.mjs +18620 -0
- package/components/index-Bc7UifHG.js +1 -0
- package/components/index-D0D9ABpH.js +108 -0
- package/components/{index-CeHbpfCD.mjs → index-DCNYT7Wv.mjs} +0 -1
- package/components/information-collection/index.cjs +1 -1
- package/components/information-collection/index.mjs +32 -38
- package/components/information-collection/src/ctx.d.ts +7 -2
- package/components/information-collection/src/index.vue.d.ts +17 -6
- package/components/information-tag/index.cjs +1 -1
- package/components/information-tag/index.mjs +9 -12
- package/components/information-tag/src/index.vue.d.ts +1 -1
- package/components/input/index.cjs +1 -1
- package/components/input/index.mjs +27 -27
- package/components/input/src/ctx.d.ts +9 -4
- package/components/input/src/index.vue.d.ts +35 -13
- package/components/input-array/index.cjs +1 -1
- package/components/input-array/index.mjs +71 -74
- package/components/input-array/src/ctx.d.ts +7 -2
- package/components/input-array/src/index.vue.d.ts +18 -7
- package/components/input-collection/index.cjs +1 -1
- package/components/input-collection/index.mjs +121 -126
- package/components/input-collection/src/core.vue.d.ts +17 -6
- package/components/input-collection/src/ctx.d.ts +7 -2
- package/components/input-collection/src/index.vue.d.ts +17 -6
- package/components/input-file/src/index.vue.d.ts +19 -8
- package/components/input-link/index.cjs +1 -1
- package/components/input-link/index.mjs +1 -1
- package/components/input-link/src/ctx.d.ts +7 -2
- package/components/input-link/src/index.vue.d.ts +54 -21
- package/components/input-number/index.cjs +1 -1
- package/components/input-number/index.mjs +30 -33
- package/components/input-number/src/ctx.d.ts +8 -3
- package/components/input-number/src/index.vue.d.ts +33 -11
- package/components/input-tag/index.cjs +1 -1
- package/components/input-tag/index.mjs +24 -24
- package/components/input-tag/src/ctx.d.ts +9 -4
- package/components/input-tag/src/index.vue.d.ts +33 -11
- package/components/monaco-editor/src/ctx.d.ts +8 -3
- package/components/monaco-editor/src/index.vue.d.ts +38 -16
- package/components/radio/src/ctx.d.ts +7 -2
- package/components/radio/src/index.vue.d.ts +40 -18
- package/components/radio/src/wraper.vue.d.ts +22 -11
- package/components/renderer-data/index.cjs +1 -1
- package/components/renderer-data/index.mjs +14 -17
- package/components/select/index.cjs +1 -1
- package/components/select/index.mjs +165 -112
- package/components/select/src/core.vue.d.ts +107 -70
- package/components/select/src/ctx.d.ts +16 -4
- package/components/select/src/index.vue.d.ts +62 -42
- package/components/slider/index.cjs +1 -1
- package/components/slider/index.mjs +30 -31
- package/components/slider/src/ctx.d.ts +7 -2
- package/components/slider/src/index.vue.d.ts +18 -7
- package/components/switch/src/ctx.d.ts +7 -2
- package/components/switch/src/index.vue.d.ts +18 -7
- package/components/tables-select/index.cjs +1 -1
- package/components/tables-select/index.mjs +4 -4
- package/components/tables-select/src/ctx.d.ts +68 -68
- package/components/tables-select/src/index.vue.d.ts +52 -420
- package/components/template-instances-provider/index.cjs +1 -1
- package/components/template-instances-provider/index.mjs +11 -17
- package/components/templates-default/src/index.vue.d.ts +413 -185
- package/components/templates-esri/src/index.vue.d.ts +65 -30
- package/components/templates-variant/src/index.vue.d.ts +48 -26
- package/components/time-picker/index.cjs +1 -1
- package/components/time-picker/index.mjs +38 -39
- package/components/time-picker/src/ctx.d.ts +8 -3
- package/components/time-picker/src/index.vue.d.ts +17 -6
- package/components/upload/index.cjs +1 -1
- package/components/upload/index.mjs +244 -253
- package/components/upload/src/ctx.d.ts +8 -3
- package/components/upload/src/file.vue.d.ts +3 -3
- package/components/upload/src/index.vue.d.ts +37 -15
- package/components/upload/src/wraper.vue.d.ts +19 -8
- package/components/upload-plus/index.cjs +7 -15
- package/components/upload-plus/index.mjs +1879 -1897
- package/components/upload-plus/src/ctx.d.ts +7 -2
- package/components/upload-plus/src/index.vue.d.ts +18 -7
- package/components/use-watch-C3iIa2DX.js +1 -0
- package/components/use-watch-Dp64x0si.mjs +411 -0
- package/components/van-cascader/src/ctx.d.ts +7 -2
- package/components/van-cascader/src/index.vue.d.ts +19 -8
- package/components/var-datetime-picker/src/ctx.d.ts +7 -2
- package/components/var-datetime-picker/src/index.vue.d.ts +30 -8
- package/components/vditor/src/ctx.d.ts +7 -2
- package/components/vditor/src/index.vue.d.ts +41 -19
- package/composables/element-plus/index.cjs +1 -1
- package/composables/element-plus/index.mjs +10 -10
- package/composables/form-mitt/index.mjs +1 -1
- package/composables/index.cjs +1 -1
- package/composables/index.mjs +53 -53
- package/index.css +1 -1
- package/locale/index.cjs +1 -1
- package/locale/index.mjs +8 -5
- package/locale/lang/ar.d.ts +1 -0
- package/locale/lang/en.d.ts +1 -0
- package/locale/lang/zh-cn.d.ts +1 -0
- package/package.json +9 -1
- package/shared/element-plus/ctx.d.ts +16 -16
- package/shared/types/source/index.d.ts +5 -0
- package/shared/upload/index.cjs +1 -1
- package/shared/upload/index.mjs +166 -165
- package/components/cloneDeep-DaYwfXwD.js +0 -1
- package/components/index-BBriTmQP.js +0 -1
- package/components/use-watch-Bfrz9pv_.js +0 -1
- package/components/use-watch-t49wP7jy.mjs +0 -414
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { formItemProps as
|
|
2
|
-
import { bindPropsFactory as
|
|
3
|
-
import { defineComponent as
|
|
4
|
-
import { createFormItemBindProps as
|
|
5
|
-
import {
|
|
6
|
-
import { useLocale as
|
|
7
|
-
import { isPlainObject as
|
|
8
|
-
import { PATTERN_OPTIONS as
|
|
9
|
-
import { w as
|
|
10
|
-
import { useCollapseItemContext as
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { formItemProps as w, ElFormItem as L, ElTooltip as G, ElButton as j, ElIcon as K } from "element-plus";
|
|
2
|
+
import { bindPropsFactory as x } from "@vunk/core/shared/utils-vue";
|
|
3
|
+
import { ref as _, computed as I, defineComponent as z, openBlock as c, createBlock as O, unref as f, mergeProps as R, withCtx as u, renderSlot as d, normalizeProps as $, guardReactiveProps as B, createElementBlock as A, toDisplayString as D, createCommentVNode as y, createVNode as T, normalizeClass as W, createElementVNode as H, h as J } from "vue";
|
|
4
|
+
import { createFormItemBindProps as Q } from "@vunk/form/shared/element-plus";
|
|
5
|
+
import { useRendererData as q, useFormMitt as U, useComputedReadonly as X, useComputedLabelPosition as Y } from "@vunk/form/composables";
|
|
6
|
+
import { useLocale as F } from "@vunk/form/composables/element-plus";
|
|
7
|
+
import { isPlainObject as E } from "@vunk/core/shared/utils-object";
|
|
8
|
+
import { PATTERN_OPTIONS as Z } from "@vunk/form/shared/rules";
|
|
9
|
+
import { w as ee } from "../index-DCNYT7Wv.mjs";
|
|
10
|
+
import { useCollapseItemContext as te } from "@vunk/form/components/collapse-item";
|
|
11
|
+
import { VkfGenerateIcon as le } from "@vunk/form/icons/generate";
|
|
12
|
+
import { useAi as ae } from "@vunk/form/components/ai-provider";
|
|
13
|
+
import { useAiSchema as oe } from "@vunk/form/components/form-item-renderer";
|
|
14
|
+
const M = {
|
|
15
|
+
...w,
|
|
13
16
|
labelPosition: {
|
|
14
17
|
type: String,
|
|
15
18
|
default: void 0
|
|
@@ -52,20 +55,76 @@ const E = {
|
|
|
52
55
|
labelTipProps: {
|
|
53
56
|
type: Object,
|
|
54
57
|
default: () => ({})
|
|
55
|
-
}
|
|
58
|
+
},
|
|
59
|
+
ai: {
|
|
60
|
+
type: Object,
|
|
61
|
+
default: void 0
|
|
62
|
+
},
|
|
63
|
+
aiOutput: null
|
|
56
64
|
};
|
|
57
|
-
Reflect.deleteProperty(
|
|
58
|
-
const
|
|
65
|
+
Reflect.deleteProperty(M, "size");
|
|
66
|
+
const V = M, ne = x(V), Se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
59
67
|
__proto__: null,
|
|
60
|
-
createBindProps:
|
|
61
|
-
props:
|
|
62
|
-
}, Symbol.toStringTag, { value: "Module" }))
|
|
68
|
+
createBindProps: ne,
|
|
69
|
+
props: V
|
|
70
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
71
|
+
function re(e) {
|
|
72
|
+
const r = ae(), { data: b, getDataValue: p, emitSetData: i } = q(), { tr: s } = F(), v = oe(), a = _(!1), o = (t) => Array.isArray(t) ? t.join() : String(t), n = I(() => v?.find((t) => o(t.prop) === o(e.prop))), m = I(() => typeof e.ai == "object" && e.ai !== null ? e.ai : void 0), P = I(() => !!r && !!m.value && m.value.enable !== !1), S = (t) => s(
|
|
73
|
+
"vkf.formItem.aiPrompt",
|
|
74
|
+
"请为表单字段「{label}」生成一个合理的值,只输出值本身。",
|
|
75
|
+
{ label: t }
|
|
76
|
+
);
|
|
77
|
+
function h() {
|
|
78
|
+
const t = m.value ?? {};
|
|
79
|
+
return {
|
|
80
|
+
...t,
|
|
81
|
+
prompt: t.prompt ?? S(e.label ?? o(e.prop)),
|
|
82
|
+
output: t.output ?? e.aiOutput
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async function l() {
|
|
86
|
+
if (!r || a.value || e.prop == null) return;
|
|
87
|
+
const t = {
|
|
88
|
+
data: b?.value,
|
|
89
|
+
getDataValue: p,
|
|
90
|
+
emitSetData: i,
|
|
91
|
+
client: r,
|
|
92
|
+
formItem: n.value,
|
|
93
|
+
ai: h()
|
|
94
|
+
};
|
|
95
|
+
a.value = !0;
|
|
96
|
+
try {
|
|
97
|
+
if (t.ai.stream && r.generateStream) {
|
|
98
|
+
let k = "";
|
|
99
|
+
await r.generateStream(t, {
|
|
100
|
+
onChunk(N) {
|
|
101
|
+
k += N, i?.({ k: e.prop, v: k });
|
|
102
|
+
},
|
|
103
|
+
onDone() {
|
|
104
|
+
k && i?.({ k: e.prop, v: k });
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const g = (await r.generate(t))?.[o(e.prop)];
|
|
110
|
+
g !== void 0 && i?.({ k: e.prop, v: g });
|
|
111
|
+
} finally {
|
|
112
|
+
a.value = !1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
hasAi: P,
|
|
117
|
+
generating: a,
|
|
118
|
+
handleGenerate: l
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const ie = {
|
|
63
122
|
key: 0,
|
|
64
123
|
class: "vkf-form-item-label__span"
|
|
65
|
-
},
|
|
66
|
-
key:
|
|
124
|
+
}, fe = {
|
|
125
|
+
key: 3,
|
|
67
126
|
class: "vkf-form-item-label__actions"
|
|
68
|
-
},
|
|
127
|
+
}, ue = /* @__PURE__ */ z({
|
|
69
128
|
inheritAttrs: !1,
|
|
70
129
|
__name: "core",
|
|
71
130
|
props: {
|
|
@@ -81,62 +140,61 @@ const T = E, ee = L(T), be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Objec
|
|
|
81
140
|
elRef: null,
|
|
82
141
|
label: null,
|
|
83
142
|
prop: null,
|
|
84
|
-
labelTipProps: null
|
|
143
|
+
labelTipProps: null,
|
|
144
|
+
ai: null,
|
|
145
|
+
aiOutput: null
|
|
85
146
|
},
|
|
86
147
|
setup(e) {
|
|
87
|
-
const
|
|
88
|
-
return
|
|
89
|
-
if (!
|
|
90
|
-
const
|
|
91
|
-
if (!
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
if (Object.keys(
|
|
95
|
-
if (
|
|
96
|
-
|
|
148
|
+
const r = e, { mittOn: b } = U(), { hasAi: p, generating: i, handleGenerate: s } = re(r), v = te();
|
|
149
|
+
return b("afterValidate", ({ invalidFields: a }) => {
|
|
150
|
+
if (!a || r.prop == null || !(r.prop in a)) return;
|
|
151
|
+
const o = v;
|
|
152
|
+
if (!o) return;
|
|
153
|
+
const n = o.name;
|
|
154
|
+
if (o.accordion) {
|
|
155
|
+
if (Object.keys(a)[0] === r.prop) {
|
|
156
|
+
if (o.activeNames.includes(n)) return;
|
|
157
|
+
o.handleItemClick(n);
|
|
97
158
|
}
|
|
98
159
|
} else {
|
|
99
|
-
if (
|
|
100
|
-
|
|
160
|
+
if (o.activeNames.includes(n)) return;
|
|
161
|
+
o.handleItemClick(n);
|
|
101
162
|
}
|
|
102
|
-
}), (
|
|
103
|
-
ref: (
|
|
104
|
-
var f;
|
|
105
|
-
return (f = i.elRef) == null ? void 0 : f.call(i, o);
|
|
106
|
-
},
|
|
163
|
+
}), (a, o) => (c(), O(f(L), R(a.$attrs, {
|
|
164
|
+
ref: (n) => r.elRef?.(n),
|
|
107
165
|
prop: e.prop,
|
|
108
166
|
class: ["vkf-form-item", {
|
|
109
|
-
"has-label-actions":
|
|
167
|
+
"has-label-actions": a.$slots.labelActions
|
|
110
168
|
}],
|
|
111
169
|
label: e.label
|
|
112
170
|
}), {
|
|
113
|
-
default:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
e.formItemTip ? (
|
|
171
|
+
default: u(() => [
|
|
172
|
+
d(a.$slots, "before"),
|
|
173
|
+
d(a.$slots, "default"),
|
|
174
|
+
d(a.$slots, "after"),
|
|
175
|
+
e.formItemTip ? (c(), A("div", {
|
|
118
176
|
key: 0,
|
|
119
|
-
class:
|
|
177
|
+
class: W(["vkf-form-item__tip", e.formItemTipClass])
|
|
120
178
|
}, [
|
|
121
|
-
|
|
122
|
-
], 2)) :
|
|
179
|
+
H("span", null, D(e.formItemTip), 1)
|
|
180
|
+
], 2)) : y("", !0)
|
|
123
181
|
]),
|
|
124
|
-
label:
|
|
125
|
-
|
|
126
|
-
e.label ? (
|
|
127
|
-
e.labelTip ? (
|
|
182
|
+
label: u((n) => [
|
|
183
|
+
d(a.$slots, "label", $(B(n)), () => [
|
|
184
|
+
e.label ? (c(), A("span", ie, D(n.label), 1)) : y("", !0),
|
|
185
|
+
e.labelTip ? (c(), O(f(G), R({
|
|
128
186
|
key: 1,
|
|
129
187
|
content: e.labelTip
|
|
130
188
|
}, e.labelTipProps), {
|
|
131
|
-
default:
|
|
132
|
-
|
|
189
|
+
default: u(() => [
|
|
190
|
+
T(f(j), {
|
|
133
191
|
text: "",
|
|
134
192
|
class: "vkf-form-item-label-tip-button"
|
|
135
193
|
}, {
|
|
136
|
-
default:
|
|
137
|
-
|
|
138
|
-
default:
|
|
139
|
-
|
|
194
|
+
default: u(() => [
|
|
195
|
+
T(f(K), null, {
|
|
196
|
+
default: u(() => [
|
|
197
|
+
T(f(ee))
|
|
140
198
|
]),
|
|
141
199
|
_: 1
|
|
142
200
|
})
|
|
@@ -145,89 +203,103 @@ const T = E, ee = L(T), be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Objec
|
|
|
145
203
|
})
|
|
146
204
|
]),
|
|
147
205
|
_: 1
|
|
148
|
-
}, 16, ["content"])) :
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
206
|
+
}, 16, ["content"])) : y("", !0),
|
|
207
|
+
f(p) ? (c(), O(f(j), {
|
|
208
|
+
key: 2,
|
|
209
|
+
text: "",
|
|
210
|
+
class: "vkf-form-item-label-tip-button",
|
|
211
|
+
type: "primary",
|
|
212
|
+
onClick: f(s)
|
|
213
|
+
}, {
|
|
214
|
+
default: u(() => [
|
|
215
|
+
T(f(le), { generating: f(i) }, null, 8, ["generating"])
|
|
216
|
+
]),
|
|
217
|
+
_: 1
|
|
218
|
+
}, 8, ["onClick"])) : y("", !0),
|
|
219
|
+
a.$slots.labelActions ? (c(), A("div", fe, [
|
|
220
|
+
d(a.$slots, "labelActions")
|
|
221
|
+
])) : y("", !0)
|
|
152
222
|
])
|
|
153
223
|
]),
|
|
154
|
-
error:
|
|
155
|
-
|
|
224
|
+
error: u((n) => [
|
|
225
|
+
d(a.$slots, "error", $(B(n)))
|
|
156
226
|
]),
|
|
157
227
|
_: 3
|
|
158
228
|
}, 16, ["prop", "class", "label"]));
|
|
159
229
|
}
|
|
160
|
-
}),
|
|
230
|
+
}), he = /* @__PURE__ */ z({
|
|
161
231
|
name: "VkfFormItem",
|
|
162
|
-
props:
|
|
232
|
+
props: V,
|
|
163
233
|
setup(e, {
|
|
164
|
-
slots:
|
|
234
|
+
slots: r
|
|
165
235
|
}) {
|
|
166
|
-
const
|
|
167
|
-
tr:
|
|
168
|
-
} =
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
label:
|
|
236
|
+
const b = Q(e, ["rules"]), p = X(e), {
|
|
237
|
+
tr: i
|
|
238
|
+
} = F(), s = _(), v = I(() => e.labelPosition), a = Y(s, v), o = () => e.label || i("vkf.formItem.defaultField", "该字段"), n = (l) => {
|
|
239
|
+
if (l.message) return;
|
|
240
|
+
l.required && (l.message = i("vkf.formItem.required", "{label}不能为空", {
|
|
241
|
+
label: o()
|
|
172
242
|
}));
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
label:
|
|
176
|
-
pattern:
|
|
243
|
+
const t = Z.find((C) => C.value === l.pattern);
|
|
244
|
+
t && (l.message = i("vkf.formItem.pattern", "输入 {label} {pattern}", {
|
|
245
|
+
label: o(),
|
|
246
|
+
pattern: t.title
|
|
177
247
|
}));
|
|
178
|
-
},
|
|
179
|
-
let
|
|
180
|
-
return !e.rules && e.required &&
|
|
248
|
+
}, m = I(() => {
|
|
249
|
+
let l = [];
|
|
250
|
+
return !e.rules && e.required && l.push({
|
|
181
251
|
required: !0
|
|
182
|
-
}),
|
|
252
|
+
}), E(e.rules) && (l = [e.rules]), Array.isArray(e.rules) && (l = e.rules, e.required && !e.rules.find((t) => t.required) && l.push({
|
|
183
253
|
required: !0
|
|
184
|
-
})),
|
|
185
|
-
if (
|
|
186
|
-
return Object.keys(
|
|
187
|
-
}),
|
|
188
|
-
|
|
189
|
-
}),
|
|
254
|
+
})), l = l.filter((t) => {
|
|
255
|
+
if (t && E(t))
|
|
256
|
+
return Object.keys(t).filter((g) => !g.startsWith("data-")).length > 0;
|
|
257
|
+
}), l.forEach((t) => {
|
|
258
|
+
n(t);
|
|
259
|
+
}), l;
|
|
190
260
|
}), {
|
|
191
|
-
getDataValue:
|
|
192
|
-
emitSetData:
|
|
193
|
-
} =
|
|
261
|
+
getDataValue: P,
|
|
262
|
+
emitSetData: S
|
|
263
|
+
} = q();
|
|
194
264
|
setTimeout(() => {
|
|
195
|
-
e.defaultModelValue !== void 0 && e.prop && (
|
|
265
|
+
e.defaultModelValue !== void 0 && e.prop && P?.(e.prop) === void 0 && S?.({
|
|
196
266
|
k: e.prop,
|
|
197
267
|
v: e.defaultModelValue
|
|
198
|
-
})
|
|
268
|
+
});
|
|
199
269
|
});
|
|
200
|
-
const
|
|
201
|
-
|
|
270
|
+
const h = (l) => {
|
|
271
|
+
s.value = l?.$el ?? l, typeof e.elRef == "function" && e.elRef(l);
|
|
202
272
|
};
|
|
203
|
-
return () =>
|
|
204
|
-
...
|
|
205
|
-
"label-position":
|
|
206
|
-
elRef:
|
|
273
|
+
return () => J(ue, {
|
|
274
|
+
...b.value,
|
|
275
|
+
"label-position": a.value,
|
|
276
|
+
elRef: h,
|
|
207
277
|
class: {
|
|
208
|
-
"is-readonly":
|
|
278
|
+
"is-readonly": p.value,
|
|
209
279
|
"vkf-form-item--inline": e.inline,
|
|
210
280
|
"is-empty-label": !e.label,
|
|
211
281
|
"is-information": e.information
|
|
212
282
|
},
|
|
213
283
|
size: e.formItemSize,
|
|
214
|
-
rules:
|
|
284
|
+
rules: m.value,
|
|
215
285
|
formItemTip: e.formItemTip,
|
|
216
286
|
formItemTipClass: e.formItemTipClass,
|
|
217
287
|
labelTip: e.labelTip,
|
|
218
288
|
label: e.label,
|
|
219
|
-
labelTipProps: e.labelTipProps
|
|
289
|
+
labelTipProps: e.labelTipProps,
|
|
290
|
+
ai: e.ai,
|
|
291
|
+
aiOutput: e.aiOutput
|
|
220
292
|
}, {
|
|
221
|
-
...
|
|
293
|
+
...r,
|
|
222
294
|
...e.formItemSlots
|
|
223
295
|
});
|
|
224
296
|
}
|
|
225
|
-
}),
|
|
297
|
+
}), Ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
226
298
|
__proto__: null
|
|
227
299
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
228
300
|
export {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
301
|
+
he as VkfFormItem,
|
|
302
|
+
Se as _VkfFormItemCtx,
|
|
303
|
+
Ce as __VkfFormItem,
|
|
304
|
+
he as default
|
|
233
305
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare var __VLS_9: {}, __VLS_11: {}, __VLS_13: {}, __VLS_16: {
|
|
2
2
|
label: string;
|
|
3
|
-
},
|
|
3
|
+
}, __VLS_54: {}, __VLS_57: {
|
|
4
4
|
error: string;
|
|
5
5
|
};
|
|
6
6
|
type __VLS_Slots = {} & {
|
|
@@ -12,9 +12,9 @@ type __VLS_Slots = {} & {
|
|
|
12
12
|
} & {
|
|
13
13
|
label?: (props: typeof __VLS_16) => any;
|
|
14
14
|
} & {
|
|
15
|
-
labelActions?: (props: typeof
|
|
15
|
+
labelActions?: (props: typeof __VLS_54) => any;
|
|
16
16
|
} & {
|
|
17
|
-
error?: (props: typeof
|
|
17
|
+
error?: (props: typeof __VLS_57) => any;
|
|
18
18
|
};
|
|
19
19
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
20
20
|
labelTip: {
|
|
@@ -30,6 +30,8 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
30
30
|
label: null;
|
|
31
31
|
prop: null;
|
|
32
32
|
labelTipProps: null;
|
|
33
|
+
ai: null;
|
|
34
|
+
aiOutput: null;
|
|
33
35
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
34
36
|
labelTip: {
|
|
35
37
|
type: StringConstructor;
|
|
@@ -44,6 +46,8 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
44
46
|
label: null;
|
|
45
47
|
prop: null;
|
|
46
48
|
labelTipProps: null;
|
|
49
|
+
ai: null;
|
|
50
|
+
aiOutput: null;
|
|
47
51
|
}>> & Readonly<{}>, {
|
|
48
52
|
formItemTip: string;
|
|
49
53
|
labelTip: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FormItemSlots } from './types';
|
|
2
2
|
import { UseTooltipProps } from 'element-plus';
|
|
3
3
|
import type { PropType } from 'vue';
|
|
4
|
+
import type { AiConfig } from '@vunk/form/components/ai-provider';
|
|
4
5
|
declare const _props: {
|
|
5
6
|
labelPosition: {
|
|
6
7
|
type: PropType<"left" | "right" | "top" | "start" | "end">;
|
|
@@ -45,6 +46,11 @@ declare const _props: {
|
|
|
45
46
|
type: PropType<UseTooltipProps>;
|
|
46
47
|
default: () => {};
|
|
47
48
|
};
|
|
49
|
+
ai: {
|
|
50
|
+
type: PropType<AiConfig>;
|
|
51
|
+
default: undefined;
|
|
52
|
+
};
|
|
53
|
+
aiOutput: null;
|
|
48
54
|
label: StringConstructor;
|
|
49
55
|
labelWidth: {
|
|
50
56
|
readonly type: PropType<import("element-plus/es/utils/index.mjs").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
|
|
@@ -77,5 +83,5 @@ declare const _props: {
|
|
|
77
83
|
};
|
|
78
84
|
};
|
|
79
85
|
export declare const props: Omit<typeof _props, "size">;
|
|
80
|
-
export declare const createBindProps: <T2 extends import("@vunk/core").NormalObject, EX extends (Extract<"required", keyof T2> | Extract<"labelPosition", keyof T2> | Extract<"formItemSize", keyof T2> | Extract<"formItemSlots", keyof T2> | Extract<"elRef", keyof T2> | Extract<"inline", keyof T2> | Extract<"readonly", keyof T2> | Extract<"formItemTip", keyof T2> | Extract<"formItemTipClass", keyof T2> | Extract<"labelTip", keyof T2> | Extract<"information", keyof T2> | Extract<"
|
|
86
|
+
export declare const createBindProps: <T2 extends import("@vunk/core").NormalObject, EX extends (Extract<"required", keyof T2> | Extract<"error", keyof T2> | Extract<"prop", keyof T2> | Extract<"labelPosition", keyof T2> | Extract<"formItemSize", keyof T2> | Extract<"formItemSlots", keyof T2> | Extract<"elRef", keyof T2> | Extract<"inline", keyof T2> | Extract<"readonly", keyof T2> | Extract<"formItemTip", keyof T2> | Extract<"formItemTipClass", keyof T2> | Extract<"labelTip", keyof T2> | Extract<"information", keyof T2> | Extract<"defaultModelValue", keyof T2> | Extract<"labelTipProps", keyof T2> | Extract<"ai", keyof T2> | Extract<"aiOutput", keyof T2> | Extract<"label", keyof T2> | Extract<"labelWidth", keyof T2> | Extract<"rules", keyof T2> | Extract<"validateStatus", keyof T2> | Extract<"for", keyof T2> | Extract<"inlineMessage", keyof T2> | Extract<"showMessage", keyof T2>)[]>(propsArg: T2, excludes?: EX | undefined) => import("vue").ComputedRef<{ [P in EX extends (infer KE)[] ? Exclude<Extract<"required", keyof T2>, KE> | Exclude<Extract<"error", keyof T2>, KE> | Exclude<Extract<"prop", keyof T2>, KE> | Exclude<Extract<"labelPosition", keyof T2>, KE> | Exclude<Extract<"formItemSize", keyof T2>, KE> | Exclude<Extract<"formItemSlots", keyof T2>, KE> | Exclude<Extract<"elRef", keyof T2>, KE> | Exclude<Extract<"inline", keyof T2>, KE> | Exclude<Extract<"readonly", keyof T2>, KE> | Exclude<Extract<"formItemTip", keyof T2>, KE> | Exclude<Extract<"formItemTipClass", keyof T2>, KE> | Exclude<Extract<"labelTip", keyof T2>, KE> | Exclude<Extract<"information", keyof T2>, KE> | Exclude<Extract<"defaultModelValue", keyof T2>, KE> | Exclude<Extract<"labelTipProps", keyof T2>, KE> | Exclude<Extract<"ai", keyof T2>, KE> | Exclude<Extract<"aiOutput", keyof T2>, KE> | Exclude<Extract<"label", keyof T2>, KE> | Exclude<Extract<"labelWidth", keyof T2>, KE> | Exclude<Extract<"rules", keyof T2>, KE> | Exclude<Extract<"validateStatus", keyof T2>, KE> | Exclude<Extract<"for", keyof T2>, KE> | Exclude<Extract<"inlineMessage", keyof T2>, KE> | Exclude<Extract<"showMessage", keyof T2>, KE> : Extract<"required", keyof T2> | Extract<"error", keyof T2> | Extract<"prop", keyof T2> | Extract<"labelPosition", keyof T2> | Extract<"formItemSize", keyof T2> | Extract<"formItemSlots", keyof T2> | Extract<"elRef", keyof T2> | Extract<"inline", keyof T2> | Extract<"readonly", keyof T2> | Extract<"formItemTip", keyof T2> | Extract<"formItemTipClass", keyof T2> | Extract<"labelTip", keyof T2> | Extract<"information", keyof T2> | Extract<"defaultModelValue", keyof T2> | Extract<"labelTipProps", keyof T2> | Extract<"ai", keyof T2> | Extract<"aiOutput", keyof T2> | Extract<"label", keyof T2> | Extract<"labelWidth", keyof T2> | Extract<"rules", keyof T2> | Extract<"validateStatus", keyof T2> | Extract<"for", keyof T2> | Extract<"inlineMessage", keyof T2> | Extract<"showMessage", keyof T2>]: { [k in Extract<"required", keyof T2> | Extract<"error", keyof T2> | Extract<"prop", keyof T2> | Extract<"labelPosition", keyof T2> | Extract<"formItemSize", keyof T2> | Extract<"formItemSlots", keyof T2> | Extract<"elRef", keyof T2> | Extract<"inline", keyof T2> | Extract<"readonly", keyof T2> | Extract<"formItemTip", keyof T2> | Extract<"formItemTipClass", keyof T2> | Extract<"labelTip", keyof T2> | Extract<"information", keyof T2> | Extract<"defaultModelValue", keyof T2> | Extract<"labelTipProps", keyof T2> | Extract<"ai", keyof T2> | Extract<"aiOutput", keyof T2> | Extract<"label", keyof T2> | Extract<"labelWidth", keyof T2> | Extract<"rules", keyof T2> | Extract<"validateStatus", keyof T2> | Extract<"for", keyof T2> | Extract<"inlineMessage", keyof T2> | Extract<"showMessage", keyof T2>]: T2[k]; }[P]; }>;
|
|
81
87
|
export {};
|
|
@@ -45,6 +45,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
45
45
|
type: import("vue").PropType<import("element-plus").UseTooltipProps>;
|
|
46
46
|
default: () => {};
|
|
47
47
|
};
|
|
48
|
+
ai: {
|
|
49
|
+
type: import("vue").PropType<import("../../ai-provider/index.ts").AiConfig>;
|
|
50
|
+
default: undefined;
|
|
51
|
+
};
|
|
52
|
+
aiOutput: null;
|
|
48
53
|
label: StringConstructor;
|
|
49
54
|
labelWidth: {
|
|
50
55
|
readonly type: import("vue").PropType<import("element-plus/es/utils/index.mjs").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
|
|
@@ -121,6 +126,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
121
126
|
type: import("vue").PropType<import("element-plus").UseTooltipProps>;
|
|
122
127
|
default: () => {};
|
|
123
128
|
};
|
|
129
|
+
ai: {
|
|
130
|
+
type: import("vue").PropType<import("../../ai-provider/index.ts").AiConfig>;
|
|
131
|
+
default: undefined;
|
|
132
|
+
};
|
|
133
|
+
aiOutput: null;
|
|
124
134
|
label: StringConstructor;
|
|
125
135
|
labelWidth: {
|
|
126
136
|
readonly type: import("vue").PropType<import("element-plus/es/utils/index.mjs").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
|
|
@@ -153,8 +163,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
153
163
|
};
|
|
154
164
|
}, "size">>> & Readonly<{}>, {
|
|
155
165
|
required: import("element-plus/es/utils/index.mjs").EpPropMergeType<BooleanConstructor, unknown, unknown>;
|
|
156
|
-
labelPosition: "
|
|
157
|
-
formItemSize: "
|
|
166
|
+
labelPosition: "start" | "left" | "right" | "top" | "end";
|
|
167
|
+
formItemSize: "small" | "default" | "large";
|
|
158
168
|
formItemSlots: import("./types.ts").FormItemSlots;
|
|
159
169
|
inline: boolean;
|
|
160
170
|
readonly: boolean;
|
|
@@ -162,6 +172,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
162
172
|
labelTip: string;
|
|
163
173
|
information: boolean;
|
|
164
174
|
labelTipProps: import("element-plus").UseTooltipProps;
|
|
175
|
+
ai: import("../../ai-provider/index.ts").AiConfig;
|
|
165
176
|
inlineMessage: import("element-plus/es/utils/index.mjs").EpPropMergeType<BooleanConstructor, unknown, unknown>;
|
|
166
177
|
showMessage: import("element-plus/es/utils/index.mjs").EpPropMergeType<BooleanConstructor, unknown, unknown>;
|
|
167
178
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AiConfig } from '@vunk/form/components/ai-provider';
|
|
2
|
+
export declare function useAiGenerate(props: {
|
|
3
|
+
ai?: AiConfig;
|
|
4
|
+
aiOutput?: any;
|
|
5
|
+
prop?: any;
|
|
6
|
+
label?: string;
|
|
7
|
+
}): {
|
|
8
|
+
hasAi: import("vue").ComputedRef<boolean>;
|
|
9
|
+
generating: import("vue").Ref<boolean, boolean>;
|
|
10
|
+
handleGenerate: () => Promise<void>;
|
|
11
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),x=require("@vunk/form/components/template-instances-provider"),D=require("@vunk/form/shared/form"),S=require("@vunk/form/composables"),m=require("@vunk/shared/function"),h={source:{type:Array,default:()=>[]},templateInstances:{type:Object,default:void 0},k:{type:Array,default:()=>[]}},O=r=>{if(r)return typeof r=="function"?r:typeof r=="string"?new Function("value","context",r):m.noop},c=Symbol("vkfAiSchemaKey");function _(r){const o=t.inject(c,null);return o||(t.provide(c,r),r)}function K(){return t.inject(c,null)}const b=t.defineComponent({name:"VkfFormItemRenderer",props:h,setup(r,o){_(r.source);const{templateInstances:p,getTemplateInstance:a}=S.useTemplateInstancesContext(),{emitSetData:f,data:l,getDataValue:d}=S.useRendererData(),A=s=>t.h(b,{templateInstances:p,...s}),V=(s,j=[])=>s.reduce((i,e,C)=>{e.key=e.key??(Array.isArray(e.prop)?e.prop.join():e.prop);const y=[...r.k,...j,C],F=()=>{t.nextTick(()=>{e.templateType&&!a(e.templateType)&&console.warn(e.templateType,"templateType不存在将跳过")})};if(e.templateType&&a(e.templateType)){const n={...e};Object.assign(n,m.isCallable(e.templateProps)?e.templateProps(l?.value):e.templateProps);const P=D.genTemplateIfFunc(n.templateIf);if(!(l?P(l.value):!0))return i;const R=m.isCallable(n.informationProps)?n.informationProps(l?.value):n.informationProps,T=O(n.inputEffect);Reflect.deleteProperty(n,"templateType"),Reflect.deleteProperty(n,"templateIf"),Reflect.deleteProperty(n,"templateProps"),Reflect.deleteProperty(n,"informationProps"),Reflect.deleteProperty(n,"inputEffect");const q=y.join(",")+"-"+e.templateType+"-"+(e.prop||"no-prop"),v=t.computed({get:()=>e.prop&&d?.(e.prop),set:u=>f?.({k:e.prop,v:u})}),k={data:n,raw:e,props:n,k:y,key:q,value:v.value,input:u=>{v.value=u,T?.(u,{...k,parentProp:[e.prop].flat(1/0).slice(0,-1)})},informationProps:R,templateIf:P,Renderer:A,getDataValue:d,emitSetData:f,inputEffect:T},I=a(e.templateType)?.slots.default?.(k);I&&i.push(I)}else F();return i},[]);return()=>[o.slots.default?.(),V(r.source)]}}),g=t.defineComponent({__name:"index",props:h,setup(r){const o=r;return(p,a)=>(t.openBlock(),t.createBlock(t.unref(x.VkfTemplateInstancesProvider),null,{placeholder:t.withCtx(()=>[t.renderSlot(p.$slots,"placeholder")]),default:t.withCtx(()=>[t.createVNode(b,t.normalizeProps(t.guardReactiveProps({...o,...p.$attrs})),{default:t.withCtx(()=>[t.renderSlot(p.$slots,"default")]),_:3},16)]),_:3}))}}),M=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.VkfFormItemRenderer=g;exports.__VkfFormItemRenderer=M;exports.default=g;exports.initAiSchema=_;exports.useAiSchema=K;
|