Skip to content

input: Refactor Input, Picker as stateless mode. #858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 16, 2025
Merged

Conversation

huacnlee
Copy link
Member

@huacnlee huacnlee commented May 15, 2025

This PR to improve TextInput and NumberInput as a stateless mode by split a TextState to keep the editing state.

  • TextInput, ColorPicker - RenderOnce for appearance
  • TextState, ColorState - Entity For keep editing state

So we can easily control the UI style in render stage.

Break Changes

  • TextInput separated to as InputState (for Entity) and TextInput for render.

    - let text_input = cx.new(|cx| TextInput::new(window, cx))
    + let input_state = cx.new(|cx| InputState::new(window, cx))
    - div().child(text_input);
    + div().child(TextInput::new(text_input));
  • TextInput - Renamed text to value, set_text to set_value and also added default_value method to set default value.

  • ColorPicker separated to as ColorPickerState and ColorPicker like input.

  • Calendar separated to as CalendarState and Calendar like input.

    • Added bordered and default true to Calendar.
  • DatePicker separated to as DatePickerState and DatePicker like input.

  • Slider separated to as SliderState and Slider like input.

    • Add disabled state to slider.
  • Dropdown separated to as DropdownState and Dropdown.

@huacnlee huacnlee changed the title input: Refactor Input to a stateless. input: Refactor Input as stateless mode. May 15, 2025
@huacnlee huacnlee changed the title input: Refactor Input as stateless mode. input: Refactor Input, Picker as stateless mode. May 15, 2025
@huacnlee huacnlee merged commit bc398ad into main May 16, 2025
4 checks passed
@huacnlee huacnlee deleted the stateless-input branch May 16, 2025 15:41
huacnlee added a commit that referenced this pull request May 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant