mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-31 05:03:21 +08:00
fix(knobs): update visibility of methods to avoid too broad .d.ts
files
All theses functions shouldn't be used outside the class, making them private simplify the types generated in type definition files (`.d.ts`). This enable us to move some deps to devDeps if they are not used (imported) in generated definition files.
This commit is contained in:
parent
59a3c87a99
commit
5b59ae62f4
@ -78,7 +78,7 @@ export default class CheckboxesType extends Component<CheckboxesTypeProps, Check
|
||||
};
|
||||
}
|
||||
|
||||
handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
private handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const { onChange } = this.props;
|
||||
const currentValue = (e.target as HTMLInputElement).value;
|
||||
const { values } = this.state;
|
||||
@ -94,10 +94,10 @@ export default class CheckboxesType extends Component<CheckboxesTypeProps, Check
|
||||
onChange(values);
|
||||
};
|
||||
|
||||
renderCheckboxList = ({ options }: CheckboxesTypeKnob) =>
|
||||
private renderCheckboxList = ({ options }: CheckboxesTypeKnob) =>
|
||||
Object.keys(options).map((key) => this.renderCheckbox(key, options[key]));
|
||||
|
||||
renderCheckbox = (label: string, value: string) => {
|
||||
private renderCheckbox = (label: string, value: string) => {
|
||||
const { knob } = this.props;
|
||||
const { name } = knob;
|
||||
const id = `${name}-${value}`;
|
||||
|
@ -95,7 +95,7 @@ export default class ColorType extends Component<ColorTypeProps, ColorTypeState>
|
||||
});
|
||||
};
|
||||
|
||||
handleClick = () => {
|
||||
private handleClick = () => {
|
||||
const { displayColorPicker } = this.state;
|
||||
|
||||
this.setState({
|
||||
@ -103,7 +103,7 @@ export default class ColorType extends Component<ColorTypeProps, ColorTypeState>
|
||||
});
|
||||
};
|
||||
|
||||
handleChange = (color: ColorResult) => {
|
||||
private handleChange = (color: ColorResult) => {
|
||||
const { onChange } = this.props;
|
||||
|
||||
onChange(`rgba(${color.rgb.r},${color.rgb.g},${color.rgb.b},${color.rgb.a})`);
|
||||
|
@ -78,7 +78,7 @@ export default class DateType extends Component<DateTypeProps, DateTypeState> {
|
||||
}
|
||||
}
|
||||
|
||||
onDateChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
private onDateChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const { knob, onChange } = this.props;
|
||||
const { state } = this;
|
||||
|
||||
@ -99,7 +99,7 @@ export default class DateType extends Component<DateTypeProps, DateTypeState> {
|
||||
}
|
||||
};
|
||||
|
||||
onTimeChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
private onTimeChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const { knob, onChange } = this.props;
|
||||
const { state } = this;
|
||||
|
||||
|
@ -80,7 +80,7 @@ export default class NumberType extends Component<NumberTypeProps> {
|
||||
return nextProps.knob.value !== knob.value;
|
||||
}
|
||||
|
||||
handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
||||
private handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
||||
const { onChange } = this.props;
|
||||
const { value } = event.target;
|
||||
|
||||
|
@ -59,14 +59,14 @@ class RadiosType extends Component<RadiosTypeProps> {
|
||||
|
||||
static deserialize = (value: RadiosTypeKnobValue) => value;
|
||||
|
||||
renderRadioButtonList({ options }: RadiosTypeKnob) {
|
||||
private renderRadioButtonList({ options }: RadiosTypeKnob) {
|
||||
if (Array.isArray(options)) {
|
||||
return options.map((val) => this.renderRadioButton(val, val));
|
||||
}
|
||||
return Object.keys(options).map((key) => this.renderRadioButton(key, options[key]));
|
||||
}
|
||||
|
||||
renderRadioButton(label: string, value: RadiosTypeKnobValue) {
|
||||
private renderRadioButton(label: string, value: RadiosTypeKnobValue) {
|
||||
const opts = { label, value };
|
||||
const { onChange, knob } = this.props;
|
||||
const { name } = knob;
|
||||
|
@ -32,7 +32,7 @@ export default class TextType extends Component<TextTypeProps> {
|
||||
return nextProps.knob.value !== knob.value;
|
||||
}
|
||||
|
||||
handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
|
||||
private handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
|
||||
const { onChange } = this.props;
|
||||
const { value } = event.target;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user