File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,23 @@ export default {
3030
3131 data () {
3232 return {
33- val: this .value || (this .config .max - this .config .min ) / 2
33+ val: this .value || this .config .default || this .getDefault ()
34+ }
35+ },
36+
37+ methods: {
38+ getDefault () {
39+ // Spec: https://html.spec.whatwg.org/multipage/input.html#range-state-(type=range)
40+ if (this .config .max < this .config .min ) return this .config .min ;
41+
42+ var val = this .config .min + (this .config .max - this .config .min ) / 2 ;
43+
44+ // make sure on a valid step
45+ if (this .config .step ) {
46+ val = Math .floor (val / this .config .step ) * this .config .step ;
47+ }
48+
49+ return val;
3450 }
3551 },
3652
Original file line number Diff line number Diff line change 11<?php
22
33return [
4+ 'any.config.default ' => 'Set the default value. ' ,
45 'array.config.keys ' => 'Set the array keys (variables) and optional labels. ' ,
56 'array.config.mode ' => 'Dynamic mode gives the user control of the data while keyed mode does not. ' ,
67 'assets.config.allow_uploads ' => 'Allow new file uploads. ' ,
Original file line number Diff line number Diff line change @@ -25,14 +25,21 @@ protected function configFieldItems(): array
2525 'instructions ' => __ ('statamic::fieldtypes.range.config.min ' ),
2626 'type ' => 'integer ' ,
2727 'default ' => 0 ,
28- 'width ' => 50 ,
28+ 'width ' => 33 ,
2929 ],
3030 'max ' => [
3131 'display ' => __ ('Max ' ),
3232 'instructions ' => __ ('statamic::fieldtypes.range.config.max ' ),
3333 'type ' => 'integer ' ,
3434 'default ' => 100 ,
35- 'width ' => 50 ,
35+ 'width ' => 33 ,
36+ ],
37+ 'default ' => [
38+ 'display ' => __ ('Default ' ),
39+ 'instructions ' => __ ('statamic::fieldtypes.any.config.default ' ),
40+ 'type ' => 'integer ' ,
41+ 'default ' => null ,
42+ 'width ' => 33 ,
3643 ],
3744 'prepend ' => [
3845 'display ' => __ ('Prepend ' ),
You can’t perform that action at this time.
0 commit comments