-
Notifications
You must be signed in to change notification settings - Fork 114
WIP/Extended options - Add slider form control #2220
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
base: develop
Are you sure you want to change the base?
Changes from 1 commit
26b5b66
523826d
f20ffd5
1bd2d1f
2c80ee3
9305eed
73ded47
a0d5fb0
1ce3092
02d3e00
1320399
9c54381
2546f87
641c54b
62a001b
91eed9e
27c5895
07790e8
313f118
3718627
946f736
c51fe87
fe4ce8d
03dfb2a
0c0a7db
7f5ae5a
817ddf2
7f40ad0
99b314e
e853926
5b68c47
48aa458
faa508f
a3d8366
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,215 @@ | ||||||||||||||
| <?php | ||||||||||||||
|
|
||||||||||||||
| declare(strict_types=1); | ||||||||||||||
|
|
||||||||||||||
| namespace Atk4\Ui\Form\Control; | ||||||||||||||
|
|
||||||||||||||
| use Atk4\Ui\View; | ||||||||||||||
| use Atk4\Ui\Js\JsExpression; | ||||||||||||||
| use Atk4\Ui\Js\JsFunction; | ||||||||||||||
| use Atk4\Ui\Js\JsReload; | ||||||||||||||
|
|
||||||||||||||
| class Slider extends Input | ||||||||||||||
| { | ||||||||||||||
| public string $inputType = 'hidden'; | ||||||||||||||
|
|
||||||||||||||
| /** The lowest value the slider can be. */ | ||||||||||||||
| public int $min = 0; | ||||||||||||||
|
||||||||||||||
|
|
||||||||||||||
| /** The max value the slider can be. */ | ||||||||||||||
| public int $max = 10; | ||||||||||||||
|
|
||||||||||||||
| /** @var float|null The slider step. Set to 0 to disable step. */ | ||||||||||||||
| public $step = 0; | ||||||||||||||
|
||||||||||||||
|
|
||||||||||||||
| /** The value the slider will start at. */ | ||||||||||||||
| public int $start = 0; | ||||||||||||||
|
|
||||||||||||||
| /** @var int|null The second value to set in case of a range slider. */ | ||||||||||||||
| public $end = null; | ||||||||||||||
|
|
||||||||||||||
| /** @var int|false Makes sure that the two thumbs of a range slider always need to have a difference of the given value. */ | ||||||||||||||
| public $minRange = false; | ||||||||||||||
|
|
||||||||||||||
| /** @var int|false Makes sure that the two thumbs of a range slider don't exceed a difference of the given value. */ | ||||||||||||||
| public $maxRange = false; | ||||||||||||||
|
|
||||||||||||||
| /** @var 'number'|'letter' The type of label to display for a labeled slider. Can be number or letter. */ | ||||||||||||||
| public $labelType = 'number'; | ||||||||||||||
|
|
||||||||||||||
| /** @var array|null An array of label values which restrict the displayed labels to only those which are defined. */ | ||||||||||||||
| public $restrictedLabels = null; | ||||||||||||||
|
|
||||||||||||||
| /** Whether a tooltip should be shown to the thumb(s) on hover. Will contain the current slider value. */ | ||||||||||||||
| public bool $showThumbTooltip = false; | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Tooltip configuration used when showThumbTooltip is true | ||||||||||||||
| * Refer to Tooltip Variations for possible values. | ||||||||||||||
| * | ||||||||||||||
| * @var array|null | ||||||||||||||
| */ | ||||||||||||||
| public $tooltipConfig = null; | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Show ticks on a labeled slider. | ||||||||||||||
| *'always'will always show the ticks for all labels (even if not shown) | ||||||||||||||
| * true will display the ticks only if the related label is also shown. | ||||||||||||||
| * | ||||||||||||||
| * @var 'always'|bool | ||||||||||||||
| */ | ||||||||||||||
| public $showLabelTicks = false; | ||||||||||||||
|
|
||||||||||||||
| /** Define smoothness when the slider is moving. */ | ||||||||||||||
| public bool $smooth = false; | ||||||||||||||
|
||||||||||||||
|
|
||||||||||||||
| /** Whether labels should auto adjust on window resize. */ | ||||||||||||||
| public bool $autoAdjustLabels = true; | ||||||||||||||
|
|
||||||||||||||
| /** The distance between labels. */ | ||||||||||||||
| public int $labelDistance = 100; | ||||||||||||||
|
||||||||||||||
|
|
||||||||||||||
| /** Number of decimals to use with an unstepped slider. */ | ||||||||||||||
| public int $decimalPlaces = 2; | ||||||||||||||
|
||||||||||||||
|
|
||||||||||||||
| /** Page up/down multiplier. Define how many more times the steps to take on page up/down press. */ | ||||||||||||||
| public int $pageMultiplier = 2; | ||||||||||||||
|
|
||||||||||||||
| /** Prevents the lower thumb to crossover the thumb handle. */ | ||||||||||||||
| public bool $preventCrossover = true; | ||||||||||||||
|
|
||||||||||||||
| /** Settings for the slider-class */ | ||||||||||||||
| /** Whether the slider should be ticked or not. */ | ||||||||||||||
| public bool $ticked = false; | ||||||||||||||
|
|
||||||||||||||
| /** Whether the slider should be labeled or not. */ | ||||||||||||||
| public bool $labeled = false; | ||||||||||||||
|
||||||||||||||
|
|
||||||||||||||
| /** Whether the ticks and labels should be at the bottom. */ | ||||||||||||||
| public bool $bottom = false; | ||||||||||||||
|
|
||||||||||||||
| /** @var object */ | ||||||||||||||
|
||||||||||||||
| /** @var object */ | |
| /** @var View */ |
at least if general View type is needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must be View not object|View, not only because we do not want to support general object, but also PHPStan will simplify object|View into object only
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
owner is stored in the parent API already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find this, do you have an example? I just need to know how to find the parent object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mvorisek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mvorisek marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #[\Override] | |
| protected function recursiveRender(): void | |
| { | |
| parent::recursiveRender(); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove it later, now I'm using it to check variables and classes after render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enabled/disabled/readonly demo should be added into
demos/form-control/input2.phpand there should be probably a separate demo for Slicer + Behat tests are needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll get to this in time...