mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-05-25 07:59:09 +03:00
* chore(deps): update dependency prettier to v3 * Format --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nathan Bierema <nbierema@gmail.com>
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import { FieldProps, Widget, WidgetProps } from '@rjsf/core';
|
|
import Select from '../Select';
|
|
import Slider from '../Slider';
|
|
|
|
/* eslint-disable react/prop-types */
|
|
const SelectWidget: Widget = ({
|
|
options,
|
|
onChange,
|
|
value,
|
|
onBlur,
|
|
defaultValue,
|
|
tabIndex,
|
|
onFocus,
|
|
'aria-invalid': ariaInvalid,
|
|
...rest
|
|
}) => (
|
|
<Select<{ label: string; value: string }>
|
|
options={options.enumOptions as { label: string; value: string }[]}
|
|
onChange={(option) => {
|
|
onChange(option?.value);
|
|
}}
|
|
value={(options.enumOptions as { label: string; value: string }[]).find(
|
|
(option) => option.value === value,
|
|
)}
|
|
{...rest}
|
|
/>
|
|
);
|
|
|
|
const RangeWidget: Widget = (({
|
|
schema,
|
|
disabled,
|
|
label, // eslint-disable-line
|
|
options, // eslint-disable-line
|
|
formContext, // eslint-disable-line
|
|
registry, // eslint-disable-line
|
|
...rest
|
|
}: WidgetProps & { registry: FieldProps['registry'] }) =>
|
|
(
|
|
<Slider
|
|
{...rest}
|
|
disabled={disabled}
|
|
min={schema.minimum}
|
|
max={schema.maximum}
|
|
withValue
|
|
/>
|
|
) as unknown) as Widget;
|
|
|
|
export default { SelectWidget, RangeWidget };
|