fix(materials): json schema title & variable selector long text style (#438)

* fix: json schema title

* fix: variable selector style

* feat: add missing license header

* feat: add doc build in gitignore
This commit is contained in:
Yiwei Mao 2025-07-01 20:44:12 +08:00 committed by GitHub
parent 2d5fac776a
commit 867ceb8bc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 104 additions and 5 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
# e2e results # e2e results
test-results/ test-results/
doc_build/
# Logs # Logs
*.log *.log

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { useVariableTree } from '@flowgram.ai/form-materials'; import { useVariableTree } from '@flowgram.ai/form-materials';
import { Tree } from '@douyinfe/semi-ui'; import { Tree } from '@douyinfe/semi-ui';

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { useEffect } from 'react'; import { useEffect } from 'react';
import { JsonSchemaEditor, JsonSchemaUtils } from '@flowgram.ai/form-materials'; import { JsonSchemaEditor, JsonSchemaUtils } from '@flowgram.ai/form-materials';

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
.panel-wrapper { .panel-wrapper {
position: relative; position: relative;
z-index: 9999; z-index: 9999;

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { useState } from 'react'; import { useState } from 'react';
import { Button, Collapsible, Tabs, Tooltip } from '@douyinfe/semi-ui'; import { Button, Collapsible, Tabs, Tooltip } from '@douyinfe/semi-ui';

View File

@ -1 +1,6 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
export { createVariablePanelPlugin } from './variable-panel-plugin'; export { createVariablePanelPlugin } from './variable-panel-plugin';

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { domUtils, injectable, Layer } from '@flowgram.ai/fixed-layout-editor'; import { domUtils, injectable, Layer } from '@flowgram.ai/fixed-layout-editor';
import { VariablePanel } from './components/variable-panel'; import { VariablePanel } from './components/variable-panel';

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { JsonSchemaUtils } from '@flowgram.ai/form-materials'; import { JsonSchemaUtils } from '@flowgram.ai/form-materials';
import { ASTFactory, definePluginCreator, GlobalScope } from '@flowgram.ai/fixed-layout-editor'; import { ASTFactory, definePluginCreator, GlobalScope } from '@flowgram.ai/fixed-layout-editor';

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { useVariableTree } from '@flowgram.ai/form-materials'; import { useVariableTree } from '@flowgram.ai/form-materials';
import { Tree } from '@douyinfe/semi-ui'; import { Tree } from '@douyinfe/semi-ui';

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { useEffect } from 'react'; import { useEffect } from 'react';
import { import {

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
.panel-wrapper { .panel-wrapper {
position: relative; position: relative;
} }

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { useState } from 'react'; import { useState } from 'react';
import { Button, Collapsible, Tabs, Tooltip } from '@douyinfe/semi-ui'; import { Button, Collapsible, Tabs, Tooltip } from '@douyinfe/semi-ui';

View File

@ -1 +1,6 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
export { createVariablePanelPlugin } from './variable-panel-plugin'; export { createVariablePanelPlugin } from './variable-panel-plugin';

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { domUtils, injectable, Layer } from '@flowgram.ai/free-layout-editor'; import { domUtils, injectable, Layer } from '@flowgram.ai/free-layout-editor';
import { VariablePanel } from './components/variable-panel'; import { VariablePanel } from './components/variable-panel';

View File

@ -1,3 +1,8 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { ASTFactory, definePluginCreator, GlobalScope } from '@flowgram.ai/free-layout-editor'; import { ASTFactory, definePluginCreator, GlobalScope } from '@flowgram.ai/free-layout-editor';
import { JsonSchemaUtils } from '@flowgram.ai/form-materials'; import { JsonSchemaUtils } from '@flowgram.ai/form-materials';

View File

@ -50,6 +50,7 @@ export function DynamicValueInput({
// Display Variable Or Delete // Display Variable Or Delete
return ( return (
<VariableSelector <VariableSelector
style={{ width: '100%' }}
value={value?.content} value={value?.content}
onChange={(_v) => onChange(_v ? { type: 'ref', content: _v } : undefined)} onChange={(_v) => onChange(_v ? { type: 'ref', content: _v } : undefined)}
includeSchema={includeSchema} includeSchema={includeSchema}

View File

@ -13,6 +13,8 @@ export const UIContainer = styled.div`
export const UIMain = styled.div` export const UIMain = styled.div`
flex-grow: 1; flex-grow: 1;
overflow: hidden;
min-width: 0;
& .semi-tree-select, & .semi-tree-select,
& .semi-input-number, & .semi-input-number,

View File

@ -11,7 +11,7 @@ import { IconChevronDownStroked, IconIssueStroked } from '@douyinfe/semi-icons';
import { IJsonSchema } from '../../typings/json-schema'; import { IJsonSchema } from '../../typings/json-schema';
import { useVariableTree } from './use-variable-tree'; import { useVariableTree } from './use-variable-tree';
import { UIRootTitle, UITag, UITreeSelect } from './styles'; import { UIRootTitle, UITag, UITreeSelect, UIVarName } from './styles';
interface PropTypes { interface PropTypes {
value?: string[]; value?: string[];
@ -102,7 +102,7 @@ export const VariableSelector = ({
<UIRootTitle> <UIRootTitle>
{_option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null} {_option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null}
</UIRootTitle> </UIRootTitle>
{_option.label} <UIVarName>{_option.label}</UIVarName>
</UITag> </UITag>
); );
}} }}

View File

@ -6,11 +6,22 @@
import styled from 'styled-components'; import styled from 'styled-components';
import { Tag, TreeSelect } from '@douyinfe/semi-ui'; import { Tag, TreeSelect } from '@douyinfe/semi-ui';
export const UIRootTitle = styled.span` export const UIRootTitle = styled.div`
margin-right: 4px; margin-right: 4px;
min-width: 20px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--semi-color-text-2); color: var(--semi-color-text-2);
`; `;
export const UIVarName = styled.div`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 50%;
`;
export const UITag = styled(Tag)` export const UITag = styled(Tag)`
width: 100%; width: 100%;
display: flex; display: flex;

View File

@ -42,7 +42,10 @@ export namespace JsonSchemaUtils {
.map(([key, _property]) => ({ .map(([key, _property]) => ({
key, key,
type: schemaToAST(_property), type: schemaToAST(_property),
meta: { description: _property.description }, meta: {
title: _property.title,
description: _property.description,
},
})), })),
}); });
case 'array': case 'array':
@ -114,7 +117,18 @@ export namespace JsonSchemaUtils {
type: 'object', type: 'object',
properties: drilldown properties: drilldown
? Object.fromEntries( ? Object.fromEntries(
typeAST.properties.map((property) => [property.key, astToSchema(property.type)!]) typeAST.properties.map((property) => {
const schema = astToSchema(property.type);
if (property.meta?.title && schema) {
schema.title = property.meta.title;
}
if (property.meta?.description && schema) {
schema.description = property.meta.description;
}
return [property.key, schema!];
})
) )
: {}, : {},
}; };