@zag-js/number-input 2.0.0-next.0 → 2.0.0-next.2

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/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ export { anatomy } from './number-input.anatomy.mjs';
2
2
  export { connect } from './number-input.connect.mjs';
3
3
  export { machine } from './number-input.machine.mjs';
4
4
  export { props, splitProps } from './number-input.props.mjs';
5
- export { NumberInputApi as Api, ElementIds, FocusChangeDetails, HintValue, InputMode, IntlTranslations, NumberInputMachine as Machine, NumberInputProps as Props, NumberInputService as Service, ValidityState, ValueChangeDetails, ValueInvalidDetails } from './number-input.types.mjs';
5
+ export { NumberInputApi as Api, DecrementTriggerState, ElementIds, FocusChangeDetails, HintValue, IncrementTriggerState, InputMode, InputState, IntlTranslations, NumberInputMachine as Machine, NumberInputProps as Props, RootState, NumberInputService as Service, ValidityState, ValueChangeDetails, ValueInvalidDetails } from './number-input.types.mjs';
6
6
  import '@zag-js/anatomy';
7
7
  import '@zag-js/types';
8
8
  import '@zag-js/core';
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { anatomy } from './number-input.anatomy.js';
2
2
  export { connect } from './number-input.connect.js';
3
3
  export { machine } from './number-input.machine.js';
4
4
  export { props, splitProps } from './number-input.props.js';
5
- export { NumberInputApi as Api, ElementIds, FocusChangeDetails, HintValue, InputMode, IntlTranslations, NumberInputMachine as Machine, NumberInputProps as Props, NumberInputService as Service, ValidityState, ValueChangeDetails, ValueInvalidDetails } from './number-input.types.js';
5
+ export { NumberInputApi as Api, DecrementTriggerState, ElementIds, FocusChangeDetails, HintValue, IncrementTriggerState, InputMode, InputState, IntlTranslations, NumberInputMachine as Machine, NumberInputProps as Props, RootState, NumberInputService as Service, ValidityState, ValueChangeDetails, ValueInvalidDetails } from './number-input.types.js';
6
6
  import '@zag-js/anatomy';
7
7
  import '@zag-js/types';
8
8
  import '@zag-js/core';
@@ -38,6 +38,7 @@ var import_utils = require("@zag-js/utils");
38
38
  var import_cursor = require("./cursor.js");
39
39
  var import_number_input = require("./number-input.anatomy.js");
40
40
  var dom = __toESM(require("./number-input.dom.js"));
41
+ var import_number_input2 = require("./number-input.translations.js");
41
42
  function connect(service, normalize) {
42
43
  const { state, send, prop, scope, computed, context } = service;
43
44
  const focused = state.hasTag("focus");
@@ -49,7 +50,19 @@ function connect(service, normalize) {
49
50
  const invalid = prop("invalid") !== void 0 ? !!prop("invalid") : computed("isOutOfRange");
50
51
  const isIncrementDisabled = disabled || !computed("canIncrement") || readOnly;
51
52
  const isDecrementDisabled = disabled || !computed("canDecrement") || readOnly;
52
- const translations = prop("translations");
53
+ const translations = (0, import_utils.mergeWithDefault)(import_number_input2.defaultTranslations, prop("translations"));
54
+ function getRootState() {
55
+ return { disabled, focused, invalid, scrubbing };
56
+ }
57
+ function getInputState() {
58
+ return { disabled, invalid, readOnly, scrubbing };
59
+ }
60
+ function getIncrementTriggerState() {
61
+ return { disabled: isIncrementDisabled };
62
+ }
63
+ function getDecrementTriggerState() {
64
+ return { disabled: isDecrementDisabled };
65
+ }
53
66
  return {
54
67
  focused,
55
68
  scrubbing,
@@ -58,34 +71,36 @@ function connect(service, normalize) {
58
71
  value: computed("formattedValue"),
59
72
  valueAsNumber: computed("valueAsNumber"),
60
73
  setValue(value) {
61
- send({ type: "VALUE.SET", value });
74
+ send({ type: "VALUE.SET", value, src: "script" });
62
75
  },
63
76
  clearValue() {
64
- send({ type: "VALUE.CLEAR" });
77
+ send({ type: "VALUE.CLEAR", src: "script" });
65
78
  },
66
79
  increment() {
67
- send({ type: "VALUE.INCREMENT" });
80
+ send({ type: "VALUE.INCREMENT", src: "script" });
68
81
  },
69
82
  decrement() {
70
- send({ type: "VALUE.DECREMENT" });
83
+ send({ type: "VALUE.DECREMENT", src: "script" });
71
84
  },
72
85
  setToMax() {
73
- send({ type: "VALUE.SET", value: prop("max") });
86
+ send({ type: "VALUE.SET", value: prop("max"), src: "script" });
74
87
  },
75
88
  setToMin() {
76
- send({ type: "VALUE.SET", value: prop("min") });
89
+ send({ type: "VALUE.SET", value: prop("min"), src: "script" });
77
90
  },
78
91
  focus() {
79
92
  dom.getInputEl(scope)?.focus();
80
93
  },
94
+ getRootState,
81
95
  getRootProps() {
96
+ const rootState = getRootState();
82
97
  return normalize.element({
83
98
  ...import_number_input.parts.root.attrs(scope.id),
84
99
  dir: prop("dir"),
85
- "data-disabled": (0, import_dom_query.dataAttr)(disabled),
86
- "data-focus": (0, import_dom_query.dataAttr)(focused),
87
- "data-invalid": (0, import_dom_query.dataAttr)(invalid),
88
- "data-scrubbing": (0, import_dom_query.dataAttr)(scrubbing)
100
+ "data-disabled": (0, import_dom_query.dataAttr)(rootState.disabled),
101
+ "data-focus": (0, import_dom_query.dataAttr)(rootState.focused),
102
+ "data-invalid": (0, import_dom_query.dataAttr)(rootState.invalid),
103
+ "data-scrubbing": (0, import_dom_query.dataAttr)(rootState.scrubbing)
89
104
  });
90
105
  },
91
106
  getLabelProps() {
@@ -129,7 +144,9 @@ function connect(service, normalize) {
129
144
  "data-scrubbing": (0, import_dom_query.dataAttr)(scrubbing)
130
145
  });
131
146
  },
147
+ getInputState,
132
148
  getInputProps() {
149
+ const inputState = getInputState();
133
150
  return normalize.input({
134
151
  ...import_number_input.parts.input.attrs(scope.id),
135
152
  dir: prop("dir"),
@@ -140,11 +157,11 @@ function connect(service, normalize) {
140
157
  defaultValue: computed("formattedValue"),
141
158
  pattern: prop("formatOptions") ? void 0 : prop("pattern"),
142
159
  inputMode: prop("inputMode"),
143
- "aria-invalid": (0, import_dom_query.ariaAttr)(invalid),
144
- "data-invalid": (0, import_dom_query.dataAttr)(invalid),
145
- disabled,
146
- "data-disabled": (0, import_dom_query.dataAttr)(disabled),
147
- readOnly,
160
+ "aria-invalid": (0, import_dom_query.ariaAttr)(inputState.invalid),
161
+ "data-invalid": (0, import_dom_query.dataAttr)(inputState.invalid),
162
+ disabled: inputState.disabled,
163
+ "data-disabled": (0, import_dom_query.dataAttr)(inputState.disabled),
164
+ readOnly: inputState.readOnly,
148
165
  required: prop("required"),
149
166
  autoComplete: "off",
150
167
  autoCorrect: "off",
@@ -155,16 +172,16 @@ function connect(service, normalize) {
155
172
  "aria-valuemax": prop("max"),
156
173
  "aria-valuenow": Number.isNaN(computed("valueAsNumber")) ? void 0 : computed("valueAsNumber"),
157
174
  "aria-valuetext": computed("valueText"),
158
- "data-scrubbing": (0, import_dom_query.dataAttr)(scrubbing),
175
+ "data-scrubbing": (0, import_dom_query.dataAttr)(inputState.scrubbing),
159
176
  onFocus() {
160
177
  send({ type: "INPUT.FOCUS" });
161
178
  },
162
179
  onBlur() {
163
- send({ type: "INPUT.BLUR" });
180
+ send({ type: "INPUT.BLUR", src: "input-blur" });
164
181
  },
165
182
  onInput(event) {
166
183
  const selection = (0, import_cursor.recordCursor)(event.currentTarget, scope);
167
- send({ type: "INPUT.CHANGE", target: event.currentTarget, hint: "set", selection });
184
+ send({ type: "INPUT.CHANGE", target: event.currentTarget, hint: "set", selection, src: "input-change" });
168
185
  },
169
186
  onBeforeInput(event) {
170
187
  try {
@@ -181,33 +198,47 @@ function connect(service, normalize) {
181
198
  if (event.defaultPrevented) return;
182
199
  if (readOnly) return;
183
200
  if ((0, import_dom_query.isComposingEvent)(event)) return;
184
- const step = (0, import_dom_query.getEventStep)(event, {
201
+ const step = (0, import_dom_query.getEventStepValue)(event, {
185
202
  step: prop("step"),
186
203
  largeStep: prop("largeStep"),
187
204
  smallStep: prop("smallStep")
188
205
  });
189
206
  const keyMap = {
190
207
  ArrowUp() {
191
- send({ type: "INPUT.ARROW_UP", step });
208
+ send({ type: "INPUT.ARROW_UP", step, src: "keyboard" });
192
209
  event.preventDefault();
210
+ event.stopPropagation();
193
211
  },
194
212
  ArrowDown() {
195
- send({ type: "INPUT.ARROW_DOWN", step });
213
+ send({ type: "INPUT.ARROW_DOWN", step, src: "keyboard" });
214
+ event.preventDefault();
215
+ event.stopPropagation();
216
+ },
217
+ PageUp() {
218
+ send({ type: "INPUT.ARROW_UP", step, src: "keyboard" });
219
+ event.preventDefault();
220
+ event.stopPropagation();
221
+ },
222
+ PageDown() {
223
+ send({ type: "INPUT.ARROW_DOWN", step, src: "keyboard" });
196
224
  event.preventDefault();
225
+ event.stopPropagation();
197
226
  },
198
227
  Home() {
199
228
  if ((0, import_dom_query.isModifierKey)(event)) return;
200
- send({ type: "INPUT.HOME" });
229
+ send({ type: "INPUT.HOME", src: "keyboard" });
201
230
  event.preventDefault();
231
+ event.stopPropagation();
202
232
  },
203
233
  End() {
204
234
  if ((0, import_dom_query.isModifierKey)(event)) return;
205
- send({ type: "INPUT.END" });
235
+ send({ type: "INPUT.END", src: "keyboard" });
206
236
  event.preventDefault();
237
+ event.stopPropagation();
207
238
  },
208
239
  Enter(event2) {
209
240
  const selection = (0, import_cursor.recordCursor)(event2.currentTarget, scope);
210
- send({ type: "INPUT.ENTER", selection });
241
+ send({ type: "INPUT.ENTER", selection, src: "keyboard" });
211
242
  }
212
243
  };
213
244
  const exec = keyMap[event.key];
@@ -215,21 +246,28 @@ function connect(service, normalize) {
215
246
  }
216
247
  });
217
248
  },
249
+ getDecrementTriggerState,
218
250
  getDecrementTriggerProps() {
251
+ const decrementTriggerState = getDecrementTriggerState();
219
252
  return normalize.button({
220
253
  ...import_number_input.parts.decrementTrigger.attrs(scope.id),
221
254
  dir: prop("dir"),
222
- disabled: isDecrementDisabled,
223
- "data-disabled": (0, import_dom_query.dataAttr)(isDecrementDisabled),
255
+ disabled: decrementTriggerState.disabled,
256
+ "data-disabled": (0, import_dom_query.dataAttr)(decrementTriggerState.disabled),
224
257
  "aria-label": translations.decrementLabel,
225
258
  type: "button",
226
259
  tabIndex: -1,
227
260
  "aria-controls": dom.getInputId(scope),
228
261
  "data-scrubbing": (0, import_dom_query.dataAttr)(scrubbing),
229
262
  onPointerDown(event) {
230
- if (isDecrementDisabled) return;
263
+ if (decrementTriggerState.disabled) return;
231
264
  if (!(0, import_dom_query.isLeftClick)(event)) return;
232
- send({ type: "TRIGGER.PRESS_DOWN", hint: "decrement", pointerType: event.pointerType });
265
+ send({
266
+ type: "TRIGGER.PRESS_DOWN",
267
+ hint: "decrement",
268
+ pointerType: event.pointerType,
269
+ src: "decrement-press"
270
+ });
233
271
  if (event.pointerType === "mouse") {
234
272
  event.preventDefault();
235
273
  }
@@ -238,28 +276,38 @@ function connect(service, normalize) {
238
276
  }
239
277
  },
240
278
  onPointerUp(event) {
241
- send({ type: "TRIGGER.PRESS_UP", hint: "decrement", pointerType: event.pointerType });
279
+ send({ type: "TRIGGER.PRESS_UP", hint: "decrement", pointerType: event.pointerType, src: "decrement-press" });
242
280
  },
243
281
  onPointerLeave() {
244
- if (isDecrementDisabled) return;
245
- send({ type: "TRIGGER.PRESS_UP", hint: "decrement" });
282
+ if (decrementTriggerState.disabled) return;
283
+ send({ type: "TRIGGER.PRESS_UP", hint: "decrement", src: "decrement-press" });
284
+ },
285
+ onPointerCancel(event) {
286
+ send({ type: "TRIGGER.PRESS_UP", hint: "decrement", pointerType: event.pointerType, src: "decrement-press" });
246
287
  }
247
288
  });
248
289
  },
290
+ getIncrementTriggerState,
249
291
  getIncrementTriggerProps() {
292
+ const incrementTriggerState = getIncrementTriggerState();
250
293
  return normalize.button({
251
294
  ...import_number_input.parts.incrementTrigger.attrs(scope.id),
252
295
  dir: prop("dir"),
253
- disabled: isIncrementDisabled,
254
- "data-disabled": (0, import_dom_query.dataAttr)(isIncrementDisabled),
296
+ disabled: incrementTriggerState.disabled,
297
+ "data-disabled": (0, import_dom_query.dataAttr)(incrementTriggerState.disabled),
255
298
  "aria-label": translations.incrementLabel,
256
299
  type: "button",
257
300
  tabIndex: -1,
258
301
  "aria-controls": dom.getInputId(scope),
259
302
  "data-scrubbing": (0, import_dom_query.dataAttr)(scrubbing),
260
303
  onPointerDown(event) {
261
- if (isIncrementDisabled || !(0, import_dom_query.isLeftClick)(event)) return;
262
- send({ type: "TRIGGER.PRESS_DOWN", hint: "increment", pointerType: event.pointerType });
304
+ if (incrementTriggerState.disabled || !(0, import_dom_query.isLeftClick)(event)) return;
305
+ send({
306
+ type: "TRIGGER.PRESS_DOWN",
307
+ hint: "increment",
308
+ pointerType: event.pointerType,
309
+ src: "increment-press"
310
+ });
263
311
  if (event.pointerType === "mouse") {
264
312
  event.preventDefault();
265
313
  }
@@ -268,10 +316,13 @@ function connect(service, normalize) {
268
316
  }
269
317
  },
270
318
  onPointerUp(event) {
271
- send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType });
319
+ send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType, src: "increment-press" });
272
320
  },
273
321
  onPointerLeave(event) {
274
- send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType });
322
+ send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType, src: "increment-press" });
323
+ },
324
+ onPointerCancel(event) {
325
+ send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType, src: "increment-press" });
275
326
  }
276
327
  });
277
328
  },
@@ -3,7 +3,7 @@ import {
3
3
  ariaAttr,
4
4
  dataAttr,
5
5
  getEventPoint,
6
- getEventStep,
6
+ getEventStepValue,
7
7
  getWindow,
8
8
  MAX_Z_INDEX,
9
9
  isComposingEvent,
@@ -12,10 +12,11 @@ import {
12
12
  raf,
13
13
  setCaretToEnd
14
14
  } from "@zag-js/dom-query";
15
- import { roundToDpr, toPx } from "@zag-js/utils";
15
+ import { mergeWithDefault, roundToDpr, toPx } from "@zag-js/utils";
16
16
  import { recordCursor } from "./cursor.mjs";
17
17
  import { parts } from "./number-input.anatomy.mjs";
18
18
  import * as dom from "./number-input.dom.mjs";
19
+ import { defaultTranslations } from "./number-input.translations.mjs";
19
20
  function connect(service, normalize) {
20
21
  const { state, send, prop, scope, computed, context } = service;
21
22
  const focused = state.hasTag("focus");
@@ -27,7 +28,19 @@ function connect(service, normalize) {
27
28
  const invalid = prop("invalid") !== void 0 ? !!prop("invalid") : computed("isOutOfRange");
28
29
  const isIncrementDisabled = disabled || !computed("canIncrement") || readOnly;
29
30
  const isDecrementDisabled = disabled || !computed("canDecrement") || readOnly;
30
- const translations = prop("translations");
31
+ const translations = mergeWithDefault(defaultTranslations, prop("translations"));
32
+ function getRootState() {
33
+ return { disabled, focused, invalid, scrubbing };
34
+ }
35
+ function getInputState() {
36
+ return { disabled, invalid, readOnly, scrubbing };
37
+ }
38
+ function getIncrementTriggerState() {
39
+ return { disabled: isIncrementDisabled };
40
+ }
41
+ function getDecrementTriggerState() {
42
+ return { disabled: isDecrementDisabled };
43
+ }
31
44
  return {
32
45
  focused,
33
46
  scrubbing,
@@ -36,34 +49,36 @@ function connect(service, normalize) {
36
49
  value: computed("formattedValue"),
37
50
  valueAsNumber: computed("valueAsNumber"),
38
51
  setValue(value) {
39
- send({ type: "VALUE.SET", value });
52
+ send({ type: "VALUE.SET", value, src: "script" });
40
53
  },
41
54
  clearValue() {
42
- send({ type: "VALUE.CLEAR" });
55
+ send({ type: "VALUE.CLEAR", src: "script" });
43
56
  },
44
57
  increment() {
45
- send({ type: "VALUE.INCREMENT" });
58
+ send({ type: "VALUE.INCREMENT", src: "script" });
46
59
  },
47
60
  decrement() {
48
- send({ type: "VALUE.DECREMENT" });
61
+ send({ type: "VALUE.DECREMENT", src: "script" });
49
62
  },
50
63
  setToMax() {
51
- send({ type: "VALUE.SET", value: prop("max") });
64
+ send({ type: "VALUE.SET", value: prop("max"), src: "script" });
52
65
  },
53
66
  setToMin() {
54
- send({ type: "VALUE.SET", value: prop("min") });
67
+ send({ type: "VALUE.SET", value: prop("min"), src: "script" });
55
68
  },
56
69
  focus() {
57
70
  dom.getInputEl(scope)?.focus();
58
71
  },
72
+ getRootState,
59
73
  getRootProps() {
74
+ const rootState = getRootState();
60
75
  return normalize.element({
61
76
  ...parts.root.attrs(scope.id),
62
77
  dir: prop("dir"),
63
- "data-disabled": dataAttr(disabled),
64
- "data-focus": dataAttr(focused),
65
- "data-invalid": dataAttr(invalid),
66
- "data-scrubbing": dataAttr(scrubbing)
78
+ "data-disabled": dataAttr(rootState.disabled),
79
+ "data-focus": dataAttr(rootState.focused),
80
+ "data-invalid": dataAttr(rootState.invalid),
81
+ "data-scrubbing": dataAttr(rootState.scrubbing)
67
82
  });
68
83
  },
69
84
  getLabelProps() {
@@ -107,7 +122,9 @@ function connect(service, normalize) {
107
122
  "data-scrubbing": dataAttr(scrubbing)
108
123
  });
109
124
  },
125
+ getInputState,
110
126
  getInputProps() {
127
+ const inputState = getInputState();
111
128
  return normalize.input({
112
129
  ...parts.input.attrs(scope.id),
113
130
  dir: prop("dir"),
@@ -118,11 +135,11 @@ function connect(service, normalize) {
118
135
  defaultValue: computed("formattedValue"),
119
136
  pattern: prop("formatOptions") ? void 0 : prop("pattern"),
120
137
  inputMode: prop("inputMode"),
121
- "aria-invalid": ariaAttr(invalid),
122
- "data-invalid": dataAttr(invalid),
123
- disabled,
124
- "data-disabled": dataAttr(disabled),
125
- readOnly,
138
+ "aria-invalid": ariaAttr(inputState.invalid),
139
+ "data-invalid": dataAttr(inputState.invalid),
140
+ disabled: inputState.disabled,
141
+ "data-disabled": dataAttr(inputState.disabled),
142
+ readOnly: inputState.readOnly,
126
143
  required: prop("required"),
127
144
  autoComplete: "off",
128
145
  autoCorrect: "off",
@@ -133,16 +150,16 @@ function connect(service, normalize) {
133
150
  "aria-valuemax": prop("max"),
134
151
  "aria-valuenow": Number.isNaN(computed("valueAsNumber")) ? void 0 : computed("valueAsNumber"),
135
152
  "aria-valuetext": computed("valueText"),
136
- "data-scrubbing": dataAttr(scrubbing),
153
+ "data-scrubbing": dataAttr(inputState.scrubbing),
137
154
  onFocus() {
138
155
  send({ type: "INPUT.FOCUS" });
139
156
  },
140
157
  onBlur() {
141
- send({ type: "INPUT.BLUR" });
158
+ send({ type: "INPUT.BLUR", src: "input-blur" });
142
159
  },
143
160
  onInput(event) {
144
161
  const selection = recordCursor(event.currentTarget, scope);
145
- send({ type: "INPUT.CHANGE", target: event.currentTarget, hint: "set", selection });
162
+ send({ type: "INPUT.CHANGE", target: event.currentTarget, hint: "set", selection, src: "input-change" });
146
163
  },
147
164
  onBeforeInput(event) {
148
165
  try {
@@ -159,33 +176,47 @@ function connect(service, normalize) {
159
176
  if (event.defaultPrevented) return;
160
177
  if (readOnly) return;
161
178
  if (isComposingEvent(event)) return;
162
- const step = getEventStep(event, {
179
+ const step = getEventStepValue(event, {
163
180
  step: prop("step"),
164
181
  largeStep: prop("largeStep"),
165
182
  smallStep: prop("smallStep")
166
183
  });
167
184
  const keyMap = {
168
185
  ArrowUp() {
169
- send({ type: "INPUT.ARROW_UP", step });
186
+ send({ type: "INPUT.ARROW_UP", step, src: "keyboard" });
170
187
  event.preventDefault();
188
+ event.stopPropagation();
171
189
  },
172
190
  ArrowDown() {
173
- send({ type: "INPUT.ARROW_DOWN", step });
191
+ send({ type: "INPUT.ARROW_DOWN", step, src: "keyboard" });
174
192
  event.preventDefault();
193
+ event.stopPropagation();
194
+ },
195
+ PageUp() {
196
+ send({ type: "INPUT.ARROW_UP", step, src: "keyboard" });
197
+ event.preventDefault();
198
+ event.stopPropagation();
199
+ },
200
+ PageDown() {
201
+ send({ type: "INPUT.ARROW_DOWN", step, src: "keyboard" });
202
+ event.preventDefault();
203
+ event.stopPropagation();
175
204
  },
176
205
  Home() {
177
206
  if (isModifierKey(event)) return;
178
- send({ type: "INPUT.HOME" });
207
+ send({ type: "INPUT.HOME", src: "keyboard" });
179
208
  event.preventDefault();
209
+ event.stopPropagation();
180
210
  },
181
211
  End() {
182
212
  if (isModifierKey(event)) return;
183
- send({ type: "INPUT.END" });
213
+ send({ type: "INPUT.END", src: "keyboard" });
184
214
  event.preventDefault();
215
+ event.stopPropagation();
185
216
  },
186
217
  Enter(event2) {
187
218
  const selection = recordCursor(event2.currentTarget, scope);
188
- send({ type: "INPUT.ENTER", selection });
219
+ send({ type: "INPUT.ENTER", selection, src: "keyboard" });
189
220
  }
190
221
  };
191
222
  const exec = keyMap[event.key];
@@ -193,21 +224,28 @@ function connect(service, normalize) {
193
224
  }
194
225
  });
195
226
  },
227
+ getDecrementTriggerState,
196
228
  getDecrementTriggerProps() {
229
+ const decrementTriggerState = getDecrementTriggerState();
197
230
  return normalize.button({
198
231
  ...parts.decrementTrigger.attrs(scope.id),
199
232
  dir: prop("dir"),
200
- disabled: isDecrementDisabled,
201
- "data-disabled": dataAttr(isDecrementDisabled),
233
+ disabled: decrementTriggerState.disabled,
234
+ "data-disabled": dataAttr(decrementTriggerState.disabled),
202
235
  "aria-label": translations.decrementLabel,
203
236
  type: "button",
204
237
  tabIndex: -1,
205
238
  "aria-controls": dom.getInputId(scope),
206
239
  "data-scrubbing": dataAttr(scrubbing),
207
240
  onPointerDown(event) {
208
- if (isDecrementDisabled) return;
241
+ if (decrementTriggerState.disabled) return;
209
242
  if (!isLeftClick(event)) return;
210
- send({ type: "TRIGGER.PRESS_DOWN", hint: "decrement", pointerType: event.pointerType });
243
+ send({
244
+ type: "TRIGGER.PRESS_DOWN",
245
+ hint: "decrement",
246
+ pointerType: event.pointerType,
247
+ src: "decrement-press"
248
+ });
211
249
  if (event.pointerType === "mouse") {
212
250
  event.preventDefault();
213
251
  }
@@ -216,28 +254,38 @@ function connect(service, normalize) {
216
254
  }
217
255
  },
218
256
  onPointerUp(event) {
219
- send({ type: "TRIGGER.PRESS_UP", hint: "decrement", pointerType: event.pointerType });
257
+ send({ type: "TRIGGER.PRESS_UP", hint: "decrement", pointerType: event.pointerType, src: "decrement-press" });
220
258
  },
221
259
  onPointerLeave() {
222
- if (isDecrementDisabled) return;
223
- send({ type: "TRIGGER.PRESS_UP", hint: "decrement" });
260
+ if (decrementTriggerState.disabled) return;
261
+ send({ type: "TRIGGER.PRESS_UP", hint: "decrement", src: "decrement-press" });
262
+ },
263
+ onPointerCancel(event) {
264
+ send({ type: "TRIGGER.PRESS_UP", hint: "decrement", pointerType: event.pointerType, src: "decrement-press" });
224
265
  }
225
266
  });
226
267
  },
268
+ getIncrementTriggerState,
227
269
  getIncrementTriggerProps() {
270
+ const incrementTriggerState = getIncrementTriggerState();
228
271
  return normalize.button({
229
272
  ...parts.incrementTrigger.attrs(scope.id),
230
273
  dir: prop("dir"),
231
- disabled: isIncrementDisabled,
232
- "data-disabled": dataAttr(isIncrementDisabled),
274
+ disabled: incrementTriggerState.disabled,
275
+ "data-disabled": dataAttr(incrementTriggerState.disabled),
233
276
  "aria-label": translations.incrementLabel,
234
277
  type: "button",
235
278
  tabIndex: -1,
236
279
  "aria-controls": dom.getInputId(scope),
237
280
  "data-scrubbing": dataAttr(scrubbing),
238
281
  onPointerDown(event) {
239
- if (isIncrementDisabled || !isLeftClick(event)) return;
240
- send({ type: "TRIGGER.PRESS_DOWN", hint: "increment", pointerType: event.pointerType });
282
+ if (incrementTriggerState.disabled || !isLeftClick(event)) return;
283
+ send({
284
+ type: "TRIGGER.PRESS_DOWN",
285
+ hint: "increment",
286
+ pointerType: event.pointerType,
287
+ src: "increment-press"
288
+ });
241
289
  if (event.pointerType === "mouse") {
242
290
  event.preventDefault();
243
291
  }
@@ -246,10 +294,13 @@ function connect(service, normalize) {
246
294
  }
247
295
  },
248
296
  onPointerUp(event) {
249
- send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType });
297
+ send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType, src: "increment-press" });
250
298
  },
251
299
  onPointerLeave(event) {
252
- send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType });
300
+ send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType, src: "increment-press" });
301
+ },
302
+ onPointerCancel(event) {
303
+ send({ type: "TRIGGER.PRESS_UP", hint: "increment", pointerType: event.pointerType, src: "increment-press" });
253
304
  }
254
305
  });
255
306
  },