@symbo.ls/range 2.11.482 → 2.11.491
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 +13 -84
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isFunction } from '@domql/utils'
|
|
4
3
|
import { opacify } from '@symbo.ls/scratch'
|
|
5
4
|
|
|
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
|
-
}
|
|
11
|
-
|
|
12
5
|
export const Range = {
|
|
13
6
|
props: {
|
|
14
7
|
appearance: 'none',
|
|
@@ -19,7 +12,7 @@ export const Range = {
|
|
|
19
12
|
|
|
20
13
|
onInput: (ev, el, s) => {
|
|
21
14
|
const props = el.props
|
|
22
|
-
if (isFunction
|
|
15
|
+
if (el.call('isFunction', props.onInput)) {
|
|
23
16
|
props.onInput(ev, el, s)
|
|
24
17
|
} else {
|
|
25
18
|
s.update({ value: parseFloat(el.node.value) })
|
|
@@ -27,7 +20,7 @@ export const Range = {
|
|
|
27
20
|
},
|
|
28
21
|
onChange: (ev, el, s) => {
|
|
29
22
|
const props = el.props
|
|
30
|
-
if (isFunction
|
|
23
|
+
if (el.call('isFunction', props.onChange)) {
|
|
31
24
|
props.onChange(ev, el, s)
|
|
32
25
|
} else {
|
|
33
26
|
s.update({ value: parseFloat(el.node.value) })
|
|
@@ -94,85 +87,21 @@ export const Range = {
|
|
|
94
87
|
}
|
|
95
88
|
},
|
|
96
89
|
|
|
90
|
+
deps: {
|
|
91
|
+
returnPropertyValue: (el, property, def) => {
|
|
92
|
+
const val = el.props && el.call('exec', el.props[property], el)
|
|
93
|
+
const r = (el.call('isFunction', val) ? val(el, el.state) : val !== undefined ? val : def !== undefined ? def : 0)
|
|
94
|
+
return r + ''
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
|
|
97
98
|
tag: 'input',
|
|
98
99
|
|
|
99
100
|
attr: {
|
|
100
101
|
type: 'range',
|
|
101
102
|
value: (el, s) => parseFloat(el.state.value || el.props.value || el.props.defaultValue),
|
|
102
|
-
min: (el, s) => returnPropertyValue(el, 'min', 0),
|
|
103
|
-
max: (el, s) => returnPropertyValue(el, 'max', 100),
|
|
104
|
-
step: (el, s) => returnPropertyValue(el, 'step', 1)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export const RangeWithButtons = {
|
|
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 })
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
Value: {
|
|
128
|
-
tag: 'span',
|
|
129
|
-
width: '4ch',
|
|
130
|
-
text: ({ state, parent }) => {
|
|
131
|
-
const unit = returnPropertyValue(parent, 'unit', '')
|
|
132
|
-
return '' + (state.value || state.defaultValue || 0) + unit
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
Range: {
|
|
137
|
-
attr: {
|
|
138
|
-
value: (el, s) => parseFloat(s.value || s.defaultValue),
|
|
139
|
-
min: (el, s) => returnPropertyValue(el.parent, 'min', 0),
|
|
140
|
-
max: (el, s) => returnPropertyValue(el.parent, 'max', 100),
|
|
141
|
-
step: (el, s) => returnPropertyValue(el.parent, 'step', 1)
|
|
142
|
-
},
|
|
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) })
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
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 })
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
103
|
+
min: (el, s) => el.deps.returnPropertyValue(el, 'min', 0),
|
|
104
|
+
max: (el, s) => el.deps.returnPropertyValue(el, 'max', 100),
|
|
105
|
+
step: (el, s) => el.deps.returnPropertyValue(el, 'step', 1)
|
|
177
106
|
}
|
|
178
107
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/range",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.491",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "ddd06b2b342480b2e20c02df04f9856d4ddf7060",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@domql/utils": "^2.5.0",
|
|
9
|
-
"@symbo.ls/button": "^2.11.
|
|
9
|
+
"@symbo.ls/button": "^2.11.491",
|
|
10
10
|
"@symbo.ls/scratch": "^2.11.475"
|
|
11
11
|
},
|
|
12
12
|
"source": "src/index.js"
|