|
@@ -9,15 +9,16 @@ import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
|
import { I18n } from '@flowgram.ai/editor';
|
|
import { I18n } from '@flowgram.ai/editor';
|
|
|
import { type TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
import { type TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
|
import { type TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
import { type TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
|
-import { Popover } from '@douyinfe/semi-ui';
|
|
|
|
|
|
|
+import { Popover, Tag, TreeSelect } from '@douyinfe/semi-ui';
|
|
|
import { IconChevronDownStroked, IconIssueStroked } from '@douyinfe/semi-icons';
|
|
import { IconChevronDownStroked, IconIssueStroked } from '@douyinfe/semi-icons';
|
|
|
|
|
|
|
|
import { createInjectMaterial } from '@/shared';
|
|
import { createInjectMaterial } from '@/shared';
|
|
|
|
|
|
|
|
import { useVariableTree } from './use-variable-tree';
|
|
import { useVariableTree } from './use-variable-tree';
|
|
|
-import { UIPopoverContent, UIRootTitle, UITag, UITreeSelect, UIVarName } from './styles';
|
|
|
|
|
import { useVariableSelectorContext } from './context';
|
|
import { useVariableSelectorContext } from './context';
|
|
|
|
|
|
|
|
|
|
+import './styles.css';
|
|
|
|
|
+
|
|
|
export interface VariableSelectorProps {
|
|
export interface VariableSelectorProps {
|
|
|
value?: string[];
|
|
value?: string[];
|
|
|
config?: {
|
|
config?: {
|
|
@@ -75,62 +76,71 @@ export const VariableSelector = ({
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
- <UITreeSelect
|
|
|
|
|
|
|
+ <TreeSelect
|
|
|
|
|
+ className={`flowgram-variable-selector-tree-select ${hasError ? 'error' : ''}`}
|
|
|
dropdownMatchSelectWidth={false}
|
|
dropdownMatchSelectWidth={false}
|
|
|
disabled={readonly}
|
|
disabled={readonly}
|
|
|
treeData={treeData}
|
|
treeData={treeData}
|
|
|
size="small"
|
|
size="small"
|
|
|
value={treeValue}
|
|
value={treeValue}
|
|
|
clearIcon={null}
|
|
clearIcon={null}
|
|
|
- $error={hasError}
|
|
|
|
|
style={style}
|
|
style={style}
|
|
|
validateStatus={hasError ? 'error' : undefined}
|
|
validateStatus={hasError ? 'error' : undefined}
|
|
|
|
|
+ dropdownClassName="flowgram-variable-selector-dropdown"
|
|
|
onChange={(_, _config) => {
|
|
onChange={(_, _config) => {
|
|
|
onChange((_config as TreeNodeData).keyPath as string[]);
|
|
onChange((_config as TreeNodeData).keyPath as string[]);
|
|
|
}}
|
|
}}
|
|
|
renderSelectedItem={(_option: TreeNodeData) => {
|
|
renderSelectedItem={(_option: TreeNodeData) => {
|
|
|
if (!_option?.keyPath) {
|
|
if (!_option?.keyPath) {
|
|
|
return (
|
|
return (
|
|
|
- <UITag
|
|
|
|
|
|
|
+ <Tag
|
|
|
|
|
+ className="flowgram-variable-selector-tag"
|
|
|
prefixIcon={<IconIssueStroked />}
|
|
prefixIcon={<IconIssueStroked />}
|
|
|
color="amber"
|
|
color="amber"
|
|
|
closable={!readonly}
|
|
closable={!readonly}
|
|
|
onClose={() => onChange(undefined)}
|
|
onClose={() => onChange(undefined)}
|
|
|
>
|
|
>
|
|
|
{config?.notFoundContent ?? 'Undefined'}
|
|
{config?.notFoundContent ?? 'Undefined'}
|
|
|
- </UITag>
|
|
|
|
|
|
|
+ </Tag>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
|
|
|
|
|
|
const rootTitle = (
|
|
const rootTitle = (
|
|
|
- <UIRootTitle>
|
|
|
|
|
|
|
+ <div className="flowgram-variable-selector-root-title">
|
|
|
{_option.rootMeta?.title
|
|
{_option.rootMeta?.title
|
|
|
? `${_option.rootMeta?.title} ${_option.isRoot ? '' : '-'} `
|
|
? `${_option.rootMeta?.title} ${_option.isRoot ? '' : '-'} `
|
|
|
: null}
|
|
: null}
|
|
|
- </UIRootTitle>
|
|
|
|
|
|
|
+ </div>
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div>
|
|
<div>
|
|
|
<Popover
|
|
<Popover
|
|
|
content={
|
|
content={
|
|
|
- <UIPopoverContent>
|
|
|
|
|
|
|
+ <div className="flowgram-variable-selector-tag-pop">
|
|
|
{rootIcon}
|
|
{rootIcon}
|
|
|
{rootTitle}
|
|
{rootTitle}
|
|
|
- <UIVarName>{_option.keyPath.slice(1).join('.')}</UIVarName>
|
|
|
|
|
- </UIPopoverContent>
|
|
|
|
|
|
|
+ <div className="flowgram-variable-selector-var-name">
|
|
|
|
|
+ {_option.keyPath.slice(1).join('.')}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
}
|
|
}
|
|
|
>
|
|
>
|
|
|
- <UITag
|
|
|
|
|
|
|
+ <Tag
|
|
|
|
|
+ className="flowgram-variable-selector-tag"
|
|
|
prefixIcon={rootIcon}
|
|
prefixIcon={rootIcon}
|
|
|
closable={!readonly}
|
|
closable={!readonly}
|
|
|
onClose={() => onChange(undefined)}
|
|
onClose={() => onChange(undefined)}
|
|
|
>
|
|
>
|
|
|
{rootTitle}
|
|
{rootTitle}
|
|
|
- {!_option.isRoot && <UIVarName $inSelector>{_option.label}</UIVarName>}
|
|
|
|
|
- </UITag>
|
|
|
|
|
|
|
+ {!_option.isRoot && (
|
|
|
|
|
+ <div className="flowgram-variable-selector-var-name in-selector">
|
|
|
|
|
+ {_option.label}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </Tag>
|
|
|
</Popover>
|
|
</Popover>
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|