refactor: unified cn utils (#29916)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
This commit is contained in:
@@ -10,7 +10,7 @@ import { EditionType, PromptRole } from '../../../types'
|
||||
import useAvailableVarList from '../../_base/hooks/use-available-var-list'
|
||||
import { useWorkflowStore } from '../../../store'
|
||||
import ConfigPromptItem from './config-prompt-item'
|
||||
import cn from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor'
|
||||
import AddButton from '@/app/components/workflow/nodes/_base/components/add-button'
|
||||
import { DragHandle } from '@/app/components/base/icons/src/vender/line/others'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { type FC, useCallback, useEffect, useMemo, useRef } from 'react'
|
||||
import useTheme from '@/hooks/use-theme'
|
||||
import { Theme } from '@/types/app'
|
||||
import classNames from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { Editor } from '@monaco-editor/react'
|
||||
import { RiClipboardLine, RiIndentIncrease } from '@remixicon/react'
|
||||
import copy from 'copy-to-clipboard'
|
||||
@@ -112,7 +112,7 @@ const CodeEditor: FC<CodeEditorProps> = ({
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className={classNames('flex h-full flex-col overflow-hidden bg-components-input-bg-normal', hideTopMenu && 'pt-2', className)}>
|
||||
<div className={cn('flex h-full flex-col overflow-hidden bg-components-input-bg-normal', hideTopMenu && 'pt-2', className)}>
|
||||
{!hideTopMenu && (
|
||||
<div className='flex items-center justify-between pl-2 pr-1 pt-1'>
|
||||
<div className='system-xs-semibold-uppercase py-0.5 text-text-secondary'>
|
||||
@@ -142,7 +142,7 @@ const CodeEditor: FC<CodeEditorProps> = ({
|
||||
</div>
|
||||
)}
|
||||
{topContent}
|
||||
<div className={classNames('relative overflow-hidden', editorWrapperClassName)}>
|
||||
<div className={cn('relative overflow-hidden', editorWrapperClassName)}>
|
||||
<Editor
|
||||
defaultLanguage='json'
|
||||
theme={isMounted ? editorTheme : 'default-theme'} // sometimes not load the default theme
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import type { FC } from 'react'
|
||||
import { RiErrorWarningFill } from '@remixicon/react'
|
||||
import classNames from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
|
||||
type ErrorMessageProps = {
|
||||
message: string
|
||||
@@ -12,10 +12,8 @@ const ErrorMessage: FC<ErrorMessageProps> = ({
|
||||
className,
|
||||
}) => {
|
||||
return (
|
||||
<div className={classNames(
|
||||
'mt-1 flex gap-x-1 rounded-lg border-[0.5px] border-components-panel-border bg-toast-error-bg p-2',
|
||||
className,
|
||||
)}>
|
||||
<div className={cn('mt-1 flex gap-x-1 rounded-lg border-[0.5px] border-components-panel-border bg-toast-error-bg p-2',
|
||||
className)}>
|
||||
<RiErrorWarningFill className='h-4 w-4 shrink-0 text-text-destructive' />
|
||||
<div className='system-xs-medium max-h-12 grow overflow-y-auto whitespace-pre-line break-words text-text-primary'>
|
||||
{message}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { type FC, useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem'
|
||||
import cn from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { RiCloseLine } from '@remixicon/react'
|
||||
import Button from '@/app/components/base/button'
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { CompletionParams, Model } from '@/types/app'
|
||||
import { ModelModeType } from '@/types/app'
|
||||
import { Theme } from '@/types/app'
|
||||
import { SchemaGeneratorDark, SchemaGeneratorLight } from './assets'
|
||||
import cn from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import PromptEditor from './prompt-editor'
|
||||
import GeneratedResult from './generated-result'
|
||||
import { useGenerateStructuredOutputRules } from '@/service/use-common'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { type FC } from 'react'
|
||||
import CodeEditor from './code-editor'
|
||||
import cn from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import LargeDataAlert from '@/app/components/workflow/variable-inspect/large-data-alert'
|
||||
|
||||
type SchemaEditorProps = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import type { FC } from 'react'
|
||||
import cn from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
|
||||
type AutoWidthInputProps = {
|
||||
value: string
|
||||
|
||||
@@ -9,7 +9,7 @@ import Actions from './actions'
|
||||
import AdvancedActions from './advanced-actions'
|
||||
import AdvancedOptions, { type AdvancedOptionsType } from './advanced-options'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import classNames from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { useVisualEditorStore } from '../store'
|
||||
import { useMittContext } from '../context'
|
||||
import { useUnmount } from 'ahooks'
|
||||
@@ -255,7 +255,7 @@ const EditCard: FC<EditCardProps> = ({
|
||||
</div>
|
||||
|
||||
{(fields.description || isAdvancedEditing) && (
|
||||
<div className={classNames('flex', isAdvancedEditing ? 'p-2 pt-1' : 'px-2 pb-1')}>
|
||||
<div className={cn('flex', isAdvancedEditing ? 'p-2 pt-1' : 'px-2 pb-1')}>
|
||||
<input
|
||||
value={currentFields.description}
|
||||
className='system-xs-regular placeholder:system-xs-regular h-4 w-full p-0 text-text-tertiary caret-[#295EFF] outline-none placeholder:text-text-placeholder'
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { ArrayType, Type } from '../../../../types'
|
||||
import type { FC } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { RiArrowDownSLine, RiCheckLine } from '@remixicon/react'
|
||||
import cn from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
|
||||
export type TypeItem = {
|
||||
value: Type | ArrayType
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { FC } from 'react'
|
||||
import type { SchemaRoot } from '../../../types'
|
||||
import SchemaNode from './schema-node'
|
||||
import { useSchemaNodeOperations } from './hooks'
|
||||
import cn from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
|
||||
export type VisualEditorProps = {
|
||||
className?: string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { FC } from 'react'
|
||||
import React, { useMemo, useState } from 'react'
|
||||
import { type Field, Type } from '../../../types'
|
||||
import classNames from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { RiArrowDropDownLine, RiArrowDropRightLine } from '@remixicon/react'
|
||||
import { getFieldType, getHasChildren } from '../../../utils'
|
||||
import Divider from '@/app/components/base/divider'
|
||||
@@ -92,12 +92,10 @@ const SchemaNode: FC<SchemaNodeProps> = ({
|
||||
|
||||
return (
|
||||
<div className='relative'>
|
||||
<div className={classNames('relative z-10', indentPadding[depth])}>
|
||||
<div className={cn('relative z-10', indentPadding[depth])}>
|
||||
{depth > 0 && hasChildren && (
|
||||
<div className={classNames(
|
||||
'absolute top-0 z-10 flex h-7 w-5 items-center bg-background-section-burn px-0.5',
|
||||
indentLeft[depth - 1],
|
||||
)}>
|
||||
<div className={cn('absolute top-0 z-10 flex h-7 w-5 items-center bg-background-section-burn px-0.5',
|
||||
indentLeft[depth - 1])}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleExpand}
|
||||
@@ -140,14 +138,12 @@ const SchemaNode: FC<SchemaNodeProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={classNames(
|
||||
'absolute z-0 flex w-5 justify-center',
|
||||
<div className={cn('absolute z-0 flex w-5 justify-center',
|
||||
schema.description ? 'top-12 h-[calc(100%-3rem)]' : 'top-7 h-[calc(100%-1.75rem)]',
|
||||
indentLeft[depth],
|
||||
)}>
|
||||
indentLeft[depth])}>
|
||||
<Divider
|
||||
type='vertical'
|
||||
className={classNames('mx-0', isHovering ? 'bg-divider-deep' : 'bg-divider-subtle')}
|
||||
className={cn('mx-0', isHovering ? 'bg-divider-deep' : 'bg-divider-subtle')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { FC } from 'react'
|
||||
import React, { useCallback } from 'react'
|
||||
import { useBoolean } from 'ahooks'
|
||||
import cn from 'classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { Generator } from '@/app/components/base/icons/src/vender/other'
|
||||
import { ActionButton } from '@/app/components/base/action-button'
|
||||
import GetAutomaticResModal from '@/app/components/app/configuration/config/automatic/get-automatic-res'
|
||||
|
||||
@@ -7,7 +7,7 @@ import { type SchemaRoot, type StructuredOutput, Type } from '../types'
|
||||
import ShowPanel from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show'
|
||||
import { useBoolean } from 'ahooks'
|
||||
import JsonSchemaConfigModal from './json-schema-config-modal'
|
||||
import cn from '@/utils/classnames'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
type Props = {
|
||||
|
||||
Reference in New Issue
Block a user