mockaton 13.11.0 → 13.11.1

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "HTTP Mock Server",
4
4
  "type": "module",
5
- "version": "13.11.0",
5
+ "version": "13.11.1",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./index.js",
@@ -140,10 +140,16 @@ function HelpLink() {
140
140
  }
141
141
 
142
142
 
143
- function SlidableNumberField({ className, label, onChange, min, max, step, value }) {
143
+ function SlidableNumberField({ name, className, label, onChange, min, max, step, value }) {
144
+ function clamp(val) {
145
+ return Math.min(Math.max(val, min), max)
146
+ }
147
+
144
148
  function onPointerDown(event) {
145
149
  let lastX = event.clientX
146
- const input = event.target
150
+ const input = /** @type {HTMLInputElement} */ event.target
151
+ const initialVal = input.value
152
+
147
153
  input.setPointerCapture(event.pointerId)
148
154
  window.addEventListener('pointerup', onPointerUp, { once: true })
149
155
  window.addEventListener('pointermove', onPointerMove)
@@ -151,23 +157,21 @@ function SlidableNumberField({ className, label, onChange, min, max, step, value
151
157
  function onPointerUp(ev) {
152
158
  input.releasePointerCapture(ev.pointerId)
153
159
  window.removeEventListener('pointermove', onPointerMove)
160
+ if (input.value !== initialVal)
161
+ input.dispatchEvent(new Event('change'))
154
162
  }
155
163
 
156
164
  function onPointerMove(ev) {
157
165
  const diff = ev.clientX - lastX
158
- if (Math.abs(diff) < 10)
159
- return
160
-
161
- lastX = ev.clientX
162
- const v = input.value
166
+ if (Math.abs(diff) > 10) {
167
+ lastX = ev.clientX
163
168
 
164
- if (diff > 0)
165
- input.stepUp()
166
- else
167
- input.stepDown()
169
+ let s = step
170
+ if (ev.shiftKey) s *= 2
171
+ else if (ev.altKey) s /= 2
168
172
 
169
- if (v !== input.value)
170
- input.dispatchEvent(new Event('change'))
173
+ input.valueAsNumber = clamp(input.valueAsNumber + Math.sign(diff) * s)
174
+ }
171
175
  }
172
176
  }
173
177
 
@@ -34,7 +34,7 @@ export async function rm(path) {
34
34
  export async function resolveIn(baseDir, file) {
35
35
  try {
36
36
  const parent = await realpath(baseDir)
37
- const child = resolve(join(parent, file))
37
+ const child = resolve(join(parent, file)) // realpath not needed because we don't write symlinks
38
38
  return child.startsWith(join(parent, sep))
39
39
  ? child
40
40
  : null