@symbo.ls/range 2.11.231 → 2.11.271
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 +36 -11
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -78,23 +78,48 @@ const props = {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
const returnPropertyValue = (el, property, def) => {
|
|
82
|
+
const val = el.props && el.props[property]
|
|
83
|
+
const r = (isFunction(val) ? val(el, el.state) : val !== undefined ? val : def !== undefined ? def : 0)
|
|
84
|
+
return r + ''
|
|
85
|
+
}
|
|
86
|
+
|
|
81
87
|
export const Range = {
|
|
82
88
|
props,
|
|
83
|
-
|
|
84
89
|
tag: 'input',
|
|
85
|
-
attr: { type: 'range' }
|
|
86
|
-
}
|
|
87
90
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
attr: {
|
|
92
|
+
type: 'range',
|
|
93
|
+
value: (el, s) => parseFloat(el.state.value || el.props.value || el.props.defaultValue),
|
|
94
|
+
min: (el, s) => returnPropertyValue(el, 'min', 0),
|
|
95
|
+
max: (el, s) => returnPropertyValue(el, 'max', 100),
|
|
96
|
+
step: (el, s) => returnPropertyValue(el, 'step', 1)
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
on: {
|
|
100
|
+
input: (ev, el, s) => {
|
|
101
|
+
const props = el.props
|
|
102
|
+
if (isFunction(props.onInput)) {
|
|
103
|
+
props.onInput(ev, el, s)
|
|
104
|
+
} else {
|
|
105
|
+
s.update({ value: parseFloat(el.node.value) })
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
change: (ev, el, s) => {
|
|
109
|
+
const props = el.props
|
|
110
|
+
if (isFunction(props.onChange)) {
|
|
111
|
+
props.onChange(ev, el, s)
|
|
112
|
+
} else {
|
|
113
|
+
s.update({ value: parseFloat(el.node.value) })
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
92
117
|
}
|
|
93
118
|
|
|
94
119
|
export const RangeWithButtons = {
|
|
95
120
|
minus: {
|
|
96
121
|
extend: SquareButton,
|
|
97
|
-
props: { theme: '
|
|
122
|
+
props: { theme: 'field', icon: 'minus' },
|
|
98
123
|
on: {
|
|
99
124
|
click: (ev, el, s) => {
|
|
100
125
|
const parentProps = el.parent.props
|
|
@@ -116,13 +141,13 @@ export const RangeWithButtons = {
|
|
|
116
141
|
tag: 'span',
|
|
117
142
|
text: ({ state, parent }) => {
|
|
118
143
|
const unit = returnPropertyValue(parent, 'unit', '')
|
|
119
|
-
return '' + (state.value ||
|
|
144
|
+
return '' + (state.value || state.defaultValue || 0) + unit
|
|
120
145
|
}
|
|
121
146
|
},
|
|
122
147
|
input: {
|
|
123
148
|
extend: Range,
|
|
124
149
|
attr: {
|
|
125
|
-
value: (el, s) => parseFloat(
|
|
150
|
+
value: (el, s) => parseFloat(s.value || s.defaultValue),
|
|
126
151
|
min: (el, s) => returnPropertyValue(el.parent, 'min', 0),
|
|
127
152
|
max: (el, s) => returnPropertyValue(el.parent, 'max', 100),
|
|
128
153
|
step: (el, s) => returnPropertyValue(el.parent, 'step', 1)
|
|
@@ -148,7 +173,7 @@ export const RangeWithButtons = {
|
|
|
148
173
|
},
|
|
149
174
|
plus: {
|
|
150
175
|
extend: SquareButton,
|
|
151
|
-
props: { theme: '
|
|
176
|
+
props: { theme: 'field', icon: 'plus' },
|
|
152
177
|
on: {
|
|
153
178
|
click: (ev, el, s) => {
|
|
154
179
|
const parentProps = el.parent.props
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/range",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.271",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "a57eda1f271195de0c1da82ebe89541a2874e1ad",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@domql/utils": "latest",
|
|
9
9
|
"@symbo.ls/button": "latest",
|