Merge branch 'feat/plugins' of github.com:langgenius/dify into feat/plugins
This commit is contained in:
commit
0e52971997
@ -1,19 +1,19 @@
|
||||
import type { StorybookConfig } from '@storybook/nextjs'
|
||||
|
||||
const config: StorybookConfig = {
|
||||
// stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
stories: ['../app/components/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
addons: [
|
||||
'@storybook/addon-onboarding',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addon-essentials',
|
||||
'@chromatic-com/storybook',
|
||||
'@storybook/addon-interactions',
|
||||
],
|
||||
framework: {
|
||||
name: '@storybook/nextjs',
|
||||
options: {},
|
||||
},
|
||||
staticDirs: ['../public'],
|
||||
// stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
stories: ['../app/components/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
addons: [
|
||||
'@storybook/addon-onboarding',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addon-essentials',
|
||||
'@chromatic-com/storybook',
|
||||
'@storybook/addon-interactions',
|
||||
],
|
||||
framework: {
|
||||
name: '@storybook/nextjs',
|
||||
options: {},
|
||||
},
|
||||
staticDirs: ['../public'],
|
||||
}
|
||||
export default config
|
||||
|
@ -8,30 +8,30 @@ import '../app/styles/markdown.scss'
|
||||
import './storybook.css'
|
||||
|
||||
export const decorators = [
|
||||
withThemeByDataAttribute({
|
||||
themes: {
|
||||
light: 'light',
|
||||
dark: 'dark',
|
||||
},
|
||||
defaultTheme: 'light',
|
||||
attributeName: 'data-theme',
|
||||
}),
|
||||
(Story) => {
|
||||
return <I18nServer>
|
||||
<Story />
|
||||
</I18nServer>
|
||||
}
|
||||
]
|
||||
withThemeByDataAttribute({
|
||||
themes: {
|
||||
light: 'light',
|
||||
dark: 'dark',
|
||||
},
|
||||
defaultTheme: 'light',
|
||||
attributeName: 'data-theme',
|
||||
}),
|
||||
(Story) => {
|
||||
return <I18nServer>
|
||||
<Story />
|
||||
</I18nServer>
|
||||
},
|
||||
]
|
||||
|
||||
const preview: Preview = {
|
||||
parameters: {
|
||||
controls: {
|
||||
matchers: {
|
||||
color: /(background|color)$/i,
|
||||
date: /Date$/i,
|
||||
},
|
||||
},
|
||||
controls: {
|
||||
matchers: {
|
||||
color: /(background|color)$/i,
|
||||
date: /Date$/i,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default preview
|
||||
|
3
web/.vscode/settings.example.json
vendored
3
web/.vscode/settings.example.json
vendored
@ -21,5 +21,6 @@
|
||||
"editor.defaultFormatter": "vscode.json-language-features"
|
||||
},
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||
"npm.packageManager": "pnpm"
|
||||
}
|
||||
|
@ -216,8 +216,8 @@ const Chart: React.FC<IChartProps> = ({
|
||||
return `<div style='color:#6B7280;font-size:12px'>${params.name}</div>
|
||||
<div style='font-size:14px;color:#1F2A37'>${valueFormatter((params.data as any)[yField])}
|
||||
${!CHART_TYPE_CONFIG[chartType].showTokens
|
||||
? ''
|
||||
: `<span style='font-size:12px'>
|
||||
? ''
|
||||
: `<span style='font-size:12px'>
|
||||
<span style='margin-left:4px;color:#6B7280'>(</span>
|
||||
<span style='color:#FF8A4C'>~$${get(params.data, 'total_price', 0)}</span>
|
||||
<span style='color:#6B7280'>)</span>
|
||||
@ -243,7 +243,7 @@ const Chart: React.FC<IChartProps> = ({
|
||||
? ''
|
||||
: <span>{t('appOverview.analysis.tokenUsage.consumed')} Tokens<span className='text-sm'>
|
||||
<span className='ml-1 text-gray-500'>(</span>
|
||||
<span className='text-orange-400'>~{sum(statistics.map(item => parseFloat(get(item, 'total_price', '0')))).toLocaleString('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 4 })}</span>
|
||||
<span className='text-orange-400'>~{sum(statistics.map(item => Number.parseFloat(get(item, 'total_price', '0')))).toLocaleString('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 4 })}</span>
|
||||
<span className='text-gray-500'>)</span>
|
||||
</span></span>}
|
||||
textStyle={{ main: `!text-3xl !font-normal ${sumData === 0 ? '!text-gray-300' : ''}` }} />
|
||||
|
@ -35,12 +35,12 @@ const OPTION_MAP = {
|
||||
`<script>
|
||||
window.difyChatbotConfig = {
|
||||
token: '${token}'${isTestEnv
|
||||
? `,
|
||||
? `,
|
||||
isDev: true`
|
||||
: ''}${IS_CE_EDITION
|
||||
? `,
|
||||
: ''}${IS_CE_EDITION
|
||||
? `,
|
||||
baseUrl: '${url}'`
|
||||
: ''}
|
||||
: ''}
|
||||
}
|
||||
</script>
|
||||
<script
|
||||
|
@ -106,7 +106,7 @@ export function PortalToFollowElem({
|
||||
}
|
||||
|
||||
export const PortalToFollowElemTrigger = React.forwardRef<
|
||||
HTMLElement,
|
||||
HTMLElement,
|
||||
React.HTMLProps<HTMLElement> & { asChild?: boolean }
|
||||
>(({ children, asChild = false, ...props }, propRef) => {
|
||||
const context = usePortalToFollowElemContext()
|
||||
@ -141,8 +141,8 @@ React.HTMLProps<HTMLElement> & { asChild?: boolean }
|
||||
PortalToFollowElemTrigger.displayName = 'PortalToFollowElemTrigger'
|
||||
|
||||
export const PortalToFollowElemContent = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLProps<HTMLDivElement>
|
||||
HTMLDivElement,
|
||||
React.HTMLProps<HTMLDivElement>
|
||||
>(({ style, ...props }, propRef) => {
|
||||
const context = usePortalToFollowElemContext()
|
||||
const ref = useMergeRefs([context.refs.setFloating, propRef])
|
||||
|
@ -264,7 +264,7 @@ const InstallFromGitHub: React.FC<InstallFromGitHubProps> = ({ onClose }) => {
|
||||
className='min-w-[72px]'
|
||||
onClick={onClose}
|
||||
>
|
||||
Close
|
||||
Close
|
||||
</Button>
|
||||
)
|
||||
: (
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {
|
||||
GLOB_JSX, GLOB_TESTS, GLOB_TSX, combine, javascript, node,
|
||||
stylistic, typescript, unicorn
|
||||
} from '@antfu/eslint-config'
|
||||
GLOB_TESTS, combine, javascript, node,
|
||||
stylistic, typescript, unicorn,
|
||||
} from '@antfu/eslint-config'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import js from '@eslint/js'
|
||||
@ -21,27 +21,27 @@ const storybook = [
|
||||
{
|
||||
plugins: ['storybook'],
|
||||
files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
|
||||
rules: {
|
||||
'react-hooks/rules-of-hooks': 'off',
|
||||
'import/no-anonymous-default-export': 'off',
|
||||
'storybook/await-interactions': 'error',
|
||||
'storybook/context-in-play-function': 'error',
|
||||
'storybook/default-exports': 'error',
|
||||
'storybook/hierarchy-separator': 'warn',
|
||||
'storybook/no-redundant-story-name': 'warn',
|
||||
'storybook/prefer-pascal-case': 'warn',
|
||||
'storybook/story-exports': 'error',
|
||||
'storybook/use-storybook-expect': 'error',
|
||||
'storybook/use-storybook-testing-library': 'error',
|
||||
}
|
||||
rules: {
|
||||
'react-hooks/rules-of-hooks': 'off',
|
||||
'import/no-anonymous-default-export': 'off',
|
||||
'storybook/await-interactions': 'error',
|
||||
'storybook/context-in-play-function': 'error',
|
||||
'storybook/default-exports': 'error',
|
||||
'storybook/hierarchy-separator': 'warn',
|
||||
'storybook/no-redundant-story-name': 'warn',
|
||||
'storybook/prefer-pascal-case': 'warn',
|
||||
'storybook/story-exports': 'error',
|
||||
'storybook/use-storybook-expect': 'error',
|
||||
'storybook/use-storybook-testing-library': 'error',
|
||||
},
|
||||
},
|
||||
{
|
||||
plugins: ['storybook'],
|
||||
files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
|
||||
rules: {
|
||||
'storybook/no-uninstalled-addons': 'error',
|
||||
}
|
||||
}
|
||||
rules: {
|
||||
'storybook/no-uninstalled-addons': 'error',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
export default combine(
|
||||
@ -49,27 +49,41 @@ export default combine(
|
||||
lessOpinionated: true,
|
||||
// original @antfu/eslint-config does not support jsx
|
||||
jsx: false,
|
||||
semi: false,
|
||||
quotes: 'single',
|
||||
overrides: {
|
||||
// original config
|
||||
"style/indent": "off",
|
||||
'style/indent': ['error', 2],
|
||||
'style/quotes': ['error', 'single'],
|
||||
'curly': ['error', 'multi-line'],
|
||||
'style/comma-spacing': ['error', { before: false, after: true }],
|
||||
'style/quote-props': ['warn', 'consistent-as-needed'],
|
||||
|
||||
// these options does not exist in old version
|
||||
// maybe useless
|
||||
"style/indent-binary-ops": "off",
|
||||
"style/multiline-ternary": "off",
|
||||
'style/indent-binary-ops': 'off',
|
||||
'style/multiline-ternary': 'off',
|
||||
'antfu/top-level-function': 'off',
|
||||
'antfu/curly': 'off',
|
||||
'antfu/consistent-chaining': 'off',
|
||||
|
||||
// copy from eslint-config-antfu 0.36.0
|
||||
'style/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
||||
'style/dot-location': ['error', 'property'],
|
||||
'style/object-curly-newline': ['error', { consistent: true, multiline: true }],
|
||||
'style/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
|
||||
'style/template-curly-spacing': ['error', 'never'],
|
||||
'style/keyword-spacing': 'off',
|
||||
|
||||
// not exist in old version, and big change
|
||||
"style/quote-props": "off",
|
||||
"style/member-delimiter-style": "off",
|
||||
"style/quotes": "off",
|
||||
"style/comma-dangle": "off",
|
||||
}
|
||||
'style/member-delimiter-style': 'off',
|
||||
},
|
||||
}),
|
||||
typescript({
|
||||
overrides: {
|
||||
// useful, but big change
|
||||
"ts/no-empty-object-type": "off",
|
||||
}
|
||||
'ts/no-empty-object-type': 'off',
|
||||
},
|
||||
}),
|
||||
javascript({
|
||||
overrides: {
|
||||
@ -77,8 +91,8 @@ export default combine(
|
||||
'no-unused-vars': 'off',
|
||||
|
||||
// useless
|
||||
'no-use-before-define': 'warn'
|
||||
}
|
||||
'no-use-before-define': 'warn',
|
||||
},
|
||||
}),
|
||||
unicorn(),
|
||||
node(),
|
||||
@ -96,30 +110,36 @@ export default combine(
|
||||
'**/.next/',
|
||||
'**/public/*',
|
||||
'**/*.json',
|
||||
]
|
||||
],
|
||||
},
|
||||
{
|
||||
// orignal config
|
||||
rules: {
|
||||
// from old version of antfu/eslint-config
|
||||
// typescript will handle this, see https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
||||
"no-undef": "off",
|
||||
'no-undef': 'off',
|
||||
|
||||
'ts/consistent-type-definitions': ['error', 'type'],
|
||||
// orignal ts/no-var-requires
|
||||
'ts/no-require-imports': 'off',
|
||||
"no-console": 'off',
|
||||
"react-hooks/exhaustive-deps": "warn",
|
||||
"react/display-name": "off",
|
||||
'no-console': 'off',
|
||||
'react-hooks/exhaustive-deps': 'warn',
|
||||
'react/display-name': 'off',
|
||||
'array-callback-return': ['error', {
|
||||
allowImplicit: false,
|
||||
checkForEach: false,
|
||||
}],
|
||||
|
||||
// orignal config, but removed in new version antfu/eslint-config
|
||||
// big change
|
||||
"curly": "off",
|
||||
// copy from eslint-config-antfu 0.36.0
|
||||
'camelcase': 'off',
|
||||
'curly': ['error', 'multi-or-nest', 'consistent'],
|
||||
'default-case-last': 'error',
|
||||
'dot-notation': ['error', { allowKeywords: true }],
|
||||
'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
|
||||
|
||||
// antfu use eslint-plugin-perfectionist to replace this
|
||||
// will cause big change, so keep the original
|
||||
// sort-imports
|
||||
"sort-imports": [
|
||||
// will cause big change, so keep the original sort-imports
|
||||
'sort-imports': [
|
||||
'error',
|
||||
{
|
||||
ignoreCase: false,
|
||||
@ -131,8 +151,8 @@ export default combine(
|
||||
],
|
||||
|
||||
// antfu migrate to eslint-plugin-unused-imports
|
||||
"unused-imports/no-unused-vars": "warn",
|
||||
"unused-imports/no-unused-imports": "warn",
|
||||
'unused-imports/no-unused-vars': 'warn',
|
||||
'unused-imports/no-unused-imports': 'warn',
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
@ -140,25 +160,25 @@ export default combine(
|
||||
...globals.browser,
|
||||
...globals.es2025,
|
||||
...globals.node,
|
||||
'React': 'readable',
|
||||
'JSX': 'readable',
|
||||
}
|
||||
}
|
||||
React: 'readable',
|
||||
JSX: 'readable',
|
||||
},
|
||||
},
|
||||
},
|
||||
storybook,
|
||||
// need futher research
|
||||
{
|
||||
rules: {
|
||||
// not exist in old version
|
||||
"antfu/consistent-list-newline": "off",
|
||||
'antfu/consistent-list-newline': 'off',
|
||||
'node/prefer-global/process': 'off',
|
||||
'node/prefer-global/buffer': 'off',
|
||||
'node/no-callback-literal': 'off',
|
||||
|
||||
// useful, but big change
|
||||
"unicorn/prefer-number-properties": "warn",
|
||||
"unicorn/no-new-array": "warn"
|
||||
}
|
||||
'unicorn/prefer-number-properties': 'warn',
|
||||
'unicorn/no-new-array': 'warn',
|
||||
},
|
||||
},
|
||||
// suppress error for `no-undef` rule
|
||||
{
|
||||
|
@ -9,22 +9,22 @@ export type metadataType = DocType | 'originInfo' | 'technicalParameters'
|
||||
|
||||
type MetadataMap =
|
||||
Record<
|
||||
metadataType,
|
||||
{
|
||||
text: string
|
||||
allowEdit?: boolean
|
||||
icon?: React.ReactNode
|
||||
iconName?: string
|
||||
subFieldsMap: Record<
|
||||
string,
|
||||
metadataType,
|
||||
{
|
||||
label: string
|
||||
inputType?: inputType
|
||||
field?: string
|
||||
render?: (value: any, total?: number) => React.ReactNode | string
|
||||
text: string
|
||||
allowEdit?: boolean
|
||||
icon?: React.ReactNode
|
||||
iconName?: string
|
||||
subFieldsMap: Record<
|
||||
string,
|
||||
{
|
||||
label: string
|
||||
inputType?: inputType
|
||||
field?: string
|
||||
render?: (value: any, total?: number) => React.ReactNode | string
|
||||
}
|
||||
>
|
||||
}
|
||||
>
|
||||
}
|
||||
>
|
||||
|
||||
const fieldPrefix = 'datasetDocuments.metadata.field'
|
||||
|
Loading…
Reference in New Issue
Block a user