forked from appsmithorg/appsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add slider control (appsmithorg#39058)
## Description Add slider control for UQI forms. ![Снимок экрана 2025-02-06 в 10 04 22](https://github.com/user-attachments/assets/4aea28c8-5cc0-4b82-96b8-ca3645789c4b) ## Automation /ok-to-test tags="@tag.Datasource" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/13173679109> > Commit: 2aa1362 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13173679109&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Datasource` > Spec: > <hr>Thu, 06 Feb 2025 07:59:48 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced an interactive slider control for forms, allowing users to adjust numerical values with ease. - Enhanced form input options by integrating the slider into the existing control suite for a smoother, more intuitive user experience. - Added a new form control type, "SLIDER", to expand the available input options. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from "react"; | ||
import { Field, type WrappedFieldInputProps } from "redux-form"; | ||
import BaseControl from "./BaseControl"; | ||
import type { ControlProps } from "./BaseControl"; | ||
import { Slider, type SliderProps } from "@appsmith/ads"; | ||
|
||
export interface SliderControlProps | ||
extends ControlProps, | ||
Omit<SliderProps, "id" | "label"> {} | ||
|
||
export class SliderControl extends BaseControl<SliderControlProps> { | ||
render() { | ||
const { configProperty, ...rest } = this.props; | ||
|
||
return ( | ||
<Field | ||
component={renderSliderControl} | ||
name={configProperty} | ||
props={{ ...rest }} | ||
/> | ||
); | ||
} | ||
|
||
getControlType(): string { | ||
return "SLIDER"; | ||
} | ||
} | ||
|
||
const renderSliderControl = ( | ||
props: { | ||
input?: WrappedFieldInputProps; | ||
} & SliderControlProps, | ||
) => { | ||
const { input, maxValue, minValue, step, title } = props; | ||
|
||
return ( | ||
<Slider | ||
defaultValue={input?.value} | ||
// use title as label because UQI label form placed above the component witch breaks the layout | ||
label={title} | ||
maxValue={maxValue} | ||
minValue={minValue} | ||
onChangeEnd={input?.onChange} | ||
step={step} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters