@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
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { computed, defineComponent, h, ref, type PropType } from 'vue';
|
|
8
|
+
import { IJsonSchema, JsonSchemaTypeManager, useTypeManager } from '@flowgram-vue/json-schema';
|
|
9
|
+
import { I18n } from '@flowgram-vue/i18n';
|
|
10
|
+
|
|
11
|
+
import { InjectTypeSelector } from '@/components/type-selector';
|
|
12
|
+
import { BlurInput } from '@/components/blur-input';
|
|
13
|
+
import {
|
|
14
|
+
FgCheckbox,
|
|
15
|
+
FgIconButton,
|
|
16
|
+
IconAddChildren,
|
|
17
|
+
IconChevronDown,
|
|
18
|
+
IconChevronRight,
|
|
19
|
+
IconExpand,
|
|
20
|
+
IconMinus,
|
|
21
|
+
IconShrink,
|
|
22
|
+
} from '@/ui';
|
|
23
|
+
|
|
24
|
+
import type { ConfigType, PropertyValueType } from './types';
|
|
25
|
+
import { usePropertiesEdit } from './hooks';
|
|
26
|
+
import DefaultValue from './default-value.vue';
|
|
27
|
+
|
|
28
|
+
function getSchemaDefaultValue(
|
|
29
|
+
typeManager: JsonSchemaTypeManager,
|
|
30
|
+
schema: Partial<IJsonSchema> | undefined
|
|
31
|
+
) {
|
|
32
|
+
if (schema?.type === 'object') {
|
|
33
|
+
return '{}';
|
|
34
|
+
}
|
|
35
|
+
if (schema?.type === 'array') {
|
|
36
|
+
return '[]';
|
|
37
|
+
}
|
|
38
|
+
return typeManager.getDefaultValue(schema || {});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const PropertyEdit = defineComponent({
|
|
42
|
+
name: 'PropertyEdit',
|
|
43
|
+
props: {
|
|
44
|
+
value: { type: Object as PropType<PropertyValueType> },
|
|
45
|
+
config: { type: Object as PropType<ConfigType> },
|
|
46
|
+
onChange: { type: Function as PropType<(value: PropertyValueType) => void> },
|
|
47
|
+
onRemove: { type: Function as PropType<() => void> },
|
|
48
|
+
readonly: { type: Boolean, default: false },
|
|
49
|
+
$isLast: { type: Boolean, default: false },
|
|
50
|
+
$level: { type: Number, default: 0 },
|
|
51
|
+
},
|
|
52
|
+
setup(props) {
|
|
53
|
+
const expand = ref(false);
|
|
54
|
+
const collapse = ref(false);
|
|
55
|
+
const typeManagerInner = useTypeManager() as JsonSchemaTypeManager;
|
|
56
|
+
const typeSelectorValue = computed(() => ({
|
|
57
|
+
type: props.value?.type,
|
|
58
|
+
items: props.value?.items,
|
|
59
|
+
}));
|
|
60
|
+
const nested = usePropertiesEdit(props.value, props.onChange);
|
|
61
|
+
const showCollapse = computed(
|
|
62
|
+
() => nested.canAddField.value && nested.propertyList.value.length > 0
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const onFieldChange = (key: string, next: unknown) => {
|
|
66
|
+
props.onChange?.({
|
|
67
|
+
...(props.value || {}),
|
|
68
|
+
[key]: next,
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return () =>
|
|
73
|
+
h('div', { style: { display: 'contents' } }, [
|
|
74
|
+
h(
|
|
75
|
+
'div',
|
|
76
|
+
{
|
|
77
|
+
class: `gedit-m-json-schema-editor-tree-item-left ${props.$level > 0 ? 'show-line' : ''} ${
|
|
78
|
+
props.$isLast ? 'is-last' : ''
|
|
79
|
+
} ${showCollapse.value ? 'show-collapse' : ''}`,
|
|
80
|
+
},
|
|
81
|
+
showCollapse.value
|
|
82
|
+
? [
|
|
83
|
+
h(
|
|
84
|
+
'div',
|
|
85
|
+
{
|
|
86
|
+
class: 'gedit-m-json-schema-editor-collapse-trigger',
|
|
87
|
+
onClick: () => {
|
|
88
|
+
collapse.value = !collapse.value;
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
[collapse.value ? h(IconChevronDown) : h(IconChevronRight)]
|
|
92
|
+
),
|
|
93
|
+
]
|
|
94
|
+
: []
|
|
95
|
+
),
|
|
96
|
+
h('div', { class: 'gedit-m-json-schema-editor-tree-item-right' }, [
|
|
97
|
+
h('div', { class: 'gedit-m-json-schema-editor-tree-item-main' }, [
|
|
98
|
+
h('div', { class: 'gedit-m-json-schema-editor-row' }, [
|
|
99
|
+
h('div', { class: 'gedit-m-json-schema-editor-name' }, [
|
|
100
|
+
h(BlurInput, {
|
|
101
|
+
disabled: props.readonly,
|
|
102
|
+
placeholder: props.config?.placeholder ?? I18n.t('Input Variable Name'),
|
|
103
|
+
value: props.value?.name,
|
|
104
|
+
onChange: (v: string) => onFieldChange('name', v),
|
|
105
|
+
}),
|
|
106
|
+
]),
|
|
107
|
+
h('div', { class: 'gedit-m-json-schema-editor-type' }, [
|
|
108
|
+
h(InjectTypeSelector, {
|
|
109
|
+
value: typeSelectorValue.value,
|
|
110
|
+
readonly: props.readonly,
|
|
111
|
+
onChange: (_value?: Partial<IJsonSchema>) => {
|
|
112
|
+
const nextTypeSchema = _value || {};
|
|
113
|
+
props.onChange?.({
|
|
114
|
+
...(props.value || {}),
|
|
115
|
+
...nextTypeSchema,
|
|
116
|
+
default: getSchemaDefaultValue(typeManagerInner, nextTypeSchema),
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
]),
|
|
121
|
+
h('div', { class: 'gedit-m-json-schema-editor-required' }, [
|
|
122
|
+
h(FgCheckbox, {
|
|
123
|
+
disabled: props.readonly,
|
|
124
|
+
checked: props.value?.isPropertyRequired,
|
|
125
|
+
onChange: (checked: boolean) => onFieldChange('isPropertyRequired', checked),
|
|
126
|
+
}),
|
|
127
|
+
]),
|
|
128
|
+
h('div', { class: 'gedit-m-json-schema-editor-actions' }, [
|
|
129
|
+
h(FgIconButton, {
|
|
130
|
+
disabled: props.readonly,
|
|
131
|
+
icon: expand.value ? IconShrink() : IconExpand(),
|
|
132
|
+
onClick: () => {
|
|
133
|
+
expand.value = !expand.value;
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
nested.canAddField.value
|
|
137
|
+
? h(FgIconButton, {
|
|
138
|
+
disabled: props.readonly,
|
|
139
|
+
icon: IconAddChildren(),
|
|
140
|
+
onClick: () => {
|
|
141
|
+
nested.onAddProperty();
|
|
142
|
+
collapse.value = true;
|
|
143
|
+
},
|
|
144
|
+
})
|
|
145
|
+
: null,
|
|
146
|
+
h(FgIconButton, {
|
|
147
|
+
disabled: props.readonly,
|
|
148
|
+
icon: IconMinus(),
|
|
149
|
+
onClick: () => props.onRemove?.(),
|
|
150
|
+
}),
|
|
151
|
+
]),
|
|
152
|
+
]),
|
|
153
|
+
expand.value
|
|
154
|
+
? h('div', { class: 'gedit-m-json-schema-editor-expand-detail' }, [
|
|
155
|
+
h('div', { class: 'gedit-m-json-schema-editor-label' }, [
|
|
156
|
+
props.config?.descTitle ?? I18n.t('Description'),
|
|
157
|
+
]),
|
|
158
|
+
h(BlurInput, {
|
|
159
|
+
disabled: props.readonly,
|
|
160
|
+
value: props.value?.description,
|
|
161
|
+
placeholder:
|
|
162
|
+
props.config?.descPlaceholder ?? I18n.t('Help LLM to understand the property'),
|
|
163
|
+
onChange: (v: string) => onFieldChange('description', v),
|
|
164
|
+
}),
|
|
165
|
+
props.$level === 0
|
|
166
|
+
? h('div', {}, [
|
|
167
|
+
h(
|
|
168
|
+
'div',
|
|
169
|
+
{ class: 'gedit-m-json-schema-editor-label', style: { marginTop: '10px' } },
|
|
170
|
+
props.config?.defaultValueTitle ?? I18n.t('Default Value')
|
|
171
|
+
),
|
|
172
|
+
h('div', { class: 'gedit-m-json-schema-editor-default-value-wrapper' }, [
|
|
173
|
+
h(DefaultValue, {
|
|
174
|
+
value: props.value?.default,
|
|
175
|
+
schema: props.value,
|
|
176
|
+
placeholder:
|
|
177
|
+
props.config?.defaultValuePlaceholder ?? I18n.t('Default Value'),
|
|
178
|
+
onChange: (v: unknown) => onFieldChange('default', v),
|
|
179
|
+
}),
|
|
180
|
+
]),
|
|
181
|
+
])
|
|
182
|
+
: null,
|
|
183
|
+
])
|
|
184
|
+
: null,
|
|
185
|
+
]),
|
|
186
|
+
showCollapse.value
|
|
187
|
+
? h(
|
|
188
|
+
'div',
|
|
189
|
+
{
|
|
190
|
+
class: `gedit-m-json-schema-editor-collapsible ${collapse.value ? 'collapse' : ''}`,
|
|
191
|
+
},
|
|
192
|
+
[
|
|
193
|
+
h(
|
|
194
|
+
'div',
|
|
195
|
+
{ class: 'gedit-m-json-schema-editor-tree-items shrink' },
|
|
196
|
+
nested.propertyList.value.map((_property, index) =>
|
|
197
|
+
h(PropertyEdit, {
|
|
198
|
+
readonly: props.readonly,
|
|
199
|
+
key: _property.key,
|
|
200
|
+
value: _property,
|
|
201
|
+
config: props.config,
|
|
202
|
+
$level: (props.$level || 0) + 1,
|
|
203
|
+
$isLast: index === nested.propertyList.value.length - 1,
|
|
204
|
+
onChange: (_v: PropertyValueType) => {
|
|
205
|
+
nested.onEditProperty(_property.key!, _v);
|
|
206
|
+
},
|
|
207
|
+
onRemove: () => {
|
|
208
|
+
nested.onRemoveProperty(_property.key!);
|
|
209
|
+
},
|
|
210
|
+
})
|
|
211
|
+
)
|
|
212
|
+
),
|
|
213
|
+
]
|
|
214
|
+
)
|
|
215
|
+
: null,
|
|
216
|
+
]),
|
|
217
|
+
]);
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
export default PropertyEdit;
|
|
222
|
+
</script>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.gedit-m-json-schema-editor-container {
|
|
7
|
+
/* & .semi-input {
|
|
8
|
+
background-color: #fff;
|
|
9
|
+
border-radius: 6px;
|
|
10
|
+
height: 24px;
|
|
11
|
+
} */
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.gedit-m-json-schema-editor-row {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 6px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.gedit-m-json-schema-editor-collapse-trigger {
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
margin-right: 5px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.gedit-m-json-schema-editor-expand-detail {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.gedit-m-json-schema-editor-label {
|
|
31
|
+
font-size: 12px;
|
|
32
|
+
color: #999;
|
|
33
|
+
font-weight: 400;
|
|
34
|
+
margin-bottom: 2px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.gedit-m-json-schema-editor-tree-items {
|
|
38
|
+
display: grid;
|
|
39
|
+
grid-template-columns: auto 1fr;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.gedit-m-json-schema-editor-tree-items.shrink {
|
|
43
|
+
padding-left: 3px;
|
|
44
|
+
margin-top: 10px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.gedit-m-json-schema-editor-tree-item-left {
|
|
48
|
+
grid-column: 1;
|
|
49
|
+
position: relative;
|
|
50
|
+
width: 16px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.gedit-m-json-schema-editor-tree-item-left.show-line::before {
|
|
54
|
+
/* 竖线 */
|
|
55
|
+
content: "";
|
|
56
|
+
height: var(--line-height, 100%);
|
|
57
|
+
position: absolute;
|
|
58
|
+
left: -14px;
|
|
59
|
+
top: -16px;
|
|
60
|
+
width: 1px;
|
|
61
|
+
background: #d9d9d9;
|
|
62
|
+
display: block;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.gedit-m-json-schema-editor-tree-item-left.show-line::after {
|
|
66
|
+
/* 横线 */
|
|
67
|
+
content: "";
|
|
68
|
+
position: absolute;
|
|
69
|
+
left: -14px; /* 横线起点和竖线对齐 */
|
|
70
|
+
top: 8px; /* 跟随你的行高调整 */
|
|
71
|
+
width: var(--line-width, 30px); /* 横线长度 */
|
|
72
|
+
height: 1px;
|
|
73
|
+
background: #d9d9d9;
|
|
74
|
+
display: block;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.gedit-m-json-schema-editor-tree-item-left.show-line.is-last::before {
|
|
78
|
+
height: 24px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.gedit-m-json-schema-editor-tree-item-left.show-line.show-collapse::after {
|
|
82
|
+
width: 12px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.gedit-m-json-schema-editor-tree-item-right {
|
|
86
|
+
grid-column: 2;
|
|
87
|
+
margin-bottom: 10px;
|
|
88
|
+
|
|
89
|
+
&:last-child {
|
|
90
|
+
margin-bottom: 0px;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.gedit-m-json-schema-editor-tree-item-main {
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
gap: 10px;
|
|
98
|
+
position: relative;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.gedit-m-json-schema-editor-collapsible {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.gedit-m-json-schema-editor-collapsible.collapse {
|
|
106
|
+
display: block;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.gedit-m-json-schema-editor-name {
|
|
110
|
+
flex-grow: 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.gedit-m-json-schema-editor-type {
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.gedit-m-json-schema-editor-required {
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.gedit-m-json-schema-editor-actions {
|
|
120
|
+
white-space: nowrap;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.gedit-m-json-schema-editor-default-value-wrapper {
|
|
124
|
+
margin: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.gedit-m-json-schema-editor-constant-input-wrapper {
|
|
128
|
+
flex-grow: 1;
|
|
129
|
+
|
|
130
|
+
& .semi-tree-select,
|
|
131
|
+
& .semi-input-number,
|
|
132
|
+
& .semi-select {
|
|
133
|
+
width: 100%;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IJsonSchema } from '@flowgram-vue/json-schema';
|
|
7
|
+
|
|
8
|
+
export interface PropertyValueType extends IJsonSchema {
|
|
9
|
+
name?: string;
|
|
10
|
+
key?: number;
|
|
11
|
+
isPropertyRequired?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type PropertiesValueType = Pick<PropertyValueType, 'properties' | 'required'>;
|
|
15
|
+
|
|
16
|
+
export type JsonSchemaProperties = IJsonSchema['properties'];
|
|
17
|
+
|
|
18
|
+
export interface ConfigType {
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
descTitle?: string;
|
|
21
|
+
descPlaceholder?: string;
|
|
22
|
+
defaultValueTitle?: string;
|
|
23
|
+
defaultValuePlaceholder?: string;
|
|
24
|
+
addButtonText?: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { CSSProperties } from 'vue';
|
|
8
|
+
import { IFlowTemplateValue } from '@/shared';
|
|
9
|
+
|
|
10
|
+
defineProps<{
|
|
11
|
+
value?: IFlowTemplateValue;
|
|
12
|
+
onChange?: (value?: IFlowTemplateValue) => void;
|
|
13
|
+
readonly?: boolean;
|
|
14
|
+
hasError?: boolean;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
activeLinePlaceholder?: string;
|
|
17
|
+
disableMarkdownHighlight?: boolean;
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
options?: Record<string, unknown>;
|
|
20
|
+
}>();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<div class="gedit-m-prompt-editor-container" :class="{ 'has-error': hasError }" :style="style">
|
|
25
|
+
<textarea
|
|
26
|
+
class="fg-textarea"
|
|
27
|
+
:value="value?.content"
|
|
28
|
+
:disabled="readonly"
|
|
29
|
+
:placeholder="placeholder || activeLinePlaceholder"
|
|
30
|
+
:style="{ minHeight: '80px', fontFamily: 'monospace' }"
|
|
31
|
+
@input="
|
|
32
|
+
onChange?.({
|
|
33
|
+
type: 'template',
|
|
34
|
+
content: ($event.target as HTMLTextAreaElement).value,
|
|
35
|
+
})
|
|
36
|
+
"
|
|
37
|
+
/>
|
|
38
|
+
<slot />
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.gedit-m-prompt-editor-container {
|
|
7
|
+
background-color: var(--semi-color-fill-0);
|
|
8
|
+
padding-left: 10px;
|
|
9
|
+
padding-right: 6px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.gedit-m-prompt-editor-container.has-error {
|
|
13
|
+
border: 1px solid var(--semi-color-danger-6);
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import { IFlowTemplateValue } from '@/shared';
|
|
8
|
+
|
|
9
|
+
export type PromptEditorPropsType = {
|
|
10
|
+
value?: IFlowTemplateValue;
|
|
11
|
+
onChange: (value?: IFlowTemplateValue) => void;
|
|
12
|
+
readonly?: boolean;
|
|
13
|
+
hasError?: boolean;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
activeLinePlaceholder?: string;
|
|
16
|
+
disableMarkdownHighlight?: boolean;
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
options?: Record<string, unknown>;
|
|
19
|
+
children?: VNode;
|
|
20
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { PromptEditor, type PromptEditorPropsType } from '@/components/prompt-editor';
|
|
8
|
+
import { EditorInputsTree } from '@/components/coze-editor-extensions';
|
|
9
|
+
import type { PromptEditorWithInputsProps } from './types';
|
|
10
|
+
|
|
11
|
+
defineProps<PromptEditorWithInputsProps>();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<PromptEditor v-bind="$props">
|
|
16
|
+
<EditorInputsTree :inputs-values="inputsValues" />
|
|
17
|
+
</PromptEditor>
|
|
18
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IInputsValues } from '@/shared/flow-value';
|
|
7
|
+
import { type PromptEditorPropsType } from '@/components/prompt-editor';
|
|
8
|
+
|
|
9
|
+
export interface PromptEditorWithInputsProps extends PromptEditorPropsType {
|
|
10
|
+
inputsValues: IInputsValues;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { PromptEditor, type PromptEditorPropsType } from '@/components/prompt-editor';
|
|
8
|
+
import { EditorVariableTree, EditorVariableTagInject } from '@/components/coze-editor-extensions';
|
|
9
|
+
import type { PromptEditorWithVariablesProps } from './types';
|
|
10
|
+
|
|
11
|
+
defineProps<PromptEditorWithVariablesProps>();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<PromptEditor v-bind="$props">
|
|
16
|
+
<EditorVariableTree />
|
|
17
|
+
<EditorVariableTagInject />
|
|
18
|
+
</PromptEditor>
|
|
19
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { I18n } from '@flowgram-vue/i18n';
|
|
8
|
+
|
|
9
|
+
import { EditorVariableTree, EditorVariableTagInject } from '@/components/coze-editor-extensions';
|
|
10
|
+
import { SQLCodeEditor, type CodeEditorPropsType } from '@/components/code-editor';
|
|
11
|
+
import type { SQLEditorWithVariablesProps } from './types';
|
|
12
|
+
|
|
13
|
+
defineProps<SQLEditorWithVariablesProps>();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<SQLCodeEditor
|
|
18
|
+
:active-line-placeholder="activeLinePlaceholder || I18n.t(`Press '@' to Select variable`)"
|
|
19
|
+
v-bind="$props"
|
|
20
|
+
>
|
|
21
|
+
<EditorVariableTree />
|
|
22
|
+
<EditorVariableTagInject />
|
|
23
|
+
</SQLCodeEditor>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import TypeSelector from './type-selector.vue';
|
|
7
|
+
import { createInjectMaterial } from '@/shared/inject-material';
|
|
8
|
+
|
|
9
|
+
export { default as TypeSelector } from './type-selector.vue';
|
|
10
|
+
export const InjectTypeSelector = createInjectMaterial(TypeSelector);
|
|
11
|
+
export { getTypeSelectValue, parseTypeSelectValue, type TypeSelectorProps } from './types';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { computed, defineComponent, h, type PropType, type CSSProperties } from 'vue';
|
|
8
|
+
import { IJsonSchema, useTypeManager, JsonSchemaTypeManager } from '@flowgram-vue/json-schema';
|
|
9
|
+
|
|
10
|
+
import { FgCascader, FgIconButton, type FgCascaderOption } from '@/ui';
|
|
11
|
+
|
|
12
|
+
import { getTypeSelectValue, parseTypeSelectValue } from './types';
|
|
13
|
+
|
|
14
|
+
const TypeSelectorImpl = defineComponent({
|
|
15
|
+
name: 'TypeSelector',
|
|
16
|
+
props: {
|
|
17
|
+
value: { type: Object as PropType<Partial<IJsonSchema>> },
|
|
18
|
+
readonly: { type: Boolean, default: false },
|
|
19
|
+
disabled: { type: Boolean, default: false },
|
|
20
|
+
style: { type: Object as PropType<CSSProperties> },
|
|
21
|
+
onChange: { type: Function as PropType<(value?: Partial<IJsonSchema>) => void> },
|
|
22
|
+
},
|
|
23
|
+
setup(props) {
|
|
24
|
+
const selectValue = computed(() => getTypeSelectValue(props.value));
|
|
25
|
+
const typeManager = useTypeManager() as JsonSchemaTypeManager;
|
|
26
|
+
const icon = computed(() => typeManager.getDisplayIcon(props.value || {}));
|
|
27
|
+
const isDisabled = computed(() => props.readonly || props.disabled);
|
|
28
|
+
|
|
29
|
+
const options = computed<FgCascaderOption[]>(() =>
|
|
30
|
+
typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
31
|
+
const isArray = _type.type === 'array';
|
|
32
|
+
return {
|
|
33
|
+
label: h('div', { style: { display: 'flex', alignItems: 'center', gap: '5px' } }, [
|
|
34
|
+
_type.icon,
|
|
35
|
+
typeManager.getTypeBySchema(_type)?.label || _type.type,
|
|
36
|
+
]),
|
|
37
|
+
value: _type.type,
|
|
38
|
+
children: isArray
|
|
39
|
+
? typeManager.getTypeRegistriesWithParentType('array').map((childType) => ({
|
|
40
|
+
label: h('div', { style: { display: 'flex', alignItems: 'center', gap: '5px' } }, [
|
|
41
|
+
typeManager.getDisplayIcon({
|
|
42
|
+
type: 'array',
|
|
43
|
+
items: { type: childType.type },
|
|
44
|
+
}),
|
|
45
|
+
typeManager.getTypeBySchema(childType)?.label || childType.type,
|
|
46
|
+
]),
|
|
47
|
+
value: childType.type,
|
|
48
|
+
}))
|
|
49
|
+
: [],
|
|
50
|
+
};
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return () =>
|
|
55
|
+
h(FgCascader, {
|
|
56
|
+
disabled: isDisabled.value,
|
|
57
|
+
options: options.value,
|
|
58
|
+
value: selectValue.value,
|
|
59
|
+
triggerRender: () =>
|
|
60
|
+
h(FgIconButton, {
|
|
61
|
+
disabled: isDisabled.value,
|
|
62
|
+
style: {
|
|
63
|
+
...(isDisabled.value ? { pointerEvents: 'none' } : {}),
|
|
64
|
+
...(props.style || {}),
|
|
65
|
+
},
|
|
66
|
+
icon: icon.value,
|
|
67
|
+
}),
|
|
68
|
+
onChange: (value: string[]) => {
|
|
69
|
+
props.onChange?.(parseTypeSelectValue(value));
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
(TypeSelectorImpl as typeof TypeSelectorImpl & { renderKey: string }).renderKey =
|
|
76
|
+
'type-selector-render-key';
|
|
77
|
+
|
|
78
|
+
export default TypeSelectorImpl;
|
|
79
|
+
</script>
|