@flowgram-vue/form-materials 0.2.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/LICENSE +22 -0
- package/bin/run.sh +7 -0
- package/dist/index.cjs +0 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +0 -0
- package/dist/index.js.map +1 -0
- package/package.json +86 -0
- package/src/components/assign-row/assign-row.vue +69 -0
- package/src/components/assign-row/index.ts +7 -0
- package/src/components/assign-row/types.ts +25 -0
- package/src/components/assign-rows/assign-rows.vue +44 -0
- package/src/components/assign-rows/index.ts +6 -0
- package/src/components/batch-outputs/batch-outputs.vue +46 -0
- package/src/components/batch-outputs/index.ts +6 -0
- package/src/components/batch-outputs/styles.css +17 -0
- package/src/components/batch-outputs/types.ts +23 -0
- package/src/components/batch-variable-selector/batch-variable-selector.vue +24 -0
- package/src/components/batch-variable-selector/index.ts +6 -0
- package/src/components/blur-input/blur-input.vue +47 -0
- package/src/components/blur-input/index.ts +6 -0
- package/src/components/code-editor/base-code-editor.vue +44 -0
- package/src/components/code-editor/index.ts +58 -0
- package/src/components/code-editor/styles.css +27 -0
- package/src/components/code-editor/types.ts +20 -0
- package/src/components/code-editor/utils.ts +24 -0
- package/src/components/code-editor-mini/code-editor-mini.vue +16 -0
- package/src/components/code-editor-mini/index.ts +6 -0
- package/src/components/condition-context/context.ts +45 -0
- package/src/components/condition-context/hooks/use-condition.ts +120 -0
- package/src/components/condition-context/index.ts +14 -0
- package/src/components/condition-context/op.ts +86 -0
- package/src/components/condition-context/types.ts +22 -0
- package/src/components/condition-row/condition-row.vue +126 -0
- package/src/components/condition-row/index.ts +7 -0
- package/src/components/condition-row/styles.css +30 -0
- package/src/components/condition-row/types.ts +12 -0
- package/src/components/constant-input/constant-input.vue +48 -0
- package/src/components/constant-input/index.ts +7 -0
- package/src/components/constant-input/types.ts +23 -0
- package/src/components/coze-editor-extensions/extensions/inputs-tree.vue +16 -0
- package/src/components/coze-editor-extensions/extensions/variable-tag.vue +10 -0
- package/src/components/coze-editor-extensions/extensions/variable-tree.vue +18 -0
- package/src/components/coze-editor-extensions/index.ts +22 -0
- package/src/components/coze-editor-extensions/styles.css +41 -0
- package/src/components/db-condition-row/db-condition-row.vue +112 -0
- package/src/components/db-condition-row/index.ts +7 -0
- package/src/components/db-condition-row/styles.css +41 -0
- package/src/components/db-condition-row/types.ts +20 -0
- package/src/components/display-flow-value/display-flow-value.vue +46 -0
- package/src/components/display-flow-value/index.ts +6 -0
- package/src/components/display-inputs-values/display-inputs-value-all-in-tag.vue +26 -0
- package/src/components/display-inputs-values/display-inputs-values.vue +43 -0
- package/src/components/display-inputs-values/index.ts +7 -0
- package/src/components/display-inputs-values/styles.css +10 -0
- package/src/components/display-outputs/display-outputs.vue +62 -0
- package/src/components/display-outputs/index.ts +6 -0
- package/src/components/display-outputs/styles.css +10 -0
- package/src/components/display-schema-tag/display-schema-tag.vue +41 -0
- package/src/components/display-schema-tag/index.ts +6 -0
- package/src/components/display-schema-tag/styles.css +25 -0
- package/src/components/display-schema-tree/display-schema-tree.vue +55 -0
- package/src/components/display-schema-tree/index.ts +6 -0
- package/src/components/display-schema-tree/styles.css +84 -0
- package/src/components/dynamic-value-input/dynamic-value-input.vue +145 -0
- package/src/components/dynamic-value-input/hooks.ts +71 -0
- package/src/components/dynamic-value-input/index.ts +10 -0
- package/src/components/dynamic-value-input/styles.css +59 -0
- package/src/components/index.ts +84 -0
- package/src/components/inputs-values/index.ts +6 -0
- package/src/components/inputs-values/inputs-values.vue +67 -0
- package/src/components/inputs-values/styles.css +17 -0
- package/src/components/inputs-values/types.ts +23 -0
- package/src/components/inputs-values-tree/hooks/use-child-list.ts +65 -0
- package/src/components/inputs-values-tree/index.ts +6 -0
- package/src/components/inputs-values-tree/inputs-values-tree.vue +59 -0
- package/src/components/inputs-values-tree/row.vue +139 -0
- package/src/components/inputs-values-tree/styles.css +94 -0
- package/src/components/inputs-values-tree/types.ts +23 -0
- package/src/components/json-editor-with-variables/index.ts +7 -0
- package/src/components/json-editor-with-variables/json-editor-with-variables.vue +24 -0
- package/src/components/json-editor-with-variables/types.ts +8 -0
- package/src/components/json-schema-creator/index.ts +7 -0
- package/src/components/json-schema-creator/json-input-modal.vue +51 -0
- package/src/components/json-schema-creator/json-schema-creator.vue +27 -0
- package/src/components/json-schema-creator/types.ts +10 -0
- package/src/components/json-schema-creator/utils/json-to-schema.ts +50 -0
- package/src/components/json-schema-editor/default-value.vue +30 -0
- package/src/components/json-schema-editor/hooks.ts +134 -0
- package/src/components/json-schema-editor/index.ts +6 -0
- package/src/components/json-schema-editor/json-schema-editor.vue +53 -0
- package/src/components/json-schema-editor/property-edit.vue +222 -0
- package/src/components/json-schema-editor/styles.css +135 -0
- package/src/components/json-schema-editor/types.ts +25 -0
- package/src/components/prompt-editor/index.ts +7 -0
- package/src/components/prompt-editor/prompt-editor.vue +40 -0
- package/src/components/prompt-editor/styles.css +14 -0
- package/src/components/prompt-editor/types.ts +20 -0
- package/src/components/prompt-editor-with-inputs/index.ts +7 -0
- package/src/components/prompt-editor-with-inputs/prompt-editor-with-inputs.vue +18 -0
- package/src/components/prompt-editor-with-inputs/types.ts +11 -0
- package/src/components/prompt-editor-with-variables/index.ts +7 -0
- package/src/components/prompt-editor-with-variables/prompt-editor-with-variables.vue +19 -0
- package/src/components/prompt-editor-with-variables/types.ts +8 -0
- package/src/components/sql-editor-with-variables/index.ts +7 -0
- package/src/components/sql-editor-with-variables/sql-editor-with-variables.vue +24 -0
- package/src/components/sql-editor-with-variables/types.ts +8 -0
- package/src/components/type-selector/index.ts +11 -0
- package/src/components/type-selector/type-selector.vue +79 -0
- package/src/components/type-selector/types.ts +33 -0
- package/src/components/variable-selector/context.ts +44 -0
- package/src/components/variable-selector/index.ts +13 -0
- package/src/components/variable-selector/styles.css +70 -0
- package/src/components/variable-selector/types.ts +22 -0
- package/src/components/variable-selector/use-variable-tree.ts +108 -0
- package/src/components/variable-selector/variable-selector.vue +139 -0
- package/src/effects/auto-rename-ref/index.ts +109 -0
- package/src/effects/index.ts +12 -0
- package/src/effects/listen-ref-schema-change/index.ts +56 -0
- package/src/effects/listen-ref-value-change/index.ts +53 -0
- package/src/effects/provide-batch-input/index.ts +40 -0
- package/src/effects/provide-json-schema-outputs/index.ts +23 -0
- package/src/effects/sync-variable-title/index.ts +25 -0
- package/src/effects/validate-when-variable-sync/index.ts +34 -0
- package/src/env.d.ts +12 -0
- package/src/form-plugins/batch-outputs-plugin/index.ts +120 -0
- package/src/form-plugins/index.ts +8 -0
- package/src/form-plugins/infer-assign-plugin/index.ts +87 -0
- package/src/form-plugins/infer-inputs-plugin/index.ts +85 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/use-object-list/index.ts +161 -0
- package/src/index.ts +125 -0
- package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +27 -0
- package/src/plugins/disable-declaration-plugin/index.ts +6 -0
- package/src/plugins/index.ts +16 -0
- package/src/plugins/json-schema-preset/create-type-preset-plugin.ts +35 -0
- package/src/plugins/json-schema-preset/index.ts +25 -0
- package/src/plugins/json-schema-preset/type-definition/array.ts +38 -0
- package/src/plugins/json-schema-preset/type-definition/boolean.ts +47 -0
- package/src/plugins/json-schema-preset/type-definition/date-time.ts +60 -0
- package/src/plugins/json-schema-preset/type-definition/enum.ts +31 -0
- package/src/plugins/json-schema-preset/type-definition/index.ts +37 -0
- package/src/plugins/json-schema-preset/type-definition/integer.ts +47 -0
- package/src/plugins/json-schema-preset/type-definition/map.ts +34 -0
- package/src/plugins/json-schema-preset/type-definition/number.ts +46 -0
- package/src/plugins/json-schema-preset/type-definition/object.ts +34 -0
- package/src/plugins/json-schema-preset/type-definition/string.ts +52 -0
- package/src/plugins/json-schema-preset/types.ts +25 -0
- package/src/plugins/json-schema-preset/vue.ts +38 -0
- package/src/shared/flow-value/index.ts +17 -0
- package/src/shared/flow-value/schema.ts +38 -0
- package/src/shared/flow-value/types.ts +49 -0
- package/src/shared/flow-value/utils.ts +213 -0
- package/src/shared/format-legacy-refs/index.ts +158 -0
- package/src/shared/format-legacy-refs/readme.md +38 -0
- package/src/shared/index.ts +32 -0
- package/src/shared/inject-material/index.ts +50 -0
- package/src/shared/lazy-suspense/index.ts +20 -0
- package/src/shared/polyfill-create-root/index.ts +38 -0
- package/src/ui/fg-button.vue +27 -0
- package/src/ui/fg-cascader.vue +92 -0
- package/src/ui/fg-checkbox.vue +25 -0
- package/src/ui/fg-icon-button.vue +31 -0
- package/src/ui/fg-input.vue +50 -0
- package/src/ui/fg-modal.vue +37 -0
- package/src/ui/fg-popover.vue +19 -0
- package/src/ui/fg-select.vue +81 -0
- package/src/ui/fg-tag.vue +37 -0
- package/src/ui/fg-textarea.vue +42 -0
- package/src/ui/fg-tree-nodes.vue +48 -0
- package/src/ui/fg-tree-select.vue +86 -0
- package/src/ui/icons.ts +60 -0
- package/src/ui/index.ts +20 -0
- package/src/ui/styles.css +277 -0
- package/src/ui/types.ts +36 -0
- package/src/validate/index.ts +6 -0
- package/src/validate/validate-flow-value/index.ts +62 -0
package/src/ui/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { default as FgButton } from './fg-button.vue';
|
|
7
|
+
export { default as FgIconButton } from './fg-icon-button.vue';
|
|
8
|
+
export { default as FgInput } from './fg-input.vue';
|
|
9
|
+
export { default as FgTextarea } from './fg-textarea.vue';
|
|
10
|
+
export { default as FgSelect } from './fg-select.vue';
|
|
11
|
+
export { default as FgCheckbox } from './fg-checkbox.vue';
|
|
12
|
+
export { default as FgTag } from './fg-tag.vue';
|
|
13
|
+
export { default as FgPopover } from './fg-popover.vue';
|
|
14
|
+
export { default as FgModal } from './fg-modal.vue';
|
|
15
|
+
export { default as FgTreeSelect } from './fg-tree-select.vue';
|
|
16
|
+
export { default as FgCascader } from './fg-cascader.vue';
|
|
17
|
+
export * from './icons';
|
|
18
|
+
export type { FgTreeNode, FgSelectOption, FgCascaderOption, FgStyle } from './types';
|
|
19
|
+
|
|
20
|
+
import './styles.css';
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.fg-btn,
|
|
7
|
+
.fg-icon-btn,
|
|
8
|
+
.fg-input,
|
|
9
|
+
.fg-textarea,
|
|
10
|
+
.fg-select,
|
|
11
|
+
.fg-checkbox {
|
|
12
|
+
font-family: inherit;
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.fg-btn {
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: 4px;
|
|
21
|
+
height: 24px;
|
|
22
|
+
padding: 0 8px;
|
|
23
|
+
border: 1px solid #d9d9d9;
|
|
24
|
+
border-radius: 4px;
|
|
25
|
+
background: #fff;
|
|
26
|
+
color: #1c1f23;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.fg-btn:hover:not(:disabled) {
|
|
31
|
+
border-color: #3370ff;
|
|
32
|
+
color: #3370ff;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.fg-btn:disabled {
|
|
36
|
+
opacity: 0.5;
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.fg-btn.borderless {
|
|
41
|
+
border-color: transparent;
|
|
42
|
+
background: transparent;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.fg-icon-btn {
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
width: 22px;
|
|
50
|
+
height: 22px;
|
|
51
|
+
padding: 0;
|
|
52
|
+
border: none;
|
|
53
|
+
border-radius: 4px;
|
|
54
|
+
background: transparent;
|
|
55
|
+
color: #4d5969;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.fg-icon-btn:hover:not(:disabled) {
|
|
60
|
+
background: #f2f3f5;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.fg-icon-btn:disabled {
|
|
64
|
+
opacity: 0.45;
|
|
65
|
+
cursor: not-allowed;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.fg-input,
|
|
69
|
+
.fg-textarea,
|
|
70
|
+
.fg-select {
|
|
71
|
+
width: 100%;
|
|
72
|
+
min-height: 22px;
|
|
73
|
+
padding: 2px 8px;
|
|
74
|
+
border: 1px solid #d9d9d9;
|
|
75
|
+
border-radius: 4px;
|
|
76
|
+
background: #fff;
|
|
77
|
+
color: #1c1f23;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.fg-input:focus,
|
|
81
|
+
.fg-textarea:focus,
|
|
82
|
+
.fg-select:focus {
|
|
83
|
+
outline: none;
|
|
84
|
+
border-color: #3370ff;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.fg-input:disabled,
|
|
88
|
+
.fg-textarea:disabled,
|
|
89
|
+
.fg-select:disabled {
|
|
90
|
+
background: #f5f6f7;
|
|
91
|
+
color: #8f959e;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.fg-input.error,
|
|
95
|
+
.fg-select.error,
|
|
96
|
+
.fg-tree-select.error .fg-tree-select-trigger {
|
|
97
|
+
border-color: #f93920;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.fg-textarea {
|
|
101
|
+
min-height: 48px;
|
|
102
|
+
resize: vertical;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.fg-checkbox {
|
|
106
|
+
width: 14px;
|
|
107
|
+
height: 14px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.fg-tag {
|
|
111
|
+
display: inline-flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: 4px;
|
|
114
|
+
max-width: 100%;
|
|
115
|
+
height: 22px;
|
|
116
|
+
padding: 0 6px;
|
|
117
|
+
border-radius: 4px;
|
|
118
|
+
background: #f2f3f5;
|
|
119
|
+
color: #1c1f23;
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.fg-tag.amber {
|
|
124
|
+
background: #fff3e8;
|
|
125
|
+
color: #b25e09;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.fg-tag.white {
|
|
129
|
+
background: #fff;
|
|
130
|
+
border: 1px solid #e5e6eb;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.fg-tag-close {
|
|
134
|
+
border: none;
|
|
135
|
+
background: transparent;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
padding: 0;
|
|
138
|
+
color: inherit;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.fg-popover {
|
|
142
|
+
position: relative;
|
|
143
|
+
display: inline-block;
|
|
144
|
+
max-width: 100%;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.fg-popover-content {
|
|
148
|
+
position: absolute;
|
|
149
|
+
z-index: 20;
|
|
150
|
+
top: calc(100% + 4px);
|
|
151
|
+
left: 0;
|
|
152
|
+
min-width: 120px;
|
|
153
|
+
padding: 8px;
|
|
154
|
+
background: #fff;
|
|
155
|
+
border: 1px solid #e5e6eb;
|
|
156
|
+
border-radius: 6px;
|
|
157
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.fg-modal-mask {
|
|
161
|
+
position: fixed;
|
|
162
|
+
inset: 0;
|
|
163
|
+
z-index: 1000;
|
|
164
|
+
display: flex;
|
|
165
|
+
align-items: center;
|
|
166
|
+
justify-content: center;
|
|
167
|
+
background: rgba(0, 0, 0, 0.35);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.fg-modal {
|
|
171
|
+
width: min(600px, calc(100vw - 32px));
|
|
172
|
+
background: #fff;
|
|
173
|
+
border-radius: 8px;
|
|
174
|
+
padding: 16px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.fg-modal-title {
|
|
178
|
+
font-size: 16px;
|
|
179
|
+
font-weight: 600;
|
|
180
|
+
margin-bottom: 12px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.fg-modal-actions {
|
|
184
|
+
display: flex;
|
|
185
|
+
justify-content: flex-end;
|
|
186
|
+
gap: 8px;
|
|
187
|
+
margin-top: 16px;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.fg-tree-select {
|
|
191
|
+
position: relative;
|
|
192
|
+
width: 100%;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.fg-tree-select-trigger {
|
|
196
|
+
display: flex;
|
|
197
|
+
align-items: center;
|
|
198
|
+
min-height: 22px;
|
|
199
|
+
padding: 0 6px;
|
|
200
|
+
border: 1px solid #d9d9d9;
|
|
201
|
+
border-radius: 4px;
|
|
202
|
+
background: #fff;
|
|
203
|
+
cursor: pointer;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.fg-tree-select-trigger.disabled {
|
|
207
|
+
background: #f5f6f7;
|
|
208
|
+
cursor: not-allowed;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.fg-tree-select-placeholder {
|
|
212
|
+
color: #8f959e;
|
|
213
|
+
padding-left: 4px;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.fg-tree-select-dropdown,
|
|
217
|
+
.fg-cascader-dropdown {
|
|
218
|
+
position: absolute;
|
|
219
|
+
z-index: 30;
|
|
220
|
+
top: calc(100% + 4px);
|
|
221
|
+
left: 0;
|
|
222
|
+
min-width: 180px;
|
|
223
|
+
max-height: 300px;
|
|
224
|
+
overflow: auto;
|
|
225
|
+
background: #fff;
|
|
226
|
+
border: 1px solid #e5e6eb;
|
|
227
|
+
border-radius: 6px;
|
|
228
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.fg-tree-node,
|
|
232
|
+
.fg-cascader-option,
|
|
233
|
+
.fg-select-option {
|
|
234
|
+
display: flex;
|
|
235
|
+
align-items: center;
|
|
236
|
+
gap: 6px;
|
|
237
|
+
width: 100%;
|
|
238
|
+
padding: 6px 10px;
|
|
239
|
+
border: none;
|
|
240
|
+
background: transparent;
|
|
241
|
+
text-align: left;
|
|
242
|
+
cursor: pointer;
|
|
243
|
+
color: #1c1f23;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.fg-tree-node:hover,
|
|
247
|
+
.fg-cascader-option:hover,
|
|
248
|
+
.fg-select-option:hover {
|
|
249
|
+
background: #f2f3f5;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.fg-tree-node.disabled,
|
|
253
|
+
.fg-cascader-option.disabled,
|
|
254
|
+
.fg-select-option:disabled {
|
|
255
|
+
opacity: 0.45;
|
|
256
|
+
cursor: not-allowed;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.fg-tree-children {
|
|
260
|
+
padding-left: 14px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.fg-skeleton {
|
|
264
|
+
height: 22px;
|
|
265
|
+
border-radius: 4px;
|
|
266
|
+
background: linear-gradient(90deg, #f2f3f5 25%, #e8eaed 37%, #f2f3f5 63%);
|
|
267
|
+
background-size: 400% 100%;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.fg-icon {
|
|
271
|
+
flex-shrink: 0;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.fg-select-wrap {
|
|
275
|
+
position: relative;
|
|
276
|
+
width: 100%;
|
|
277
|
+
}
|
package/src/ui/types.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { CSSProperties, VNode } from 'vue';
|
|
7
|
+
|
|
8
|
+
export interface FgTreeNode {
|
|
9
|
+
key: string;
|
|
10
|
+
label: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
keyPath?: string[];
|
|
13
|
+
icon?: VNode | string;
|
|
14
|
+
children?: FgTreeNode[];
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
rootMeta?: {
|
|
17
|
+
icon?: VNode | string;
|
|
18
|
+
title?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
};
|
|
21
|
+
isRoot?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface FgSelectOption {
|
|
25
|
+
label: string | VNode;
|
|
26
|
+
value: string | number;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FgCascaderOption {
|
|
31
|
+
label: string | VNode;
|
|
32
|
+
value: string;
|
|
33
|
+
children?: FgCascaderOption[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type FgStyle = CSSProperties;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { isNil } from 'lodash-es';
|
|
7
|
+
import { FeedbackLevel } from '@flowgram-vue/form';
|
|
8
|
+
import { FlowNodeEntity } from '@flowgram-vue/document';
|
|
9
|
+
import { getNodeScope } from '@flowgram-vue/variable-layout';
|
|
10
|
+
|
|
11
|
+
import { type IFlowValue, FlowValueUtils } from '@/shared';
|
|
12
|
+
|
|
13
|
+
interface Context {
|
|
14
|
+
node: FlowNodeEntity;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
errorMessages?: {
|
|
17
|
+
required?: string;
|
|
18
|
+
unknownVariable?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function validateFlowValue(value: IFlowValue | undefined, ctx: Context) {
|
|
23
|
+
const { node, required, errorMessages } = ctx;
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
required: requiredMessage = 'Field is required',
|
|
27
|
+
unknownVariable: unknownVariableMessage = 'Unknown Variable',
|
|
28
|
+
} = errorMessages || {};
|
|
29
|
+
|
|
30
|
+
if (required && (isNil(value) || isNil(value?.content) || value?.content === '')) {
|
|
31
|
+
return {
|
|
32
|
+
level: FeedbackLevel.Error,
|
|
33
|
+
message: requiredMessage,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (value?.type === 'ref') {
|
|
38
|
+
const variable = getNodeScope(node).available.getByKeyPath(value?.content || []);
|
|
39
|
+
if (!variable) {
|
|
40
|
+
return {
|
|
41
|
+
level: FeedbackLevel.Error,
|
|
42
|
+
message: unknownVariableMessage,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (value?.type === 'template') {
|
|
48
|
+
const allRefs = FlowValueUtils.getTemplateKeyPaths(value);
|
|
49
|
+
|
|
50
|
+
for (const ref of allRefs) {
|
|
51
|
+
const variable = getNodeScope(node).available.getByKeyPath(ref);
|
|
52
|
+
if (!variable) {
|
|
53
|
+
return {
|
|
54
|
+
level: FeedbackLevel.Error,
|
|
55
|
+
message: unknownVariableMessage,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|