@qin-ui/vant-pro 1.0.1 → 1.0.3
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/AI-CONTEXT.md +38 -0
- package/LICENSE +9 -0
- package/README.md +9 -2
- package/api.json +163 -0
- package/es/component-provider/index-DC_k4_R3.js +121 -0
- package/es/component-provider/index.js +2 -120
- package/es/core/{index-D-2iAH6o.js → index-B5vvm4Fj.js} +20 -20
- package/es/form/index.js +77 -90
- package/es/index.d.ts +464 -564
- package/es/index.js +17 -20
- package/package.json +12 -9
package/es/form/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Button, Signature, Area, Cascader, TimePicker, DatePicker, Picker, RadioGroup, CheckboxGroup, Uploader, Slider, Rate, Stepper, Switch, Field, Form, Popup } from "vant";
|
|
2
|
-
import { inject, reactive, ref, computed, provide, defineComponent,
|
|
3
|
-
import {
|
|
4
|
-
import { u as useForm$1, I as
|
|
5
|
-
import { e } from "../core/index-
|
|
2
|
+
import { inject, reactive, ref, computed, provide, defineComponent, useAttrs, mergeProps, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, createVNode, createCommentVNode, Teleport, resolveDynamicComponent, isRef, createSlots, renderList, renderSlot, normalizeProps, isVNode, createTextVNode, toDisplayString, guardReactiveProps, toValue, resolveComponent, useSlots, watchEffect, createElementVNode } from "vue";
|
|
3
|
+
import { g as getInjectConfig, I as INJECT_COMPONENTS, a as INJECT_CONFIG } from "../component-provider/index-DC_k4_R3.js";
|
|
4
|
+
import { u as useForm$1, I as InjectionPathKey, a as InjectionFormKey, c as camelizeProperties, b as useFields$1, d as useFormRef$1 } from "../core/index-B5vvm4Fj.js";
|
|
5
|
+
import { e } from "../core/index-B5vvm4Fj.js";
|
|
6
6
|
import { o as omit, c as cloneDeep, i as isPlainObject, t as toPath } from "../vendor/utils/lodash-es-DN4QDiDm.js";
|
|
7
7
|
const componentMap = {
|
|
8
8
|
field: Field,
|
|
@@ -69,60 +69,6 @@ function useForm(...args) {
|
|
|
69
69
|
const formPopup = useFormPopup(root);
|
|
70
70
|
return { ...form, formPopup };
|
|
71
71
|
}
|
|
72
|
-
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
73
|
-
...{ name: "ProForm", inheritAttrs: false },
|
|
74
|
-
__name: "index",
|
|
75
|
-
props: {
|
|
76
|
-
form: {}
|
|
77
|
-
},
|
|
78
|
-
setup(__props) {
|
|
79
|
-
const props = __props;
|
|
80
|
-
const form = props.form || useForm(true);
|
|
81
|
-
provide(InjectionFormKey, form);
|
|
82
|
-
const { fields, setFormRef, formPopup } = form;
|
|
83
|
-
const formFields = computed(() => {
|
|
84
|
-
const f = toValue(fields);
|
|
85
|
-
return Array.isArray(f) ? f : [];
|
|
86
|
-
});
|
|
87
|
-
const config = INJECT_CONFIG["pro-form"];
|
|
88
|
-
const injectAttrs = inject(config.injectionKey, config.default);
|
|
89
|
-
const slots = useSlots();
|
|
90
|
-
watchEffect(() => {
|
|
91
|
-
Object.keys(slots).forEach((name) => {
|
|
92
|
-
if (name === "default") return;
|
|
93
|
-
provide(`${TeleportComponentNamePrefix}${name}`, slots[name]);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
const popupProps = computed(() => {
|
|
97
|
-
const { container, ...rest } = formPopup.props;
|
|
98
|
-
return rest;
|
|
99
|
-
});
|
|
100
|
-
return (_ctx, _cache) => {
|
|
101
|
-
return openBlock(), createBlock(unref(Form), mergeProps({
|
|
102
|
-
ref: (el) => {
|
|
103
|
-
var _a;
|
|
104
|
-
return (_a = unref(setFormRef)) == null ? void 0 : _a(el);
|
|
105
|
-
}
|
|
106
|
-
}, mergeProps(unref(injectAttrs), unref(camelizeProperties)(_ctx.$attrs)), { class: "pro-form" }), {
|
|
107
|
-
default: withCtx(() => [
|
|
108
|
-
createVNode(unref(_sfc_main), { fields: formFields.value }, null, 8, ["fields"]),
|
|
109
|
-
createVNode(unref(Popup), mergeProps(popupProps.value, {
|
|
110
|
-
show: unref(formPopup).visible.value,
|
|
111
|
-
teleport: "#app",
|
|
112
|
-
onClose: unref(formPopup).close
|
|
113
|
-
}), {
|
|
114
|
-
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
115
|
-
createElementVNode("div", { id: "pro-form-popup-content" }, null, -1)
|
|
116
|
-
])]),
|
|
117
|
-
_: 1
|
|
118
|
-
}, 16, ["show", "onClose"]),
|
|
119
|
-
renderSlot(_ctx.$slots, "default")
|
|
120
|
-
]),
|
|
121
|
-
_: 3
|
|
122
|
-
}, 16);
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
72
|
const getInitProps = (field) => {
|
|
127
73
|
const { component } = field;
|
|
128
74
|
if (typeof component === "string") {
|
|
@@ -133,7 +79,7 @@ const getInitProps = (field) => {
|
|
|
133
79
|
}
|
|
134
80
|
return {};
|
|
135
81
|
};
|
|
136
|
-
const _sfc_main$
|
|
82
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
137
83
|
...{ name: "BaseField", inheritAttrs: false },
|
|
138
84
|
__name: "index",
|
|
139
85
|
props: {
|
|
@@ -278,7 +224,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
278
224
|
getComponentComputedProps: () => groupedAttrs.value.attrs
|
|
279
225
|
});
|
|
280
226
|
return (_ctx, _cache) => {
|
|
281
|
-
return openBlock(), createBlock(unref(_sfc_main$
|
|
227
|
+
return openBlock(), createBlock(unref(_sfc_main$5), {
|
|
282
228
|
component: groupedAttrs.value.componentContainer,
|
|
283
229
|
path: __props.path
|
|
284
230
|
}, {
|
|
@@ -296,14 +242,14 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
296
242
|
"model-value": displayValue.value,
|
|
297
243
|
onClick: onFieldClick
|
|
298
244
|
}), null, 16, ["model-value"]),
|
|
299
|
-
unref(popupFieldPath) === __props.path ? (openBlock(), createBlock(unref(_sfc_main$
|
|
245
|
+
unref(popupFieldPath) === __props.path ? (openBlock(), createBlock(unref(_sfc_main$5), {
|
|
300
246
|
key: 0,
|
|
301
247
|
component: Teleport,
|
|
302
248
|
to: "#pro-form-popup-content",
|
|
303
249
|
defer: ""
|
|
304
250
|
}, {
|
|
305
251
|
default: withCtx(() => [
|
|
306
|
-
createVNode(unref(_sfc_main$
|
|
252
|
+
createVNode(unref(_sfc_main$5), {
|
|
307
253
|
component: popupContainer.value,
|
|
308
254
|
path: __props.path
|
|
309
255
|
}, {
|
|
@@ -316,7 +262,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
316
262
|
return {
|
|
317
263
|
name,
|
|
318
264
|
fn: withCtx((scoped) => [
|
|
319
|
-
createVNode(unref(_sfc_main$
|
|
265
|
+
createVNode(unref(_sfc_main$4), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
320
266
|
])
|
|
321
267
|
};
|
|
322
268
|
})
|
|
@@ -339,7 +285,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
339
285
|
return {
|
|
340
286
|
name,
|
|
341
287
|
fn: withCtx((scoped) => [
|
|
342
|
-
createVNode(unref(_sfc_main$
|
|
288
|
+
createVNode(unref(_sfc_main$4), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
343
289
|
])
|
|
344
290
|
};
|
|
345
291
|
})
|
|
@@ -359,7 +305,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
359
305
|
return {
|
|
360
306
|
name,
|
|
361
307
|
fn: withCtx((scoped) => [
|
|
362
|
-
createVNode(unref(_sfc_main$
|
|
308
|
+
createVNode(unref(_sfc_main$4), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
363
309
|
])
|
|
364
310
|
};
|
|
365
311
|
})
|
|
@@ -378,7 +324,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
378
324
|
return {
|
|
379
325
|
name,
|
|
380
326
|
fn: withCtx((scoped) => [
|
|
381
|
-
createVNode(unref(_sfc_main$
|
|
327
|
+
createVNode(unref(_sfc_main$4), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
382
328
|
])
|
|
383
329
|
};
|
|
384
330
|
})
|
|
@@ -390,7 +336,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
390
336
|
};
|
|
391
337
|
}
|
|
392
338
|
});
|
|
393
|
-
const _sfc_main$
|
|
339
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
394
340
|
...{ name: "ContainerFragment", inheritAttrs: false },
|
|
395
341
|
__name: "index",
|
|
396
342
|
props: {
|
|
@@ -407,7 +353,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
407
353
|
};
|
|
408
354
|
}
|
|
409
355
|
});
|
|
410
|
-
const _sfc_main$
|
|
356
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
411
357
|
...{ name: "SlotComponent", inheritAttrs: false },
|
|
412
358
|
__name: "index",
|
|
413
359
|
props: {
|
|
@@ -421,7 +367,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
421
367
|
};
|
|
422
368
|
}
|
|
423
369
|
});
|
|
424
|
-
const _sfc_main$
|
|
370
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
425
371
|
__name: "index",
|
|
426
372
|
props: {
|
|
427
373
|
path: {}
|
|
@@ -437,7 +383,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
437
383
|
};
|
|
438
384
|
}
|
|
439
385
|
});
|
|
440
|
-
const _sfc_main$
|
|
386
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
441
387
|
__name: "index",
|
|
442
388
|
props: {
|
|
443
389
|
field: {}
|
|
@@ -457,7 +403,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
457
403
|
};
|
|
458
404
|
}
|
|
459
405
|
});
|
|
460
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
406
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
461
407
|
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
462
408
|
__name: "index",
|
|
463
409
|
props: {
|
|
@@ -473,14 +419,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
473
419
|
return (_ctx, _cache) => {
|
|
474
420
|
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
475
421
|
return openBlock(true), createElementBlock(Fragment, null, renderList(validFields.value, (field, index) => {
|
|
476
|
-
return openBlock(), createBlock(unref(_sfc_main$
|
|
422
|
+
return openBlock(), createBlock(unref(_sfc_main$3), {
|
|
477
423
|
key: unref(toPath)(toValue(field.path || index)).join(".") || index,
|
|
478
424
|
path: toValue(field.path)
|
|
479
425
|
}, {
|
|
480
426
|
default: withCtx(({ path }) => [
|
|
481
|
-
createVNode(unref(_sfc_main$
|
|
427
|
+
createVNode(unref(_sfc_main$2), { field }, {
|
|
482
428
|
default: withCtx(({ componentProps }) => [
|
|
483
|
-
field.fields ? (openBlock(), createBlock(unref(_sfc_main$
|
|
429
|
+
field.fields ? (openBlock(), createBlock(unref(_sfc_main$5), mergeProps({
|
|
484
430
|
key: 0,
|
|
485
431
|
component: field.fieldContainer,
|
|
486
432
|
path
|
|
@@ -491,7 +437,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
491
437
|
}, null, 8, ["fields"])
|
|
492
438
|
]),
|
|
493
439
|
_: 2
|
|
494
|
-
}, 1040, ["component", "path"])) : (openBlock(), createBlock(unref(_sfc_main$
|
|
440
|
+
}, 1040, ["component", "path"])) : (openBlock(), createBlock(unref(_sfc_main$6), mergeProps({
|
|
495
441
|
key: 1,
|
|
496
442
|
ref_for: true
|
|
497
443
|
}, componentProps, { path }), null, 16, ["path"]))
|
|
@@ -505,26 +451,67 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
505
451
|
};
|
|
506
452
|
}
|
|
507
453
|
});
|
|
454
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
455
|
+
...{ name: "ProForm", inheritAttrs: false },
|
|
456
|
+
__name: "index",
|
|
457
|
+
props: {
|
|
458
|
+
form: {}
|
|
459
|
+
},
|
|
460
|
+
setup(__props) {
|
|
461
|
+
const props = __props;
|
|
462
|
+
const form = props.form || useForm(true);
|
|
463
|
+
provide(InjectionFormKey, form);
|
|
464
|
+
const { fields, setFormRef, formPopup } = form;
|
|
465
|
+
const formFields = computed(() => {
|
|
466
|
+
const f = toValue(fields);
|
|
467
|
+
return Array.isArray(f) ? f : [];
|
|
468
|
+
});
|
|
469
|
+
const config = INJECT_CONFIG["pro-form"];
|
|
470
|
+
const injectAttrs = inject(config.injectionKey, config.default);
|
|
471
|
+
const slots = useSlots();
|
|
472
|
+
watchEffect(() => {
|
|
473
|
+
Object.keys(slots).forEach((name) => {
|
|
474
|
+
if (name === "default") return;
|
|
475
|
+
provide(`${TeleportComponentNamePrefix}${name}`, slots[name]);
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
const popupProps = computed(() => {
|
|
479
|
+
const { container, ...rest } = formPopup.props;
|
|
480
|
+
return rest;
|
|
481
|
+
});
|
|
482
|
+
return (_ctx, _cache) => {
|
|
483
|
+
return openBlock(), createBlock(unref(Form), mergeProps({
|
|
484
|
+
ref: (el) => {
|
|
485
|
+
var _a;
|
|
486
|
+
return (_a = unref(setFormRef)) == null ? void 0 : _a(el);
|
|
487
|
+
}
|
|
488
|
+
}, mergeProps(unref(injectAttrs), unref(camelizeProperties)(_ctx.$attrs)), { class: "pro-form" }), {
|
|
489
|
+
default: withCtx(() => [
|
|
490
|
+
createVNode(unref(_sfc_main$1), { fields: formFields.value }, null, 8, ["fields"]),
|
|
491
|
+
createVNode(unref(Popup), mergeProps(popupProps.value, {
|
|
492
|
+
show: unref(formPopup).visible.value,
|
|
493
|
+
onClose: unref(formPopup).close
|
|
494
|
+
}), {
|
|
495
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
496
|
+
createElementVNode("div", { id: "pro-form-popup-content" }, null, -1)
|
|
497
|
+
])]),
|
|
498
|
+
_: 1
|
|
499
|
+
}, 16, ["show", "onClose"]),
|
|
500
|
+
renderSlot(_ctx.$slots, "default")
|
|
501
|
+
]),
|
|
502
|
+
_: 3
|
|
503
|
+
}, 16);
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
});
|
|
508
507
|
const useFields = useFields$1;
|
|
509
508
|
const useFormRef = useFormRef$1;
|
|
510
509
|
export {
|
|
511
|
-
_sfc_main$5 as
|
|
512
|
-
_sfc_main$
|
|
513
|
-
_sfc_main as
|
|
514
|
-
_sfc_main$4 as ContainerFragment,
|
|
515
|
-
_sfc_main$1 as GroupedFieldAttrs,
|
|
516
|
-
InjectionFormKey,
|
|
517
|
-
InjectionPathKey,
|
|
518
|
-
InjectionPopupKey,
|
|
519
|
-
_sfc_main$2 as PathProvider,
|
|
520
|
-
_sfc_main$3 as SlotComponent,
|
|
521
|
-
TeleportComponentNamePrefix,
|
|
522
|
-
componentMap,
|
|
523
|
-
_sfc_main$6 as default,
|
|
524
|
-
getInitProps,
|
|
510
|
+
_sfc_main$5 as ContainerFragment,
|
|
511
|
+
_sfc_main$4 as SlotComponent,
|
|
512
|
+
_sfc_main as default,
|
|
525
513
|
useFields,
|
|
526
514
|
useForm,
|
|
527
515
|
e as useFormData,
|
|
528
|
-
useFormPopup,
|
|
529
516
|
useFormRef
|
|
530
517
|
};
|