@ant-design/pro-chat
Version:
a solution for ai chat
67 lines • 2.19 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["step", "value", "onChange", "max", "min", "defaultValue", "size", "controls", "style", "className", "disabled"];
import { InputNumber, Slider } from 'antd';
import { isNull } from 'lodash-es';
import { memo, useCallback } from 'react';
import { Flexbox } from 'react-layout-kit';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var SliderWithInput = /*#__PURE__*/memo(function (_ref) {
var step = _ref.step,
value = _ref.value,
onChange = _ref.onChange,
max = _ref.max,
min = _ref.min,
defaultValue = _ref.defaultValue,
size = _ref.size,
controls = _ref.controls,
style = _ref.style,
className = _ref.className,
disabled = _ref.disabled,
props = _objectWithoutProperties(_ref, _excluded);
var handleOnchange = useCallback(function (value) {
if (Number.isNaN(value) || isNull(value)) return;
onChange === null || onChange === void 0 || onChange(value);
}, []);
return /*#__PURE__*/_jsxs(Flexbox, {
align: 'center',
className: className,
direction: 'horizontal',
gap: 8,
style: style,
children: [/*#__PURE__*/_jsx(Slider, _objectSpread({
defaultValue: defaultValue,
disabled: disabled,
max: max,
min: min,
onChange: handleOnchange,
step: step,
style: size === 'small' ? {
flex: 1,
margin: 0
} : {
flex: 1
},
tooltip: {
open: false
},
value: typeof value === 'number' ? value : 0
}, props)), /*#__PURE__*/_jsx(InputNumber, {
controls: size !== 'small' || controls,
defaultValue: defaultValue,
disabled: disabled,
max: max,
min: min,
onChange: handleOnchange,
size: size,
step: Number.isNaN(step) || isNull(step) ? undefined : step,
style: {
flex: 1,
maxWidth: size === 'small' ? 40 : 64
},
value: typeof value === 'number' ? value : 0
})]
});
});
export default SliderWithInput;