@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,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { computed, ref, unref, watch } from 'vue';
|
|
7
|
+
|
|
8
|
+
import { IJsonSchema } from '@flowgram-vue/json-schema';
|
|
9
|
+
import { I18n } from '@flowgram-vue/i18n';
|
|
10
|
+
|
|
11
|
+
import { useTypeManager } from '@/plugins';
|
|
12
|
+
|
|
13
|
+
import { IConditionRule, ConditionOpConfigs } from '../types';
|
|
14
|
+
import { useConditionContext } from '../context';
|
|
15
|
+
|
|
16
|
+
interface HooksParams {
|
|
17
|
+
leftSchema?: IJsonSchema;
|
|
18
|
+
operator?: string;
|
|
19
|
+
onClearOp?: () => void;
|
|
20
|
+
onClearRight?: () => void;
|
|
21
|
+
ruleConfig?: {
|
|
22
|
+
ops?: ConditionOpConfigs;
|
|
23
|
+
rules?: Record<string, IConditionRule>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function useCondition({
|
|
28
|
+
leftSchema,
|
|
29
|
+
operator,
|
|
30
|
+
onClearOp,
|
|
31
|
+
onClearRight,
|
|
32
|
+
ruleConfig,
|
|
33
|
+
}: HooksParams) {
|
|
34
|
+
const typeManager = useTypeManager();
|
|
35
|
+
const conditionCtx = useConditionContext();
|
|
36
|
+
const contextRules = computed(() => unref(conditionCtx)?.rules);
|
|
37
|
+
const contextOps = computed(() => unref(conditionCtx)?.ops);
|
|
38
|
+
|
|
39
|
+
const userRules = computed(() => ruleConfig?.rules || contextRules.value || {});
|
|
40
|
+
const allOps = computed(() => ruleConfig?.ops || contextOps.value || {});
|
|
41
|
+
|
|
42
|
+
const config = computed(() =>
|
|
43
|
+
leftSchema ? typeManager.getTypeBySchema(leftSchema) : undefined
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const rule = computed(() => {
|
|
47
|
+
const current = config.value;
|
|
48
|
+
if (!current) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
if (userRules.value[current.type]) {
|
|
52
|
+
return userRules.value[current.type];
|
|
53
|
+
}
|
|
54
|
+
if (typeof current.conditionRule === 'function') {
|
|
55
|
+
return current.conditionRule(leftSchema);
|
|
56
|
+
}
|
|
57
|
+
return current.conditionRule;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const opOptionList = computed(() =>
|
|
61
|
+
Object.keys(rule.value || {})
|
|
62
|
+
.filter((_op) => allOps.value[_op])
|
|
63
|
+
.map((_op) => ({
|
|
64
|
+
...(allOps.value?.[_op] || {}),
|
|
65
|
+
value: _op,
|
|
66
|
+
label: I18n.t(allOps.value?.[_op]?.label || _op),
|
|
67
|
+
}))
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
watch(
|
|
71
|
+
() => [operator, opOptionList.value],
|
|
72
|
+
() => {
|
|
73
|
+
if (!operator || !rule.value) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!opOptionList.value.find((item) => item.value === operator)) {
|
|
77
|
+
onClearOp?.();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const targetSchema = computed(() => {
|
|
83
|
+
const targetType: string | IJsonSchema | null = rule.value?.[operator || ''] || null;
|
|
84
|
+
|
|
85
|
+
if (!targetType) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (typeof targetType === 'string') {
|
|
90
|
+
return { type: targetType, extra: { weak: true } };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return targetType;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const prevTargetSchemaRef = ref<IJsonSchema | undefined>(undefined);
|
|
97
|
+
|
|
98
|
+
watch(
|
|
99
|
+
() => targetSchema.value,
|
|
100
|
+
(next) => {
|
|
101
|
+
if (!prevTargetSchemaRef.value) {
|
|
102
|
+
prevTargetSchemaRef.value = next;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (prevTargetSchemaRef.value?.type !== next?.type) {
|
|
106
|
+
onClearRight?.();
|
|
107
|
+
}
|
|
108
|
+
prevTargetSchemaRef.value = next;
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const opConfig = computed(() => allOps.value[operator || '']);
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
rule,
|
|
116
|
+
opConfig,
|
|
117
|
+
opOptionList,
|
|
118
|
+
targetSchema,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
type IConditionRule,
|
|
8
|
+
type IConditionRuleFactory,
|
|
9
|
+
type ConditionOpConfigs,
|
|
10
|
+
type ConditionOpConfig,
|
|
11
|
+
} from './types';
|
|
12
|
+
export { ConditionPresetOp } from './op';
|
|
13
|
+
export { ConditionProvider, useConditionContext } from './context';
|
|
14
|
+
export { useCondition } from './hooks/use-condition';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ConditionOpConfigs } from './types';
|
|
7
|
+
|
|
8
|
+
export enum ConditionPresetOp {
|
|
9
|
+
EQ = 'eq',
|
|
10
|
+
NEQ = 'neq',
|
|
11
|
+
GT = 'gt',
|
|
12
|
+
GTE = 'gte',
|
|
13
|
+
LT = 'lt',
|
|
14
|
+
LTE = 'lte',
|
|
15
|
+
IN = 'in',
|
|
16
|
+
NIN = 'nin',
|
|
17
|
+
CONTAINS = 'contains',
|
|
18
|
+
NOT_CONTAINS = 'not_contains',
|
|
19
|
+
IS_EMPTY = 'is_empty',
|
|
20
|
+
IS_NOT_EMPTY = 'is_not_empty',
|
|
21
|
+
IS_TRUE = 'is_true',
|
|
22
|
+
IS_FALSE = 'is_false',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const defaultConditionOpConfigs: ConditionOpConfigs = {
|
|
26
|
+
[ConditionPresetOp.EQ]: {
|
|
27
|
+
label: 'Equal',
|
|
28
|
+
abbreviation: '=',
|
|
29
|
+
},
|
|
30
|
+
[ConditionPresetOp.NEQ]: {
|
|
31
|
+
label: 'Not Equal',
|
|
32
|
+
abbreviation: '≠',
|
|
33
|
+
},
|
|
34
|
+
[ConditionPresetOp.GT]: {
|
|
35
|
+
label: 'Greater Than',
|
|
36
|
+
abbreviation: '>',
|
|
37
|
+
},
|
|
38
|
+
[ConditionPresetOp.GTE]: {
|
|
39
|
+
label: 'Greater Than or Equal',
|
|
40
|
+
abbreviation: '>=',
|
|
41
|
+
},
|
|
42
|
+
[ConditionPresetOp.LT]: {
|
|
43
|
+
label: 'Less Than',
|
|
44
|
+
abbreviation: '<',
|
|
45
|
+
},
|
|
46
|
+
[ConditionPresetOp.LTE]: {
|
|
47
|
+
label: 'Less Than or Equal',
|
|
48
|
+
abbreviation: '<=',
|
|
49
|
+
},
|
|
50
|
+
[ConditionPresetOp.IN]: {
|
|
51
|
+
label: 'In',
|
|
52
|
+
abbreviation: '∈',
|
|
53
|
+
},
|
|
54
|
+
[ConditionPresetOp.NIN]: {
|
|
55
|
+
label: 'Not In',
|
|
56
|
+
abbreviation: '∉',
|
|
57
|
+
},
|
|
58
|
+
[ConditionPresetOp.CONTAINS]: {
|
|
59
|
+
label: 'Contains',
|
|
60
|
+
abbreviation: '⊇',
|
|
61
|
+
},
|
|
62
|
+
[ConditionPresetOp.NOT_CONTAINS]: {
|
|
63
|
+
label: 'Not Contains',
|
|
64
|
+
abbreviation: '⊉',
|
|
65
|
+
},
|
|
66
|
+
[ConditionPresetOp.IS_EMPTY]: {
|
|
67
|
+
label: 'Is Empty',
|
|
68
|
+
abbreviation: '=',
|
|
69
|
+
rightDisplay: 'Empty',
|
|
70
|
+
},
|
|
71
|
+
[ConditionPresetOp.IS_NOT_EMPTY]: {
|
|
72
|
+
label: 'Is Not Empty',
|
|
73
|
+
abbreviation: '≠',
|
|
74
|
+
rightDisplay: 'Empty',
|
|
75
|
+
},
|
|
76
|
+
[ConditionPresetOp.IS_TRUE]: {
|
|
77
|
+
label: 'Is True',
|
|
78
|
+
abbreviation: '=',
|
|
79
|
+
rightDisplay: 'True',
|
|
80
|
+
},
|
|
81
|
+
[ConditionPresetOp.IS_FALSE]: {
|
|
82
|
+
label: 'Is False',
|
|
83
|
+
abbreviation: '=',
|
|
84
|
+
rightDisplay: 'False',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { type IJsonSchema } from '@flowgram-vue/json-schema';
|
|
7
|
+
|
|
8
|
+
export interface ConditionOpConfig {
|
|
9
|
+
label: string;
|
|
10
|
+
abbreviation: string;
|
|
11
|
+
// When right is not a value, display this text
|
|
12
|
+
rightDisplay?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type OpKey = string;
|
|
16
|
+
|
|
17
|
+
export type ConditionOpConfigs = Record<OpKey, ConditionOpConfig>;
|
|
18
|
+
|
|
19
|
+
export type IConditionRule = Record<OpKey, string | IJsonSchema | null>;
|
|
20
|
+
export type IConditionRuleFactory = (
|
|
21
|
+
schema?: IJsonSchema
|
|
22
|
+
) => Record<OpKey, string | IJsonSchema | null>;
|
|
@@ -0,0 +1,126 @@
|
|
|
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 { computed, unref, type CSSProperties } from 'vue';
|
|
8
|
+
import { JsonSchemaUtils } from '@flowgram-vue/json-schema';
|
|
9
|
+
import { I18n } from '@flowgram-vue/i18n';
|
|
10
|
+
import { useScopeAvailable } from '@flowgram-vue/variable-core';
|
|
11
|
+
|
|
12
|
+
import { InjectVariableSelector } from '@/components/variable-selector';
|
|
13
|
+
import { InjectDynamicValueInput } from '@/components/dynamic-value-input';
|
|
14
|
+
import {
|
|
15
|
+
type IConditionRule,
|
|
16
|
+
type ConditionOpConfigs,
|
|
17
|
+
useCondition,
|
|
18
|
+
} from '@/components/condition-context';
|
|
19
|
+
import { FgButton, FgInput, FgSelect, IconChevronDown } from '@/ui';
|
|
20
|
+
|
|
21
|
+
import type { ConditionRowValueType } from './types';
|
|
22
|
+
import './styles.css';
|
|
23
|
+
|
|
24
|
+
const props = defineProps<{
|
|
25
|
+
value?: ConditionRowValueType;
|
|
26
|
+
onChange: (value?: ConditionRowValueType) => void;
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
readonly?: boolean;
|
|
29
|
+
ruleConfig?: {
|
|
30
|
+
ops?: ConditionOpConfigs;
|
|
31
|
+
rules?: Record<string, IConditionRule>;
|
|
32
|
+
};
|
|
33
|
+
}>();
|
|
34
|
+
|
|
35
|
+
const available = useScopeAvailable();
|
|
36
|
+
const left = computed(() => props.value?.left);
|
|
37
|
+
const operator = computed(() => props.value?.operator);
|
|
38
|
+
const right = computed(() => props.value?.right);
|
|
39
|
+
|
|
40
|
+
const variable = computed(() => {
|
|
41
|
+
if (!left.value) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return available.value.getByKeyPath(left.value.content);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const leftSchema = computed(() => {
|
|
48
|
+
if (!variable.value) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return JsonSchemaUtils.astToSchema(variable.value.type, { drilldown: false });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const condition = useCondition({
|
|
55
|
+
get leftSchema() {
|
|
56
|
+
return leftSchema.value;
|
|
57
|
+
},
|
|
58
|
+
get operator() {
|
|
59
|
+
return operator.value;
|
|
60
|
+
},
|
|
61
|
+
ruleConfig: props.ruleConfig,
|
|
62
|
+
onClearOp() {
|
|
63
|
+
props.onChange({
|
|
64
|
+
...props.value,
|
|
65
|
+
operator: undefined,
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
onClearRight() {
|
|
69
|
+
props.onChange({
|
|
70
|
+
...props.value,
|
|
71
|
+
right: undefined,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<div class="gedit-m-condition-row-container" :style="style">
|
|
79
|
+
<div class="gedit-m-condition-row-operator">
|
|
80
|
+
<FgSelect
|
|
81
|
+
:disabled="readonly"
|
|
82
|
+
:value="operator"
|
|
83
|
+
:options="unref(condition.opOptionList)"
|
|
84
|
+
@change="(v) => onChange({ ...value, operator: String(v) })"
|
|
85
|
+
>
|
|
86
|
+
<template #trigger>
|
|
87
|
+
<FgButton :disabled="!unref(condition.rule)">
|
|
88
|
+
{{ unref(condition.opConfig)?.abbreviation || '' }}
|
|
89
|
+
<IconChevronDown v-if="!unref(condition.opConfig)?.abbreviation" />
|
|
90
|
+
</FgButton>
|
|
91
|
+
</template>
|
|
92
|
+
</FgSelect>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="gedit-m-condition-row-values">
|
|
95
|
+
<div class="gedit-m-condition-row-left">
|
|
96
|
+
<InjectVariableSelector
|
|
97
|
+
:readonly="readonly"
|
|
98
|
+
:style="{ width: '100%' }"
|
|
99
|
+
:value="left?.content"
|
|
100
|
+
:on-change="
|
|
101
|
+
(v: string[] | undefined) =>
|
|
102
|
+
onChange({
|
|
103
|
+
...value,
|
|
104
|
+
left: { type: 'ref', content: v },
|
|
105
|
+
})
|
|
106
|
+
"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
<div class="gedit-m-condition-row-right">
|
|
110
|
+
<InjectDynamicValueInput
|
|
111
|
+
v-if="unref(condition.targetSchema)"
|
|
112
|
+
:readonly="readonly || !unref(condition.rule)"
|
|
113
|
+
:value="right"
|
|
114
|
+
:schema="unref(condition.targetSchema)"
|
|
115
|
+
:on-change="(v) => onChange({ ...value, right: v })"
|
|
116
|
+
/>
|
|
117
|
+
<FgInput
|
|
118
|
+
v-else
|
|
119
|
+
disabled
|
|
120
|
+
:style="{ pointerEvents: 'none' }"
|
|
121
|
+
:value="unref(condition.opConfig)?.rightDisplay || I18n.t('Empty')"
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.gedit-m-condition-row-container {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: 4px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.gedit-m-condition-row-operator {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.gedit-m-condition-row-left {
|
|
16
|
+
width: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.gedit-m-condition-row-right {
|
|
20
|
+
width: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.gedit-m-condition-row-values {
|
|
24
|
+
flex-grow: 1;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: 4px;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IFlowConstantRefValue, IFlowRefValue } from '@/shared';
|
|
7
|
+
|
|
8
|
+
export interface ConditionRowValueType {
|
|
9
|
+
left?: IFlowRefValue;
|
|
10
|
+
operator?: string;
|
|
11
|
+
right?: IFlowConstantRefValue;
|
|
12
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { computed, h } from 'vue';
|
|
8
|
+
import { I18n } from '@flowgram-vue/i18n';
|
|
9
|
+
|
|
10
|
+
import { useTypeManager } from '@/plugins';
|
|
11
|
+
import { FgInput } from '@/ui';
|
|
12
|
+
|
|
13
|
+
import type { PropsType } from './types';
|
|
14
|
+
|
|
15
|
+
const props = defineProps<PropsType>();
|
|
16
|
+
|
|
17
|
+
const typeManager = useTypeManager();
|
|
18
|
+
|
|
19
|
+
const Renderer = computed(() => {
|
|
20
|
+
const strategy = (props.strategies || []).find((_strategy) => _strategy.hit(props.schema));
|
|
21
|
+
if (!strategy) {
|
|
22
|
+
return typeManager.getTypeBySchema(props.schema)?.ConstantRenderer;
|
|
23
|
+
}
|
|
24
|
+
return strategy?.Renderer;
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<component
|
|
30
|
+
:is="Renderer"
|
|
31
|
+
v-if="Renderer"
|
|
32
|
+
:value="value"
|
|
33
|
+
:readonly="readonly"
|
|
34
|
+
:schema="schema"
|
|
35
|
+
v-bind="{ ...$attrs }"
|
|
36
|
+
@change="onChange"
|
|
37
|
+
/>
|
|
38
|
+
<component
|
|
39
|
+
:is="fallbackRenderer"
|
|
40
|
+
v-else-if="fallbackRenderer"
|
|
41
|
+
:value="value"
|
|
42
|
+
:readonly="readonly"
|
|
43
|
+
:schema="schema"
|
|
44
|
+
v-bind="{ ...$attrs }"
|
|
45
|
+
@change="onChange"
|
|
46
|
+
/>
|
|
47
|
+
<FgInput v-else disabled :placeholder="I18n.t('Unsupported type')" />
|
|
48
|
+
</template>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Component } from 'vue';
|
|
7
|
+
import { IJsonSchema } from '@flowgram-vue/json-schema';
|
|
8
|
+
|
|
9
|
+
import { ConstantRendererProps } from '@/plugins';
|
|
10
|
+
|
|
11
|
+
export interface Strategy<Value = any> {
|
|
12
|
+
hit: (schema: IJsonSchema) => boolean;
|
|
13
|
+
Renderer: Component;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PropsType extends ConstantRendererProps {
|
|
17
|
+
schema: IJsonSchema;
|
|
18
|
+
strategies?: Strategy[];
|
|
19
|
+
fallbackRenderer?: Component;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ConstantInputStrategy = Strategy;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { IInputsValues } from '@/shared/flow-value';
|
|
8
|
+
|
|
9
|
+
defineProps<{
|
|
10
|
+
inputsValues?: IInputsValues;
|
|
11
|
+
}>();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div class="gedit-m-editor-inputs-tree" />
|
|
16
|
+
</template>
|
|
@@ -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 { VariableSelector } from '@/components/variable-selector';
|
|
8
|
+
|
|
9
|
+
defineProps<{
|
|
10
|
+
triggerCharacters?: string[];
|
|
11
|
+
}>();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div class="gedit-m-editor-variable-tree">
|
|
16
|
+
<VariableSelector :on-change="() => undefined" />
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createInjectMaterial } from '@/shared';
|
|
7
|
+
|
|
8
|
+
import VariableTree from './extensions/variable-tree.vue';
|
|
9
|
+
import VariableTagInject from './extensions/variable-tag.vue';
|
|
10
|
+
import InputsTree from './extensions/inputs-tree.vue';
|
|
11
|
+
|
|
12
|
+
export const EditorVariableTree = createInjectMaterial(VariableTree, {
|
|
13
|
+
renderKey: 'EditorVariableTree',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const EditorVariableTagInject = createInjectMaterial(VariableTagInject, {
|
|
17
|
+
renderKey: 'EditorVariableTagInject',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const EditorInputsTree = createInjectMaterial(InputsTree, {
|
|
21
|
+
renderKey: 'EditorInputsTree',
|
|
22
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.gedit-m-coze-editor-root-title {
|
|
7
|
+
margin-right: 4px;
|
|
8
|
+
min-width: 20px;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
text-overflow: ellipsis;
|
|
11
|
+
white-space: nowrap;
|
|
12
|
+
color: var(--semi-color-text-2);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.gedit-m-coze-editor-var-name {
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
text-overflow: ellipsis;
|
|
18
|
+
white-space: nowrap;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.gedit-m-coze-editor-tag {
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: flex-start;
|
|
25
|
+
max-width: 300px;
|
|
26
|
+
|
|
27
|
+
& .semi-tag-content-center {
|
|
28
|
+
justify-content: flex-start;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.semi-tag {
|
|
32
|
+
margin: 0 5px;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.gedit-m-coze-editor-popover-content {
|
|
37
|
+
padding: 10px;
|
|
38
|
+
display: inline-flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: flex-start;
|
|
41
|
+
}
|