@silver-formily/element-plus 2.4.0 → 3.0.0
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/README.en-US.md +32 -32
- package/README.md +32 -32
- package/esm/__builtins__/configs/index.mjs.map +1 -1
- package/esm/__builtins__/index.mjs +18 -18
- package/esm/__builtins__/shared/loading.mjs.map +1 -1
- package/esm/__builtins__/shared/simple-version-compare.mjs.map +1 -1
- package/esm/__builtins__/shared/transform-component.d.ts +1 -1
- package/esm/__builtins__/shared/transform-component.mjs.map +1 -1
- package/esm/__builtins__/shared/use-enter-submit.mjs.map +1 -1
- package/esm/__builtins__/shared/utils.mjs +0 -2
- package/esm/__builtins__/shared/utils.mjs.map +1 -1
- package/esm/array-base/index.mjs +59 -63
- package/esm/array-base/index.mjs.map +1 -1
- package/esm/array-base/symbols.mjs +1 -1
- package/esm/array-base/symbols.mjs.map +1 -1
- package/esm/array-base/utils.mjs +31 -38
- package/esm/array-base/utils.mjs.map +1 -1
- package/esm/array-cards/index.mjs +33 -36
- package/esm/array-cards/index.mjs.map +1 -1
- package/esm/array-collapse/index.mjs +38 -43
- package/esm/array-collapse/index.mjs.map +1 -1
- package/esm/array-collapse/utils.mjs +2 -9
- package/esm/array-collapse/utils.mjs.map +1 -1
- package/esm/array-items/index.mjs +34 -38
- package/esm/array-items/index.mjs.map +1 -1
- package/esm/array-list-tabs/index.mjs +39 -41
- package/esm/array-list-tabs/index.mjs.map +1 -1
- package/esm/array-list-tabs/utils.mjs +5 -12
- package/esm/array-list-tabs/utils.mjs.map +1 -1
- package/esm/array-table/index.mjs +63 -68
- package/esm/array-table/index.mjs.map +1 -1
- package/esm/array-table/utils.mjs +11 -18
- package/esm/array-table/utils.mjs.map +1 -1
- package/esm/array-tabs/index.mjs +25 -29
- package/esm/array-tabs/index.mjs.map +1 -1
- package/esm/autocomplete/autocomplete.d.ts +16 -16
- package/esm/autocomplete/index.d.ts +8 -8
- package/esm/autocomplete/index.mjs +18 -24
- package/esm/autocomplete/index.mjs.map +1 -1
- package/esm/cascader/index.mjs +18 -22
- package/esm/cascader/index.mjs.map +1 -1
- package/esm/checkbox/index.d.ts +27 -27
- package/esm/checkbox/index.mjs +21 -30
- package/esm/checkbox/index.mjs.map +1 -1
- package/esm/color-picker/index.mjs +6 -9
- package/esm/color-picker/index.mjs.map +1 -1
- package/esm/color-picker-panel/index.mjs +6 -9
- package/esm/color-picker-panel/index.mjs.map +1 -1
- package/esm/date-picker/index.mjs +11 -14
- package/esm/date-picker/index.mjs.map +1 -1
- package/esm/date-picker/utils.mjs.map +1 -1
- package/esm/date-picker-panel/index.mjs +11 -14
- package/esm/date-picker-panel/index.mjs.map +1 -1
- package/esm/editable/editable.d.ts +12 -12
- package/esm/editable/index.d.ts +6 -6
- package/esm/editable/index.mjs +49 -58
- package/esm/editable/index.mjs.map +1 -1
- package/esm/env.d.d.ts +1 -0
- package/esm/form/form.mjs +10 -10
- package/esm/form/form.mjs.map +1 -1
- package/esm/form-button-group/index.mjs +14 -25
- package/esm/form-button-group/index.mjs.map +1 -1
- package/esm/form-button-group/utils.mjs +2 -9
- package/esm/form-button-group/utils.mjs.map +1 -1
- package/esm/form-collapse/index.mjs +19 -22
- package/esm/form-collapse/index.mjs.map +1 -1
- package/esm/form-collapse/utils.mjs +0 -2
- package/esm/form-collapse/utils.mjs.map +1 -1
- package/esm/form-dialog/index.mjs +63 -70
- package/esm/form-dialog/index.mjs.map +1 -1
- package/esm/form-drawer/index.mjs +62 -69
- package/esm/form-drawer/index.mjs.map +1 -1
- package/esm/form-grid/form-grid.d.ts +2 -2
- package/esm/form-grid/hooks.d.ts +1 -2
- package/esm/form-grid/hooks.mjs +4 -11
- package/esm/form-grid/hooks.mjs.map +1 -1
- package/esm/form-grid/index.mjs +39 -40
- package/esm/form-grid/index.mjs.map +1 -1
- package/esm/form-item/index.mjs +57 -65
- package/esm/form-item/index.mjs.map +1 -1
- package/esm/form-item/types.d.ts +8 -6
- package/esm/form-item/utils.mjs.map +1 -1
- package/esm/form-layout/form-layout.mjs +12 -16
- package/esm/form-layout/form-layout.mjs.map +1 -1
- package/esm/form-layout/utils.mjs +2 -2
- package/esm/form-layout/utils.mjs.map +1 -1
- package/esm/form-step/index.mjs +27 -30
- package/esm/form-step/index.mjs.map +1 -1
- package/esm/form-step/utils.mjs +0 -3
- package/esm/form-step/utils.mjs.map +1 -1
- package/esm/form-tab/hooks.d.ts +2 -1
- package/esm/form-tab/hooks.mjs +13 -20
- package/esm/form-tab/hooks.mjs.map +1 -1
- package/esm/form-tab/index.mjs +38 -41
- package/esm/form-tab/index.mjs.map +1 -1
- package/esm/form-tab/utils.mjs.map +1 -1
- package/esm/index.mjs +76 -76
- package/esm/input/index.mjs +26 -30
- package/esm/input/index.mjs.map +1 -1
- package/esm/input-number/index.d.ts +15 -15
- package/esm/input-number/index.mjs +8 -11
- package/esm/input-number/index.mjs.map +1 -1
- package/esm/input-tag/index.mjs +16 -20
- package/esm/input-tag/index.mjs.map +1 -1
- package/esm/mention/index.mjs +20 -24
- package/esm/mention/index.mjs.map +1 -1
- package/esm/pagination/components/jumper.mjs.map +1 -1
- package/esm/pagination/components/next.mjs.map +1 -1
- package/esm/pagination/components/pager.mjs.map +1 -1
- package/esm/pagination/components/prev.mjs.map +1 -1
- package/esm/pagination/components/total.mjs.map +1 -1
- package/esm/pagination/pagination.mjs +1 -1
- package/esm/pagination/pagination.mjs.map +1 -1
- package/esm/password/index.mjs.map +1 -1
- package/esm/preview-text/index.mjs +27 -40
- package/esm/preview-text/index.mjs.map +1 -1
- package/esm/preview-text/utils.mjs +1 -1
- package/esm/preview-text/utils.mjs.map +1 -1
- package/esm/query-form/default-components.mjs.map +1 -1
- package/esm/query-form/hooks.mjs.map +1 -1
- package/esm/query-form/index.d.ts +3 -3
- package/esm/query-form/index.mjs +55 -61
- package/esm/query-form/index.mjs.map +1 -1
- package/esm/query-form/query-form.d.ts +1 -1
- package/esm/query-form/types.d.ts +1 -1
- package/esm/query-form-item/index.mjs +37 -44
- package/esm/query-form-item/index.mjs.map +1 -1
- package/esm/radio/index.d.ts +18 -18
- package/esm/radio/index.mjs +30 -39
- package/esm/radio/index.mjs.map +1 -1
- package/esm/rate/index.mjs +10 -13
- package/esm/rate/index.mjs.map +1 -1
- package/esm/reset/index.mjs +2 -2
- package/esm/reset/index.mjs.map +1 -1
- package/esm/segmented/index.mjs +13 -17
- package/esm/segmented/index.mjs.map +1 -1
- package/esm/select/index.d.ts +16 -16
- package/esm/select/index.mjs +22 -26
- package/esm/select/index.mjs.map +1 -1
- package/esm/select-table/index.d.ts +6 -6
- package/esm/select-table/index.mjs +16 -21
- package/esm/select-table/index.mjs.map +1 -1
- package/esm/select-table/select-table.d.ts +2 -2
- package/esm/shared/overlay-elements.mjs.map +1 -1
- package/esm/slider/index.mjs +10 -13
- package/esm/slider/index.mjs.map +1 -1
- package/esm/styles/form-grid/index.css +1 -1
- package/esm/submit/index.mjs +3 -3
- package/esm/submit/index.mjs.map +1 -1
- package/esm/switch/index.d.ts +9 -9
- package/esm/switch/index.mjs.map +1 -1
- package/esm/time-picker/index.mjs +6 -9
- package/esm/time-picker/index.mjs.map +1 -1
- package/esm/time-select/index.d.ts +12 -12
- package/esm/time-select/index.mjs +6 -9
- package/esm/time-select/index.mjs.map +1 -1
- package/esm/transfer/index.d.ts +12 -12
- package/esm/transfer/index.mjs.map +1 -1
- package/esm/tree/index.mjs +29 -33
- package/esm/tree/index.mjs.map +1 -1
- package/esm/tree/utils.mjs +0 -2
- package/esm/tree/utils.mjs.map +1 -1
- package/esm/tree-select/index.mjs +14 -18
- package/esm/tree-select/index.mjs.map +1 -1
- package/esm/upload/index.d.ts +12 -12
- package/esm/upload/index.mjs +10 -13
- package/esm/upload/index.mjs.map +1 -1
- package/esm/upload/upload.d.ts +24 -24
- package/esm/vendor/icon.mjs.map +1 -1
- package/esm/vendor/lodash.mjs +111 -85
- package/esm/vendor/lodash.mjs.map +1 -1
- package/esm/vendor/runtime.mjs +23 -29
- package/esm/vendor/runtime.mjs.map +1 -1
- package/esm/vendor/shared.esm-bundler.mjs +2 -7
- package/esm/vendor/shared.esm-bundler.mjs.map +1 -1
- package/esm/vendor/sizes.mjs.map +1 -1
- package/esm/vendor/types.mjs +5 -5
- package/esm/vendor/types.mjs.map +1 -1
- package/package.json +56 -82
- package/LICENSE +0 -21
package/esm/form-item/index.mjs
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import { isVoidField as ce } from "@formily/core";
|
|
2
2
|
import { useField as fe, connect as ve, mapProps as pe } from "@silver-formily/vue";
|
|
3
|
-
import {
|
|
4
|
-
import "@
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import "
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { i as Ne } from "../vendor/shared.esm-bundler.mjs";
|
|
16
|
-
import { getFeedbackMessage as Oe, determineFeedbackStatus as qe } from "./utils.mjs";
|
|
3
|
+
import { defineComponent as me, useSlots as be, computed as s, ref as b, reactive as ye, watch as ke, provide as D, openBlock as a, createElementBlock as n, unref as l, normalizeClass as u, createBlock as f, resolveDynamicComponent as g, normalizeStyle as F, withCtx as m, isVNode as h, createVNode as x, createElementVNode as C, toDisplayString as y, Fragment as I, createTextVNode as R, createCommentVNode as c, renderSlot as G, TransitionGroup as ge } from "vue";
|
|
4
|
+
import { InfoFilled as Se, CircleClose as he, CircleCheck as xe, Warning as Ce } from "@element-plus/icons-vue";
|
|
5
|
+
import { isValid as v, isArr as Ie } from "@formily/shared";
|
|
6
|
+
import { useResizeObserver as _e } from "@vueuse/core";
|
|
7
|
+
import { useNamespace as $e, useFormSize as we, useId as Fe, formItemContextKey as We, ElTooltip as E, ElIcon as K } from "element-plus";
|
|
8
|
+
import { FORM_LAYOUT_PROPS_KEYS as Ae, useFormLayout as Le, formLayoutShallowContext as ze } from "../form-layout/utils.mjs";
|
|
9
|
+
import { p as Be } from "../vendor/lodash.mjs";
|
|
10
|
+
import { i as Te, a as Re, d as Ee } from "../vendor/types.mjs";
|
|
11
|
+
import { a as Ve } from "../vendor/shared.esm-bundler.mjs";
|
|
12
|
+
import { stylePrefix as Pe } from "../__builtins__/configs/index.mjs";
|
|
13
|
+
import { getFeedbackMessage as Ne, determineFeedbackStatus as Oe } from "./utils.mjs";
|
|
14
|
+
import { composeExport as qe } from "../__builtins__/shared/utils.mjs";
|
|
17
15
|
import '../styles/form-item/index.css';const Me = "utils/dom/style";
|
|
18
16
|
function U(i, p = "px") {
|
|
19
17
|
if (!i && i !== 0) return "";
|
|
20
|
-
if (
|
|
18
|
+
if (Te(i) || Re(i))
|
|
21
19
|
return `${i}${p}`;
|
|
22
|
-
if (
|
|
20
|
+
if (Ve(i))
|
|
23
21
|
return i;
|
|
24
|
-
|
|
22
|
+
Ee(Me, "binding value must be a string or number");
|
|
25
23
|
}
|
|
26
|
-
const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */
|
|
24
|
+
const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ me({
|
|
27
25
|
name: "FFormItem",
|
|
28
26
|
__name: "form-item",
|
|
29
27
|
props: {
|
|
@@ -52,21 +50,21 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
52
50
|
tooltipLayout: {}
|
|
53
51
|
},
|
|
54
52
|
setup(i, { expose: p }) {
|
|
55
|
-
const e = i, W =
|
|
53
|
+
const e = i, W = be(), o = $e("form-item"), d = `${Pe}-form-item`, H = s(() => e.internalFormItemClass || o.b()), J = s(
|
|
56
54
|
() => Object.fromEntries(
|
|
57
|
-
Object.entries(
|
|
55
|
+
Object.entries(Be(e, Ae)).filter(([r, w]) => v(w))
|
|
58
56
|
)
|
|
59
|
-
), Q =
|
|
57
|
+
), Q = Le(), t = s(() => Object.assign({
|
|
60
58
|
colon: !0,
|
|
61
59
|
feedbackLayout: "loose",
|
|
62
60
|
fullness: !1,
|
|
63
61
|
labelWrap: !1
|
|
64
|
-
}, Q.value, J.value)), V = fe(), X =
|
|
62
|
+
}, Q.value, J.value)), V = fe(), X = we(void 0, { formItem: !1 }), P = s(() => v(t.value.size) ? t.value.size : X.value), A = Fe().value, k = b([]), N = b(""), O = b(), S = b(), q = b();
|
|
65
63
|
p({
|
|
66
64
|
feedbackTooltipRef: q
|
|
67
65
|
});
|
|
68
66
|
const _ = s(
|
|
69
|
-
() => t.value.layout === "vertical" ||
|
|
67
|
+
() => t.value.layout === "vertical" || Ie(t.value.layout) && t.value.layout.includes("vertical") ? "top" : t.value.labelAlign ?? "right"
|
|
70
68
|
), Z = s(() => {
|
|
71
69
|
if (_.value === "top")
|
|
72
70
|
return {};
|
|
@@ -101,24 +99,18 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
101
99
|
async function oe() {
|
|
102
100
|
return !0;
|
|
103
101
|
}
|
|
104
|
-
/* istanbul ignore next -- @preserve */
|
|
105
102
|
const re = () => {
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const se = async () => {
|
|
109
|
-
};
|
|
110
|
-
/* istanbul ignore next -- @preserve */
|
|
111
|
-
const ie = () => {
|
|
103
|
+
}, se = async () => {
|
|
104
|
+
}, ie = () => {
|
|
112
105
|
}, ne = (r) => {
|
|
113
|
-
/* istanbul ignore else -- @preserve */
|
|
114
106
|
k.value.includes(r) || k.value.push(r);
|
|
115
107
|
}, ue = (r) => {
|
|
116
108
|
k.value = k.value.filter((w) => w !== r);
|
|
117
109
|
}, j = b(!1);
|
|
118
|
-
|
|
110
|
+
_e(S, () => {
|
|
119
111
|
j.value = S.value?.scrollWidth > S.value?.clientWidth;
|
|
120
112
|
});
|
|
121
|
-
const T = s(() => j.value && !t.value.labelWrap), de = b(""), $ =
|
|
113
|
+
const T = s(() => j.value && !t.value.labelWrap), de = b(""), $ = ye({
|
|
122
114
|
$el: O,
|
|
123
115
|
labelWidth: t.value?.labelWidth,
|
|
124
116
|
size: P,
|
|
@@ -140,7 +132,7 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
140
132
|
propString: "",
|
|
141
133
|
setInitialValue: ie
|
|
142
134
|
});
|
|
143
|
-
return
|
|
135
|
+
return ke(() => e.feedbackStatus, (r) => {
|
|
144
136
|
if (r === "pending") {
|
|
145
137
|
$.validateState = "validating";
|
|
146
138
|
return;
|
|
@@ -152,10 +144,10 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
152
144
|
$.validateState = r;
|
|
153
145
|
}, {
|
|
154
146
|
immediate: !0
|
|
155
|
-
}),
|
|
147
|
+
}), D(ze, b({
|
|
156
148
|
...v(t.value.size) && { size: t.value.size },
|
|
157
149
|
...v(t.value.colon) && { colon: t.value.colon }
|
|
158
|
-
})),
|
|
150
|
+
})), D(We, $), (r, w) => (a(), n("div", {
|
|
159
151
|
ref_key: "formItemRef",
|
|
160
152
|
ref: O,
|
|
161
153
|
class: u([d, t.value.labelWrap && "is-warp", ...le.value]),
|
|
@@ -170,34 +162,34 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
170
162
|
style: F(Z.value)
|
|
171
163
|
}, {
|
|
172
164
|
default: m(() => [
|
|
173
|
-
|
|
165
|
+
h(e.label) ? (a(), f(g(e.label), { key: 0 })) : (a(), n("div", {
|
|
174
166
|
key: 1,
|
|
175
167
|
class: u(`${d}-label__wrapper`)
|
|
176
168
|
}, [
|
|
177
|
-
|
|
169
|
+
x(l(E), {
|
|
178
170
|
disabled: !T.value && t.value.tooltipLayout !== "text"
|
|
179
171
|
}, {
|
|
180
172
|
content: m(() => [
|
|
181
|
-
|
|
173
|
+
h(e.tooltip) ? (a(), f(g(e.tooltip), { key: 0 })) : (a(), n("div", {
|
|
182
174
|
key: 1,
|
|
183
175
|
style: F(`width: ${S.value?.clientWidth ?? 0}px;`)
|
|
184
176
|
}, [
|
|
185
177
|
T.value ? (a(), n(I, { key: 0 }, [
|
|
186
|
-
|
|
178
|
+
R(y(e.label), 1)
|
|
187
179
|
], 64)) : c("", !0),
|
|
188
180
|
t.value.tooltipLayout === "text" ? (a(), n(I, { key: 1 }, [
|
|
189
|
-
|
|
181
|
+
R(y(e.tooltip), 1)
|
|
190
182
|
], 64)) : c("", !0)
|
|
191
183
|
], 4))
|
|
192
184
|
]),
|
|
193
185
|
default: m(() => [
|
|
194
|
-
|
|
186
|
+
C("span", {
|
|
195
187
|
class: u({
|
|
196
188
|
[`${d}-label-content`]: !0,
|
|
197
189
|
"is-tooltip": T.value || e.tooltip && t.value.tooltipLayout === "text"
|
|
198
190
|
})
|
|
199
191
|
}, [
|
|
200
|
-
|
|
192
|
+
C("span", {
|
|
201
193
|
ref_key: "labelRef",
|
|
202
194
|
ref: S
|
|
203
195
|
}, y(e.label), 513)
|
|
@@ -205,16 +197,16 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
205
197
|
]),
|
|
206
198
|
_: 1
|
|
207
199
|
}, 8, ["disabled"]),
|
|
208
|
-
e.tooltip && t.value.tooltipLayout !== "text" ? (a(), f(l(
|
|
200
|
+
e.tooltip && t.value.tooltipLayout !== "text" ? (a(), f(l(E), {
|
|
209
201
|
key: 0,
|
|
210
202
|
content: e.tooltip
|
|
211
203
|
}, {
|
|
212
204
|
default: m(() => [
|
|
213
|
-
|
|
205
|
+
x(l(K), {
|
|
214
206
|
class: u(`${d}-label-tooltip`)
|
|
215
207
|
}, {
|
|
216
208
|
default: m(() => [
|
|
217
|
-
|
|
209
|
+
x(l(Se))
|
|
218
210
|
]),
|
|
219
211
|
_: 1
|
|
220
212
|
}, 8, ["class"])
|
|
@@ -229,7 +221,7 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
229
221
|
]),
|
|
230
222
|
_: 1
|
|
231
223
|
}, 8, ["id", "for", "class", "style"])) : c("", !0),
|
|
232
|
-
|
|
224
|
+
C("div", {
|
|
233
225
|
class: u([
|
|
234
226
|
`${d}-content__wrapper`,
|
|
235
227
|
l(v)(t.value.wrapperCol) && `${d}-col-${t.value.wrapperCol}`
|
|
@@ -237,12 +229,12 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
237
229
|
style: F(te.value)
|
|
238
230
|
}, [
|
|
239
231
|
l(v)(e.addonBefore) ? (a(), n(I, { key: 0 }, [
|
|
240
|
-
|
|
232
|
+
h(e.addonBefore) ? (a(), f(g(e.addonBefore), { key: 0 })) : (a(), n("div", {
|
|
241
233
|
key: 1,
|
|
242
234
|
class: u(`${d}-addon-before`)
|
|
243
235
|
}, y(e.addonBefore), 3))
|
|
244
236
|
], 64)) : c("", !0),
|
|
245
|
-
|
|
237
|
+
C("div", {
|
|
246
238
|
class: u([
|
|
247
239
|
l(o).e("content"),
|
|
248
240
|
t.value.fullness && "is-fullness",
|
|
@@ -250,7 +242,7 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
250
242
|
]),
|
|
251
243
|
style: F(ee.value)
|
|
252
244
|
}, [
|
|
253
|
-
t.value.feedbackLayout === "popover" ? (a(), f(l(
|
|
245
|
+
t.value.feedbackLayout === "popover" ? (a(), f(l(E), {
|
|
254
246
|
key: 0,
|
|
255
247
|
ref_key: "feedbackTooltipRef",
|
|
256
248
|
ref: q,
|
|
@@ -259,26 +251,26 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
259
251
|
offset: 6
|
|
260
252
|
}, {
|
|
261
253
|
default: m(() => [
|
|
262
|
-
|
|
254
|
+
G(r.$slots, "default")
|
|
263
255
|
]),
|
|
264
256
|
content: m(() => [
|
|
265
|
-
|
|
257
|
+
C("div", {
|
|
266
258
|
class: u([...M.value, l(o).is("tooltip")])
|
|
267
259
|
}, [
|
|
268
|
-
|
|
260
|
+
x(l(K), null, {
|
|
269
261
|
default: m(() => [
|
|
270
|
-
e.feedbackStatus === "error" ? (a(), f(l(
|
|
271
|
-
e.feedbackStatus === "success" ? (a(), f(l(
|
|
272
|
-
e.feedbackStatus === "warning" ? (a(), f(l(
|
|
262
|
+
e.feedbackStatus === "error" ? (a(), f(l(he), { key: 0 })) : c("", !0),
|
|
263
|
+
e.feedbackStatus === "success" ? (a(), f(l(xe), { key: 1 })) : c("", !0),
|
|
264
|
+
e.feedbackStatus === "warning" ? (a(), f(l(Ce), { key: 2 })) : c("", !0)
|
|
273
265
|
]),
|
|
274
266
|
_: 1
|
|
275
267
|
}),
|
|
276
|
-
|
|
268
|
+
R(" " + y(e.feedbackText), 1)
|
|
277
269
|
], 2)
|
|
278
270
|
]),
|
|
279
271
|
_: 3
|
|
280
|
-
}, 8, ["visible"])) :
|
|
281
|
-
|
|
272
|
+
}, 8, ["visible"])) : G(r.$slots, "default", { key: 1 }),
|
|
273
|
+
x(ge, {
|
|
282
274
|
name: `${l(o).namespace.value}-zoom-in-top`
|
|
283
275
|
}, {
|
|
284
276
|
default: m(() => [
|
|
@@ -287,7 +279,7 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
287
279
|
class: u(M.value)
|
|
288
280
|
}, y(e.feedbackText), 3)) : c("", !0),
|
|
289
281
|
l(v)(e.extra) ? (a(), n(I, { key: 1 }, [
|
|
290
|
-
|
|
282
|
+
h(e.extra) ? (a(), f(g(e.extra), { key: 0 })) : (a(), n("div", {
|
|
291
283
|
key: 1,
|
|
292
284
|
class: u(`${d}-extra`)
|
|
293
285
|
}, y(e.extra), 3))
|
|
@@ -297,7 +289,7 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
297
289
|
}, 8, ["name"])
|
|
298
290
|
], 6),
|
|
299
291
|
l(v)(e.addonAfter) ? (a(), n(I, { key: 1 }, [
|
|
300
|
-
|
|
292
|
+
h(e.addonAfter) ? (a(), f(g(e.addonAfter), { key: 0 })) : (a(), n("div", {
|
|
301
293
|
key: 1,
|
|
302
294
|
class: u(`${d}-addon-after`)
|
|
303
295
|
}, y(e.addonAfter), 3))
|
|
@@ -309,7 +301,7 @@ const je = ["role", "aria-labelledby"], Y = /* @__PURE__ */ Se({
|
|
|
309
301
|
function De(i, p) {
|
|
310
302
|
if (ce(p) || !p)
|
|
311
303
|
return i;
|
|
312
|
-
const e =
|
|
304
|
+
const e = Ne(p), W = Oe(p), o = "asterisk" in i ? i.asterisk : p.required && p.pattern !== "readPretty";
|
|
313
305
|
return {
|
|
314
306
|
...i,
|
|
315
307
|
feedbackText: e,
|
|
@@ -328,13 +320,13 @@ const Ge = ve(
|
|
|
328
320
|
},
|
|
329
321
|
De
|
|
330
322
|
)
|
|
331
|
-
),
|
|
323
|
+
), st = qe(Ge, {
|
|
332
324
|
BaseItem: Y
|
|
333
325
|
});
|
|
334
326
|
export {
|
|
335
327
|
Y as FormBaseItem,
|
|
336
|
-
|
|
337
|
-
|
|
328
|
+
st as FormItem,
|
|
329
|
+
st as default,
|
|
338
330
|
De as fieldFeedbackMapper
|
|
339
331
|
};
|
|
340
332
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../node_modules/.pnpm/element-plus@2.13.2_vue@3.5.22_typescript@5.9.3_/node_modules/element-plus/es/utils/dom/style.mjs","../../src/form-item/form-item.vue","../../src/form-item/index.ts"],"sourcesContent":["import { isNumber, isStringNumber } from '../types.mjs';\nimport { isClient } from '@vueuse/core';\nimport { isString, camelize, isObject } from '@vue/shared';\nimport { entriesOf, keysOf } from '../objects.mjs';\nimport { debugWarn } from '../error.mjs';\n\nconst SCOPE = \"utils/dom/style\";\nconst classNameToArray = (cls = \"\") => cls.split(\" \").filter((item) => !!item.trim());\nconst hasClass = (el, cls) => {\n if (!el || !cls) return false;\n if (cls.includes(\" \")) throw new Error(\"className should not contain space.\");\n return el.classList.contains(cls);\n};\nconst addClass = (el, cls) => {\n if (!el || !cls.trim()) return;\n el.classList.add(...classNameToArray(cls));\n};\nconst removeClass = (el, cls) => {\n if (!el || !cls.trim()) return;\n el.classList.remove(...classNameToArray(cls));\n};\nconst getStyle = (element, styleName) => {\n var _a;\n if (!isClient || !element || !styleName) return \"\";\n let key = camelize(styleName);\n if (key === \"float\") key = \"cssFloat\";\n try {\n const style = element.style[key];\n if (style) return style;\n const computed = (_a = document.defaultView) == null ? void 0 : _a.getComputedStyle(element, \"\");\n return computed ? computed[key] : \"\";\n } catch (e) {\n return element.style[key];\n }\n};\nconst setStyle = (element, styleName, value) => {\n if (!element || !styleName) return;\n if (isObject(styleName)) {\n entriesOf(styleName).forEach(\n ([prop, value2]) => setStyle(element, prop, value2)\n );\n } else {\n const key = camelize(styleName);\n element.style[key] = value;\n }\n};\nconst removeStyle = (element, style) => {\n if (!element || !style) return;\n if (isObject(style)) {\n keysOf(style).forEach((prop) => removeStyle(element, prop));\n } else {\n setStyle(element, style, \"\");\n }\n};\nfunction addUnit(value, defaultUnit = \"px\") {\n if (!value && value !== 0) return \"\";\n if (isNumber(value) || isStringNumber(value)) {\n return `${value}${defaultUnit}`;\n } else if (isString(value)) {\n return value;\n }\n debugWarn(SCOPE, \"binding value must be a string or number\");\n}\n\nexport { addClass, addUnit, classNameToArray, getStyle, hasClass, removeClass, removeStyle, setStyle };\n//# sourceMappingURL=style.mjs.map\n","<script lang=\"ts\" setup>\nimport type { Field } from '@formily/core'\nimport type {\n FormItemContext,\n FormItemValidateState,\n FormValidationResult,\n TooltipInstance,\n} from 'element-plus'\nimport type { ICalculatedFormLayoutProps } from 'src/form-layout/types'\nimport type { CSSProperties } from 'vue'\nimport type { IFormItemProps } from './types'\nimport { CircleCheck, CircleClose, InfoFilled, Warning } from '@element-plus/icons-vue'\nimport { isArr, isValid } from '@formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport { useResizeObserver } from '@vueuse/core'\nimport { ElIcon, ElTooltip, formItemContextKey, useFormSize, useId, useNamespace } from 'element-plus'\nimport { addUnit } from 'element-plus/es/utils/index'\nimport { pick } from 'lodash-es'\nimport { computed, isVNode, provide, reactive, ref, useSlots, watch } from 'vue'\nimport { stylePrefix } from '../__builtins__'\nimport { FORM_LAYOUT_PROPS_KEYS, formLayoutShallowContext, useFormLayout } from '../form-layout/utils'\n\ndefineOptions({\n name: 'FFormItem',\n})\nconst props = withDefaults(defineProps<IFormItemProps>(), {\n asterisk: undefined,\n colon: undefined,\n labelWrap: undefined,\n fullness: undefined,\n})\nconst slots = useSlots()\nconst ns = useNamespace('form-item')\nconst prefixCls = `${stylePrefix}-form-item`\nconst rootFormItemClass = computed(() => props.internalFormItemClass || ns.b())\nconst formItemConfig = computed<Partial<ICalculatedFormLayoutProps>>(() =>\n Object.fromEntries(\n Object.entries(pick(props, FORM_LAYOUT_PROPS_KEYS))\n .filter(([_, value]) => isValid(value)),\n ),\n)\nconst formlayoutConfig = useFormLayout()\nconst formlayout = computed(() => Object.assign({\n colon: true,\n feedbackLayout: 'loose',\n fullness: false,\n labelWrap: false,\n}, formlayoutConfig.value, formItemConfig.value))\nconst field = useField<Field>()\n\nconst inheritedSize = useFormSize(undefined, { formItem: false })\nconst formItemSize = computed(() => {\n if (isValid(formlayout.value.size)) {\n return formlayout.value.size\n }\n return inheritedSize.value\n})\n\nconst labelId = useId().value\nconst inputIds = ref<string[]>([])\n\nconst validateState = ref<FormItemValidateState>('')\nconst formItemRef = ref<HTMLDivElement>()\nconst labelRef = ref<HTMLElement>()\nconst feedbackTooltipRef = ref<TooltipInstance>()\ndefineExpose({\n feedbackTooltipRef,\n})\n\nconst labelPosition = computed(\n () => {\n if (formlayout.value.layout === 'vertical' || (isArr(formlayout.value.layout) && formlayout.value.layout.includes('vertical' as any))) {\n return 'top'\n }\n return formlayout.value.labelAlign ?? 'right'\n },\n)\n\nconst labelStyle = computed<CSSProperties>(() => {\n if (labelPosition.value === 'top') {\n return {}\n }\n\n const labelWidth = addUnit(formlayout.value.labelWidth || '')\n if (labelWidth)\n return { width: labelWidth }\n return {}\n})\n\nconst contentStyle = computed<CSSProperties>(() => {\n const contentWidth = addUnit(formlayout.value?.wrapperWidth || '')\n if (contentWidth)\n return { width: contentWidth, flex: 'unset' }\n return {}\n})\n\nconst contentWrapperStyle = computed<CSSProperties>(() => {\n return {\n justifyContent: formlayout.value?.wrapperAlign === 'right' && 'flex-end',\n }\n})\n\nconst isRequired = computed(() =>\n props.asterisk && field.value?.pattern !== 'readPretty',\n)\n\nconst formItemClasses = computed(() => [\n rootFormItemClass.value,\n ns.m(formItemSize.value || 'default'),\n ns.is(props.feedbackStatus),\n ns.is('validating', validateState.value === 'validating'),\n ns.is('success', validateState.value === 'success'),\n ns.is('required', isRequired.value || props.asterisk),\n ns.is('no-asterisk', formlayout.value?.hideRequiredAsterisk),\n ns.is(formlayout.value.feedbackLayout),\n formlayout.value?.requireAsteriskPosition === 'right'\n ? 'asterisk-right'\n : 'asterisk-left',\n {\n [ns.m('feedback')]: formlayout.value?.statusIcon,\n [ns.m(`label-${labelPosition.value}`)]: labelPosition.value,\n },\n])\n\nconst validateClasses = computed(() => [\n `${prefixCls}-feedback`,\n ns.is(props.feedbackStatus),\n ns.is('loose', formlayout.value.feedbackLayout === 'loose'),\n])\n\nconst hasLabel = computed<boolean>(() => {\n return (props.label !== '' && isValid(props.label)) || isValid(slots.label)\n})\n\nconst labelFor = computed<string | undefined>(() => {\n return (\n props.for || (inputIds.value.length === 1 ? inputIds.value[0] : undefined)\n )\n})\n\nconst isGroup = computed<boolean>(() => {\n return !labelFor.value && hasLabel.value\n})\n\nasync function validate(): FormValidationResult {\n return true\n}\n/* istanbul ignore next -- @preserve */\nconst clearValidate: FormItemContext['clearValidate'] = () => {}\n/* istanbul ignore next -- @preserve */\nconst resetField: FormItemContext['resetField'] = async () => {}\n/* istanbul ignore next -- @preserve */\nconst setInitialValue: FormItemContext['setInitialValue'] = () => {}\n\nconst addInputId: FormItemContext['addInputId'] = (id: string) => {\n /* istanbul ignore else -- @preserve */\n if (!inputIds.value.includes(id)) {\n inputIds.value.push(id)\n }\n}\n\nconst removeInputId: FormItemContext['removeInputId'] = (id: string) => {\n inputIds.value = inputIds.value.filter(listId => listId !== id)\n}\n\nconst isEllipsisActive = ref(false)\nuseResizeObserver(labelRef, () => {\n isEllipsisActive.value = labelRef.value?.scrollWidth > labelRef.value?.clientWidth\n})\nconst isEllipsis = computed(() => {\n return isEllipsisActive.value && !formlayout.value.labelWrap\n})\n\n// HACK computed无法监听到props.feedbackStatus的变化\nconst _validateState = ref<FormItemValidateState>('')\nconst context: FormItemContext = reactive({\n $el: formItemRef,\n labelWidth: formlayout.value?.labelWidth,\n size: formItemSize,\n validateState: _validateState.value,\n labelId,\n inputIds,\n isGroup,\n hasLabel,\n addInputId,\n removeInputId,\n resetField,\n clearValidate,\n validate,\n labelPosition,\n inlineMessage: true,\n showMessage: true,\n fieldValue: field.value?.value,\n validateMessage: '',\n propString: '',\n setInitialValue,\n})\nwatch(() => props.feedbackStatus, (val) => {\n if (val === 'pending') {\n context.validateState = 'validating'\n return\n }\n if (val === 'warning') {\n context.validateState = ''\n return\n }\n context.validateState = val\n}, {\n immediate: true,\n})\n\nprovide(formLayoutShallowContext, ref({\n ...(isValid(formlayout.value.size) && { size: formlayout.value.size }),\n ...(isValid(formlayout.value.colon) && { colon: formlayout.value.colon }),\n}))\nprovide(formItemContextKey, context)\n</script>\n\n<template>\n <div\n ref=\"formItemRef\" :class=\"[prefixCls, formlayout.labelWrap && 'is-warp', ...formItemClasses]\"\n :role=\"isGroup ? 'group' : undefined\" :aria-labelledby=\"isGroup ? labelId : undefined\"\n >\n <component\n :is=\"labelFor ? 'label' : 'div'\" v-if=\"hasLabel\" :id=\"labelId\" :for=\"labelFor\"\n :class=\"[ns.e('label'), isValid(formlayout.labelCol) && `${prefixCls}-col-${formlayout.labelCol}`]\"\n :style=\"labelStyle\"\n >\n <!-- label -->\n <template v-if=\"isVNode(props.label)\">\n <component :is=\"props.label\" />\n </template>\n <div v-else :class=\"`${prefixCls}-label__wrapper`\">\n <ElTooltip :disabled=\"!isEllipsis && formlayout.tooltipLayout !== 'text'\">\n <span\n :class=\"{\n [`${prefixCls}-label-content`]: true,\n ['is-tooltip']: isEllipsis || (props.tooltip && formlayout.tooltipLayout === 'text'),\n }\"\n >\n <span ref=\"labelRef\">{{ props.label }}</span>\n </span>\n <template #content>\n <template v-if=\"isVNode(props.tooltip)\">\n <component :is=\"props.tooltip\" />\n </template>\n <div v-else :style=\"`width: ${labelRef?.clientWidth ?? 0}px;`\">\n <template v-if=\"isEllipsis\">\n {{ props.label }}\n </template>\n <template v-if=\"formlayout.tooltipLayout === 'text'\">\n {{ props.tooltip }}\n </template>\n </div>\n </template>\n </ElTooltip>\n <ElTooltip v-if=\"props.tooltip && formlayout.tooltipLayout !== 'text'\" :content=\"props.tooltip\">\n <ElIcon :class=\"`${prefixCls}-label-tooltip`\">\n <InfoFilled />\n </ElIcon>\n </ElTooltip>\n <span v-if=\"formlayout.colon\" :class=\"`${prefixCls}-colon`\">:</span>\n </div>\n </component>\n <!-- content -->\n <div\n :class=\"[\n `${prefixCls}-content__wrapper`,\n isValid(formlayout.wrapperCol) && `${prefixCls}-col-${formlayout.wrapperCol}`,\n ]\"\n :style=\"contentWrapperStyle\"\n >\n <template v-if=\"isValid(props.addonBefore)\">\n <template v-if=\"isVNode(props.addonBefore)\">\n <component :is=\"props.addonBefore\" />\n </template>\n <div v-else :class=\"`${prefixCls}-addon-before`\">\n {{ props.addonBefore }}\n </div>\n </template>\n <div\n :class=\"[\n ns.e('content'),\n formlayout.fullness && 'is-fullness',\n ns.is('addon-after', !!props.addonAfter),\n ]\" :style=\"contentStyle\"\n >\n <ElTooltip\n v-if=\"formlayout.feedbackLayout === 'popover'\"\n ref=\"feedbackTooltipRef\"\n :visible=\"!!props.feedbackText\"\n effect=\"light\"\n :offset=\"6\"\n >\n <template #default>\n <slot />\n </template>\n <template #content>\n <div :class=\"[...validateClasses, ns.is('tooltip')]\">\n <ElIcon>\n <CircleClose v-if=\"props.feedbackStatus === 'error'\" />\n <CircleCheck v-if=\"props.feedbackStatus === 'success'\" />\n <Warning v-if=\"props.feedbackStatus === 'warning'\" />\n </ElIcon>\n {{ props.feedbackText }}\n </div>\n </template>\n </ElTooltip>\n <slot v-else />\n <TransitionGroup :name=\"`${ns.namespace.value}-zoom-in-top`\">\n <div v-if=\"props.feedbackText && formlayout.feedbackLayout !== 'popover'\" :class=\"validateClasses\">\n {{ props.feedbackText }}\n </div>\n <template v-if=\"isValid(props.extra)\">\n <template v-if=\"isVNode(props.extra)\">\n <component :is=\"props.extra\" />\n </template>\n <div v-else :class=\"`${prefixCls}-extra`\">\n {{ props.extra }}\n </div>\n </template>\n </TransitionGroup>\n </div>\n <template v-if=\"isValid(props.addonAfter)\">\n <template v-if=\"isVNode(props.addonAfter)\">\n <component :is=\"props.addonAfter\" />\n </template>\n <div v-else :class=\"`${prefixCls}-addon-after`\">\n {{ props.addonAfter }}\n </div>\n </template>\n </div>\n </div>\n</template>\n","import { isVoidField } from '@formily/core'\nimport { connect, mapProps } from '@silver-formily/vue'\nimport { composeExport } from '../__builtins__'\nimport FormBaseItem from './form-item.vue'\nimport { determineFeedbackStatus, getFeedbackMessage } from './utils'\nimport './style.scss'\n\nexport function fieldFeedbackMapper(props, field) {\n if (isVoidField(field) || !field) {\n return props\n }\n\n const feedbackText = getFeedbackMessage(field)\n const feedbackStatus = determineFeedbackStatus(field)\n const asterisk = 'asterisk' in props\n ? props.asterisk\n : field.required && field.pattern !== 'readPretty'\n\n return {\n ...props,\n feedbackText,\n feedbackStatus,\n asterisk,\n }\n}\n\nconst Item = connect<typeof FormBaseItem>(\n FormBaseItem,\n mapProps(\n {\n validateStatus: true,\n title: 'label',\n required: true,\n description: 'extra',\n },\n fieldFeedbackMapper,\n ),\n)\n\nexport const FormItem = composeExport(Item, {\n BaseItem: FormBaseItem,\n})\n\nexport default FormItem\n\nexport { default as FormBaseItem } from './form-item.vue'\nexport type { IFormItemProps } from './types'\n"],"names":["SCOPE","addUnit","value","defaultUnit","isNumber","isStringNumber","isString","debugWarn","props","__props","slots","useSlots","ns","useNamespace","prefixCls","stylePrefix","rootFormItemClass","computed","formItemConfig","pick","FORM_LAYOUT_PROPS_KEYS","_","isValid","formlayoutConfig","useFormLayout","formlayout","field","useField","inheritedSize","useFormSize","formItemSize","labelId","useId","inputIds","ref","validateState","formItemRef","labelRef","feedbackTooltipRef","__expose","labelPosition","isArr","labelStyle","labelWidth","contentStyle","contentWidth","contentWrapperStyle","isRequired","formItemClasses","validateClasses","hasLabel","labelFor","isGroup","validate","clearValidate","resetField","setInitialValue","addInputId","id","removeInputId","listId","isEllipsisActive","useResizeObserver","isEllipsis","_validateState","context","reactive","watch","val","provide","formLayoutShallowContext","formItemContextKey","_createElementBlock","_unref","_openBlock","_createBlock","_resolveDynamicComponent","_normalizeClass","isVNode","_createVNode","ElTooltip","_normalizeStyle","_Fragment","_createTextVNode","_toDisplayString","_createElementVNode","ElIcon","InfoFilled","_renderSlot","_ctx","CircleClose","CircleCheck","Warning","_TransitionGroup","fieldFeedbackMapper","isVoidField","feedbackText","getFeedbackMessage","feedbackStatus","determineFeedbackStatus","asterisk","Item","connect","FormBaseItem","mapProps","FormItem","composeExport"],"mappings":";;;;;;;;;;;;;;;;AAMA,MAAMA,KAAQ;AAgDd,SAASC,EAAQC,GAAOC,IAAc,MAAM;AAC1C,MAAI,CAACD,KAASA,MAAU,EAAG,QAAO;AAClC,MAAIE,GAASF,CAAK,KAAKG,GAAeH,CAAK;AACzC,WAAO,GAAGA,CAAK,GAAGC,CAAW;AACxB,MAAIG,GAASJ,CAAK;AACvB,WAAOA;AAET,EAAAK,GAAUP,IAAO,0CAA0C;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrCA,UAAMQ,IAAQC,GAMRC,IAAQC,GAAA,GACRC,IAAKC,GAAa,WAAW,GAC7BC,IAAY,GAAGC,EAAW,cAC1BC,IAAoBC,EAAS,MAAMT,EAAM,yBAAyBI,EAAG,GAAG,GACxEM,IAAiBD;AAAA,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AAU,GAAA,EAAA,KAAA,EAAA,CAAA,WAElCgE,EAEM,OAAA;AAAA;YAFO,YAAU1D,CAAS,cAAA;AAAA,UAAA,GAC3BsE,EAAA5E,EAAM,UAAU,GAAA,CAAA;AAAA,QAAA;;;;;ACjUtB,SAASsF,GAAoBtF,GAAOkB,GAAO;AAChD,MAAIqE,GAAYrE,CAAK,KAAK,CAACA;AACzB,WAAOlB;AAGT,QAAMwF,IAAeC,GAAmBvE,CAAK,GACvCwE,IAAiBC,GAAwBzE,CAAK,GAC9C0E,IAAW,cAAc5F,IAC3BA,EAAM,WACNkB,EAAM,YAAYA,EAAM,YAAY;AAExC,SAAO;AAAA,IACL,GAAGlB;AAAA,IACH,cAAAwF;AAAA,IACA,gBAAAE;AAAA,IACA,UAAAE;AAAA,EAAA;AAEJ;AAEA,MAAMC,KAAOC;AAAA,EACXC;AAAAA,EACAC;AAAA,IACE;AAAA,MACE,gBAAgB;AAAA,MAChB,OAAO;AAAA,MACP,UAAU;AAAA,MACV,aAAa;AAAA,IAAA;AAAA,IAEfV;AAAA,EAAA;AAEJ,GAEaW,KAAWC,GAAcL,IAAM;AAAA,EAC1C,UAAUE;AACZ,CAAC;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../node_modules/.pnpm/element-plus@2.13.2_vue@3.5.28_typescript@5.9.2_/node_modules/element-plus/es/utils/dom/style.mjs","../../src/form-item/form-item.vue","../../src/form-item/index.ts"],"sourcesContent":["import { isNumber, isStringNumber } from '../types.mjs';\nimport { isClient } from '@vueuse/core';\nimport { isString, camelize, isObject } from '@vue/shared';\nimport { entriesOf, keysOf } from '../objects.mjs';\nimport { debugWarn } from '../error.mjs';\n\nconst SCOPE = \"utils/dom/style\";\nconst classNameToArray = (cls = \"\") => cls.split(\" \").filter((item) => !!item.trim());\nconst hasClass = (el, cls) => {\n if (!el || !cls) return false;\n if (cls.includes(\" \")) throw new Error(\"className should not contain space.\");\n return el.classList.contains(cls);\n};\nconst addClass = (el, cls) => {\n if (!el || !cls.trim()) return;\n el.classList.add(...classNameToArray(cls));\n};\nconst removeClass = (el, cls) => {\n if (!el || !cls.trim()) return;\n el.classList.remove(...classNameToArray(cls));\n};\nconst getStyle = (element, styleName) => {\n var _a;\n if (!isClient || !element || !styleName) return \"\";\n let key = camelize(styleName);\n if (key === \"float\") key = \"cssFloat\";\n try {\n const style = element.style[key];\n if (style) return style;\n const computed = (_a = document.defaultView) == null ? void 0 : _a.getComputedStyle(element, \"\");\n return computed ? computed[key] : \"\";\n } catch (e) {\n return element.style[key];\n }\n};\nconst setStyle = (element, styleName, value) => {\n if (!element || !styleName) return;\n if (isObject(styleName)) {\n entriesOf(styleName).forEach(\n ([prop, value2]) => setStyle(element, prop, value2)\n );\n } else {\n const key = camelize(styleName);\n element.style[key] = value;\n }\n};\nconst removeStyle = (element, style) => {\n if (!element || !style) return;\n if (isObject(style)) {\n keysOf(style).forEach((prop) => removeStyle(element, prop));\n } else {\n setStyle(element, style, \"\");\n }\n};\nfunction addUnit(value, defaultUnit = \"px\") {\n if (!value && value !== 0) return \"\";\n if (isNumber(value) || isStringNumber(value)) {\n return `${value}${defaultUnit}`;\n } else if (isString(value)) {\n return value;\n }\n debugWarn(SCOPE, \"binding value must be a string or number\");\n}\n\nexport { addClass, addUnit, classNameToArray, getStyle, hasClass, removeClass, removeStyle, setStyle };\n//# sourceMappingURL=style.mjs.map\n","<script lang=\"ts\" setup>\r\nimport type { Field } from '@formily/core'\r\nimport type {\r\n FormItemContext,\r\n FormItemValidateState,\r\n FormValidationResult,\r\n TooltipInstance,\r\n} from 'element-plus'\r\nimport type { ICalculatedFormLayoutProps } from 'src/form-layout/types'\r\nimport type { CSSProperties } from 'vue'\r\nimport type { IFormItemProps } from './types'\r\nimport { CircleCheck, CircleClose, InfoFilled, Warning } from '@element-plus/icons-vue'\r\nimport { isArr, isValid } from '@formily/shared'\r\nimport { useField } from '@silver-formily/vue'\r\nimport { useResizeObserver } from '@vueuse/core'\r\nimport { ElIcon, ElTooltip, formItemContextKey, useFormSize, useId, useNamespace } from 'element-plus'\r\nimport { addUnit } from 'element-plus/es/utils/index'\r\nimport { pick } from 'lodash-es'\r\nimport { computed, isVNode, provide, reactive, ref, useSlots, watch } from 'vue'\r\nimport { stylePrefix } from '../__builtins__'\r\nimport { FORM_LAYOUT_PROPS_KEYS, formLayoutShallowContext, useFormLayout } from '../form-layout/utils'\r\n\r\ndefineOptions({\r\n name: 'FFormItem',\r\n})\r\nconst props = withDefaults(defineProps<IFormItemProps>(), {\r\n asterisk: undefined,\r\n colon: undefined,\r\n labelWrap: undefined,\r\n fullness: undefined,\r\n})\r\nconst slots = useSlots()\r\nconst ns = useNamespace('form-item')\r\nconst prefixCls = `${stylePrefix}-form-item`\r\nconst rootFormItemClass = computed(() => props.internalFormItemClass || ns.b())\r\nconst formItemConfig = computed<Partial<ICalculatedFormLayoutProps>>(() =>\r\n Object.fromEntries(\r\n Object.entries(pick(props, FORM_LAYOUT_PROPS_KEYS))\r\n .filter(([_, value]) => isValid(value)),\r\n ),\r\n)\r\nconst formlayoutConfig = useFormLayout()\r\nconst formlayout = computed(() => Object.assign({\r\n colon: true,\r\n feedbackLayout: 'loose',\r\n fullness: false,\r\n labelWrap: false,\r\n}, formlayoutConfig.value, formItemConfig.value))\r\nconst field = useField<Field>()\r\n\r\nconst inheritedSize = useFormSize(undefined, { formItem: false })\r\nconst formItemSize = computed(() => {\r\n if (isValid(formlayout.value.size)) {\r\n return formlayout.value.size\r\n }\r\n return inheritedSize.value\r\n})\r\n\r\nconst labelId = useId().value\r\nconst inputIds = ref<string[]>([])\r\n\r\nconst validateState = ref<FormItemValidateState>('')\r\nconst formItemRef = ref<HTMLDivElement>()\r\nconst labelRef = ref<HTMLElement>()\r\nconst feedbackTooltipRef = ref<TooltipInstance>()\r\ndefineExpose({\r\n feedbackTooltipRef,\r\n})\r\n\r\nconst labelPosition = computed(\r\n () => {\r\n if (formlayout.value.layout === 'vertical' || (isArr(formlayout.value.layout) && formlayout.value.layout.includes('vertical' as any))) {\r\n return 'top'\r\n }\r\n return formlayout.value.labelAlign ?? 'right'\r\n },\r\n)\r\n\r\nconst labelStyle = computed<CSSProperties>(() => {\r\n if (labelPosition.value === 'top') {\r\n return {}\r\n }\r\n\r\n const labelWidth = addUnit(formlayout.value.labelWidth || '')\r\n if (labelWidth)\r\n return { width: labelWidth }\r\n return {}\r\n})\r\n\r\nconst contentStyle = computed<CSSProperties>(() => {\r\n const contentWidth = addUnit(formlayout.value?.wrapperWidth || '')\r\n if (contentWidth)\r\n return { width: contentWidth, flex: 'unset' }\r\n return {}\r\n})\r\n\r\nconst contentWrapperStyle = computed<CSSProperties>(() => {\r\n return {\r\n justifyContent: formlayout.value?.wrapperAlign === 'right' && 'flex-end',\r\n }\r\n})\r\n\r\nconst isRequired = computed(() =>\r\n props.asterisk && field.value?.pattern !== 'readPretty',\r\n)\r\n\r\nconst formItemClasses = computed(() => [\r\n rootFormItemClass.value,\r\n ns.m(formItemSize.value || 'default'),\r\n ns.is(props.feedbackStatus),\r\n ns.is('validating', validateState.value === 'validating'),\r\n ns.is('success', validateState.value === 'success'),\r\n ns.is('required', isRequired.value || props.asterisk),\r\n ns.is('no-asterisk', formlayout.value?.hideRequiredAsterisk),\r\n ns.is(formlayout.value.feedbackLayout),\r\n formlayout.value?.requireAsteriskPosition === 'right'\r\n ? 'asterisk-right'\r\n : 'asterisk-left',\r\n {\r\n [ns.m('feedback')]: formlayout.value?.statusIcon,\r\n [ns.m(`label-${labelPosition.value}`)]: labelPosition.value,\r\n },\r\n])\r\n\r\nconst validateClasses = computed(() => [\r\n `${prefixCls}-feedback`,\r\n ns.is(props.feedbackStatus),\r\n ns.is('loose', formlayout.value.feedbackLayout === 'loose'),\r\n])\r\n\r\nconst hasLabel = computed<boolean>(() => {\r\n return (props.label !== '' && isValid(props.label)) || isValid(slots.label)\r\n})\r\n\r\nconst labelFor = computed<string | undefined>(() => {\r\n return (\r\n props.for || (inputIds.value.length === 1 ? inputIds.value[0] : undefined)\r\n )\r\n})\r\n\r\nconst isGroup = computed<boolean>(() => {\r\n return !labelFor.value && hasLabel.value\r\n})\r\n\r\nasync function validate(): FormValidationResult {\r\n return true\r\n}\r\n/* istanbul ignore next -- @preserve */\r\nconst clearValidate: FormItemContext['clearValidate'] = () => {}\r\n/* istanbul ignore next -- @preserve */\r\nconst resetField: FormItemContext['resetField'] = async () => {}\r\n/* istanbul ignore next -- @preserve */\r\nconst setInitialValue: FormItemContext['setInitialValue'] = () => {}\r\n\r\nconst addInputId: FormItemContext['addInputId'] = (id: string) => {\r\n /* istanbul ignore else -- @preserve */\r\n if (!inputIds.value.includes(id)) {\r\n inputIds.value.push(id)\r\n }\r\n}\r\n\r\nconst removeInputId: FormItemContext['removeInputId'] = (id: string) => {\r\n inputIds.value = inputIds.value.filter(listId => listId !== id)\r\n}\r\n\r\nconst isEllipsisActive = ref(false)\r\nuseResizeObserver(labelRef, () => {\r\n isEllipsisActive.value = labelRef.value?.scrollWidth > labelRef.value?.clientWidth\r\n})\r\nconst isEllipsis = computed(() => {\r\n return isEllipsisActive.value && !formlayout.value.labelWrap\r\n})\r\n\r\n// HACK computed无法监听到props.feedbackStatus的变化\r\nconst _validateState = ref<FormItemValidateState>('')\r\nconst context: FormItemContext = reactive({\r\n $el: formItemRef,\r\n labelWidth: formlayout.value?.labelWidth,\r\n size: formItemSize,\r\n validateState: _validateState.value,\r\n labelId,\r\n inputIds,\r\n isGroup,\r\n hasLabel,\r\n addInputId,\r\n removeInputId,\r\n resetField,\r\n clearValidate,\r\n validate,\r\n labelPosition,\r\n inlineMessage: true,\r\n showMessage: true,\r\n fieldValue: field.value?.value,\r\n validateMessage: '',\r\n propString: '',\r\n setInitialValue,\r\n})\r\nwatch(() => props.feedbackStatus, (val) => {\r\n if (val === 'pending') {\r\n context.validateState = 'validating'\r\n return\r\n }\r\n if (val === 'warning') {\r\n context.validateState = ''\r\n return\r\n }\r\n context.validateState = val\r\n}, {\r\n immediate: true,\r\n})\r\n\r\nprovide(formLayoutShallowContext, ref({\r\n ...(isValid(formlayout.value.size) && { size: formlayout.value.size }),\r\n ...(isValid(formlayout.value.colon) && { colon: formlayout.value.colon }),\r\n}))\r\nprovide(formItemContextKey, context)\r\n</script>\r\n\r\n<template>\r\n <div\r\n ref=\"formItemRef\" :class=\"[prefixCls, formlayout.labelWrap && 'is-warp', ...formItemClasses]\"\r\n :role=\"isGroup ? 'group' : undefined\" :aria-labelledby=\"isGroup ? labelId : undefined\"\r\n >\r\n <component\r\n :is=\"labelFor ? 'label' : 'div'\" v-if=\"hasLabel\" :id=\"labelId\" :for=\"labelFor\"\r\n :class=\"[ns.e('label'), isValid(formlayout.labelCol) && `${prefixCls}-col-${formlayout.labelCol}`]\"\r\n :style=\"labelStyle\"\r\n >\r\n <!-- label -->\r\n <template v-if=\"isVNode(props.label)\">\r\n <component :is=\"props.label\" />\r\n </template>\r\n <div v-else :class=\"`${prefixCls}-label__wrapper`\">\r\n <ElTooltip :disabled=\"!isEllipsis && formlayout.tooltipLayout !== 'text'\">\r\n <span\r\n :class=\"{\r\n [`${prefixCls}-label-content`]: true,\r\n ['is-tooltip']: isEllipsis || (props.tooltip && formlayout.tooltipLayout === 'text'),\r\n }\"\r\n >\r\n <span ref=\"labelRef\">{{ props.label }}</span>\r\n </span>\r\n <template #content>\r\n <template v-if=\"isVNode(props.tooltip)\">\r\n <component :is=\"props.tooltip\" />\r\n </template>\r\n <div v-else :style=\"`width: ${labelRef?.clientWidth ?? 0}px;`\">\r\n <template v-if=\"isEllipsis\">\r\n {{ props.label }}\r\n </template>\r\n <template v-if=\"formlayout.tooltipLayout === 'text'\">\r\n {{ props.tooltip }}\r\n </template>\r\n </div>\r\n </template>\r\n </ElTooltip>\r\n <ElTooltip v-if=\"props.tooltip && formlayout.tooltipLayout !== 'text'\" :content=\"props.tooltip\">\r\n <ElIcon :class=\"`${prefixCls}-label-tooltip`\">\r\n <InfoFilled />\r\n </ElIcon>\r\n </ElTooltip>\r\n <span v-if=\"formlayout.colon\" :class=\"`${prefixCls}-colon`\">:</span>\r\n </div>\r\n </component>\r\n <!-- content -->\r\n <div\r\n :class=\"[\r\n `${prefixCls}-content__wrapper`,\r\n isValid(formlayout.wrapperCol) && `${prefixCls}-col-${formlayout.wrapperCol}`,\r\n ]\"\r\n :style=\"contentWrapperStyle\"\r\n >\r\n <template v-if=\"isValid(props.addonBefore)\">\r\n <template v-if=\"isVNode(props.addonBefore)\">\r\n <component :is=\"props.addonBefore\" />\r\n </template>\r\n <div v-else :class=\"`${prefixCls}-addon-before`\">\r\n {{ props.addonBefore }}\r\n </div>\r\n </template>\r\n <div\r\n :class=\"[\r\n ns.e('content'),\r\n formlayout.fullness && 'is-fullness',\r\n ns.is('addon-after', !!props.addonAfter),\r\n ]\" :style=\"contentStyle\"\r\n >\r\n <ElTooltip\r\n v-if=\"formlayout.feedbackLayout === 'popover'\"\r\n ref=\"feedbackTooltipRef\"\r\n :visible=\"!!props.feedbackText\"\r\n effect=\"light\"\r\n :offset=\"6\"\r\n >\r\n <template #default>\r\n <slot />\r\n </template>\r\n <template #content>\r\n <div :class=\"[...validateClasses, ns.is('tooltip')]\">\r\n <ElIcon>\r\n <CircleClose v-if=\"props.feedbackStatus === 'error'\" />\r\n <CircleCheck v-if=\"props.feedbackStatus === 'success'\" />\r\n <Warning v-if=\"props.feedbackStatus === 'warning'\" />\r\n </ElIcon>\r\n {{ props.feedbackText }}\r\n </div>\r\n </template>\r\n </ElTooltip>\r\n <slot v-else />\r\n <TransitionGroup :name=\"`${ns.namespace.value}-zoom-in-top`\">\r\n <div v-if=\"props.feedbackText && formlayout.feedbackLayout !== 'popover'\" :class=\"validateClasses\">\r\n {{ props.feedbackText }}\r\n </div>\r\n <template v-if=\"isValid(props.extra)\">\r\n <template v-if=\"isVNode(props.extra)\">\r\n <component :is=\"props.extra\" />\r\n </template>\r\n <div v-else :class=\"`${prefixCls}-extra`\">\r\n {{ props.extra }}\r\n </div>\r\n </template>\r\n </TransitionGroup>\r\n </div>\r\n <template v-if=\"isValid(props.addonAfter)\">\r\n <template v-if=\"isVNode(props.addonAfter)\">\r\n <component :is=\"props.addonAfter\" />\r\n </template>\r\n <div v-else :class=\"`${prefixCls}-addon-after`\">\r\n {{ props.addonAfter }}\r\n </div>\r\n </template>\r\n </div>\r\n </div>\r\n</template>\r\n","import { isVoidField } from '@formily/core'\r\nimport { connect, mapProps } from '@silver-formily/vue'\r\nimport { composeExport } from '../__builtins__'\r\nimport FormBaseItem from './form-item.vue'\r\nimport { determineFeedbackStatus, getFeedbackMessage } from './utils'\r\nimport './style.scss'\r\n\r\nexport function fieldFeedbackMapper(props, field) {\r\n if (isVoidField(field) || !field) {\r\n return props\r\n }\r\n\r\n const feedbackText = getFeedbackMessage(field)\r\n const feedbackStatus = determineFeedbackStatus(field)\r\n const asterisk = 'asterisk' in props\r\n ? props.asterisk\r\n : field.required && field.pattern !== 'readPretty'\r\n\r\n return {\r\n ...props,\r\n feedbackText,\r\n feedbackStatus,\r\n asterisk,\r\n }\r\n}\r\n\r\nconst Item = connect<typeof FormBaseItem>(\r\n FormBaseItem,\r\n mapProps(\r\n {\r\n validateStatus: true,\r\n title: 'label',\r\n required: true,\r\n description: 'extra',\r\n },\r\n fieldFeedbackMapper,\r\n ),\r\n)\r\n\r\nexport const FormItem = composeExport(Item, {\r\n BaseItem: FormBaseItem,\r\n})\r\n\r\nexport default FormItem\r\n\r\nexport { default as FormBaseItem } from './form-item.vue'\r\nexport type { IFormItemProps } from './types'\r\n"],"names":["SCOPE","addUnit","value","defaultUnit","isNumber","isStringNumber","isString","debugWarn","props","__props","slots","useSlots","ns","useNamespace","prefixCls","stylePrefix","rootFormItemClass","computed","formItemConfig","pick","FORM_LAYOUT_PROPS_KEYS","_","isValid","formlayoutConfig","useFormLayout","formlayout","field","useField","inheritedSize","useFormSize","formItemSize","labelId","useId","inputIds","ref","validateState","formItemRef","labelRef","feedbackTooltipRef","__expose","labelPosition","isArr","labelStyle","labelWidth","contentStyle","contentWidth","contentWrapperStyle","isRequired","formItemClasses","validateClasses","hasLabel","labelFor","isGroup","validate","clearValidate","resetField","setInitialValue","addInputId","id","removeInputId","listId","isEllipsisActive","useResizeObserver","isEllipsis","_validateState","context","reactive","watch","val","provide","formLayoutShallowContext","formItemContextKey","_createElementBlock","_unref","_openBlock","_createBlock","_resolveDynamicComponent","_normalizeClass","isVNode","_createVNode","ElTooltip","_normalizeStyle","_Fragment","_createTextVNode","_toDisplayString","_createElementVNode","ElIcon","InfoFilled","_renderSlot","_ctx","CircleClose","CircleCheck","Warning","_TransitionGroup","fieldFeedbackMapper","isVoidField","feedbackText","getFeedbackMessage","feedbackStatus","determineFeedbackStatus","asterisk","Item","connect","FormBaseItem","mapProps","FormItem","composeExport"],"mappings":";;;;;;;;;;;;;;AAMA,MAAMA,KAAQ;AAgDd,SAASC,EAAQC,GAAOC,IAAc,MAAM;AAC1C,MAAI,CAACD,KAASA,MAAU,EAAG,QAAO;AAClC,MAAIE,GAASF,CAAK,KAAKG,GAAeH,CAAK;AACzC,WAAO,GAAGA,CAAK,GAAGC,CAAW;AACxB,MAAIG,GAASJ,CAAK;AACvB,WAAOA;AAET,EAAAK,GAAUP,IAAO,0CAA0C;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrCA,UAAMQ,IAAQC,GAMRC,IAAQC,GAAA,GACRC,IAAKC,GAAa,WAAW,GAC7BC,IAAY,GAAGC,EAAW,cAC1BC,IAAoBC,EAAS,MAAMT,EAAM,yBAAyBI,EAAG,GAAG,GACxEM,IAAiBD;AAAA,MAA8C,MACnE,OAAO;AAAA,QACL,OAAO,QAAQE,GAAKX,GAAOY,EAAsB,CAAC,EAC/C,OAAO,CAAC,CAACC,GAAGnB,CAAK,MAAMoB,EAAQpB,CAAK,CAAC;AAAA,MAAA;AAAA,IAC1C,GAEIqB,IAAmBC,GAAA,GACnBC,IAAaR,EAAS,MAAM,OAAO,OAAO;AAAA,MAC9C,OAAO;AAAA,MACP,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E,CAAK,GAC9C0E,IAAW,cAAc5F,IAC3BA,EAAM,WACNkB,EAAM,YAAYA,EAAM,YAAY;AAExC,SAAO;AAAA,IACL,GAAGlB;AAAA,IACH,cAAAwF;AAAA,IACA,gBAAAE;AAAA,IACA,UAAAE;AAAA,EAAA;AAEJ;AAEA,MAAMC,KAAOC;AAAA,EACXC;AAAAA,EACAC;AAAA,IACE;AAAA,MACE,gBAAgB;AAAA,MAChB,OAAO;AAAA,MACP,UAAU;AAAA,MACV,aAAa;AAAA,IAAA;AAAA,IAEfV;AAAA,EAAA;AAEJ,GAEaW,KAAWC,GAAcL,IAAM;AAAA,EAC1C,UAAUE;AACZ,CAAC;","x_google_ignoreList":[0]}
|
package/esm/form-item/types.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
export type FormItemContent = string | VNode;
|
|
1
3
|
export interface IFormItemProps {
|
|
2
4
|
/**
|
|
3
5
|
* Internal: override Element Plus root class for isolated scenes (e.g. QueryFormItem).
|
|
4
6
|
*/
|
|
5
7
|
internalFormItemClass?: string;
|
|
6
|
-
label?:
|
|
8
|
+
label?: FormItemContent;
|
|
7
9
|
for?: string;
|
|
8
|
-
tooltip?:
|
|
9
|
-
addonBefore?:
|
|
10
|
-
addonAfter?:
|
|
11
|
-
extra?:
|
|
12
|
-
feedbackText?:
|
|
10
|
+
tooltip?: FormItemContent;
|
|
11
|
+
addonBefore?: FormItemContent;
|
|
12
|
+
addonAfter?: FormItemContent;
|
|
13
|
+
extra?: FormItemContent;
|
|
14
|
+
feedbackText?: FormItemContent;
|
|
13
15
|
feedbackStatus?: 'error' | 'warning' | 'success' | 'pending';
|
|
14
16
|
asterisk?: boolean;
|
|
15
17
|
colon?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/form-item/utils.ts"],"sourcesContent":["import type { Field } from '@formily/core'\nimport { isArr } from '@formily/shared'\n\nexport function getFeedbackMessage(field: Field) {\n const messages = {\n errors: field.selfErrors.join(', '),\n warnings: field.selfWarnings.join(', '),\n successes: field.selfSuccesses.join(', '),\n }\n\n return messages.errors || messages.warnings || messages.successes\n}\n\nexport function determineFeedbackStatus(field: Field) {\n return isArr(field.decorator)\n ? (field.decorator[1]?.feedbackStatus ?? field.validateStatus)\n : field.validateStatus\n}\n"],"names":["getFeedbackMessage","field","messages","determineFeedbackStatus","isArr"],"mappings":";AAGO,SAASA,EAAmBC,GAAc;AAC/C,QAAMC,IAAW;AAAA,IACf,QAAQD,EAAM,WAAW,KAAK,IAAI;AAAA,IAClC,UAAUA,EAAM,aAAa,KAAK,IAAI;AAAA,IACtC,WAAWA,EAAM,cAAc,KAAK,IAAI;AAAA,EAAA;AAG1C,SAAOC,EAAS,UAAUA,EAAS,YAAYA,EAAS;AAC1D;AAEO,SAASC,EAAwBF,GAAc;AACpD,SAAOG,EAAMH,EAAM,SAAS,IACvBA,EAAM,UAAU,CAAC,GAAG,kBAAkBA,EAAM,iBAC7CA,EAAM;AACZ;"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../src/form-item/utils.ts"],"sourcesContent":["import type { Field } from '@formily/core'\r\nimport { isArr } from '@formily/shared'\r\n\r\nexport function getFeedbackMessage(field: Field) {\r\n const messages = {\r\n errors: field.selfErrors.join(', '),\r\n warnings: field.selfWarnings.join(', '),\r\n successes: field.selfSuccesses.join(', '),\r\n }\r\n\r\n return messages.errors || messages.warnings || messages.successes\r\n}\r\n\r\nexport function determineFeedbackStatus(field: Field) {\r\n return isArr(field.decorator)\r\n ? (field.decorator[1]?.feedbackStatus ?? field.validateStatus)\r\n : field.validateStatus\r\n}\r\n"],"names":["getFeedbackMessage","field","messages","determineFeedbackStatus","isArr"],"mappings":";AAGO,SAASA,EAAmBC,GAAc;AAC/C,QAAMC,IAAW;AAAA,IACf,QAAQD,EAAM,WAAW,KAAK,IAAI;AAAA,IAClC,UAAUA,EAAM,aAAa,KAAK,IAAI;AAAA,IACtC,WAAWA,EAAM,cAAc,KAAK,IAAI;AAAA,EAAA;AAG1C,SAAOC,EAAS,UAAUA,EAAS,YAAYA,EAAS;AAC1D;AAEO,SAASC,EAAwBF,GAAc;AACpD,SAAOG,EAAMH,EAAM,SAAS,IACvBA,EAAM,UAAU,CAAC,GAAG,kBAAkBA,EAAM,iBAC7CA,EAAM;AACZ;"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { defineComponent as A, ref as l, computed as d, provide as e, watch as x, reactive as B, toRef as t,
|
|
1
|
+
import { defineComponent as A, ref as l, computed as d, provide as e, watch as x, reactive as B, toRef as t, openBlock as P, createBlock as g, resolveDynamicComponent as I, mergeProps as b, unref as F, withModifiers as R, withCtx as _, renderSlot as q } from "vue";
|
|
2
2
|
import { isValid as z, isEmpty as D } from "@formily/shared";
|
|
3
3
|
import { useThrottleFn as T } from "@vueuse/core";
|
|
4
4
|
import { useId as M, formContextKey as S } from "element-plus";
|
|
5
|
-
import {
|
|
6
|
-
import "
|
|
7
|
-
import "
|
|
8
|
-
|
|
9
|
-
import "@silver-formily/vue";
|
|
10
|
-
import { useCleanAttrs as $ } from "../__builtins__/shared/utils.mjs";
|
|
11
|
-
import { formLayoutIdContext as H, useFormDeepLayout as V, useResponsiveFormLayout as E, filterValidFormLayoutProps as r, formLayoutDeepContext as K, formLayoutShallowContext as j } from "./utils.mjs";
|
|
12
|
-
const to = /* @__PURE__ */ A({
|
|
5
|
+
import { formLayoutIdContext as W, useFormDeepLayout as $, useResponsiveFormLayout as H, filterValidFormLayoutProps as r, formLayoutDeepContext as V, formLayoutShallowContext as E } from "./utils.mjs";
|
|
6
|
+
import { useCleanAttrs as K } from "../__builtins__/shared/utils.mjs";
|
|
7
|
+
import { stylePrefix as j } from "../__builtins__/configs/index.mjs";
|
|
8
|
+
const Y = /* @__PURE__ */ A({
|
|
13
9
|
name: "FFormLayout",
|
|
14
10
|
inheritAttrs: !1,
|
|
15
11
|
__name: "form-layout",
|
|
@@ -35,18 +31,18 @@ const to = /* @__PURE__ */ A({
|
|
|
35
31
|
requireAsteriskPosition: {}
|
|
36
32
|
},
|
|
37
33
|
setup(c) {
|
|
38
|
-
const o = c, y = `${
|
|
39
|
-
u && e(
|
|
40
|
-
const h =
|
|
34
|
+
const o = c, y = `${j}-form`, { props: s } = K(), n = l(), u = o.tag === "form", v = M(), p = d(() => s.value.id ?? `formily-${v.value}`), L = d(() => u ? p.value : s.value.id);
|
|
35
|
+
u && e(W, p);
|
|
36
|
+
const h = $(), { props: a } = H(o, n), C = l({
|
|
41
37
|
...h.value,
|
|
42
38
|
...o.shallow ? {
|
|
43
39
|
size: o.size,
|
|
44
40
|
...z(o.colon) && { colon: o.colon }
|
|
45
41
|
} : r(o)
|
|
46
42
|
});
|
|
47
|
-
e(
|
|
43
|
+
e(V, C);
|
|
48
44
|
const f = l(o.shallow ? r(o) : {});
|
|
49
|
-
e(
|
|
45
|
+
e(E, f);
|
|
50
46
|
const k = T(() => {
|
|
51
47
|
if (!D(a.value)) {
|
|
52
48
|
const i = r(a.value);
|
|
@@ -63,7 +59,7 @@ const to = /* @__PURE__ */ A({
|
|
|
63
59
|
hideRequiredAsterisk: t(o, "hideRequiredAsterisk"),
|
|
64
60
|
requireAsteriskPosition: t(o, "requireAsteriskPosition")
|
|
65
61
|
});
|
|
66
|
-
return e(S, w), (i, m) => (
|
|
62
|
+
return e(S, w), (i, m) => (P(), g(I(o.tag), b({
|
|
67
63
|
id: L.value,
|
|
68
64
|
ref_key: "rootHTMLRef",
|
|
69
65
|
ref: n,
|
|
@@ -80,6 +76,6 @@ const to = /* @__PURE__ */ A({
|
|
|
80
76
|
}
|
|
81
77
|
});
|
|
82
78
|
export {
|
|
83
|
-
|
|
79
|
+
Y as _
|
|
84
80
|
};
|
|
85
81
|
//# sourceMappingURL=form-layout.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-layout.mjs","sources":["../../src/form-layout/form-layout.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { FormContext } from 'element-plus'\nimport type { IFormLayoutProps } from './types'\nimport { isEmpty, isValid } from '@formily/shared'\nimport { useThrottleFn } from '@vueuse/core'\nimport { formContextKey, useId } from 'element-plus'\nimport { computed, provide, reactive, ref, toRef, watch } from 'vue'\nimport { stylePrefix, useCleanAttrs } from '../__builtins__'\nimport { filterValidFormLayoutProps, formLayoutDeepContext, formLayoutIdContext, formLayoutShallowContext, useFormDeepLayout, useResponsiveFormLayout } from './utils'\n\ndefineOptions({\n name: 'FFormLayout',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<IFormLayoutProps>(), {\n tag: 'form',\n colon: undefined,\n labelWrap: undefined,\n fullness: undefined,\n size: 'default',\n layout: 'horizontal',\n shallow: true,\n statusIcon: true,\n asterisk: undefined,\n})\nconst formPrefixCls = `${stylePrefix}-form`\nconst { props: attrs } = useCleanAttrs()\nconst rootHTMLRef = ref<HTMLElement>()\nconst isFormTag = props.tag === 'form'\nconst formLayoutBaseId = useId()\nconst formLayoutId = computed(() => attrs.value.id ?? `formily-${formLayoutBaseId.value}`)\nconst formLayoutDomId = computed(() => (isFormTag ? formLayoutId.value : attrs.value.id))\nif (isFormTag) {\n provide(formLayoutIdContext, formLayoutId)\n}\n\nconst formLayoutDeepConfig = useFormDeepLayout()\nconst { props: responsiveProps } = useResponsiveFormLayout(props, rootHTMLRef)\n\nconst deepLayout = ref({\n ...formLayoutDeepConfig.value,\n ...(props.shallow\n ? {\n size: props.size,\n ...(isValid(props.colon) && { colon: props.colon }),\n }\n : filterValidFormLayoutProps(props)),\n})\nprovide(formLayoutDeepContext, deepLayout)\n\nconst shallowLayout = ref(props.shallow ? filterValidFormLayoutProps(props) : {})\nprovide(formLayoutShallowContext, shallowLayout)\n\nconst updateLayout = useThrottleFn(() => {\n if (!isEmpty(responsiveProps.value)) {\n const _responsiveProps = filterValidFormLayoutProps(responsiveProps.value)\n shallowLayout.value = filterValidFormLayoutProps({ ...props, ..._responsiveProps })\n }\n}, 200, true)\n\nwatch(() => [props, responsiveProps], updateLayout, {\n deep: true,\n immediate: true,\n})\n\nconst formContext = reactive({\n size: toRef(props, 'size'),\n statusIcon: toRef(props, 'statusIcon'),\n hideRequiredAsterisk: toRef(props, 'hideRequiredAsterisk'),\n requireAsteriskPosition: toRef(props, 'requireAsteriskPosition'),\n})\nprovide(formContextKey, formContext as FormContext)\n</script>\n\n<template>\n <component\n :is=\"props.tag\"\n :id=\"formLayoutDomId\"\n ref=\"rootHTMLRef\"\n :class=\"formPrefixCls\"\n v-bind=\"attrs\"\n @submit.prevent.stop\n >\n <slot />\n </component>\n</template>\n"],"names":["props","__props","formPrefixCls","stylePrefix","attrs","useCleanAttrs","rootHTMLRef","ref","isFormTag","formLayoutBaseId","useId","formLayoutId","computed","formLayoutDomId","provide","formLayoutIdContext","formLayoutDeepConfig","useFormDeepLayout","responsiveProps","useResponsiveFormLayout","deepLayout","isValid","filterValidFormLayoutProps","formLayoutDeepContext","shallowLayout","formLayoutShallowContext","updateLayout","useThrottleFn","isEmpty","_responsiveProps","watch","formContext","reactive","toRef","formContextKey","_openBlock","_createBlock","_resolveDynamicComponent","_mergeProps","_unref","_renderSlot","_ctx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"form-layout.mjs","sources":["../../src/form-layout/form-layout.vue"],"sourcesContent":["<script lang=\"ts\" setup>\r\nimport type { FormContext } from 'element-plus'\r\nimport type { IFormLayoutProps } from './types'\r\nimport { isEmpty, isValid } from '@formily/shared'\r\nimport { useThrottleFn } from '@vueuse/core'\r\nimport { formContextKey, useId } from 'element-plus'\r\nimport { computed, provide, reactive, ref, toRef, watch } from 'vue'\r\nimport { stylePrefix, useCleanAttrs } from '../__builtins__'\r\nimport { filterValidFormLayoutProps, formLayoutDeepContext, formLayoutIdContext, formLayoutShallowContext, useFormDeepLayout, useResponsiveFormLayout } from './utils'\r\n\r\ndefineOptions({\r\n name: 'FFormLayout',\r\n inheritAttrs: false,\r\n})\r\n\r\nconst props = withDefaults(defineProps<IFormLayoutProps>(), {\r\n tag: 'form',\r\n colon: undefined,\r\n labelWrap: undefined,\r\n fullness: undefined,\r\n size: 'default',\r\n layout: 'horizontal',\r\n shallow: true,\r\n statusIcon: true,\r\n asterisk: undefined,\r\n})\r\nconst formPrefixCls = `${stylePrefix}-form`\r\nconst { props: attrs } = useCleanAttrs()\r\nconst rootHTMLRef = ref<HTMLElement>()\r\nconst isFormTag = props.tag === 'form'\r\nconst formLayoutBaseId = useId()\r\nconst formLayoutId = computed(() => attrs.value.id ?? `formily-${formLayoutBaseId.value}`)\r\nconst formLayoutDomId = computed(() => (isFormTag ? formLayoutId.value : attrs.value.id))\r\nif (isFormTag) {\r\n provide(formLayoutIdContext, formLayoutId)\r\n}\r\n\r\nconst formLayoutDeepConfig = useFormDeepLayout()\r\nconst { props: responsiveProps } = useResponsiveFormLayout(props, rootHTMLRef)\r\n\r\nconst deepLayout = ref({\r\n ...formLayoutDeepConfig.value,\r\n ...(props.shallow\r\n ? {\r\n size: props.size,\r\n ...(isValid(props.colon) && { colon: props.colon }),\r\n }\r\n : filterValidFormLayoutProps(props)),\r\n})\r\nprovide(formLayoutDeepContext, deepLayout)\r\n\r\nconst shallowLayout = ref(props.shallow ? filterValidFormLayoutProps(props) : {})\r\nprovide(formLayoutShallowContext, shallowLayout)\r\n\r\nconst updateLayout = useThrottleFn(() => {\r\n if (!isEmpty(responsiveProps.value)) {\r\n const _responsiveProps = filterValidFormLayoutProps(responsiveProps.value)\r\n shallowLayout.value = filterValidFormLayoutProps({ ...props, ..._responsiveProps })\r\n }\r\n}, 200, true)\r\n\r\nwatch(() => [props, responsiveProps], updateLayout, {\r\n deep: true,\r\n immediate: true,\r\n})\r\n\r\nconst formContext = reactive({\r\n size: toRef(props, 'size'),\r\n statusIcon: toRef(props, 'statusIcon'),\r\n hideRequiredAsterisk: toRef(props, 'hideRequiredAsterisk'),\r\n requireAsteriskPosition: toRef(props, 'requireAsteriskPosition'),\r\n})\r\nprovide(formContextKey, formContext as FormContext)\r\n</script>\r\n\r\n<template>\r\n <component\r\n :is=\"props.tag\"\r\n :id=\"formLayoutDomId\"\r\n ref=\"rootHTMLRef\"\r\n :class=\"formPrefixCls\"\r\n v-bind=\"attrs\"\r\n @submit.prevent.stop\r\n >\r\n <slot />\r\n </component>\r\n</template>\r\n"],"names":["props","__props","formPrefixCls","stylePrefix","attrs","useCleanAttrs","rootHTMLRef","ref","isFormTag","formLayoutBaseId","useId","formLayoutId","computed","formLayoutDomId","provide","formLayoutIdContext","formLayoutDeepConfig","useFormDeepLayout","responsiveProps","useResponsiveFormLayout","deepLayout","isValid","filterValidFormLayoutProps","formLayoutDeepContext","shallowLayout","formLayoutShallowContext","updateLayout","useThrottleFn","isEmpty","_responsiveProps","watch","formContext","reactive","toRef","formContextKey","_openBlock","_createBlock","_resolveDynamicComponent","_mergeProps","_unref","_renderSlot","_ctx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,UAAMA,IAAQC,GAWRC,IAAgB,GAAGC,CAAW,SAC9B,EAAE,OAAOC,EAAA,IAAUC,EAAA,GACnBC,IAAcC,EAAA,GACdC,IAAYR,EAAM,QAAQ,QAC1BS,IAAmBC,EAAA,GACnBC,IAAeC,EAAS,MAAMR,EAAM,MAAM,MAAM,WAAWK,EAAiB,KAAK,EAAE,GACnFI,IAAkBD,EAAS,MAAOJ,IAAYG,EAAa,QAAQP,EAAM,MAAM,EAAG;AACxF,IAAII,KACFM,EAAQC,GAAqBJ,CAAY;AAG3C,UAAMK,IAAuBC,EAAA,GACvB,EAAE,OAAOC,EAAA,IAAoBC,EAAwBnB,GAAOM,CAAW,GAEvEc,IAAab,EAAI;AAAA,MACrB,GAAGS,EAAqB;AAAA,MACxB,GAAIhB,EAAM,UACN;AAAA,QACE,MAAMA,EAAM;AAAA,QACZ,GAAIqB,EAAQrB,EAAM,KAAK,KAAK,EAAE,OAAOA,EAAM,MAAA;AAAA,MAAM,IAEnDsB,EAA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*/ Symbol(
|
|
55
55
|
"formLayoutDeepContext"
|
|
56
|
-
), w = Symbol("formLayoutShallowContext"), k = Symbol("formLayoutIdContext");
|
|
56
|
+
), w = /* @__PURE__ */ Symbol("formLayoutShallowContext"), k = /* @__PURE__ */ Symbol("formLayoutIdContext");
|
|
57
57
|
function S() {
|
|
58
58
|
return l(s, i({}));
|
|
59
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/form-layout/utils.ts"],"sourcesContent":["import type { ComputedRef, InjectionKey, Ref } from 'vue'\nimport type { IFormLayoutProps } from './types'\nimport { isArr, isValid } from '@formily/shared'\nimport { useResizeObserver } from '@vueuse/core'\nimport { computed, inject, ref } from 'vue'\n\nexport function calcBreakpointIndex(breakpoints: number[], width: number): number {\n for (const [i, breakpoint] of breakpoints.entries()) {\n if (width <= breakpoint) {\n return i\n }\n }\n return -1\n}\n\nexport function calcFactor<T>(value: T | readonly T[], breakpointIndex: number): T {\n if (!Array.isArray(value) || value.length === 0) {\n return value as T\n }\n const safeIndex = Math.max(-1, Math.min(breakpointIndex, value.length - 1))\n return value.at(safeIndex)\n}\n\nexport function factor<T>(value: T | T[], breakpointIndex: number): T {\n return isValid(value) ? calcFactor<T>(value, breakpointIndex) : value as T\n}\n\nexport function calculateProps(target: Element, props: IFormLayoutProps): IFormLayoutProps {\n const { clientWidth } = target\n const {\n breakpoints,\n layout,\n labelAlign,\n wrapperAlign,\n labelCol,\n wrapperCol,\n ...otherProps\n } = props\n const breakpointIndex = calcBreakpointIndex(\n breakpoints as number[],\n clientWidth,\n )\n\n return {\n layout: factor(layout, breakpointIndex),\n labelAlign: factor(labelAlign, breakpointIndex),\n wrapperAlign: factor(wrapperAlign, breakpointIndex),\n labelCol: factor(labelCol, breakpointIndex),\n wrapperCol: factor(wrapperCol, breakpointIndex),\n ...otherProps,\n }\n}\n\nexport function useResponsiveFormLayout(props: IFormLayoutProps, root: Ref<HTMLElement | null>) {\n const { breakpoints } = props\n if (!isArr(breakpoints)) {\n return {\n props: ref(props),\n }\n }\n\n const layoutProps = ref<IFormLayoutProps>({})\n\n useResizeObserver(root, () => {\n layoutProps.value = calculateProps(root.value, props)\n })\n\n return {\n props: layoutProps,\n }\n}\n\nexport const formLayoutDeepContext: InjectionKey<Ref<IFormLayoutProps>> = Symbol(\n 'formLayoutDeepContext',\n)\n\nexport const formLayoutShallowContext: InjectionKey<Ref<IFormLayoutProps>>\n = Symbol('formLayoutShallowContext')\n\nexport const formLayoutIdContext: InjectionKey<ComputedRef<string>>\n = Symbol('formLayoutIdContext')\n\nexport function useFormDeepLayout(): Ref<IFormLayoutProps> {\n return inject(formLayoutDeepContext, ref({}))\n}\n\nexport function useFormLayout(): Ref<IFormLayoutProps> {\n const shallowLayout = inject(formLayoutShallowContext, ref({}))\n const deepLayout = inject(formLayoutDeepContext, ref({}))\n\n const formLayout = computed(() => {\n return {\n ...deepLayout.value,\n ...shallowLayout.value,\n }\n })\n\n return formLayout\n}\n\nexport function useFormLayoutId(): ComputedRef<string> {\n return inject(formLayoutIdContext)\n}\n\nexport const FORM_LAYOUT_PROPS_KEYS: ReadonlyArray<keyof IFormLayoutProps> = [\n 'colon',\n 'labelAlign',\n 'wrapperAlign',\n 'labelWrap',\n 'labelWidth',\n 'wrapperWidth',\n 'labelCol',\n 'wrapperCol',\n 'fullness',\n 'size',\n 'layout',\n 'feedbackLayout',\n 'tooltipLayout',\n 'breakpoints',\n 'hideRequiredAsterisk',\n 'statusIcon',\n 'requireAsteriskPosition',\n] as const\n\nexport function filterValidFormLayoutProps(props: IFormLayoutProps): IFormLayoutProps {\n return Object.fromEntries(\n Object.entries(props)\n .filter(([_, value]) => isValid(value)),\n )\n}\n"],"names":["calcBreakpointIndex","breakpoints","width","i","breakpoint","calcFactor","value","breakpointIndex","safeIndex","factor","isValid","calculateProps","target","props","clientWidth","layout","labelAlign","wrapperAlign","labelCol","wrapperCol","otherProps","useResponsiveFormLayout","root","isArr","ref","layoutProps","useResizeObserver","formLayoutDeepContext","formLayoutShallowContext","formLayoutIdContext","useFormDeepLayout","inject","useFormLayout","shallowLayout","deepLayout","computed","useFormLayoutId","FORM_LAYOUT_PROPS_KEYS","filterValidFormLayoutProps","_"],"mappings":";;;AAMO,SAASA,EAAoBC,GAAuBC,GAAuB;AAChF,aAAW,CAACC,GAAGC,CAAU,KAAKH,EAAY;AACxC,QAAIC,KAASE;AACX,aAAOD;AAGX,SAAO;AACT;AAEO,SAASE,EAAcC,GAAyBC,GAA4B;AACjF,MAAI,CAAC,MAAM,QAAQD,CAAK,KAAKA,EAAM,WAAW;AAC5C,WAAOA;AAET,QAAME,IAAY,KAAK,IAAI,IAAI,KAAK,IAAID,GAAiBD,EAAM,SAAS,CAAC,CAAC;AAC1E,SAAOA,EAAM,GAAGE,CAAS;AAC3B;AAEO,SAASC,EAAUH,GAAgBC,GAA4B;AACpE,SAAOG,EAAQJ,CAAK,IAAID,EAAcC,GAAOC,CAAe,IAAID;AAClE;AAEO,SAASK,EAAeC,GAAiBC,GAA2C;AACzF,QAAM,EAAE,aAAAC,MAAgBF,GAClB;AAAA,IACJ,aAAAX;AAAA,IACA,QAAAc;AAAA,IACA,YAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,IACDP,GACEN,IAAkBP;AAAA,IACtBC;AAAA,IACAa;AAAA,EAAA;AAGF,SAAO;AAAA,IACL,QAAQL,EAAOM,GAAQR,CAAe;AAAA,IACtC,YAAYE,EAAOO,GAAYT,CAAe;AAAA,IAC9C,cAAcE,EAAOQ,GAAcV,CAAe;AAAA,IAClD,UAAUE,EAAOS,GAAUX,CAAe;AAAA,IAC1C,YAAYE,EAAOU,GAAYZ,CAAe;AAAA,IAC9C,GAAGa;AAAA,EAAA;AAEP;AAEO,SAASC,EAAwBR,GAAyBS,GAA+B;AAC9F,QAAM,EAAE,aAAArB,MAAgBY;AACxB,MAAI,CAACU,EAAMtB,CAAW;AACpB,WAAO;AAAA,MACL,OAAOuB,EAAIX,CAAK;AAAA,IAAA;AAIpB,QAAMY,IAAcD,EAAsB,EAAE;AAE5C,SAAAE,EAAkBJ,GAAM,MAAM;AAC5B,IAAAG,EAAY,QAAQd,EAAeW,EAAK,OAAOT,CAAK;AAAA,EACtD,CAAC,GAEM;AAAA,IACL,OAAOY;AAAA,EAAA;AAEX;AAEO,MAAME,IAA6D;AAAA,EACxE;AACF,GAEaC,
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../src/form-layout/utils.ts"],"sourcesContent":["import type { ComputedRef, InjectionKey, Ref } from 'vue'\r\nimport type { IFormLayoutProps } from './types'\r\nimport { isArr, isValid } from '@formily/shared'\r\nimport { useResizeObserver } from '@vueuse/core'\r\nimport { computed, inject, ref } from 'vue'\r\n\r\nexport function calcBreakpointIndex(breakpoints: number[], width: number): number {\r\n for (const [i, breakpoint] of breakpoints.entries()) {\r\n if (width <= breakpoint) {\r\n return i\r\n }\r\n }\r\n return -1\r\n}\r\n\r\nexport function calcFactor<T>(value: T | readonly T[], breakpointIndex: number): T {\r\n if (!Array.isArray(value) || value.length === 0) {\r\n return value as T\r\n }\r\n const safeIndex = Math.max(-1, Math.min(breakpointIndex, value.length - 1))\r\n return value.at(safeIndex)\r\n}\r\n\r\nexport function factor<T>(value: T | T[], breakpointIndex: number): T {\r\n return isValid(value) ? calcFactor<T>(value, breakpointIndex) : value as T\r\n}\r\n\r\nexport function calculateProps(target: Element, props: IFormLayoutProps): IFormLayoutProps {\r\n const { clientWidth } = target\r\n const {\r\n breakpoints,\r\n layout,\r\n labelAlign,\r\n wrapperAlign,\r\n labelCol,\r\n wrapperCol,\r\n ...otherProps\r\n } = props\r\n const breakpointIndex = calcBreakpointIndex(\r\n breakpoints as number[],\r\n clientWidth,\r\n )\r\n\r\n return {\r\n layout: factor(layout, breakpointIndex),\r\n labelAlign: factor(labelAlign, breakpointIndex),\r\n wrapperAlign: factor(wrapperAlign, breakpointIndex),\r\n labelCol: factor(labelCol, breakpointIndex),\r\n wrapperCol: factor(wrapperCol, breakpointIndex),\r\n ...otherProps,\r\n }\r\n}\r\n\r\nexport function useResponsiveFormLayout(props: IFormLayoutProps, root: Ref<HTMLElement | null>) {\r\n const { breakpoints } = props\r\n if (!isArr(breakpoints)) {\r\n return {\r\n props: ref(props),\r\n }\r\n }\r\n\r\n const layoutProps = ref<IFormLayoutProps>({})\r\n\r\n useResizeObserver(root, () => {\r\n layoutProps.value = calculateProps(root.value, props)\r\n })\r\n\r\n return {\r\n props: layoutProps,\r\n }\r\n}\r\n\r\nexport const formLayoutDeepContext: InjectionKey<Ref<IFormLayoutProps>> = Symbol(\r\n 'formLayoutDeepContext',\r\n)\r\n\r\nexport const formLayoutShallowContext: InjectionKey<Ref<IFormLayoutProps>>\r\n = Symbol('formLayoutShallowContext')\r\n\r\nexport const formLayoutIdContext: InjectionKey<ComputedRef<string>>\r\n = Symbol('formLayoutIdContext')\r\n\r\nexport function useFormDeepLayout(): Ref<IFormLayoutProps> {\r\n return inject(formLayoutDeepContext, ref({}))\r\n}\r\n\r\nexport function useFormLayout(): Ref<IFormLayoutProps> {\r\n const shallowLayout = inject(formLayoutShallowContext, ref({}))\r\n const deepLayout = inject(formLayoutDeepContext, ref({}))\r\n\r\n const formLayout = computed(() => {\r\n return {\r\n ...deepLayout.value,\r\n ...shallowLayout.value,\r\n }\r\n })\r\n\r\n return formLayout\r\n}\r\n\r\nexport function useFormLayoutId(): ComputedRef<string> {\r\n return inject(formLayoutIdContext)\r\n}\r\n\r\nexport const FORM_LAYOUT_PROPS_KEYS: ReadonlyArray<keyof IFormLayoutProps> = [\r\n 'colon',\r\n 'labelAlign',\r\n 'wrapperAlign',\r\n 'labelWrap',\r\n 'labelWidth',\r\n 'wrapperWidth',\r\n 'labelCol',\r\n 'wrapperCol',\r\n 'fullness',\r\n 'size',\r\n 'layout',\r\n 'feedbackLayout',\r\n 'tooltipLayout',\r\n 'breakpoints',\r\n 'hideRequiredAsterisk',\r\n 'statusIcon',\r\n 'requireAsteriskPosition',\r\n] as const\r\n\r\nexport function filterValidFormLayoutProps(props: IFormLayoutProps): IFormLayoutProps {\r\n return Object.fromEntries(\r\n Object.entries(props)\r\n .filter(([_, value]) => isValid(value)),\r\n )\r\n}\r\n"],"names":["calcBreakpointIndex","breakpoints","width","i","breakpoint","calcFactor","value","breakpointIndex","safeIndex","factor","isValid","calculateProps","target","props","clientWidth","layout","labelAlign","wrapperAlign","labelCol","wrapperCol","otherProps","useResponsiveFormLayout","root","isArr","ref","layoutProps","useResizeObserver","formLayoutDeepContext","formLayoutShallowContext","formLayoutIdContext","useFormDeepLayout","inject","useFormLayout","shallowLayout","deepLayout","computed","useFormLayoutId","FORM_LAYOUT_PROPS_KEYS","filterValidFormLayoutProps","_"],"mappings":";;;AAMO,SAASA,EAAoBC,GAAuBC,GAAuB;AAChF,aAAW,CAACC,GAAGC,CAAU,KAAKH,EAAY;AACxC,QAAIC,KAASE;AACX,aAAOD;AAGX,SAAO;AACT;AAEO,SAASE,EAAcC,GAAyBC,GAA4B;AACjF,MAAI,CAAC,MAAM,QAAQD,CAAK,KAAKA,EAAM,WAAW;AAC5C,WAAOA;AAET,QAAME,IAAY,KAAK,IAAI,IAAI,KAAK,IAAID,GAAiBD,EAAM,SAAS,CAAC,CAAC;AAC1E,SAAOA,EAAM,GAAGE,CAAS;AAC3B;AAEO,SAASC,EAAUH,GAAgBC,GAA4B;AACpE,SAAOG,EAAQJ,CAAK,IAAID,EAAcC,GAAOC,CAAe,IAAID;AAClE;AAEO,SAASK,EAAeC,GAAiBC,GAA2C;AACzF,QAAM,EAAE,aAAAC,MAAgBF,GAClB;AAAA,IACJ,aAAAX;AAAA,IACA,QAAAc;AAAA,IACA,YAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,IACDP,GACEN,IAAkBP;AAAA,IACtBC;AAAA,IACAa;AAAA,E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