@@ -2,7 +2,6 @@ import { Component, Show, createEffect, createSignal, on } from 'solid-js'
2
2
import type { JSX } from 'solid-js'
3
3
import { PresetAISettings , samplerDisableValues } from '../../common/adapters'
4
4
import { markdown } from './markdown'
5
- import { round } from '/common/util'
6
5
7
6
const RangeInput : Component < {
8
7
label : string | JSX . Element
@@ -26,21 +25,23 @@ const RangeInput: Component<{
26
25
27
26
const [ display , setDisplay ] = createSignal ( props . value . toString ( ) )
28
27
29
- function updateRangeSliders ( next ?: string ) {
28
+ function updateRangeSliders ( evented : boolean , next ?: string ) {
30
29
if ( ! input || ! slider ) return
31
30
32
- if ( next === undefined && props . value === + display ( ) ) {
31
+ if ( ! evented && next === undefined ) {
33
32
return
34
33
}
35
34
36
- const parsed = next !== undefined ? next || '0' : props . value . toString ( )
35
+ const parsed = next !== undefined ? next || '0' : '0'
36
+
37
37
if ( isNaN ( + parsed ) ) {
38
38
input . value = display ( )
39
39
slider . value = display ( )
40
40
return
41
41
}
42
+
42
43
input . value = parsed
43
- slider . value = parsed
44
+ // slider.value = parsed
44
45
setDisplay ( parsed )
45
46
46
47
const percent = Math . min ( + parsed , + input . max )
@@ -64,22 +65,22 @@ const RangeInput: Component<{
64
65
}
65
66
66
67
const onInput : JSX . EventHandler < HTMLInputElement , InputEvent > = ( event ) => {
67
- updateRangeSliders ( event . currentTarget . value as any )
68
- props . onChange ( + event . currentTarget . value )
68
+ updateRangeSliders ( true , event . currentTarget . value as any )
69
+ // props.onChange(+event.currentTarget.value)
69
70
}
70
71
71
72
createEffect (
72
73
on (
73
74
( ) => props . value ,
74
- ( ) => updateRangeSliders ( )
75
+ ( ) => updateRangeSliders ( false , props . value . toString ( ) )
75
76
)
76
77
)
77
78
78
79
const disableSampler = ( ) => {
79
80
if ( ! props . aiSetting ) return
80
81
const value = samplerDisableValues [ props . aiSetting ]
81
82
if ( value === undefined ) return
82
- updateRangeSliders ( value . toString ( ) )
83
+ updateRangeSliders ( true , value . toString ( ) )
83
84
}
84
85
85
86
return (
@@ -145,17 +146,16 @@ const RangeInput: Component<{
145
146
max = { props . max }
146
147
step = { props . step }
147
148
onInput = { onInput }
148
- onKeyDown = { ( ev ) => {
149
- if ( ! props . step ) return
150
- if ( ev . key !== 'ArrowDown' && ev . key !== 'ArrowUp' ) return
149
+ // onKeyDown={(ev) => {
150
+ // if (ev.key !== 'ArrowDown' && ev.key !== 'ArrowUp') return
151
151
152
- const places = ( props . step . toString ( ) . split ( '.' ) [ 1 ] || '' ) . length
153
- const dir = ev . key === 'ArrowDown' ? - props . step : props . step
154
- let value = round ( props . value + dir , places )
155
- if ( props . max !== undefined ) value = Math . min ( value , props . max )
156
- if ( props . min !== undefined ) value = Math . max ( value , props . min )
157
- updateRangeSliders ( value . toString ( ) )
158
- } }
152
+ // const places = (props.step.toString().split('.')[1] || '').length
153
+ // const dir = ev.key === 'ArrowDown' ? -props.step : props.step
154
+ // let value = round(props.value + dir, places)
155
+ // if (props.max !== undefined) value = Math.min(value, props.max)
156
+ // if (props.min !== undefined) value = Math.max(value, props.min)
157
+ // updateRangeSliders(value.toString())
158
+ // }}
159
159
disabled = { props . disabled }
160
160
/>
161
161
</ div >
0 commit comments