@web-utils/form-ui 1.0.0-beta81 → 1.0.0-beta83

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.
@@ -1,109 +0,0 @@
1
- import { m as e } from "./ClVh1Lek.mjs";
2
- import { formHolderContextKey as t, formViewContextKey as n } from "../constants/index.mjs";
3
- import { allProps as r, predicate as i } from "../props/form.mjs";
4
- import a from "../form-advice/index.mjs";
5
- import o from "../form-red-table/index.mjs";
6
- import { ElForm as s, ElRow as c } from "element-plus/es";
7
- import "element-plus/es/components/base/style/css";
8
- import { computed as l, createVNode as u, inject as d, mergeProps as f, nextTick as p, provide as m, reactive as h, toRef as g, useTemplateRef as _ } from "vue";
9
- import { animate as v } from "@web-utils/core";
10
- import "element-plus/es/components/row/style/css";
11
- import "element-plus/es/components/form/style/css";
12
- //#endregion
13
- //#region src/components/form/FormHolder.vue
14
- var y = {
15
- name: "FormHolder",
16
- inheritAttrs: !1,
17
- props: { ...r },
18
- emits: {},
19
- setup(r, { slots: y, expose: b, attrs: x }) {
20
- let { autoBindProps: S, listeners: C } = e(r, { predicate: i }), w = d(n, null), T = _("form"), E = l(() => r.notTableForm === void 0 ? (w == null ? void 0 : w.tableForm) === void 0 ? !1 : w == null ? void 0 : w.tableForm : !r.notTableForm), D = l(() => E.value ? !1 : r.showMessage), O = l(() => {
21
- let e = {};
22
- return r.disabledFields && r.disabledFields.forEach((t) => {
23
- e[t] = !0;
24
- }), e;
25
- }), k = l(() => {
26
- let e = {};
27
- return r.enabledFields && r.enabledFields.length && r.enabledFields.forEach((t) => {
28
- e[t] = !0;
29
- }), e;
30
- }), A = l(() => {
31
- let e = {};
32
- return r.requiredFields && r.requiredFields.length && r.requiredFields.forEach((t) => {
33
- e[t] = !0;
34
- }), e;
35
- }), j = l(() => r.disabled === !0 ? !0 : r.disabled), M = g(() => r.enabledFields), N = g(() => r.requiredFields), P = g(() => r.disabledFields), F = async () => {
36
- await p();
37
- let e = T.value.$el.querySelector(".el-form-item.is-error");
38
- e && e.scrollIntoView({
39
- block: "center",
40
- inline: "center",
41
- behavior: "smooth"
42
- });
43
- }, I = h({
44
- tableForm: E,
45
- disabled: j,
46
- enabledFields: M,
47
- requiredFields: N,
48
- enabledFieldsMap: k,
49
- disabledFieldsMap: O,
50
- requiredFieldsMap: A,
51
- disabledFields: P,
52
- scrollIntoRequiredField: F,
53
- formRef: T,
54
- validate: async () => {
55
- try {
56
- return await T.value.validate();
57
- } catch {
58
- throw await F(), T.value.$el.querySelectorAll(".el-form-item.is-error .el-form-item__content > :first-child").forEach((e) => {
59
- v(e, "breathe-animation");
60
- }), Error("表单验证不通过!");
61
- }
62
- },
63
- validateField: (e) => T.value.validateField(e),
64
- resetFields: (e) => T.value.resetFields(e),
65
- scrollToField: (e) => T.value.scrollToField(e),
66
- clearValidate: (e) => T.value.clearValidate(e),
67
- getField: () => T.value.getField(),
68
- setInitialValues: (e) => T.value.setInitialValues(e),
69
- getFields: () => T.value.fields
70
- });
71
- return m(t, I), b(I), () => u(s, f(C.value, S.value, x, {
72
- ref: "form",
73
- class: [
74
- "form-holder",
75
- "clear-fix",
76
- { "red-form": E }
77
- ],
78
- "show-message": D.value
79
- }), { default: () => {
80
- if (E.value) {
81
- var e, t, n;
82
- return [
83
- (e = y.top) == null ? void 0 : e.call(y),
84
- u(o, {
85
- class: { "hide-error-message": E.value },
86
- columns: r.columns,
87
- "col-count": r.colCount
88
- }, { default: () => {
89
- var e;
90
- return [(e = y.default) == null ? void 0 : e.call(y), r.showAdvice ? u(a, {
91
- "label-colspan": r.commentLabelColspan,
92
- "value-colspan": r.commentValueColspan
93
- }, null) : null];
94
- } }),
95
- (t = y.bottom) == null ? void 0 : t.call(y),
96
- u("div", { class: "red-form-footer" }, [(n = y.footer) == null ? void 0 : n.call(y)])
97
- ];
98
- } else {
99
- var i;
100
- return r.wrapRow ? u(c, null, { default: () => {
101
- var e;
102
- return [(e = y.default) == null ? void 0 : e.call(y)];
103
- } }) : (i = y.default) == null ? void 0 : i.call(y);
104
- }
105
- } });
106
- }
107
- };
108
- //#endregion
109
- export { y as t };
@@ -1,61 +0,0 @@
1
- import { allProps as e, predicate as t } from "../props/date.mjs";
2
- import { n, o as r } from "./DzCIClcZ.mjs";
3
- import { ElDatePicker as i } from "element-plus/es";
4
- import "element-plus/es/components/base/style/css";
5
- import { computed as a, createVNode as o, mergeProps as s } from "vue";
6
- import "element-plus/es/components/date-picker/style/css";
7
- import { toDate as c } from "@web-utils/integrations/dayjs";
8
- //#endregion
9
- //#region src/components/form/FormDatePicker.vue
10
- var l = {
11
- name: "FormDatePicker",
12
- inheritAttrs: !1,
13
- props: { ...e },
14
- emits: {
15
- ...n,
16
- "update:startDate": null,
17
- "update:endDate": null
18
- },
19
- setup(e, { emit: n, slots: l, attrs: u }) {
20
- let { emitInput: d, render: f, placeholder: p, disabled: m, listeners: h, inputProps: g } = r(e, {
21
- emit: n,
22
- slots: l,
23
- attrs: u,
24
- predicate: t,
25
- messagePrefix: "请选择"
26
- }), _ = a(() => e.dateTimeRange || e.dateRange || e.monthRange), v = a(() => e.year ? "YYYY" : e.month || e.monthRange ? "YYYY-MM" : e.week ? "YYYY 第 WW 周" : e.dateTime || e.dateTimeRange ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD"), y = a(() => e.year ? "year" : e.month ? "month" : e.dates ? "dates" : e.week ? "week" : e.dateTime ? "datetime" : e.dateTimeRange ? "datetimerange" : e.dateRange ? "daterange" : e.monthRange ? "monthrange" : "date"), b = a(() => {
27
- if (e.miniDate) {
28
- let t = c(e.miniDate);
29
- return t.setDate(t.getDate() - 1), t;
30
- } else return null;
31
- }), x = a(() => e.maxDate ? c(e.maxDate) : null), S = (e) => {
32
- if (!b.value && !x.value) return !1;
33
- let t = e.getTime();
34
- return b.value && !x.value ? t <= b.value.getTime() : !b.value && x.value ? t >= x.value.getTime() : b.value && x.value ? !(t > b.value.getTime() && t <= x.value.getTime()) : !1;
35
- }, C = (e, t) => {
36
- n("update:startDate", e), n("update:endDate", t);
37
- }, w = (t) => {
38
- _.value && e.split ? t ? C(t[0], t[1]) : C(null, null) : d(t);
39
- }, T = a(() => _.value && e.split ? [e.startDate, e.endDate] : e.modelValue), E = a(() => e.week ? "YYYY-MM-DD" : e.valueFormat || v.value), D = a(() => e.format || v.value);
40
- return () => f({ vNodes: o(i, s(h.value, g.value, {
41
- style: "width: 100%",
42
- type: y.value,
43
- modelValue: T.value,
44
- disabled: m.value,
45
- placeholder: p.value,
46
- format: D.value,
47
- disabledDate: S,
48
- "value-format": E.value,
49
- "onUpdate:modelValue": w
50
- }), {
51
- default: l.default,
52
- "range-separator": l["range-separator"],
53
- "pre-month": l["pre-month"],
54
- "next-month": l["next-month"],
55
- "pre-year": l["pre-year"],
56
- "next-year": l["next-year"]
57
- }) });
58
- }
59
- };
60
- //#endregion
61
- export { l as t };