@cloudbase/weda-ui 3.6.3 → 3.7.1

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 (92) hide show
  1. package/dist/configs/components/form-location.d.ts +2 -2
  2. package/dist/configs/components/wd-card.d.ts +14 -14
  3. package/dist/configs/components/wd-card.js +38 -32
  4. package/dist/configs/components/wd-cascader.d.ts +276 -0
  5. package/dist/configs/components/wd-cascader.js +183 -0
  6. package/dist/configs/components/wd-code-editor.d.ts +245 -0
  7. package/dist/configs/components/wd-code-editor.js +92 -0
  8. package/dist/configs/components/wd-form-arr.d.ts +193 -0
  9. package/dist/configs/components/wd-form-arr.js +206 -0
  10. package/dist/configs/components/wd-form-obj.d.ts +181 -0
  11. package/dist/configs/components/wd-form-obj.js +107 -0
  12. package/dist/configs/components/wd-form.d.ts +2 -2
  13. package/dist/configs/components/wd-image.js +1 -1
  14. package/dist/configs/components/wd-table.d.ts +3 -3
  15. package/dist/configs/components/wd-upload-file.d.ts +1 -0
  16. package/dist/configs/components/wd-upload-file.js +4 -1
  17. package/dist/configs/components/wd-upload-image.d.ts +2 -0
  18. package/dist/configs/components/wd-upload-image.js +4 -1
  19. package/dist/configs/components/web-view.d.ts +20 -1
  20. package/dist/configs/components/web-view.js +22 -1
  21. package/dist/configs/index.d.ts +1604 -28
  22. package/dist/configs/index.js +8 -0
  23. package/dist/configs/type-utils/type-form.d.ts +22 -0
  24. package/dist/configs/type-utils/type-form.js +58 -1
  25. package/dist/configs/type-utils/x-runtime-default.d.ts +3 -0
  26. package/dist/configs/type-utils/x-runtime-default.js +3 -0
  27. package/dist/enum/index.d.ts +8 -0
  28. package/dist/enum/index.js +11 -0
  29. package/dist/style/index.scss +1 -1
  30. package/dist/web/components/container/index.js +49 -1
  31. package/dist/web/components/form/uploader/uploader.h5.js +3 -3
  32. package/dist/web/components/form/uploader/uploader.pc.js +3 -3
  33. package/dist/web/components/form-input-hooks/index.js +14 -7
  34. package/dist/web/components/form-input-hooks/validator.js +2 -2
  35. package/dist/web/components/form-location/index.d.ts +1 -1
  36. package/dist/web/components/index.d.ts +4 -0
  37. package/dist/web/components/index.js +6 -0
  38. package/dist/web/components/richTextView/index.css +2 -1
  39. package/dist/web/components/wd-cascader/cascader.d.ts +6 -0
  40. package/dist/web/components/wd-cascader/cascader.h5.d.ts +2 -0
  41. package/dist/web/components/wd-cascader/cascader.h5.js +132 -0
  42. package/dist/web/components/wd-cascader/cascader.js +97 -0
  43. package/dist/web/components/wd-cascader/index.d.ts +4 -0
  44. package/dist/web/components/wd-cascader/index.js +3 -0
  45. package/dist/web/components/wd-cascader/interface.d.ts +26 -0
  46. package/dist/web/components/wd-cascader/interface.js +1 -0
  47. package/dist/web/components/wd-cascader/utils.d.ts +6 -0
  48. package/dist/web/components/wd-cascader/utils.js +63 -0
  49. package/dist/web/components/wd-code-editor/index.d.ts +3 -0
  50. package/dist/web/components/wd-code-editor/index.js +3 -0
  51. package/dist/web/components/wd-code-editor/lang/index.d.ts +17 -0
  52. package/dist/web/components/wd-code-editor/lang/index.js +21 -0
  53. package/dist/web/components/wd-code-editor/lang/mongodb/complete.d.ts +8 -0
  54. package/dist/web/components/wd-code-editor/lang/mongodb/complete.js +222 -0
  55. package/dist/web/components/wd-code-editor/lang/mongodb/index.d.ts +2 -0
  56. package/dist/web/components/wd-code-editor/lang/mongodb/index.js +60 -0
  57. package/dist/web/components/wd-code-editor/lang/mongodb/snippets.d.ts +6 -0
  58. package/dist/web/components/wd-code-editor/lang/mongodb/snippets.js +189 -0
  59. package/dist/web/components/wd-code-editor/theme.d.ts +4 -0
  60. package/dist/web/components/wd-code-editor/theme.js +5 -0
  61. package/dist/web/components/wd-code-editor/wd-code-editor.d.ts +9 -0
  62. package/dist/web/components/wd-code-editor/wd-code-editor.js +66 -0
  63. package/dist/web/components/wd-date/elements/Modal.h5.d.ts +2 -0
  64. package/dist/web/components/wd-date/elements/Modal.h5.js +4 -2
  65. package/dist/web/components/wd-form/form-utils.js +1 -1
  66. package/dist/web/components/wd-form/index.d.ts +4 -4
  67. package/dist/web/components/wd-form-arr/index.d.ts +4 -0
  68. package/dist/web/components/wd-form-arr/index.js +3 -0
  69. package/dist/web/components/wd-form-arr/wd-form-arr.d.ts +8 -0
  70. package/dist/web/components/wd-form-arr/wd-form-arr.js +6 -0
  71. package/dist/web/components/wd-form-item/wd-form-item.js +3 -3
  72. package/dist/web/components/wd-form-obj/base-form-obj.d.ts +13 -0
  73. package/dist/web/components/wd-form-obj/base-form-obj.js +351 -0
  74. package/dist/web/components/wd-form-obj/index.d.ts +4 -0
  75. package/dist/web/components/wd-form-obj/index.js +3 -0
  76. package/dist/web/components/wd-form-obj/wd-form-obj.d.ts +9 -0
  77. package/dist/web/components/wd-form-obj/wd-form-obj.js +7 -0
  78. package/dist/web/components/wd-input/wd-input.d.ts +2 -2
  79. package/dist/web/components/wd-input-phone/wd-input-phone.js +2 -2
  80. package/dist/web/components/wd-table/utils/index.js +20 -8
  81. package/dist/web/components/wd-table/wd-table.js +4 -2
  82. package/dist/web/components/wd-tabs/tabs.d.ts +1 -1
  83. package/dist/web/components/wd-textarea/calcTextareaHeight.d.ts +1 -0
  84. package/dist/web/components/wd-textarea/calcTextareaHeight.js +45 -0
  85. package/dist/web/components/wd-textarea/wd-textarea.js +4 -6
  86. package/dist/web/components/wd-unified-link/index.js +2 -2
  87. package/dist/web/components/web-view/web-view.js +15 -4
  88. package/dist/web/utils/tool.d.ts +1 -0
  89. package/dist/web/utils/tool.js +4 -1
  90. package/dist/web/utils/widget-api/index.d.ts +20 -0
  91. package/dist/web/utils/widget-api/index.js +14 -0
  92. package/package.json +8 -1
@@ -0,0 +1,21 @@
1
+ import { javascript } from '@codemirror/lang-javascript';
2
+ import { sql, MySQL } from '@codemirror/lang-sql';
3
+ import jsbeautifier from 'js-beautify';
4
+ import { mongodb } from './mongodb';
5
+ export const langs = {
6
+ javascript,
7
+ jsx: () => javascript({ jsx: true }),
8
+ typescript: () => javascript({ typescript: true }),
9
+ tsx: () => javascript({ jsx: true, typescript: true }),
10
+ mongodb,
11
+ sql,
12
+ mysql: () => sql({ dialect: MySQL }),
13
+ };
14
+ /** Language list */
15
+ export const langNames = Object.keys(langs);
16
+ export function loadLanguage(name) {
17
+ return langs[name] ? langs[name]() : null;
18
+ }
19
+ export async function format(value) {
20
+ return jsbeautifier(value);
21
+ }
@@ -0,0 +1,8 @@
1
+ import { CompletionContext, type CompletionResult, type CompletionSource } from '@codemirror/autocomplete';
2
+ export declare const dontComplete: string[];
3
+ export declare function localCompletionSource(context: CompletionContext): CompletionResult | null;
4
+ export declare function completionPath(context: CompletionContext): {
5
+ path: readonly string[];
6
+ name: string;
7
+ } | null;
8
+ export declare function scopeCompletionSource(scope: any): CompletionSource;
@@ -0,0 +1,222 @@
1
+ /* eslint-disable rulesdir/no-phantom-deps*/
2
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
3
+ import {
4
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
5
+ NodeWeakMap, IterMode, } from '@lezer/common';
6
+ import { syntaxTree } from '@codemirror/language';
7
+ const cache = new NodeWeakMap();
8
+ const ScopeNodes = new Set([
9
+ 'Script',
10
+ 'Block',
11
+ 'FunctionExpression',
12
+ 'FunctionDeclaration',
13
+ 'ArrowFunction',
14
+ 'MethodDeclaration',
15
+ 'ForStatement',
16
+ ]);
17
+ function defID(type) {
18
+ return (node, def) => {
19
+ const id = node.node.getChild('VariableDefinition');
20
+ if (id)
21
+ def(id, type);
22
+ return true;
23
+ };
24
+ }
25
+ const functionContext = ['FunctionDeclaration'];
26
+ const gatherCompletions = {
27
+ FunctionDeclaration: defID('function'),
28
+ ClassDeclaration: defID('class'),
29
+ ClassExpression: () => true,
30
+ EnumDeclaration: defID('constant'),
31
+ TypeAliasDeclaration: defID('type'),
32
+ NamespaceDeclaration: defID('namespace'),
33
+ VariableDefinition(node, def) {
34
+ if (!node.matchContext(functionContext))
35
+ def(node, 'variable');
36
+ },
37
+ TypeDefinition(node, def) {
38
+ def(node, 'type');
39
+ },
40
+ __proto__: null,
41
+ };
42
+ function getScope(doc, node) {
43
+ const cached = cache.get(node);
44
+ if (cached)
45
+ return cached;
46
+ const completions = [];
47
+ let top = true;
48
+ function def(node, type) {
49
+ const name = doc.sliceString(node.from, node.to);
50
+ completions.push({ label: name, type });
51
+ }
52
+ node.cursor(IterMode.IncludeAnonymous).iterate((node) => {
53
+ if (top) {
54
+ top = false;
55
+ }
56
+ else if (node.name) {
57
+ const gather = gatherCompletions[node.name];
58
+ if ((gather && gather(node, def)) || ScopeNodes.has(node.name))
59
+ return false;
60
+ }
61
+ else if (node.to - node.from > 8192) {
62
+ // Allow caching for bigger internal nodes
63
+ for (const c of getScope(doc, node.node))
64
+ completions.push(c);
65
+ return false;
66
+ }
67
+ });
68
+ cache.set(node, completions);
69
+ return completions;
70
+ }
71
+ const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;
72
+ export const dontComplete = [
73
+ 'TemplateString',
74
+ 'String',
75
+ 'RegExp',
76
+ 'LineComment',
77
+ 'BlockComment',
78
+ 'VariableDefinition',
79
+ 'TypeDefinition',
80
+ 'Label',
81
+ 'PropertyDefinition',
82
+ 'PropertyName',
83
+ 'PrivatePropertyDefinition',
84
+ 'PrivatePropertyName',
85
+ '.',
86
+ '?.',
87
+ ];
88
+ /// Completion source that looks up locally defined names in
89
+ /// JavaScript code.
90
+ export function localCompletionSource(context) {
91
+ const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
92
+ if (dontComplete.indexOf(inner.name) > -1)
93
+ return null;
94
+ const isWord = inner.name == 'VariableName' ||
95
+ (inner.to - inner.from < 20 &&
96
+ Identifier.test(context.state.sliceDoc(inner.from, inner.to)));
97
+ if (!isWord && !context.explicit)
98
+ return null;
99
+ let options = [];
100
+ for (let pos = inner; pos; pos = pos.parent) {
101
+ if (ScopeNodes.has(pos.name))
102
+ options = options.concat(getScope(context.state.doc, pos));
103
+ }
104
+ return {
105
+ options,
106
+ from: isWord ? inner.from : context.pos,
107
+ validFor: Identifier,
108
+ };
109
+ }
110
+ function pathFor(read, member, name) {
111
+ var _a;
112
+ const path = [];
113
+ for (;;) {
114
+ const obj = member.firstChild;
115
+ let prop;
116
+ if ((obj === null || obj === void 0 ? void 0 : obj.name) == 'VariableName') {
117
+ path.push(read(obj));
118
+ return { path: path.reverse(), name };
119
+ }
120
+ else if ((obj === null || obj === void 0 ? void 0 : obj.name) == 'MemberExpression' &&
121
+ ((_a = (prop = obj.lastChild)) === null || _a === void 0 ? void 0 : _a.name) == 'PropertyName') {
122
+ path.push(read(prop));
123
+ member = obj;
124
+ }
125
+ else {
126
+ return null;
127
+ }
128
+ }
129
+ }
130
+ /// Helper function for defining JavaScript completion sources. It
131
+ /// returns the completable name and object path for a completion
132
+ /// context, or null if no name/property completion should happen at
133
+ /// that position. For example, when completing after `a.b.c` it will
134
+ /// return `{path: ["a", "b"], name: "c"}`. When completing after `x`
135
+ /// it will return `{path: [], name: "x"}`. When not in a property or
136
+ /// name, it will return null if `context.explicit` is false, and
137
+ /// `{path: [], name: ""}` otherwise.
138
+ export function completionPath(context) {
139
+ const read = (node) => context.state.doc.sliceString(node.from, node.to);
140
+ const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
141
+ if (inner.name == 'PropertyName') {
142
+ return pathFor(read, inner.parent, read(inner));
143
+ }
144
+ else if ((inner.name == '.' || inner.name == '?.') &&
145
+ inner.parent.name == 'MemberExpression') {
146
+ return pathFor(read, inner.parent, '');
147
+ }
148
+ else if (dontComplete.indexOf(inner.name) > -1) {
149
+ return null;
150
+ }
151
+ else if (inner.name == 'VariableName' ||
152
+ (inner.to - inner.from < 20 && Identifier.test(read(inner)))) {
153
+ return { path: [], name: read(inner) };
154
+ }
155
+ else if (inner.name == 'MemberExpression') {
156
+ return pathFor(read, inner, '');
157
+ }
158
+ else {
159
+ return context.explicit ? { path: [], name: '' } : null;
160
+ }
161
+ }
162
+ function enumeratePropertyCompletions(obj, top) {
163
+ const options = [], seen = new Set();
164
+ for (let depth = 0;; depth++) {
165
+ for (const name of (Object.getOwnPropertyNames || Object.keys)(obj)) {
166
+ if (!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(name) ||
167
+ seen.has(name))
168
+ continue;
169
+ seen.add(name);
170
+ let value;
171
+ try {
172
+ value = obj[name];
173
+ }
174
+ catch (_) {
175
+ continue;
176
+ }
177
+ options.push({
178
+ label: name,
179
+ type: typeof value == 'function'
180
+ ? /^[A-Z]/.test(name)
181
+ ? 'class'
182
+ : top
183
+ ? 'function'
184
+ : 'method'
185
+ : top
186
+ ? 'variable'
187
+ : 'property',
188
+ boost: -depth,
189
+ });
190
+ }
191
+ const next = Object.getPrototypeOf(obj);
192
+ if (!next)
193
+ return options;
194
+ obj = next;
195
+ }
196
+ }
197
+ /// Defines a [completion source](#autocomplete.CompletionSource) that
198
+ /// completes from the given scope object (for example `globalThis`).
199
+ /// Will enter properties of the object when completing properties on
200
+ /// a directly-named path.
201
+ export function scopeCompletionSource(scope) {
202
+ const cache = new Map();
203
+ return (context) => {
204
+ const path = completionPath(context);
205
+ if (!path)
206
+ return null;
207
+ let target = scope;
208
+ for (const step of path.path) {
209
+ target = target[step];
210
+ if (!target)
211
+ return null;
212
+ }
213
+ let options = cache.get(target);
214
+ if (!options)
215
+ cache.set(target, (options = enumeratePropertyCompletions(target, !path.path.length)));
216
+ return {
217
+ from: context.pos - path.name.length,
218
+ options,
219
+ validFor: Identifier,
220
+ };
221
+ };
222
+ }
@@ -0,0 +1,2 @@
1
+ import { LanguageSupport } from '@codemirror/language';
2
+ export declare function mongodb(): LanguageSupport;
@@ -0,0 +1,60 @@
1
+ /* eslint-disable rulesdir/no-phantom-deps */
2
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
3
+ import { parser } from '@lezer/javascript';
4
+ import { LRLanguage, LanguageSupport, delimitedIndent, flatIndent, continuedIndent, indentNodeProp, foldNodeProp, foldInside, } from '@codemirror/language';
5
+ import { completeFromList, ifNotIn } from '@codemirror/autocomplete';
6
+ import { getCompletions, getSnippets } from './snippets';
7
+ import { localCompletionSource, dontComplete } from './complete';
8
+ /// mongodb support. Includes [snippet](#lang-mongodb.snippets)
9
+ /// and local variable completion.
10
+ export function mongodb() {
11
+ /// A language provider based on the [Lezer mongodb
12
+ /// parser](https://github.com/lezer-parser/mongodb), extended with
13
+ /// highlighting and indentation information.
14
+ const lang = LRLanguage.define({
15
+ name: 'mongodb',
16
+ parser: parser.configure({
17
+ props: [
18
+ indentNodeProp.add({
19
+ IfStatement: continuedIndent({ except: /^\s*({|else\b)/ }),
20
+ TryStatement: continuedIndent({
21
+ except: /^\s*({|catch\b|finally\b)/,
22
+ }),
23
+ LabeledStatement: flatIndent,
24
+ SwitchBody: (context) => {
25
+ const after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
26
+ return (context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit);
27
+ },
28
+ Block: delimitedIndent({ closing: '}' }),
29
+ ArrowFunction: (cx) => cx.baseIndent + cx.unit,
30
+ 'TemplateString BlockComment': () => null,
31
+ 'Statement Property': continuedIndent({ except: /^{/ }),
32
+ }),
33
+ foldNodeProp.add({
34
+ 'Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType': foldInside,
35
+ BlockComment(tree) {
36
+ return { from: tree.from + 2, to: tree.to - 2 };
37
+ },
38
+ }),
39
+ ],
40
+ }),
41
+ languageData: {
42
+ closeBrackets: { brackets: ['(', '[', '{', "'", '"', '`'] },
43
+ commentTokens: { line: '//', block: { open: '/*', close: '*/' } },
44
+ indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
45
+ wordChars: '$',
46
+ },
47
+ });
48
+ return new LanguageSupport(lang, [
49
+ lang.data.of({
50
+ autocomplete: ifNotIn(dontComplete, completeFromList(getSnippets())),
51
+ }),
52
+ lang.data.of({
53
+ autocomplete: localCompletionSource,
54
+ }),
55
+ lang.data.of({
56
+ autocomplete: getCompletions,
57
+ }),
58
+ [],
59
+ ]);
60
+ }
@@ -0,0 +1,6 @@
1
+ export declare const getSnippets: () => import("@codemirror/autocomplete").Completion[];
2
+ export declare const getCompletions: (context: any) => {
3
+ from: any;
4
+ options: any[];
5
+ validFor: RegExp;
6
+ };
@@ -0,0 +1,189 @@
1
+ import { snippetCompletion as snip } from '@codemirror/autocomplete';
2
+ const completionMap = (name, type) => ({ label: name, type });
3
+ /// A collection of JavaScript-related
4
+ /// [snippets](#autocomplete.snippet).
5
+ export const getSnippets = () => {
6
+ const snippets = [
7
+ snip('function ${name}(${params}) {\n\t${}\n}', {
8
+ label: 'function',
9
+ detail: 'definition',
10
+ type: 'keyword',
11
+ }),
12
+ snip('for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}', {
13
+ label: 'for',
14
+ detail: 'loop',
15
+ type: 'keyword',
16
+ }),
17
+ snip('for (let ${name} of ${collection}) {\n\t${}\n}', {
18
+ label: 'for',
19
+ detail: 'of loop',
20
+ type: 'keyword',
21
+ }),
22
+ snip('do {\n\t${}\n} while (${})', {
23
+ label: 'do',
24
+ detail: 'loop',
25
+ type: 'keyword',
26
+ }),
27
+ snip('while (${}) {\n\t${}\n}', {
28
+ label: 'while',
29
+ detail: 'loop',
30
+ type: 'keyword',
31
+ }),
32
+ snip('try {\n\t${}\n} catch (${error}) {\n\t${}\n}', {
33
+ label: 'try',
34
+ detail: '/ catch block',
35
+ type: 'keyword',
36
+ }),
37
+ snip('if (${}) {\n\t${}\n}', {
38
+ label: 'if',
39
+ detail: 'block',
40
+ type: 'keyword',
41
+ }),
42
+ snip('if (${}) {\n\t${}\n} else {\n\t${}\n}', {
43
+ label: 'if',
44
+ detail: '/ else block',
45
+ type: 'keyword',
46
+ }),
47
+ snip('class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}', {
48
+ label: 'class',
49
+ detail: 'definition',
50
+ type: 'keyword',
51
+ }),
52
+ ];
53
+ const keywords = [
54
+ 'await',
55
+ 'async',
56
+ 'break',
57
+ 'case',
58
+ 'catch',
59
+ 'const',
60
+ 'constructor',
61
+ 'continue',
62
+ 'debugger',
63
+ 'default',
64
+ 'delete',
65
+ 'else',
66
+ 'enum',
67
+ 'export',
68
+ 'extends',
69
+ 'false',
70
+ 'finally',
71
+ 'implements',
72
+ 'import',
73
+ 'in',
74
+ 'instanceof',
75
+ 'interface',
76
+ 'let',
77
+ 'new',
78
+ 'private',
79
+ 'protected',
80
+ 'public',
81
+ 'return',
82
+ 'switch',
83
+ 'static',
84
+ 'throw',
85
+ 'typeof',
86
+ 'var',
87
+ 'void',
88
+ 'while',
89
+ 'yield',
90
+ ].map((i) => completionMap(i, 'keyword'));
91
+ return snippets.concat(keywords);
92
+ };
93
+ export const getCompletions = (context) => {
94
+ const classList = [
95
+ 'Math',
96
+ 'Array',
97
+ 'Object',
98
+ 'String',
99
+ 'Number',
100
+ 'Boolean',
101
+ 'Date',
102
+ 'RegExp',
103
+ 'Error',
104
+ 'Symbol',
105
+ 'Set',
106
+ 'Map',
107
+ 'WeakSet',
108
+ 'WeakMap',
109
+ 'Promise',
110
+ 'Proxy',
111
+ 'Reflect',
112
+ 'JSON',
113
+ 'Intl',
114
+ 'Function',
115
+ ].map((i) => completionMap(i, 'class'));
116
+ const constantList = [
117
+ 'undefined',
118
+ 'NaN',
119
+ 'Infinity',
120
+ 'null',
121
+ 'true',
122
+ 'false',
123
+ 'this',
124
+ 'super',
125
+ 'console',
126
+ 'process',
127
+ 'globalThis',
128
+ 'global',
129
+ 'arguments',
130
+ ].map((i) => completionMap(i, 'constant'));
131
+ const functionList = ['eval', 'require'].map((i) => completionMap(i, 'constant'));
132
+ const methodList = [
133
+ 'aggregate',
134
+ 'bulkWrite',
135
+ 'count',
136
+ 'countDocuments',
137
+ 'createIndex',
138
+ 'createIndexes',
139
+ 'dataSize',
140
+ 'deleteMany',
141
+ 'deleteOne',
142
+ 'distinct',
143
+ 'drop',
144
+ 'dropIndex',
145
+ 'dropIndexes',
146
+ 'ensureIndex',
147
+ 'estimatedDocumentCount',
148
+ 'explain',
149
+ 'find',
150
+ 'findAndModify',
151
+ 'findOne',
152
+ 'findOneAndDelete',
153
+ 'findOneAndReplace',
154
+ 'findOneAndUpdate',
155
+ 'getIndexes',
156
+ 'hideIndex',
157
+ 'insert',
158
+ 'insertOne',
159
+ 'insertMany',
160
+ 'isCapped',
161
+ 'mapReduce',
162
+ 'reIndex',
163
+ 'remove',
164
+ 'renameCollection',
165
+ 'replaceOne',
166
+ 'save',
167
+ 'stats',
168
+ 'storageSize',
169
+ 'totalIndexSize',
170
+ 'totalSize',
171
+ 'unhideIndex',
172
+ 'update',
173
+ 'updateMany',
174
+ 'updateOne',
175
+ 'watch',
176
+ ].map((i) => completionMap(i, 'method'));
177
+ const textList = ['db'].map((i) => completionMap(i, 'text'));
178
+ const completions = [].concat(textList, classList, constantList, functionList, methodList);
179
+ const before = context.matchBefore(/\w+/);
180
+ // If completion wasn't explicitly started and there
181
+ // is no word before the cursor, don't open completions.
182
+ if (!context.explicit && !before)
183
+ return null;
184
+ return {
185
+ from: before ? before.from : context.pos,
186
+ options: completions,
187
+ validFor: /^\w*$/,
188
+ };
189
+ };
@@ -0,0 +1,4 @@
1
+ export declare const themeData: {
2
+ githubLight: import("@codemirror/state").Extension;
3
+ githubDark: import("@codemirror/state").Extension;
4
+ };
@@ -0,0 +1,5 @@
1
+ import { githubLight, githubDark } from '@uiw/codemirror-theme-github';
2
+ export const themeData = {
3
+ githubLight,
4
+ githubDark,
5
+ };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { CommonPropsType } from '../../types';
3
+ import type { DataType } from '../../../configs/components/wd-code-editor';
4
+ import { LanguageName } from './lang';
5
+ export declare const WdCodeEditor: React.ForwardRefExoticComponent<WdCodeEditorProps & React.RefAttributes<any>>;
6
+ export interface WdCodeEditorProps extends CommonPropsType, DataType {
7
+ classRoot?: string;
8
+ language?: LanguageName;
9
+ }
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useImperativeHandle, useMemo, useRef, useState } from 'react';
3
+ import CodeMirror from '@uiw/react-codemirror';
4
+ import classNames from '../../utils/classnames';
5
+ import { useConfig } from '../../utils/config-context';
6
+ import { WdFormItem } from '../wd-form-item';
7
+ import { useFormInputTrait } from '../form-input-hooks';
8
+ import { filterPropsWithOn, getUuid } from '../../utils/tool';
9
+ import { useSize } from '../../utils/hooks/useFormLegacy';
10
+ import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
11
+ import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default';
12
+ import { loadLanguage, format } from './lang';
13
+ import { themeData } from './theme';
14
+ export const WdCodeEditor = React.forwardRef(function WdCodeEditor(props, ref) {
15
+ const { name, placeholder, focus = X_RUNTIME_DEFAULT.focus, events, classRoot = 'code-editor', language = X_RUNTIME_DEFAULT.codeEditorLanguage, theme = X_RUNTIME_DEFAULT.codeEditorTheme, style, } = props;
16
+ /** 兼容从 Form 获取属性,必须引入,自动挂载组件方法 */
17
+ const [innerHandle, setInnerHandle] = useState({});
18
+ const traitProps = { ...props, setInnerHandle, inputRef: ref };
19
+ const { value: _value, onChange: onChangeForm, disabled, readOnly, validateErrorMsg, validateState, visible, } = useFormInputTrait(traitProps);
20
+ const value = _value !== null && _value !== void 0 ? _value : '';
21
+ const { classPrefix } = useConfig();
22
+ const startWithOnProps = useMemo(() => filterPropsWithOn(props), [props]);
23
+ const inputId = useMemo(() => getUuid(), []);
24
+ const height = useMemo(() => {
25
+ var _a;
26
+ const height = (style === null || style === void 0 ? void 0 : style.height)
27
+ ? `${(_a = String(style.height)) === null || _a === void 0 ? void 0 : _a.replace(/(\d+(?:\.\d+)?)(%|rem)/g, '$1')}`
28
+ : '200px';
29
+ return height.includes('px') ? height : `${height}px`;
30
+ }, [style === null || style === void 0 ? void 0 : style.height]);
31
+ const size = useSize(props);
32
+ const textareaRef = useRef(null);
33
+ useImperativeHandle(ref, () => textareaRef.current, [textareaRef]);
34
+ const wrapRef = useRef(null);
35
+ const root = `${classPrefix}-${classRoot}`;
36
+ const inputWrap = `${classPrefix}-form-input-wrap`;
37
+ const textareaWrap = `${classPrefix}-form-code-editor-wrap`;
38
+ const cls = classNames(inputWrap, textareaWrap, `${root}`, `size-width-${size}`, `size-font-${size}`, {
39
+ 'size-width-hundred': true,
40
+ 'is-disabled': disabled && !readOnly,
41
+ });
42
+ /** 内部事件 */
43
+ const onChange = function (e) {
44
+ var _a;
45
+ const text = typeof e === 'string' ? e : e.target.value;
46
+ onChangeForm(text);
47
+ (_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: text }, { originEvent: e });
48
+ };
49
+ // Widget API,挂载组件只读属性和组件方法
50
+ useSetWidgetApi(() => ({
51
+ ...innerHandle,
52
+ value,
53
+ format: async () => {
54
+ try {
55
+ const result = await format(value);
56
+ onChangeForm(result);
57
+ }
58
+ catch (error) {
59
+ console.error(error);
60
+ }
61
+ },
62
+ }), [innerHandle, onChangeForm, value], ref);
63
+ const themeExtension = themeData[theme];
64
+ const languageExtension = loadLanguage(language);
65
+ return (visible && (_jsx(WdFormItem, { ...props, validateErrorMsg: validateErrorMsg, validateState: validateState, readOnly: false, disabled: disabled, readValue: value, classRoot: classRoot, inputId: inputId, layout: props.layout, children: _jsx("div", { className: cls, ref: wrapRef, onFocus: () => wrapRef.current.classList.add('is-focused'), onBlur: () => wrapRef.current.classList.remove('is-focused'), "data-color-mode": theme, children: _jsxs("div", { className: `${root}__content`, "data-testid": "wd-code-editor", children: [_jsx(CodeMirror, { value: value, height: height, extensions: [languageExtension], onChange: onChange, placeholder: placeholder, editable: !readOnly && !disabled, autoFocus: focus, theme: themeExtension }), _jsx("textarea", { id: inputId, ref: textareaRef, placeholder: placeholder, name: name, value: value, autoFocus: focus, disabled: disabled, readOnly: readOnly, onChange: onChange, spellCheck: false, ...startWithOnProps })] }) }) })));
66
+ });
@@ -4,6 +4,8 @@ export interface IModal {
4
4
  onOk?: any;
5
5
  onClose?: any;
6
6
  children?: any;
7
+ className?: string;
8
+ header?: any;
7
9
  }
8
10
  /**
9
11
  * H5端 模态框
@@ -2,13 +2,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Portal } from '../../common/portal';
3
3
  import { noop } from '../../../utils/constant';
4
4
  import { useConfig } from '../../../utils/config-context';
5
+ import classNames from '../../../utils/classnames';
5
6
  /**
6
7
  * H5端 模态框
7
8
  */
8
9
  export function Modal(props) {
9
- const { onOk = noop, onClose = noop, visible, children } = props;
10
+ const { onOk = noop, onClose = noop, visible, children, className, header, } = props;
10
11
  const { classPrefix } = useConfig();
11
12
  if (!visible)
12
13
  return null;
13
- return (_jsx(Portal, { type: "div", children: _jsxs("div", { className: `${classPrefix}-custom-picker`, children: [_jsx("div", { className: `${classPrefix}-custom-backdrop`, onClick: onClose }), _jsxs("div", { className: `${classPrefix}-custom-picker__inner`, children: [_jsxs("div", { className: `${classPrefix}-custom-picker__header`, children: [_jsx("div", { className: `${classPrefix}-custom-picker__header-cancle`, onClick: onClose, children: "\u53D6\u6D88" }), _jsx("div", { className: `${classPrefix}-custom-picker__header-confirm`, onClick: onOk, children: "\u786E\u5B9A" })] }), _jsx("div", { className: `${classPrefix}-custom-picker__body`, children: children })] })] }) }));
14
+ const renderHeader = () => header ? (header) : (_jsxs("div", { className: `${classPrefix}-custom-picker__header`, children: [_jsx("div", { className: `${classPrefix}-custom-picker__header-cancle`, onClick: onClose, children: "\u53D6\u6D88" }), _jsx("div", { className: `${classPrefix}-custom-picker__header-confirm`, onClick: onOk, children: "\u786E\u5B9A" })] }));
15
+ return (_jsx(Portal, { type: "div", children: _jsxs("div", { className: classNames(`${classPrefix}-custom-picker`, className), children: [_jsx("div", { className: `${classPrefix}-custom-backdrop`, onClick: onClose }), _jsxs("div", { className: `${classPrefix}-custom-picker__inner`, children: [renderHeader(), _jsx("div", { className: `${classPrefix}-custom-picker__body`, children: children })] })] }) }));
14
16
  }
@@ -17,7 +17,7 @@ export function getFormDataFromItemMap(formItemMap, formType) {
17
17
  formItemMap.forEach((items, name) => {
18
18
  items.forEach((item) => {
19
19
  var _a, _b, _c;
20
- if (((_b = (_a = item.getConfig) === null || _a === void 0 ? void 0 : _a.call(item)) === null || _b === void 0 ? void 0 : _b.componentType) !== 'formdetail') {
20
+ if (!['formdetail', 'formObj'].includes((_b = (_a = item.getConfig) === null || _a === void 0 ? void 0 : _a.call(item)) === null || _b === void 0 ? void 0 : _b.componentType)) {
21
21
  lodashSet(formData, name, (_c = item === null || item === void 0 ? void 0 : item.getValue) === null || _c === void 0 ? void 0 : _c.call(item));
22
22
  }
23
23
  });
@@ -14,17 +14,17 @@ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponen
14
14
  layout: "vertical" | "horizontal";
15
15
  dataSourceName: string;
16
16
  labelAlign: "left" | "right";
17
- datasourceType: "connector" | "custom-connector" | "expression" | "model";
18
- methodGetItem: string;
19
- paramGetItem: Record<string, unknown>;
17
+ isDisabledSubmit: boolean;
20
18
  methodCreate: string;
21
19
  methodUpdate: string;
22
- isDisabledSubmit: boolean;
23
20
  formType_bind: boolean;
21
+ datasourceType: "connector" | "model" | "expression" | "custom-connector";
24
22
  fields: {
25
23
  name: string;
26
24
  componentType: string;
27
25
  }[];
26
+ methodGetItem: string;
27
+ paramGetItem: Record<string, unknown>;
28
28
  colNum: never;
29
29
  lgWidth: "lg" | "sm" | "md" | "hundred";
30
30
  initialValues: Record<string, unknown>;
@@ -0,0 +1,4 @@
1
+ import { WdFormArr } from './wd-form-arr';
2
+ export { WdFormArr } from './wd-form-arr';
3
+ export type { WdFormArrProps } from './wd-form-arr';
4
+ export default WdFormArr;