mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 06:01:22 +08:00
Merge branch 'next' of github.com:storybooks/storybook into next
This commit is contained in:
commit
78dc86eb63
@ -79,7 +79,14 @@ export default class Panel extends React.Component {
|
|||||||
|
|
||||||
this.setState({ knobs: newKnobs });
|
this.setState({ knobs: newKnobs });
|
||||||
|
|
||||||
this.setState({ knobs: newKnobs }, this.emitChange(changedKnob));
|
this.setState(
|
||||||
|
{ knobs: newKnobs },
|
||||||
|
this.emitChange(
|
||||||
|
changedKnob.type === 'number'
|
||||||
|
? { ...changedKnob, value: parseFloat(changedKnob.value) }
|
||||||
|
: changedKnob
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClick(knob) {
|
handleClick(knob) {
|
||||||
|
@ -14,6 +14,7 @@ const ArrayType = ({ knob, onChange }) => (
|
|||||||
<TextInput
|
<TextInput
|
||||||
id={knob.name}
|
id={knob.name}
|
||||||
underlineColorAndroid="transparent"
|
underlineColorAndroid="transparent"
|
||||||
|
autoCapitalize="none"
|
||||||
style={{
|
style={{
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: '#f7f4f4',
|
borderColor: '#f7f4f4',
|
||||||
|
@ -9,8 +9,24 @@ class NumberType extends React.Component {
|
|||||||
this.renderRange = this.renderRange.bind(this);
|
this.renderRange = this.renderRange.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
numberTransformer = x => {
|
||||||
|
if (Number.isNaN(Number(x))) {
|
||||||
|
return x.substr(0, x.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
};
|
||||||
|
|
||||||
|
onChangeNormal = value => {
|
||||||
|
const { onChange } = this.props;
|
||||||
|
|
||||||
|
if (!Number.isNaN(value)) {
|
||||||
|
onChange(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
renderNormal() {
|
renderNormal() {
|
||||||
const { knob, onChange } = this.props;
|
const { knob } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TextInput
|
<TextInput
|
||||||
@ -22,10 +38,12 @@ class NumberType extends React.Component {
|
|||||||
padding: 5,
|
padding: 5,
|
||||||
color: '#555',
|
color: '#555',
|
||||||
}}
|
}}
|
||||||
|
autoCapitalize="none"
|
||||||
underlineColorAndroid="transparent"
|
underlineColorAndroid="transparent"
|
||||||
value={knob.value.toString()}
|
value={(knob.value || '').toString()}
|
||||||
|
transformer={this.numberTransformer}
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
onChangeText={val => onChange(parseFloat(val))}
|
onChangeText={this.onChangeNormal}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -61,7 +79,7 @@ NumberType.defaultProps = {
|
|||||||
NumberType.propTypes = {
|
NumberType.propTypes = {
|
||||||
knob: PropTypes.shape({
|
knob: PropTypes.shape({
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
value: PropTypes.number,
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||||
step: PropTypes.number,
|
step: PropTypes.number,
|
||||||
min: PropTypes.number,
|
min: PropTypes.number,
|
||||||
max: PropTypes.number,
|
max: PropTypes.number,
|
||||||
|
@ -37,12 +37,18 @@ class ObjectType extends React.Component {
|
|||||||
|
|
||||||
handleChange = value => {
|
handleChange = value => {
|
||||||
const { onChange } = this.props;
|
const { onChange } = this.props;
|
||||||
|
|
||||||
|
const withReplacedQuotes = value
|
||||||
|
.replace(/[\u2018\u2019]/g, "'")
|
||||||
|
.replace(/[\u201C\u201D]/g, '"');
|
||||||
|
|
||||||
const newState = {
|
const newState = {
|
||||||
jsonString: value,
|
jsonString: withReplacedQuotes,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newState.json = JSON.parse(value.trim());
|
newState.json = JSON.parse(withReplacedQuotes.trim());
|
||||||
|
|
||||||
onChange(newState.json);
|
onChange(newState.json);
|
||||||
this.failed = false;
|
this.failed = false;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -70,6 +76,7 @@ class ObjectType extends React.Component {
|
|||||||
value={jsonString}
|
value={jsonString}
|
||||||
onChangeText={this.handleChange}
|
onChangeText={this.handleChange}
|
||||||
multiline
|
multiline
|
||||||
|
autoCapitalize="none"
|
||||||
underlineColorAndroid="transparent"
|
underlineColorAndroid="transparent"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -40,6 +40,7 @@ class SelectType extends React.Component {
|
|||||||
}}
|
}}
|
||||||
editable={false}
|
editable={false}
|
||||||
value={selected}
|
value={selected}
|
||||||
|
autoCapitalize="none"
|
||||||
underlineColorAndroid="transparent"
|
underlineColorAndroid="transparent"
|
||||||
/>
|
/>
|
||||||
</ModalPicker>
|
</ModalPicker>
|
||||||
|
@ -16,6 +16,7 @@ const TextType = ({ knob, onChange }) => (
|
|||||||
id={knob.name}
|
id={knob.name}
|
||||||
value={knob.value}
|
value={knob.value}
|
||||||
onChangeText={onChange}
|
onChangeText={onChange}
|
||||||
|
autoCapitalize="none"
|
||||||
underlineColorAndroid="transparent"
|
underlineColorAndroid="transparent"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user