@hzab/form-render-mobile 0.0.6 → 0.0.7
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.md +1 -1
- package/lib/index.js +64 -69
- package/package.json +1 -1
- package/src/common/schemaHandler.js +25 -36
- package/src/components/Uploader/common/ossUpload.js +2 -2
- package/src/components/Uploader/uploader.jsx +17 -10
- package/src/index.tsx +2 -1
- package/src/type.d.ts +1 -1
package/README.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -22500,7 +22500,7 @@
|
|
|
22500
22500
|
return (
|
|
22501
22501
|
(() => {
|
|
22502
22502
|
"use strict";
|
|
22503
|
-
o.r(s), o.d(s, { default: () =>
|
|
22503
|
+
o.r(s), o.d(s, { default: () => Ww });
|
|
22504
22504
|
var e = {};
|
|
22505
22505
|
function t(e) {
|
|
22506
22506
|
return (
|
|
@@ -40635,8 +40635,8 @@
|
|
|
40635
40635
|
Promise.all(c).then(function (e) {
|
|
40636
40636
|
return (
|
|
40637
40637
|
null == e ||
|
|
40638
|
-
e.forEach(function (e) {
|
|
40639
|
-
r.ossUrl = e;
|
|
40638
|
+
e.forEach(function (e, t) {
|
|
40639
|
+
r[t].ossUrl = e;
|
|
40640
40640
|
}),
|
|
40641
40641
|
Promise.resolve(r)
|
|
40642
40642
|
);
|
|
@@ -40850,16 +40850,17 @@
|
|
|
40850
40850
|
capture: e.capture,
|
|
40851
40851
|
}),
|
|
40852
40852
|
k.map(function (e, t) {
|
|
40853
|
-
var n = e
|
|
40854
|
-
|
|
40855
|
-
|
|
40856
|
-
|
|
40857
|
-
|
|
40853
|
+
var n = e;
|
|
40854
|
+
"string" == typeof n && (n = { url: n, name: n });
|
|
40855
|
+
var r = n,
|
|
40856
|
+
a = r.type,
|
|
40857
|
+
i = r.name,
|
|
40858
|
+
o = r.url,
|
|
40858
40859
|
l = "",
|
|
40859
|
-
u =
|
|
40860
|
-
|
|
40861
|
-
|
|
40862
|
-
var
|
|
40860
|
+
u = "",
|
|
40861
|
+
c = void 0;
|
|
40862
|
+
if (o) {
|
|
40863
|
+
var d = (function (e) {
|
|
40863
40864
|
return lb(e, [
|
|
40864
40865
|
"apng",
|
|
40865
40866
|
"avif",
|
|
@@ -40878,32 +40879,32 @@
|
|
|
40878
40879
|
"tiff",
|
|
40879
40880
|
"webp",
|
|
40880
40881
|
]);
|
|
40881
|
-
})((
|
|
40882
|
-
(
|
|
40882
|
+
})((l = o));
|
|
40883
|
+
(n.startsWith("data:image/") || (/[ ,]?image\//.test(s) && d) || d) && (u = aw),
|
|
40883
40884
|
/[ ,]?video\//.test(s) &&
|
|
40884
40885
|
(function (e) {
|
|
40885
40886
|
return lb(e, ["3gp", "mpg", "mpeg", "mp4", "m4v", "m4p", "ogv", "ogg", "mov", "webm"]);
|
|
40886
|
-
})(
|
|
40887
|
-
(
|
|
40887
|
+
})(l) &&
|
|
40888
|
+
(u = rw),
|
|
40888
40889
|
/[ ,]?audio\//.test(s) &&
|
|
40889
40890
|
(function (e) {
|
|
40890
40891
|
return lb(e, ["3gp", "adts", "mpeg", "mp3", "mp4", "ogg", "mov", "webm", "rtp", "amr", "wav"]);
|
|
40891
|
-
})(
|
|
40892
|
-
(
|
|
40893
|
-
} else null !=
|
|
40892
|
+
})(l) &&
|
|
40893
|
+
(u = iw);
|
|
40894
|
+
} else null != a && a.startsWith("image/") && ((l = sb(l)), (u = aw)), null != a && a.startsWith("video/") && ((l = sb(l)), (u = rw), (c = l)), null != a && a.startsWith("audio/") && ((l = sb(l)), (u = iw), (c = l));
|
|
40894
40895
|
return (
|
|
40895
|
-
m && (
|
|
40896
|
-
|
|
40896
|
+
m && (l = m + l),
|
|
40897
|
+
u === aw
|
|
40897
40898
|
? ew.createElement(
|
|
40898
40899
|
j,
|
|
40899
|
-
{ index: t, key:
|
|
40900
|
-
ew.createElement(ab, { className: "file-item-view", src:
|
|
40900
|
+
{ index: t, key: i + "_" + t },
|
|
40901
|
+
ew.createElement(ab, { className: "file-item-view", src: l, alt: i }),
|
|
40901
40902
|
)
|
|
40902
|
-
:
|
|
40903
|
-
? ew.createElement(j, { index: t, key:
|
|
40904
|
-
:
|
|
40905
|
-
? ew.createElement("audio", { src:
|
|
40906
|
-
:
|
|
40903
|
+
: u === rw
|
|
40904
|
+
? ew.createElement(j, { index: t, key: i + "_" + t }, ew.createElement(eb, { src: l, href: c }))
|
|
40905
|
+
: u === iw
|
|
40906
|
+
? ew.createElement("audio", { src: l, controls: !0 })
|
|
40907
|
+
: n.name
|
|
40907
40908
|
);
|
|
40908
40909
|
}),
|
|
40909
40910
|
l || u || (!n && k.length > 0) || (h > 0 && k.length >= h)
|
|
@@ -41754,21 +41755,35 @@
|
|
|
41754
41755
|
}
|
|
41755
41756
|
return e;
|
|
41756
41757
|
}
|
|
41757
|
-
|
|
41758
|
-
|
|
41759
|
-
|
|
41760
|
-
|
|
41761
|
-
|
|
41762
|
-
|
|
41763
|
-
|
|
41764
|
-
|
|
41765
|
-
|
|
41766
|
-
|
|
41767
|
-
},
|
|
41768
|
-
},
|
|
41769
|
-
"x-designable-id": "ndi5r4fw9jd",
|
|
41770
|
-
};
|
|
41758
|
+
function Nw(e) {
|
|
41759
|
+
var t = Aw().cloneDeep(e),
|
|
41760
|
+
n = t.schema || t,
|
|
41761
|
+
r = t.form || {};
|
|
41762
|
+
return (
|
|
41763
|
+
r.layout || (r.layout = "horizontal"),
|
|
41764
|
+
zw(n.properties, r.layout),
|
|
41765
|
+
(t = Rw(Rw({}, e), {}, { form: r, schema: n }))
|
|
41766
|
+
);
|
|
41767
|
+
}
|
|
41771
41768
|
function zw(e, t) {
|
|
41769
|
+
var n = e && Object.keys(e);
|
|
41770
|
+
return (
|
|
41771
|
+
n &&
|
|
41772
|
+
n.length > 0 &&
|
|
41773
|
+
n.forEach(function (n) {
|
|
41774
|
+
var r,
|
|
41775
|
+
a,
|
|
41776
|
+
i = e[n];
|
|
41777
|
+
(i["x-decorator-props"] || (i["x-decorator-props"] = {}),
|
|
41778
|
+
i["x-decorator-props"].layout || (i["x-decorator-props"].layout = t),
|
|
41779
|
+
null != i && i.properties && zw(null == i ? void 0 : i.properties, t),
|
|
41780
|
+
null != i && null !== (r = i.items) && void 0 !== r && r.properties) &&
|
|
41781
|
+
zw(null == i || null === (a = i.items) || void 0 === a ? void 0 : a.properties, t);
|
|
41782
|
+
}),
|
|
41783
|
+
e
|
|
41784
|
+
);
|
|
41785
|
+
}
|
|
41786
|
+
function Iw(e, t) {
|
|
41772
41787
|
var n = Object.keys(e);
|
|
41773
41788
|
if (Object.getOwnPropertySymbols) {
|
|
41774
41789
|
var r = Object.getOwnPropertySymbols(e);
|
|
@@ -41780,29 +41795,29 @@
|
|
|
41780
41795
|
}
|
|
41781
41796
|
return n;
|
|
41782
41797
|
}
|
|
41783
|
-
function
|
|
41798
|
+
function Fw(e) {
|
|
41784
41799
|
for (var t = 1; t < arguments.length; t++) {
|
|
41785
41800
|
var n = null != arguments[t] ? arguments[t] : {};
|
|
41786
41801
|
t % 2
|
|
41787
|
-
?
|
|
41802
|
+
? Iw(Object(n), !0).forEach(function (t) {
|
|
41788
41803
|
r(e, t, n[t]);
|
|
41789
41804
|
})
|
|
41790
41805
|
: Object.getOwnPropertyDescriptors
|
|
41791
41806
|
? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n))
|
|
41792
|
-
:
|
|
41807
|
+
: Iw(Object(n)).forEach(function (t) {
|
|
41793
41808
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
41794
41809
|
});
|
|
41795
41810
|
}
|
|
41796
41811
|
return e;
|
|
41797
41812
|
}
|
|
41798
|
-
const
|
|
41813
|
+
const Ww = (0, a.forwardRef)(function (t, n) {
|
|
41799
41814
|
var r = (0, a.useMemo)(function () {
|
|
41800
41815
|
return (0,
|
|
41801
|
-
zm.createSchemaField)({ components:
|
|
41816
|
+
zm.createSchemaField)({ components: Fw(Fw({ FormItem: Zm, FormLayout: Hm, CascadePicker: rg, CheckList: cy, Slider: Td, Checkbox: uy, DatePicker: tg, FormGrid: Ep, Input: iy, List: $y, Selector: oy, Stepper: dy, Switch: Zy, FormButtonGroup: s_, Submit: fy, Reset: hy, Card: vo }, e), t.components), scope: Fw({}, t.schemaScope) });
|
|
41802
41817
|
}, []),
|
|
41803
41818
|
o = (0, a.useMemo)(function () {
|
|
41804
41819
|
return (0,
|
|
41805
|
-
Nm.createForm)(
|
|
41820
|
+
Nm.createForm)(Fw({ initialValues: t.initialValues, readOnly: t.readOnly, disabled: t.disabled }, t.formOptions || {}));
|
|
41806
41821
|
}, []);
|
|
41807
41822
|
(0, a.useImperativeHandle)(n, function () {
|
|
41808
41823
|
return { formRender: o };
|
|
@@ -41812,27 +41827,7 @@
|
|
|
41812
41827
|
}, []);
|
|
41813
41828
|
var s = (0, a.useMemo)(
|
|
41814
41829
|
function () {
|
|
41815
|
-
return (
|
|
41816
|
-
var t = Aw().cloneDeep(e),
|
|
41817
|
-
n = t.schema || t,
|
|
41818
|
-
r = t.form || {};
|
|
41819
|
-
if ((r.layout || (r.layout = "horizontal"), n.properties && Object.keys(n.properties).length > 0)) {
|
|
41820
|
-
var a = Object.keys(n.properties)[0];
|
|
41821
|
-
if ("FormLayout" !== n.properties[a]["x-component"]) {
|
|
41822
|
-
var i = Aw().cloneDeep(Nw);
|
|
41823
|
-
r &&
|
|
41824
|
-
(i.properties.formLayout_tfsvvph1s7i["x-component-props"]
|
|
41825
|
-
? (i.properties.formLayout_tfsvvph1s7i["x-component-props"] = Rw(
|
|
41826
|
-
Rw({}, i.properties.formLayout_tfsvvph1s7i["x-component-props"]),
|
|
41827
|
-
r,
|
|
41828
|
-
))
|
|
41829
|
-
: (i.properties.formLayout_tfsvvph1s7i["x-component-props"] = Aw().cloneDeep(r))),
|
|
41830
|
-
(i.properties.formLayout_tfsvvph1s7i.properties = n.properties),
|
|
41831
|
-
(n = i);
|
|
41832
|
-
}
|
|
41833
|
-
}
|
|
41834
|
-
return { form: r, schema: n };
|
|
41835
|
-
})(t.schema).schema;
|
|
41830
|
+
return Nw(t.schema).schema;
|
|
41836
41831
|
},
|
|
41837
41832
|
[t.schema],
|
|
41838
41833
|
);
|
package/package.json
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
|
|
3
|
-
export const formLayoutTPL = {
|
|
4
|
-
type: "object",
|
|
5
|
-
properties: {
|
|
6
|
-
formLayout_tfsvvph1s7i: {
|
|
7
|
-
type: "void",
|
|
8
|
-
"x-component": "FormLayout",
|
|
9
|
-
"x-component-props": {
|
|
10
|
-
layout: "vertical",
|
|
11
|
-
},
|
|
12
|
-
"x-designable-id": "formLayout_tfsvvph1s7i",
|
|
13
|
-
"x-index": 0,
|
|
14
|
-
properties: {},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
"x-designable-id": "ndi5r4fw9jd",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
3
|
export function schemaHandler(_schema) {
|
|
21
4
|
let formSchema = _.cloneDeep(_schema);
|
|
22
5
|
let schema = formSchema.schema || formSchema;
|
|
@@ -26,30 +9,36 @@ export function schemaHandler(_schema) {
|
|
|
26
9
|
formConf.layout = "horizontal";
|
|
27
10
|
}
|
|
28
11
|
|
|
29
|
-
|
|
30
|
-
const key = Object.keys(schema.properties)[0];
|
|
31
|
-
// 手动添加 FormLayout
|
|
32
|
-
if (schema.properties[key]["x-component"] !== "FormLayout") {
|
|
33
|
-
const _s = _.cloneDeep(formLayoutTPL);
|
|
34
|
-
if (formConf) {
|
|
35
|
-
if (!_s.properties.formLayout_tfsvvph1s7i["x-component-props"]) {
|
|
36
|
-
_s.properties.formLayout_tfsvvph1s7i["x-component-props"] = _.cloneDeep(formConf);
|
|
37
|
-
} else {
|
|
38
|
-
_s.properties.formLayout_tfsvvph1s7i["x-component-props"] = {
|
|
39
|
-
..._s.properties.formLayout_tfsvvph1s7i["x-component-props"],
|
|
40
|
-
...formConf,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
_s.properties.formLayout_tfsvvph1s7i.properties = schema.properties;
|
|
45
|
-
schema = _s;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
12
|
+
handleLayout(schema.properties, formConf.layout);
|
|
48
13
|
|
|
49
14
|
formSchema = {
|
|
15
|
+
..._schema,
|
|
50
16
|
form: formConf,
|
|
51
17
|
schema: schema,
|
|
52
18
|
};
|
|
53
19
|
|
|
54
20
|
return formSchema;
|
|
55
21
|
}
|
|
22
|
+
|
|
23
|
+
export function handleLayout(properties, layout) {
|
|
24
|
+
const keys = properties && Object.keys(properties);
|
|
25
|
+
if (keys && keys.length > 0) {
|
|
26
|
+
// 手动设置 FormLayout
|
|
27
|
+
keys.forEach((key) => {
|
|
28
|
+
const field = properties[key];
|
|
29
|
+
if (!field["x-decorator-props"]) {
|
|
30
|
+
field["x-decorator-props"] = {};
|
|
31
|
+
}
|
|
32
|
+
if (!field["x-decorator-props"].layout) {
|
|
33
|
+
field["x-decorator-props"].layout = layout;
|
|
34
|
+
}
|
|
35
|
+
if (field?.properties) {
|
|
36
|
+
handleLayout(field?.properties, layout);
|
|
37
|
+
}
|
|
38
|
+
if (field?.items?.properties) {
|
|
39
|
+
handleLayout(field?.items?.properties, layout);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return properties;
|
|
44
|
+
}
|
|
@@ -122,8 +122,8 @@ export async function handleOssUpload(files, opt) {
|
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
return Promise.all(promise).then((filePromises) => {
|
|
125
|
-
filePromises?.forEach((fileUrl) => {
|
|
126
|
-
_files.ossUrl = fileUrl;
|
|
125
|
+
filePromises?.forEach((fileUrl, idx) => {
|
|
126
|
+
_files[idx].ossUrl = fileUrl;
|
|
127
127
|
});
|
|
128
128
|
return Promise.resolve(_files);
|
|
129
129
|
});
|
|
@@ -193,45 +193,52 @@ function Uploader(props) {
|
|
|
193
193
|
accept={curAccept}
|
|
194
194
|
capture={props.capture}
|
|
195
195
|
></input>
|
|
196
|
-
{fileList.map((
|
|
196
|
+
{fileList.map((_it, idx) => {
|
|
197
|
+
let it = _it;
|
|
198
|
+
// 数据兼容处理
|
|
199
|
+
if (typeof it === "string") {
|
|
200
|
+
it = {
|
|
201
|
+
url: it,
|
|
202
|
+
name: it,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
197
205
|
const { type, name, url } = it;
|
|
198
206
|
let src = "";
|
|
199
207
|
let fileType = "";
|
|
200
208
|
let downLoadUrl = undefined;
|
|
201
209
|
|
|
202
210
|
// 判断文件类型,获取对应展示的数据
|
|
203
|
-
if (
|
|
204
|
-
src = url
|
|
205
|
-
it = url ? url : it;
|
|
211
|
+
if (url) {
|
|
212
|
+
src = url;
|
|
206
213
|
// 图片
|
|
207
|
-
const isImg = checkImageUrl(
|
|
214
|
+
const isImg = checkImageUrl(src);
|
|
208
215
|
if (it.startsWith("data:image/") || (/[ ,]?image\//.test(accept) && isImg) || isImg) {
|
|
209
216
|
fileType = TYPE_IMG;
|
|
210
217
|
}
|
|
211
218
|
// 视频
|
|
212
|
-
if (/[ ,]?video\//.test(accept) && checkVideoUrl(
|
|
219
|
+
if (/[ ,]?video\//.test(accept) && checkVideoUrl(src)) {
|
|
213
220
|
fileType = TYPE_VIDEO;
|
|
214
221
|
}
|
|
215
222
|
// 音频
|
|
216
|
-
if (/[ ,]?audio\//.test(accept) && checkAudioUrl(
|
|
223
|
+
if (/[ ,]?audio\//.test(accept) && checkAudioUrl(src)) {
|
|
217
224
|
fileType = TYPE_AUDIO;
|
|
218
225
|
}
|
|
219
226
|
} else {
|
|
220
227
|
// 图片
|
|
221
228
|
if (type?.startsWith("image/")) {
|
|
222
|
-
src = getFileURL(
|
|
229
|
+
src = getFileURL(src);
|
|
223
230
|
fileType = TYPE_IMG;
|
|
224
231
|
}
|
|
225
232
|
|
|
226
233
|
// 视频
|
|
227
234
|
if (type?.startsWith("video/")) {
|
|
228
|
-
src = getFileURL(
|
|
235
|
+
src = getFileURL(src);
|
|
229
236
|
fileType = TYPE_VIDEO;
|
|
230
237
|
// TODO: 确认下载逻辑
|
|
231
238
|
downLoadUrl = src;
|
|
232
239
|
}
|
|
233
240
|
if (type?.startsWith("audio/")) {
|
|
234
|
-
src = getFileURL(
|
|
241
|
+
src = getFileURL(src);
|
|
235
242
|
fileType = TYPE_AUDIO;
|
|
236
243
|
// TODO: 确认下载逻辑
|
|
237
244
|
downLoadUrl = src;
|
package/src/index.tsx
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
Submit,
|
|
18
18
|
Reset,
|
|
19
19
|
} from "@formily/antd-mobile";
|
|
20
|
-
import { Slider } from "antd-mobile";
|
|
20
|
+
import { Card, Slider } from "antd-mobile";
|
|
21
21
|
import { createForm } from "@formily/core";
|
|
22
22
|
import { FormProvider, createSchemaField, Schema } from "@formily/react";
|
|
23
23
|
|
|
@@ -48,6 +48,7 @@ const FormRender = forwardRef((props: formPropsI, parentRef) => {
|
|
|
48
48
|
FormButtonGroup,
|
|
49
49
|
Submit,
|
|
50
50
|
Reset,
|
|
51
|
+
Card,
|
|
51
52
|
...customComponents,
|
|
52
53
|
...props.components,
|
|
53
54
|
},
|