fix: literal infers type when any
This commit is contained in:
parent
b797657361
commit
4a7afab0df
|
@ -1,3 +1,4 @@
|
|||
import {fromLiteral} from '@avocado/behavior';
|
||||
import {compose} from '@avocado/core';
|
||||
import contempo from 'contempo';
|
||||
import React from 'react';
|
||||
|
@ -15,11 +16,12 @@ const Literal = ({
|
|||
context,
|
||||
onChange = () => {},
|
||||
type,
|
||||
value,
|
||||
value: {value},
|
||||
}) => {
|
||||
const typeRenderers = useTypeRenderers();
|
||||
const Component = typeRenderers[type];
|
||||
const [options] = opsOptions(context, [], type);
|
||||
const actualType = 'any' === type ? fromLiteral(value) : type;
|
||||
const Component = typeRenderers[actualType];
|
||||
const [options] = opsOptions(context, [], actualType);
|
||||
options.push('<literal>');
|
||||
return (
|
||||
<div className="literal">
|
||||
|
@ -40,7 +42,7 @@ const Literal = ({
|
|||
.map((option) => <option key={option}>{option}</option>)
|
||||
}
|
||||
</select>
|
||||
{Component ? <Component onChange={onChange} type={type} value={value.value} /> : null}
|
||||
{Component ? <Component onChange={onChange} type={actualType} value={value} /> : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user