icarys-fc-vant 1.0.15 → 1.0.16

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.
Files changed (101) hide show
  1. package/README.md +87 -278
  2. package/dist/components/common/subform/package.json +48 -0
  3. package/dist/components/common/subform/src/component.jsx +75 -0
  4. package/dist/components/common/subform/src/index.js +3 -0
  5. package/dist/components/common/wangeditor/package-lock.json +114 -0
  6. package/dist/components/common/wangeditor/package.json +52 -0
  7. package/dist/components/common/wangeditor/src/component.jsx +74 -0
  8. package/dist/components/common/wangeditor/src/index.js +3 -0
  9. package/dist/core/babel.config.js +13 -0
  10. package/dist/core/bili.config.js +34 -0
  11. package/dist/core/package-lock.json +13 -0
  12. package/dist/core/package.json +61 -0
  13. package/dist/core/src/components/formCreate.js +287 -0
  14. package/dist/core/src/components/fragment.js +12 -0
  15. package/dist/core/src/factory/context.js +264 -0
  16. package/dist/core/src/factory/creator.js +63 -0
  17. package/dist/core/src/factory/maker.js +17 -0
  18. package/dist/core/src/factory/manager.js +87 -0
  19. package/dist/core/src/factory/node.js +89 -0
  20. package/dist/core/src/factory/parser.js +28 -0
  21. package/dist/core/src/frame/api.js +691 -0
  22. package/dist/core/src/frame/attrs.js +12 -0
  23. package/dist/core/src/frame/dataDriver.js +76 -0
  24. package/dist/core/src/frame/fetch.js +128 -0
  25. package/dist/core/src/frame/index.js +792 -0
  26. package/dist/core/src/frame/language.js +50 -0
  27. package/dist/core/src/frame/provider.js +297 -0
  28. package/dist/core/src/frame/util.js +311 -0
  29. package/dist/core/src/handler/context.js +573 -0
  30. package/dist/core/src/handler/effect.js +122 -0
  31. package/dist/core/src/handler/index.js +143 -0
  32. package/dist/core/src/handler/inject.js +199 -0
  33. package/dist/core/src/handler/input.js +199 -0
  34. package/dist/core/src/handler/lifecycle.js +55 -0
  35. package/dist/core/src/handler/loader.js +375 -0
  36. package/dist/core/src/handler/page.js +46 -0
  37. package/dist/core/src/handler/render.js +29 -0
  38. package/dist/core/src/index.js +12 -0
  39. package/dist/core/src/parser/html.js +17 -0
  40. package/dist/core/src/render/cache.js +47 -0
  41. package/dist/core/src/render/index.js +33 -0
  42. package/dist/core/src/render/render.js +418 -0
  43. package/dist/core/types/index.d.ts +842 -0
  44. package/dist/icarys-fc-vant.umd.js +17 -0
  45. package/dist/index.d.ts +27 -0
  46. package/dist/index.esm.js +39 -0
  47. package/dist/index.js +46 -0
  48. package/dist/utils/lib/console.js +16 -0
  49. package/dist/utils/lib/debounce.js +9 -0
  50. package/dist/utils/lib/deepextend.js +51 -0
  51. package/dist/utils/lib/deepset.js +14 -0
  52. package/dist/utils/lib/extend.js +20 -0
  53. package/dist/utils/lib/index.js +14 -0
  54. package/dist/utils/lib/json.js +90 -0
  55. package/dist/utils/lib/mergeprops.js +62 -0
  56. package/dist/utils/lib/mitt.js +43 -0
  57. package/dist/utils/lib/modify.js +8 -0
  58. package/dist/utils/lib/slot.js +8 -0
  59. package/dist/utils/lib/toarray.js +5 -0
  60. package/dist/utils/lib/tocase.js +11 -0
  61. package/dist/utils/lib/todate.js +10 -0
  62. package/dist/utils/lib/toline.js +10 -0
  63. package/dist/utils/lib/topromise.js +10 -0
  64. package/dist/utils/lib/tostring.js +7 -0
  65. package/dist/utils/lib/type.js +45 -0
  66. package/dist/utils/lib/unique.js +6 -0
  67. package/dist/utils/package.json +32 -0
  68. package/dist/vant/auto-import.d.ts +5 -0
  69. package/dist/vant/auto-import.js +50 -0
  70. package/dist/vant/babel.config.js +10 -0
  71. package/dist/vant/bili.config.js +40 -0
  72. package/dist/vant/examples/main.js +13 -0
  73. package/dist/vant/examples/rule.js +366 -0
  74. package/dist/vant/package.json +83 -0
  75. package/dist/vant/src/components/calendar.jsx +128 -0
  76. package/dist/vant/src/components/cascader.jsx +120 -0
  77. package/dist/vant/src/components/checkbox.jsx +38 -0
  78. package/dist/vant/src/components/datePicker.jsx +87 -0
  79. package/dist/vant/src/components/group.jsx +384 -0
  80. package/dist/vant/src/components/index.js +26 -0
  81. package/dist/vant/src/components/radio.jsx +38 -0
  82. package/dist/vant/src/components/select.jsx +81 -0
  83. package/dist/vant/src/components/timePicker.jsx +76 -0
  84. package/dist/vant/src/components/uploader.jsx +99 -0
  85. package/dist/vant/src/core/alias.js +31 -0
  86. package/dist/vant/src/core/api.js +135 -0
  87. package/dist/vant/src/core/config.js +35 -0
  88. package/dist/vant/src/core/index.js +45 -0
  89. package/dist/vant/src/core/manager.js +282 -0
  90. package/dist/vant/src/core/provider.js +63 -0
  91. package/dist/vant/src/core/utils.js +15 -0
  92. package/dist/vant/src/index.js +13 -0
  93. package/dist/vant/src/parsers/hidden.js +12 -0
  94. package/dist/vant/src/parsers/index.js +59 -0
  95. package/dist/vant/src/parsers/row.js +10 -0
  96. package/dist/vant/src/style/index.css +495 -0
  97. package/dist/vant/types/config.d.ts +99 -0
  98. package/dist/vant/types/index.d.ts +27 -0
  99. package/dist/vant/vue.config.js +21 -0
  100. package/package.json +29 -67
  101. package/dist/index.min.js +0 -7411
@@ -0,0 +1,282 @@
1
+ import getConfig from './config';
2
+ import mergeProps from '../../../utils/lib/mergeprops';
3
+ import is, {hasProperty} from '../../../utils/lib/type';
4
+ import extend from '../../../utils/lib/extend';
5
+ import {showNotify} from 'vant';
6
+
7
+ function tidy(props, name) {
8
+ if (!hasProperty(props, name)) return;
9
+ if (is.String(props[name])) {
10
+ props[name] = {[name]: props[name], show: true};
11
+ }
12
+ }
13
+
14
+ function isFalse(val) {
15
+ return val === false;
16
+ }
17
+
18
+ function tidyBool(opt, name) {
19
+ if (hasProperty(opt, name) && !is.Object(opt[name])) {
20
+ opt[name] = {show: !!opt[name]};
21
+ }
22
+ }
23
+
24
+ function tidyRule(rule) {
25
+ const _rule = {...rule};
26
+ delete _rule.children;
27
+ return _rule;
28
+ }
29
+
30
+ export default {
31
+ validate() {
32
+ const form = this.form();
33
+ if (form) {
34
+ return form.validate();
35
+ } else {
36
+ return new Promise(v => v());
37
+ }
38
+ },
39
+ validateField(field) {
40
+ return new Promise((resolve, reject) => {
41
+ const form = this.form();
42
+ if (form) {
43
+ form.validate(field).then(resolve).catch(reject);
44
+ } else {
45
+ resolve();
46
+ }
47
+ });
48
+ },
49
+ clearValidateState(ctx) {
50
+ const form = this.form();
51
+ if (form) {
52
+ return form.resetValidation(ctx.id);
53
+ }
54
+ },
55
+ tidyOptions(options) {
56
+ ['submitBtn', 'resetBtn', 'row', 'info', 'wrap', 'col', 'title'].forEach(name => {
57
+ tidyBool(options, name);
58
+ })
59
+ return options;
60
+ },
61
+ tidyRule({prop}) {
62
+ tidy(prop, 'title');
63
+ tidy(prop, 'info');
64
+ prop.validate && prop.validate.forEach(item => {
65
+ if (is.String(item.pattern)) {
66
+ item.pattern = new RegExp(item.pattern);
67
+ }
68
+ });
69
+ return prop;
70
+ },
71
+ mergeProp(ctx) {
72
+ const def = {
73
+ info: {
74
+ icon: true,
75
+ },
76
+ title: {},
77
+ col: {span: 24},
78
+ wrap: {},
79
+ };
80
+ ['info', 'wrap', 'col', 'title'].forEach(name => {
81
+ ctx.prop[name] = mergeProps([this.options[name] || {}, ctx.prop[name] || {}], def[name]);
82
+ });
83
+ },
84
+ getDefaultOptions() {
85
+ return getConfig();
86
+ },
87
+ adapterValidate(validate, validator) {
88
+ if (validate.trigger === 'change') {
89
+ validate.trigger = 'onChange';
90
+ } else if (validate.trigger === 'blur') {
91
+ validate.trigger = 'onBlur';
92
+ }
93
+ validate.validator = (value) => {
94
+ return new Promise((resolve) => {
95
+ const callback = (err) => {
96
+ validate.message = err;
97
+ if (err) {
98
+ resolve(false);
99
+ } else {
100
+ resolve();
101
+ }
102
+ }
103
+ return validator(value, callback);
104
+ })
105
+ }
106
+ return validate;
107
+ },
108
+ update() {
109
+ const form = this.options.form;
110
+ this.rule = {
111
+ props: {...form},
112
+ on: {
113
+ submit: (e) => {
114
+ e.preventDefault();
115
+ }
116
+ },
117
+ style: form.style,
118
+ type: 'form',
119
+ };
120
+ },
121
+ beforeRender() {
122
+ const {key, ref} = this;
123
+ const form = this.options.form;
124
+ extend(this.rule, {key, ref, class: [form.className, form.class, 'form-create-m', this.$handle.preview ? 'is-preview' : '']});
125
+ },
126
+ render(children) {
127
+ if (children.slotLen() && !this.$handle.preview) {
128
+ children.setSlot(undefined, () => this.makeFormBtn());
129
+ }
130
+ return this.$r(this.rule, isFalse(this.options.row.show) ? children.getSlots() : [this.makeRow(children)]);
131
+ },
132
+ makeWrap(ctx, children) {
133
+ const rule = ctx.prop;
134
+ const uni = `${this.key}${ctx.key}`;
135
+ const col = rule.col;
136
+ const isTitle = this.isTitle(rule) && rule.wrap.title !== false;
137
+ const {col: _col} = this.rule.props;
138
+ const cls = rule.wrap.class;
139
+ delete rule.wrap.class;
140
+ delete rule.wrap.title;
141
+ const item = isFalse(rule.wrap.show) ? children : this.$r(mergeProps([rule.wrap, {
142
+ props: {
143
+ modelValue: ctx.rule.value,
144
+ label: isTitle ? rule.title.title : undefined,
145
+ ...tidyRule(rule.wrap || {}),
146
+ name: ctx.id,
147
+ rules: ctx.injectValidate(),
148
+ },
149
+ class: this.$render.mergeClass(cls || rule.className, 'fc-form-item'),
150
+ key: `${uni}fi`,
151
+ ref: ctx.wrapRef,
152
+ type: 'formItem',
153
+ }]), {input: () => children, ...(isTitle ? {label: () => this.makeInfo(rule, uni, ctx)} : {})});
154
+ return (isFalse(_col) || isFalse(col.show)) ? item : this.makeCol(rule, uni, [item]);
155
+ },
156
+ isTitle(rule) {
157
+ if (this.options.form.title === false) return false;
158
+ const title = rule.title;
159
+ return !((!title.title && !title.native) || isFalse(title.show))
160
+ },
161
+ makeInfo(rule, uni, ctx) {
162
+ const titleProp = {...rule.title};
163
+ const infoProp = {...rule.info};
164
+ const titleSlot = this.getSlot('title');
165
+ const children = [titleSlot ? titleSlot({
166
+ title: ctx.refRule?.__$title?.value,
167
+ rule: ctx.rule,
168
+ options: this.options
169
+ }) : ctx.refRule?.__$title?.value];
170
+ const flag = !isFalse(infoProp.show) && (infoProp.info || infoProp.native) && !isFalse(infoProp.icon);
171
+ if (flag) {
172
+ children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r({
173
+ type: infoProp.icon === true ? 'icon-warning' : infoProp.icon,
174
+ style: 'width:1em;',
175
+ }));
176
+ }
177
+
178
+ const _prop = mergeProps([titleProp, {
179
+ props: tidyRule(titleProp),
180
+ key: `${uni}tit`,
181
+ class: 'fc-form-title',
182
+ type: titleProp.type || 'span',
183
+ on: {
184
+ click: (...args) => {
185
+ if (flag && infoProp.info) {
186
+ showNotify({type: 'warning', message: ctx.refRule?.__$info?.value, duration: 1000});
187
+ }
188
+ this.$handle.targetHook(ctx, 'titleClick', {args});
189
+ }
190
+ }
191
+ }]);
192
+
193
+ delete _prop.props.show;
194
+ delete _prop.props.title;
195
+ delete _prop.props.native;
196
+
197
+ return this.$r(_prop, children);
198
+ },
199
+ makeCol(rule, uni, children) {
200
+ const col = rule.col;
201
+ return this.$r({
202
+ class: this.$render.mergeClass(col.class, 'fc-form-col'),
203
+ type: 'col',
204
+ props: col || {span: 24},
205
+ key: `${uni}col`
206
+ }, children);
207
+ },
208
+ makeRow(children) {
209
+ const row = this.options.row || {};
210
+ return this.$r({
211
+ type: 'row',
212
+ props: row,
213
+ class: this.$render.mergeClass(row.class, 'fc-form-row'),
214
+ key: `${this.key}row`
215
+ }, children)
216
+ },
217
+ makeFormBtn() {
218
+ let vn = [];
219
+ if (!isFalse(this.options.submitBtn.show)) {
220
+ vn.push(this.makeSubmitBtn())
221
+ }
222
+ if (!isFalse(this.options.resetBtn.show)) {
223
+ vn.push(this.makeResetBtn())
224
+ }
225
+ if (!vn.length) {
226
+ return;
227
+ }
228
+ return this.$r({
229
+ type: 'cell',
230
+ class: 'fc-form-cell fc-form-footer',
231
+ key: `${this.key}fb`
232
+ }, vn);
233
+ },
234
+
235
+ makeResetBtn() {
236
+ const resetBtn = {...this.options.resetBtn};
237
+ const innerText = resetBtn.innerText || this.$handle.api.t('reset') || '重置';
238
+ delete resetBtn.innerText;
239
+ delete resetBtn.click;
240
+ delete resetBtn.col;
241
+ delete resetBtn.show;
242
+ return this.$r({
243
+ type: 'button',
244
+ props: resetBtn,
245
+ class: 'fc-reset-btn',
246
+ style: {width: resetBtn.width},
247
+ on: {
248
+ click: () => {
249
+ const fApi = this.$handle.api;
250
+ this.options.resetBtn.click
251
+ ? this.options.resetBtn.click(fApi)
252
+ : fApi.resetFields();
253
+ }
254
+ },
255
+ key: `${this.key}b2`,
256
+ }, [innerText]);
257
+ },
258
+ makeSubmitBtn() {
259
+ const submitBtn = {...this.options.submitBtn};
260
+ const innerText = submitBtn.innerText || this.$handle.api.t('submit') || '提交';
261
+ delete submitBtn.innerText;
262
+ delete submitBtn.click;
263
+ delete submitBtn.col;
264
+ delete submitBtn.show;
265
+ return this.$r({
266
+ type: 'button',
267
+ props: submitBtn,
268
+ class: 'fc-submit-btn',
269
+ style: {width: submitBtn.width},
270
+ on: {
271
+ click: () => {
272
+ const fApi = this.$handle.api;
273
+ this.options.submitBtn.click
274
+ ? this.options.submitBtn.click(fApi)
275
+ : fApi.submit().catch(() => {
276
+ });
277
+ }
278
+ },
279
+ key: `${this.key}b1`,
280
+ }, [innerText]);
281
+ }
282
+ }
@@ -0,0 +1,63 @@
1
+ import is from '../../../utils/lib/type';
2
+
3
+ const required = {
4
+ name: 'required',
5
+ load(inject, rule, api) {
6
+ const val = parseVal(inject.getValue());
7
+ let _title = undefined;
8
+ if (val.required === false) {
9
+ inject.clearProp();
10
+ api.clearValidateState([rule.field]);
11
+ } else {
12
+ const validate = {
13
+ required: true,
14
+ validator(v) {
15
+ updateMessage();
16
+ return !is.empty(v);
17
+ },
18
+ trigger: ['onChange', 'onSubmit'],
19
+ ...val,
20
+ };
21
+ const updateMessage = () => {
22
+ const title = rule.__fc__.refRule.__$title?.value;
23
+ if (_title === title) {
24
+ return;
25
+ }
26
+ _title = title;
27
+ if (!val.message) {
28
+ validate.message = api.t('required', {title}) || (title + (api.getLocale() === 'en' ? ' is required' : '不能为空'));
29
+ } else {
30
+ const match = val.message.match(/^\{\{\s*\$t\.(.+)\s*\}\}$/);
31
+ if (match) {
32
+ validate.message = api.t(match[1], {title});
33
+ }
34
+ }
35
+ }
36
+ updateMessage();
37
+ inject.getProp().validate = [validate];
38
+ }
39
+ api.sync(rule);
40
+ },
41
+ watch(...args) {
42
+ required.load(...args);
43
+ }
44
+ }
45
+
46
+ function parseVal(val) {
47
+ if (is.Boolean(val)) {
48
+ return {required: val}
49
+ } else if (is.String(val)) {
50
+ return {message: val};
51
+ } else if (is.Undef(val)) {
52
+ return {required: false};
53
+ } else if (is.Function(val)) {
54
+ return {validator: val};
55
+ } else if (!is.Object(val)) {
56
+ return {};
57
+ } else {
58
+ return val;
59
+ }
60
+ }
61
+
62
+
63
+ export default required
@@ -0,0 +1,15 @@
1
+ export const normalizeOptions = (options) => {
2
+ if (!options || !Array.isArray(options)) {
3
+ return [];
4
+ }
5
+ return options.map(item => {
6
+ const normalized = {...item};
7
+ if (normalized.label !== undefined && normalized.text === undefined) {
8
+ normalized.text = normalized.label;
9
+ }
10
+ if (normalized.children && Array.isArray(normalized.children)) {
11
+ normalized.children = normalizeOptions(normalized.children);
12
+ }
13
+ return normalized;
14
+ })
15
+ };
@@ -0,0 +1,13 @@
1
+ import VantFormCreate from './core/index';
2
+
3
+ const FormCreateMobile = VantFormCreate();
4
+
5
+ if (typeof window !== 'undefined') {
6
+ window.formCreateMobile = FormCreateMobile;
7
+ }
8
+
9
+ const maker = FormCreateMobile.maker;
10
+
11
+ export {maker}
12
+
13
+ export default FormCreateMobile;
@@ -0,0 +1,12 @@
1
+ import {creatorFactory} from '../../../core/src/index';
2
+
3
+ const name = 'hidden';
4
+ export default {
5
+ name,
6
+ maker: {
7
+ [name]: (field, value) => creatorFactory(name)('', field, value)
8
+ },
9
+ render() {
10
+ return [];
11
+ }
12
+ }
@@ -0,0 +1,59 @@
1
+ import hidden from './hidden';
2
+ import row from './row';
3
+ import {hasProperty} from '../../../utils/lib/type';
4
+
5
+
6
+ const checkbox = {
7
+ name: 'checkbox',
8
+ mergeProp(ctx) {
9
+ const props = ctx.prop.props;
10
+ if (!hasProperty(props, 'options'))
11
+ props.options = ctx.prop.options || [];
12
+ }
13
+ }
14
+
15
+ const radio = {
16
+ name: 'radio',
17
+ mergeProp(ctx) {
18
+ const props = ctx.prop.props;
19
+ if (!hasProperty(props, 'options'))
20
+ props.options = ctx.prop.options || [];
21
+ }
22
+ }
23
+
24
+ const select = {
25
+ name: 'select',
26
+ mergeProp(ctx) {
27
+ const props = ctx.prop.props;
28
+ if (!hasProperty(props, 'options'))
29
+ props.options = ctx.prop.options || [];
30
+ }
31
+ }
32
+
33
+ const cascader = {
34
+ name: 'cascader',
35
+ mergeProp(ctx) {
36
+ const props = ctx.prop.props;
37
+ if (!hasProperty(props, 'options'))
38
+ props.options = ctx.prop.options || [];
39
+ }
40
+ }
41
+
42
+ const textarea = {
43
+ name: 'textarea',
44
+ mergeProp(ctx) {
45
+ let {props} = ctx.prop;
46
+ props.type = 'textarea';
47
+ }
48
+ }
49
+
50
+
51
+ export default [
52
+ hidden,
53
+ row,
54
+ cascader,
55
+ checkbox,
56
+ radio,
57
+ select,
58
+ textarea,
59
+ ]
@@ -0,0 +1,10 @@
1
+ export default {
2
+ name: 'FcRow',
3
+ render(_, ctx) {
4
+ return ctx.vNode.col({props: {span: 24}}, {
5
+ default:()=>[
6
+ ctx.vNode.row(ctx.prop, _)
7
+ ]
8
+ })
9
+ }
10
+ }