@symbo.ls/range 2.11.475 → 2.11.477
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +120 -134
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -3,88 +3,97 @@
|
|
|
3
3
|
import { isFunction } from '@domql/utils'
|
|
4
4
|
import { opacify } from '@symbo.ls/scratch'
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
flex: 1,
|
|
12
|
-
|
|
13
|
-
onInput: (ev, el, s) => s.update({ value: el.node.value }),
|
|
14
|
-
onChange: (ev, el, s) => s.update({ value: el.node.value }),
|
|
15
|
-
|
|
16
|
-
style: {
|
|
17
|
-
appearance: 'none'
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
'::-webkit-slider-thumb': {
|
|
21
|
-
boxSizing: 'content-box',
|
|
22
|
-
width: '8px',
|
|
23
|
-
height: '8px',
|
|
24
|
-
borderWidth: '2px',
|
|
25
|
-
borderStyle: 'solid',
|
|
26
|
-
borderRadius: '100%',
|
|
27
|
-
opacity: '.8',
|
|
28
|
-
|
|
29
|
-
style: {
|
|
30
|
-
appearance: 'none'
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
'::-webkit-slider-runnable-track': {
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
'@dark': {
|
|
38
|
-
background: 'white 0.2',
|
|
6
|
+
const returnPropertyValue = (el, property, def) => {
|
|
7
|
+
const val = el.props && el.props[property]
|
|
8
|
+
const r = (isFunction(val) ? val(el, el.state) : val !== undefined ? val : def !== undefined ? def : 0)
|
|
9
|
+
return r + ''
|
|
10
|
+
}
|
|
39
11
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
12
|
+
export const Range = {
|
|
13
|
+
props: {
|
|
14
|
+
appearance: 'none',
|
|
15
|
+
width: '100%',
|
|
16
|
+
height: '2px',
|
|
17
|
+
outline: 'none',
|
|
18
|
+
flex: 1,
|
|
19
|
+
|
|
20
|
+
onInput: (ev, el, s) => {
|
|
21
|
+
const props = el.props
|
|
22
|
+
if (isFunction(props.onInput)) {
|
|
23
|
+
props.onInput(ev, el, s)
|
|
24
|
+
} else {
|
|
25
|
+
s.update({ value: parseFloat(el.node.value) })
|
|
26
|
+
}
|
|
43
27
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
28
|
+
onChange: (ev, el, s) => {
|
|
29
|
+
const props = el.props
|
|
30
|
+
if (isFunction(props.onChange)) {
|
|
31
|
+
props.onChange(ev, el, s)
|
|
32
|
+
} else {
|
|
33
|
+
s.update({ value: parseFloat(el.node.value) })
|
|
48
34
|
}
|
|
49
35
|
},
|
|
50
36
|
|
|
51
|
-
'
|
|
52
|
-
'
|
|
53
|
-
|
|
37
|
+
'::-webkit-slider-thumb': {
|
|
38
|
+
boxSizing: 'content-box',
|
|
39
|
+
width: '8px',
|
|
40
|
+
height: '8px',
|
|
41
|
+
borderWidth: '2px',
|
|
42
|
+
borderStyle: 'solid',
|
|
43
|
+
borderRadius: '100%',
|
|
44
|
+
opacity: '.8',
|
|
45
|
+
|
|
46
|
+
style: {
|
|
47
|
+
appearance: 'none'
|
|
54
48
|
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
'@light': {
|
|
59
|
-
background: 'gray9',
|
|
49
|
+
},
|
|
60
50
|
|
|
61
|
-
'::-webkit-slider-
|
|
62
|
-
background: 'white',
|
|
63
|
-
borderColor: 'gray9'
|
|
51
|
+
'::-webkit-slider-runnable-track': {
|
|
64
52
|
},
|
|
65
53
|
|
|
66
|
-
'
|
|
54
|
+
'@dark': {
|
|
55
|
+
background: 'white 0.2',
|
|
56
|
+
|
|
67
57
|
'::-webkit-slider-thumb': {
|
|
68
|
-
|
|
58
|
+
background: '#232526',
|
|
59
|
+
borderColor: opacify('#454646', 0.75)
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
':hover': {
|
|
63
|
+
'::-webkit-slider-thumb': {
|
|
64
|
+
borderColor: opacify('#fff', 0.35)
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
':focus': {
|
|
69
|
+
'::-webkit-slider-thumb': {
|
|
70
|
+
borderColor: '#3C6AC0'
|
|
71
|
+
}
|
|
69
72
|
}
|
|
70
73
|
},
|
|
71
74
|
|
|
72
|
-
'
|
|
75
|
+
'@light': {
|
|
76
|
+
background: 'gray9',
|
|
77
|
+
|
|
73
78
|
'::-webkit-slider-thumb': {
|
|
74
|
-
|
|
79
|
+
background: 'white',
|
|
80
|
+
borderColor: 'gray9'
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
':hover': {
|
|
84
|
+
'::-webkit-slider-thumb': {
|
|
85
|
+
borderColor: 'gray7'
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
':focus': {
|
|
90
|
+
'::-webkit-slider-thumb': {
|
|
91
|
+
borderColor: 'blue'
|
|
92
|
+
}
|
|
75
93
|
}
|
|
76
94
|
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const returnPropertyValue = (el, property, def) => {
|
|
81
|
-
const val = el.props && el.props[property]
|
|
82
|
-
const r = (isFunction(val) ? val(el, el.state) : val !== undefined ? val : def !== undefined ? def : 0)
|
|
83
|
-
return r + ''
|
|
84
|
-
}
|
|
95
|
+
},
|
|
85
96
|
|
|
86
|
-
export const Range = {
|
|
87
|
-
props,
|
|
88
97
|
tag: 'input',
|
|
89
98
|
|
|
90
99
|
attr: {
|
|
@@ -93,98 +102,75 @@ export const Range = {
|
|
|
93
102
|
min: (el, s) => returnPropertyValue(el, 'min', 0),
|
|
94
103
|
max: (el, s) => returnPropertyValue(el, 'max', 100),
|
|
95
104
|
step: (el, s) => returnPropertyValue(el, 'step', 1)
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
on: {
|
|
99
|
-
input: (ev, el, s) => {
|
|
100
|
-
const props = el.props
|
|
101
|
-
if (isFunction(props.onInput)) {
|
|
102
|
-
props.onInput(ev, el, s)
|
|
103
|
-
} else {
|
|
104
|
-
s.update({ value: parseFloat(el.node.value) })
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
change: (ev, el, s) => {
|
|
108
|
-
const props = el.props
|
|
109
|
-
if (isFunction(props.onChange)) {
|
|
110
|
-
props.onChange(ev, el, s)
|
|
111
|
-
} else {
|
|
112
|
-
s.update({ value: parseFloat(el.node.value) })
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
105
|
}
|
|
116
106
|
}
|
|
117
107
|
|
|
118
108
|
export const RangeWithButtons = {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
s.update({ value: value - step })
|
|
133
|
-
}
|
|
109
|
+
SquareButton_minus: {
|
|
110
|
+
icon: 'minus',
|
|
111
|
+
theme: 'field',
|
|
112
|
+
onClick: (ev, el, s) => {
|
|
113
|
+
const parentProps = el.parent.props
|
|
114
|
+
if (isFunction(parentProps.onDecrease)) {
|
|
115
|
+
parentProps.onDecrease(ev, el.parent, s)
|
|
116
|
+
} else {
|
|
117
|
+
const value = parseFloat(s.value)
|
|
118
|
+
const min = returnPropertyValue(el.parent, 'min', 1)
|
|
119
|
+
const step = returnPropertyValue(el.parent, 'step', 1)
|
|
120
|
+
if (value > min) {
|
|
121
|
+
s.update({ value: value - step })
|
|
134
122
|
}
|
|
135
123
|
}
|
|
136
124
|
}
|
|
137
125
|
},
|
|
138
|
-
|
|
139
|
-
|
|
126
|
+
|
|
127
|
+
Value: {
|
|
140
128
|
tag: 'span',
|
|
129
|
+
width: '4ch',
|
|
141
130
|
text: ({ state, parent }) => {
|
|
142
131
|
const unit = returnPropertyValue(parent, 'unit', '')
|
|
143
132
|
return '' + (state.value || state.defaultValue || 0) + unit
|
|
144
133
|
}
|
|
145
134
|
},
|
|
146
|
-
|
|
147
|
-
|
|
135
|
+
|
|
136
|
+
Range: {
|
|
148
137
|
attr: {
|
|
149
138
|
value: (el, s) => parseFloat(s.value || s.defaultValue),
|
|
150
139
|
min: (el, s) => returnPropertyValue(el.parent, 'min', 0),
|
|
151
140
|
max: (el, s) => returnPropertyValue(el.parent, 'max', 100),
|
|
152
141
|
step: (el, s) => returnPropertyValue(el.parent, 'step', 1)
|
|
153
142
|
},
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
s.update({ value: parseFloat(el.node.value) })
|
|
169
|
-
}
|
|
143
|
+
onInput: (ev, el, s) => {
|
|
144
|
+
const parentProps = el.parent.props
|
|
145
|
+
if (isFunction(parentProps.onInput)) {
|
|
146
|
+
parentProps.onInput(ev, el, s)
|
|
147
|
+
} else {
|
|
148
|
+
s.update({ value: parseFloat(el.node.value) })
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
onChange: (ev, el, s) => {
|
|
152
|
+
const parentProps = el.parent.props
|
|
153
|
+
if (isFunction(parentProps.onChange)) {
|
|
154
|
+
parentProps.onChange(ev, el, s)
|
|
155
|
+
} else {
|
|
156
|
+
s.update({ value: parseFloat(el.node.value) })
|
|
170
157
|
}
|
|
171
158
|
}
|
|
172
159
|
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
160
|
+
|
|
161
|
+
SquareButton_plus: {
|
|
162
|
+
theme: 'field',
|
|
163
|
+
icon: 'plus',
|
|
164
|
+
onClick: (ev, el, s) => {
|
|
165
|
+
const parentProps = el.parent.props
|
|
166
|
+
if (isFunction(parentProps.onIncrease)) {
|
|
167
|
+
parentProps.onIncrease(ev, el.parent, s)
|
|
168
|
+
} else {
|
|
169
|
+
const value = parseFloat(s.value)
|
|
170
|
+
const max = returnPropertyValue(el.parent, 'max', 1)
|
|
171
|
+
const step = returnPropertyValue(el.parent, 'step', 1)
|
|
172
|
+
if (value < max) {
|
|
173
|
+
s.update({ value: value + step })
|
|
188
174
|
}
|
|
189
175
|
}
|
|
190
176
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/range",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.477",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "47546f8e3e61900fb07e92c3faf7abf2bce919ae",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@domql/utils": "^2.5.0",
|
|
9
|
-
"@symbo.ls/button": "^2.11.
|
|
9
|
+
"@symbo.ls/button": "^2.11.477",
|
|
10
10
|
"@symbo.ls/scratch": "^2.11.475"
|
|
11
11
|
},
|
|
12
12
|
"source": "src/index.js"
|