@symbo.ls/range 2.11.212 → 2.11.218
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 +45 -11
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -85,8 +85,8 @@ export const Range = {
|
|
|
85
85
|
attr: { type: 'range' }
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const
|
|
89
|
-
const val = el.props && el.props[
|
|
88
|
+
const returnPropertyValue = (el, property, def) => {
|
|
89
|
+
const val = el.props && el.props[property]
|
|
90
90
|
const r = (isFunction(val) ? val(el, el.state) : val !== undefined ? val : def !== undefined ? def : 50)
|
|
91
91
|
return r + ''
|
|
92
92
|
}
|
|
@@ -97,15 +97,25 @@ export const RangeWithButtons = {
|
|
|
97
97
|
props: { theme: 'tertiary', icon: 'minus' },
|
|
98
98
|
on: {
|
|
99
99
|
click: (ev, el, s) => {
|
|
100
|
-
|
|
100
|
+
const parentProps = el.parent.props
|
|
101
|
+
if (isFunction(parentProps.onDecrease)) {
|
|
102
|
+
parentProps.onDecrease(ev, el.parent, s)
|
|
103
|
+
} else {
|
|
104
|
+
const value = parseFloat(s.value)
|
|
105
|
+
const min = returnPropertyValue(el.parent, 'min', 1)
|
|
106
|
+
const step = returnPropertyValue(el.parent, 'step', 1)
|
|
107
|
+
if (value > min) {
|
|
108
|
+
s.update({ value: value - step })
|
|
109
|
+
}
|
|
110
|
+
}
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
113
|
},
|
|
104
114
|
value: {
|
|
105
|
-
|
|
115
|
+
props: { width: '4ch' },
|
|
106
116
|
tag: 'span',
|
|
107
117
|
text: ({ state, parent }) => {
|
|
108
|
-
const unit =
|
|
118
|
+
const unit = returnPropertyValue(parent, 'unit', '')
|
|
109
119
|
return '' + (state.value || 50) + unit
|
|
110
120
|
}
|
|
111
121
|
},
|
|
@@ -113,13 +123,27 @@ export const RangeWithButtons = {
|
|
|
113
123
|
extend: Range,
|
|
114
124
|
attr: {
|
|
115
125
|
value: (el, s) => parseFloat(el.state.value),
|
|
116
|
-
min: (el, s) =>
|
|
117
|
-
max: (el, s) =>
|
|
118
|
-
step: (el, s) =>
|
|
126
|
+
min: (el, s) => returnPropertyValue(el.parent, 'min', 0),
|
|
127
|
+
max: (el, s) => returnPropertyValue(el.parent, 'max', 100),
|
|
128
|
+
step: (el, s) => returnPropertyValue(el.parent, 'step', 1)
|
|
119
129
|
},
|
|
120
130
|
on: {
|
|
121
|
-
input: (ev, el, s) =>
|
|
122
|
-
|
|
131
|
+
input: (ev, el, s) => {
|
|
132
|
+
const parentProps = el.parent.props
|
|
133
|
+
if (isFunction(parentProps.onInput)) {
|
|
134
|
+
parentProps.onInput(ev, el, s)
|
|
135
|
+
} else {
|
|
136
|
+
s.update({ value: parseFloat(el.node.value) })
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
change: (ev, el, s) => {
|
|
140
|
+
const parentProps = el.parent.props
|
|
141
|
+
if (isFunction(parentProps.onChange)) {
|
|
142
|
+
parentProps.onChange(ev, el, s)
|
|
143
|
+
} else {
|
|
144
|
+
s.update({ value: parseFloat(el.node.value) })
|
|
145
|
+
}
|
|
146
|
+
}
|
|
123
147
|
}
|
|
124
148
|
},
|
|
125
149
|
plus: {
|
|
@@ -127,7 +151,17 @@ export const RangeWithButtons = {
|
|
|
127
151
|
props: { theme: 'tertiary', icon: 'plus' },
|
|
128
152
|
on: {
|
|
129
153
|
click: (ev, el, s) => {
|
|
130
|
-
|
|
154
|
+
const parentProps = el.parent.props
|
|
155
|
+
if (isFunction(parentProps.onIncrease)) {
|
|
156
|
+
parentProps.onIncrease(ev, el.parent, s)
|
|
157
|
+
} else {
|
|
158
|
+
const value = parseFloat(s.value)
|
|
159
|
+
const max = returnPropertyValue(el.parent, 'max', 1)
|
|
160
|
+
const step = returnPropertyValue(el.parent, 'step', 1)
|
|
161
|
+
if (value < max) {
|
|
162
|
+
s.update({ value: value + step })
|
|
163
|
+
}
|
|
164
|
+
}
|
|
131
165
|
}
|
|
132
166
|
}
|
|
133
167
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/range",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.218",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "a8a73474549ed4af1fa251a811fd1a32dea2b393",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@domql/utils": "latest",
|
|
9
9
|
"@symbo.ls/button": "latest",
|