/** * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates * SPDX-License-Identifier: MIT */ import React from 'react'; import { Field } from '@flowgram.ai/free-layout-editor'; import { ConditionRow, ConditionRowValueType, createTypePresetPlugin, DynamicValueInput, IFlowConstantRefValue, type IJsonSchema, } from '@flowgram.ai/form-materials'; import { ColorPicker } from '@douyinfe/semi-ui'; import { IconColorPalette } from '@douyinfe/semi-icons'; import { FreeFormMetaStoryBuilder, FormHeader } from '../../free-form-meta-story-builder'; import './json-schema-preset.css'; const TypeSelector = React.lazy(() => import('@flowgram.ai/form-materials').then((module) => ({ default: module.TypeSelector, })) ); export const BasicStory = () => ( { node.data.outputs = { type: 'object', properties: { color_output: { type: 'color', }, }, }; return node; }, }} plugins={() => [ createTypePresetPlugin({ types: [ { type: 'color', icon: , label: 'Color', ConstantRenderer: ({ value, onChange }) => (
onChange?.(_value.hex)} />
), conditionRule: { eq: { type: 'color' }, }, }, ], }), ]} formMeta={{ render: () => ( <> Type Selector: | undefined> name="type_selector" defaultValue={{ type: 'color' }} > {({ field }) => ( field.onChange(value)} /> )}
DynamicValueInput: name="dynamic_value_input" defaultValue={{ type: 'constant', schema: { type: 'color' }, content: '#b5ed0c' }} > {({ field }) => ( field.onChange(value)} /> )}
Condition: name="condition_row" defaultValue={{ left: { type: 'ref', content: ['start_0', 'color_output'] }, operator: 'eq', right: { type: 'ref', content: ['start_0', 'color_output'] }, }} > {({ field }) => ( field.onChange(value)} /> )}
), }} /> );