diff --git a/react-ui/.storybook/preview.tsx b/react-ui/.storybook/preview.tsx
index af81cc5c..61e82aaa 100644
--- a/react-ui/.storybook/preview.tsx
+++ b/react-ui/.storybook/preview.tsx
@@ -17,14 +17,25 @@ initialize();
const preview: Preview = {
parameters: {
controls: {
+ expanded: true,
+ sort: 'requiredFirst',
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
+ backgrounds: {
+ values: [
+ { name: 'Dark', value: '#000' },
+ { name: 'Gray', value: '#f9fafb' },
+ { name: 'Light', value: '#FFF' },
+ ],
+ default: 'Light',
+ },
options: {
storySort: {
method: 'alphabetical',
+ order: ['Documentation', 'Components'],
},
},
},
diff --git a/react-ui/package.json b/react-ui/package.json
index c98f0286..818d2144 100644
--- a/react-ui/package.json
+++ b/react-ui/package.json
@@ -36,12 +36,14 @@
"start:mock": "cross-env REACT_APP_ENV=dev UMI_ENV=dev max dev",
"start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev max dev",
"start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev max dev",
+ "storybook": "storybook dev -p 6006",
+ "storybook-build": "storybook build",
+ "storybook-docs": "storybook dev --docs",
+ "storybook-docs-build": "storybook build --docs",
"test": "jest",
"test:coverage": "npm run jest -- --coverage",
"test:update": "npm run jest -- -u",
- "tsc": "tsc --noEmit",
- "storybook": "storybook dev -p 6006",
- "build-storybook": "storybook build"
+ "tsc": "tsc --noEmit"
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",
@@ -166,4 +168,4 @@
"public"
]
}
-}
\ No newline at end of file
+}
diff --git a/react-ui/src/components/CodeSelect/index.tsx b/react-ui/src/components/CodeSelect/index.tsx
index 242183e1..d2afbb94 100644
--- a/react-ui/src/components/CodeSelect/index.tsx
+++ b/react-ui/src/components/CodeSelect/index.tsx
@@ -8,15 +8,28 @@ import CodeSelectorModal from '@/components/CodeSelectorModal';
import KFIcon from '@/components/KFIcon';
import { openAntdModal } from '@/utils/modal';
import { Button } from 'antd';
+import classNames from 'classnames';
import ParameterInput, { type ParameterInputProps } from '../ParameterInput';
import './index.less';
-export { requiredValidator, type ParameterInputObject } from '../ParameterInput';
+export {
+ requiredValidator,
+ type ParameterInputObject,
+ type ParameterInputValue,
+} from '../ParameterInput';
type CodeSelectProps = ParameterInputProps;
/** 代码配置选择表单组件 */
-function CodeSelect({ value, onChange, disabled, ...rest }: CodeSelectProps) {
+function CodeSelect({
+ value,
+ size,
+ disabled,
+ className,
+ style,
+ onChange,
+ ...rest
+}: CodeSelectProps) {
const selectResource = () => {
const { close } = openAntdModal(CodeSelectorModal, {
onOk: (res) => {
@@ -47,9 +60,10 @@ function CodeSelect({ value, onChange, disabled, ...rest }: CodeSelectProps) {
};
return (
-
+
}
disabled={disabled}
diff --git a/react-ui/src/components/ParameterInput/index.less b/react-ui/src/components/ParameterInput/index.less
index cf249e0f..fff69eb1 100644
--- a/react-ui/src/components/ParameterInput/index.less
+++ b/react-ui/src/components/ParameterInput/index.less
@@ -49,18 +49,31 @@
padding: 10px 11px;
font-size: @font-size-input-lg;
- .parameter-input__placeholder {
+ .parameter-input__placeholder,
+ .parameter-input__content__value {
+ min-height: 24px;
font-size: @font-size-input-lg;
line-height: 1.5;
}
+ .parameter-input__content__close-icon {
+ font-size: 12px;
+ }
+}
+
+.parameter-input.parameter-input--small {
+ padding: 0 7px;
+ font-size: @font-size-input;
+
+ .parameter-input__placeholder,
.parameter-input__content__value {
- font-size: @font-size-input-lg;
- line-height: 1.5;
+ min-height: 22px;
+ font-size: @font-size-input;
+ line-height: 1.5714285714285714;
}
.parameter-input__content__close-icon {
- font-size: 12px;
+ font-size: 10px;
}
}
diff --git a/react-ui/src/components/ParameterInput/index.tsx b/react-ui/src/components/ParameterInput/index.tsx
index 99bb78af..47ef5d0e 100644
--- a/react-ui/src/components/ParameterInput/index.tsx
+++ b/react-ui/src/components/ParameterInput/index.tsx
@@ -105,6 +105,7 @@ function ParameterInput({
className={classNames(
'parameter-input',
{ 'parameter-input--large': size === 'large' },
+ { 'parameter-input--small': size === 'small' },
{ [`parameter-input--${status}`]: status },
className,
)}
diff --git a/react-ui/src/components/ResourceSelect/index.tsx b/react-ui/src/components/ResourceSelect/index.tsx
index 718d571a..c4bef4bf 100644
--- a/react-ui/src/components/ResourceSelect/index.tsx
+++ b/react-ui/src/components/ResourceSelect/index.tsx
@@ -12,12 +12,17 @@ import ResourceSelectorModal, {
} from '@/components/ResourceSelectorModal';
import { openAntdModal } from '@/utils/modal';
import { Button } from 'antd';
+import classNames from 'classnames';
import { pick } from 'lodash';
import { useEffect, useState } from 'react';
import ParameterInput, { type ParameterInputProps } from '../ParameterInput';
import './index.less';
-export { requiredValidator, type ParameterInputObject } from '../ParameterInput';
+export {
+ requiredValidator,
+ type ParameterInputObject,
+ type ParameterInputValue,
+} from '../ParameterInput';
export { ResourceSelectorType, selectorTypeConfig, type ResourceSelectorResponse };
interface ResourceSelectProps extends ParameterInputProps {
@@ -31,7 +36,16 @@ const getSelectBtnIcon = (type: ResourceSelectorType) => {
};
/** 数据集、模型、镜像选择表单组件 */
-function ResourceSelect({ type, value, onChange, disabled, ...rest }: ResourceSelectProps) {
+function ResourceSelect({
+ type,
+ value,
+ size,
+ disabled,
+ className,
+ style,
+ onChange,
+ ...rest
+}: ResourceSelectProps) {
const [selectedResource, setSelectedResource] = useState
(
undefined,
);
@@ -115,18 +129,19 @@ function ResourceSelect({ type, value, onChange, disabled, ...rest }: ResourceSe
};
return (
-
+
setSelectedResource(undefined)}
onClick={selectResource}
>