@zag-js/number-input 0.10.2 → 0.10.4
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.ts +4 -7
- package/dist/index.js +8 -794
- package/dist/index.mjs +3 -16
- package/dist/number-input.anatomy.d.ts +3 -6
- package/dist/number-input.anatomy.js +10 -33
- package/dist/number-input.anatomy.mjs +14 -8
- package/dist/number-input.connect.d.ts +3 -7
- package/dist/number-input.connect.js +49 -221
- package/dist/number-input.connect.mjs +234 -9
- package/dist/number-input.dom.d.ts +19 -24
- package/dist/number-input.dom.js +15 -37
- package/dist/number-input.dom.mjs +99 -6
- package/dist/number-input.machine.d.ts +3 -7
- package/dist/number-input.machine.js +51 -211
- package/dist/number-input.machine.mjs +386 -8
- package/dist/number-input.types.d.ts +8 -10
- package/dist/number-input.utils.d.ts +11 -15
- package/dist/number-input.utils.js +16 -38
- package/dist/number-input.utils.mjs +40 -5
- package/package.json +11 -16
- package/dist/chunk-5ENKYWE3.mjs +0 -243
- package/dist/chunk-AXXDGYUW.mjs +0 -43
- package/dist/chunk-QYY4CWRS.mjs +0 -101
- package/dist/chunk-WAGQOEOU.mjs +0 -393
- package/dist/chunk-XHRILSH3.mjs +0 -17
- package/dist/number-input.types.js +0 -18
- package/dist/number-input.types.mjs +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
} from
|
|
4
|
-
import {
|
|
5
|
-
anatomy
|
|
6
|
-
} from "./chunk-XHRILSH3.mjs";
|
|
7
|
-
import {
|
|
8
|
-
machine
|
|
9
|
-
} from "./chunk-WAGQOEOU.mjs";
|
|
10
|
-
import "./chunk-QYY4CWRS.mjs";
|
|
11
|
-
import "./chunk-AXXDGYUW.mjs";
|
|
12
|
-
export {
|
|
13
|
-
anatomy,
|
|
14
|
-
connect,
|
|
15
|
-
machine
|
|
16
|
-
};
|
|
1
|
+
export { anatomy } from './number-input.anatomy.mjs';
|
|
2
|
+
export { connect } from './number-input.connect.mjs';
|
|
3
|
+
export { machine } from './number-input.machine.mjs';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const parts: Record<"root" | "label" | "input" | "control" | "incrementTrigger" | "decrementTrigger" | "scrubber", _zag_js_anatomy.AnatomyPart>;
|
|
5
|
-
|
|
6
|
-
export { anatomy, parts };
|
|
1
|
+
import { AnatomyInstance, AnatomyPart } from '@zag-js/anatomy';
|
|
2
|
+
export declare const anatomy: AnatomyInstance<"root" | "label" | "input" | "control" | "incrementTrigger" | "decrementTrigger" | "scrubber">;
|
|
3
|
+
export declare const parts: Record<"root" | "label" | "input" | "control" | "incrementTrigger" | "decrementTrigger" | "scrubber", AnatomyPart>;
|
|
@@ -1,31 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(number_input_anatomy_exports);
|
|
27
|
-
var import_anatomy = require("@zag-js/anatomy");
|
|
28
|
-
var anatomy = (0, import_anatomy.createAnatomy)("numberInput").parts(
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const anatomy$1 = require('@zag-js/anatomy');
|
|
6
|
+
|
|
7
|
+
const anatomy = anatomy$1.createAnatomy("numberInput").parts(
|
|
29
8
|
"root",
|
|
30
9
|
"label",
|
|
31
10
|
"input",
|
|
@@ -34,9 +13,7 @@ var anatomy = (0, import_anatomy.createAnatomy)("numberInput").parts(
|
|
|
34
13
|
"decrementTrigger",
|
|
35
14
|
"scrubber"
|
|
36
15
|
);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
parts
|
|
42
|
-
});
|
|
16
|
+
const parts = anatomy.build();
|
|
17
|
+
|
|
18
|
+
exports.anatomy = anatomy;
|
|
19
|
+
exports.parts = parts;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { createAnatomy } from '@zag-js/anatomy';
|
|
2
|
+
|
|
3
|
+
const anatomy = createAnatomy("numberInput").parts(
|
|
4
|
+
"root",
|
|
5
|
+
"label",
|
|
6
|
+
"input",
|
|
7
|
+
"control",
|
|
8
|
+
"incrementTrigger",
|
|
9
|
+
"decrementTrigger",
|
|
10
|
+
"scrubber"
|
|
11
|
+
);
|
|
12
|
+
const parts = anatomy.build();
|
|
13
|
+
|
|
14
|
+
export { anatomy, parts };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
1
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
2
|
+
import type { Send, State } from "./number-input.types";
|
|
3
|
+
export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
6
4
|
/**
|
|
7
5
|
* Whether the input is focused.
|
|
8
6
|
*/
|
|
@@ -63,5 +61,3 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
|
|
|
63
61
|
incrementTriggerProps: T["button"];
|
|
64
62
|
scrubberProps: T["element"];
|
|
65
63
|
};
|
|
66
|
-
|
|
67
|
-
export { connect };
|
|
@@ -1,184 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var number_input_connect_exports = {};
|
|
22
|
-
__export(number_input_connect_exports, {
|
|
23
|
-
connect: () => connect
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(number_input_connect_exports);
|
|
26
|
-
var import_dom_event2 = require("@zag-js/dom-event");
|
|
27
|
-
var import_dom_query2 = require("@zag-js/dom-query");
|
|
28
|
-
var import_number_utils3 = require("@zag-js/number-utils");
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
29
4
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"control",
|
|
37
|
-
"incrementTrigger",
|
|
38
|
-
"decrementTrigger",
|
|
39
|
-
"scrubber"
|
|
40
|
-
);
|
|
41
|
-
var parts = anatomy.build();
|
|
5
|
+
const domEvent = require('@zag-js/dom-event');
|
|
6
|
+
const domQuery = require('@zag-js/dom-query');
|
|
7
|
+
const numberUtils = require('@zag-js/number-utils');
|
|
8
|
+
const numberInput_anatomy = require('./number-input.anatomy.js');
|
|
9
|
+
const numberInput_dom = require('./number-input.dom.js');
|
|
10
|
+
const numberInput_utils = require('./number-input.utils.js');
|
|
42
11
|
|
|
43
|
-
// src/number-input.dom.ts
|
|
44
|
-
var import_dom_query = require("@zag-js/dom-query");
|
|
45
|
-
var import_number_utils = require("@zag-js/number-utils");
|
|
46
|
-
var dom = (0, import_dom_query.createScope)({
|
|
47
|
-
getRootId: (ctx) => ctx.ids?.root ?? `number-input:${ctx.id}`,
|
|
48
|
-
getInputId: (ctx) => ctx.ids?.input ?? `number-input:${ctx.id}:input`,
|
|
49
|
-
getIncrementTriggerId: (ctx) => ctx.ids?.incrementTrigger ?? `number-input:${ctx.id}:inc`,
|
|
50
|
-
getDecrementTriggerId: (ctx) => ctx.ids?.decrementTrigger ?? `number-input:${ctx.id}:dec`,
|
|
51
|
-
getScrubberId: (ctx) => ctx.ids?.scrubber ?? `number-input:${ctx.id}:scrubber`,
|
|
52
|
-
getCursorId: (ctx) => `number-input:${ctx.id}:cursor`,
|
|
53
|
-
getLabelId: (ctx) => ctx.ids?.label ?? `number-input:${ctx.id}:label`,
|
|
54
|
-
getInputEl: (ctx) => dom.getById(ctx, dom.getInputId(ctx)),
|
|
55
|
-
getIncrementTriggerEl: (ctx) => dom.getById(ctx, dom.getIncrementTriggerId(ctx)),
|
|
56
|
-
getDecrementTriggerEl: (ctx) => dom.getById(ctx, dom.getDecrementTriggerId(ctx)),
|
|
57
|
-
getScrubberEl: (ctx) => dom.getById(ctx, dom.getScrubberId(ctx)),
|
|
58
|
-
getCursorEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getCursorId(ctx)),
|
|
59
|
-
getPressedTriggerEl: (ctx, hint = ctx.hint) => {
|
|
60
|
-
let btnEl = null;
|
|
61
|
-
if (hint === "increment") {
|
|
62
|
-
btnEl = dom.getIncrementTriggerEl(ctx);
|
|
63
|
-
}
|
|
64
|
-
if (hint === "decrement") {
|
|
65
|
-
btnEl = dom.getDecrementTriggerEl(ctx);
|
|
66
|
-
}
|
|
67
|
-
return btnEl;
|
|
68
|
-
},
|
|
69
|
-
setupVirtualCursor(ctx) {
|
|
70
|
-
if ((0, import_dom_query.isSafari)())
|
|
71
|
-
return;
|
|
72
|
-
dom.createVirtualCursor(ctx);
|
|
73
|
-
return () => {
|
|
74
|
-
dom.getCursorEl(ctx)?.remove();
|
|
75
|
-
};
|
|
76
|
-
},
|
|
77
|
-
preventTextSelection(ctx) {
|
|
78
|
-
const doc = dom.getDoc(ctx);
|
|
79
|
-
const html = doc.documentElement;
|
|
80
|
-
const body = doc.body;
|
|
81
|
-
body.style.pointerEvents = "none";
|
|
82
|
-
html.style.userSelect = "none";
|
|
83
|
-
html.style.cursor = "ew-resize";
|
|
84
|
-
return () => {
|
|
85
|
-
body.style.pointerEvents = "";
|
|
86
|
-
html.style.userSelect = "";
|
|
87
|
-
html.style.cursor = "";
|
|
88
|
-
if (!html.style.length) {
|
|
89
|
-
html.removeAttribute("style");
|
|
90
|
-
}
|
|
91
|
-
if (!body.style.length) {
|
|
92
|
-
body.removeAttribute("style");
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
getMousementValue(ctx, event) {
|
|
97
|
-
const x = (0, import_number_utils.roundToDevicePixel)(event.movementX);
|
|
98
|
-
const y = (0, import_number_utils.roundToDevicePixel)(event.movementY);
|
|
99
|
-
let hint = x > 0 ? "increment" : x < 0 ? "decrement" : null;
|
|
100
|
-
if (ctx.isRtl && hint === "increment")
|
|
101
|
-
hint = "decrement";
|
|
102
|
-
if (ctx.isRtl && hint === "decrement")
|
|
103
|
-
hint = "increment";
|
|
104
|
-
const point = {
|
|
105
|
-
x: ctx.scrubberCursorPoint.x + x,
|
|
106
|
-
y: ctx.scrubberCursorPoint.y + y
|
|
107
|
-
};
|
|
108
|
-
const win = dom.getWin(ctx);
|
|
109
|
-
const width = win.innerWidth;
|
|
110
|
-
const half = (0, import_number_utils.roundToDevicePixel)(7.5);
|
|
111
|
-
point.x = (0, import_number_utils.wrap)(point.x + half, width) - half;
|
|
112
|
-
return { hint, point };
|
|
113
|
-
},
|
|
114
|
-
createVirtualCursor(ctx) {
|
|
115
|
-
const doc = dom.getDoc(ctx);
|
|
116
|
-
const el = doc.createElement("div");
|
|
117
|
-
el.className = "scrubber--cursor";
|
|
118
|
-
el.id = dom.getCursorId(ctx);
|
|
119
|
-
Object.assign(el.style, {
|
|
120
|
-
width: "15px",
|
|
121
|
-
height: "15px",
|
|
122
|
-
position: "fixed",
|
|
123
|
-
pointerEvents: "none",
|
|
124
|
-
left: "0px",
|
|
125
|
-
top: "0px",
|
|
126
|
-
zIndex: import_dom_query.MAX_Z_INDEX,
|
|
127
|
-
transform: ctx.scrubberCursorPoint ? `translate3d(${ctx.scrubberCursorPoint.x}px, ${ctx.scrubberCursorPoint.y}px, 0px)` : void 0,
|
|
128
|
-
willChange: "transform"
|
|
129
|
-
});
|
|
130
|
-
el.innerHTML = `
|
|
131
|
-
<svg width="46" height="15" style="left: -15.5px; position: absolute; top: 0; filter: drop-shadow(rgba(0, 0, 0, 0.4) 0px 1px 1.1px);">
|
|
132
|
-
<g transform="translate(2 3)">
|
|
133
|
-
<path fill-rule="evenodd" d="M 15 4.5L 15 2L 11.5 5.5L 15 9L 15 6.5L 31 6.5L 31 9L 34.5 5.5L 31 2L 31 4.5Z" style="stroke-width: 2px; stroke: white;"></path>
|
|
134
|
-
<path fill-rule="evenodd" d="M 15 4.5L 15 2L 11.5 5.5L 15 9L 15 6.5L 31 6.5L 31 9L 34.5 5.5L 31 2L 31 4.5Z"></path>
|
|
135
|
-
</g>
|
|
136
|
-
</svg>`;
|
|
137
|
-
doc.body.appendChild(el);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// src/number-input.utils.ts
|
|
142
|
-
var import_dom_event = require("@zag-js/dom-event");
|
|
143
|
-
var import_number_utils2 = require("@zag-js/number-utils");
|
|
144
|
-
var utils = {
|
|
145
|
-
isValidNumericEvent: (ctx, event) => {
|
|
146
|
-
if (event.key == null)
|
|
147
|
-
return true;
|
|
148
|
-
const isModifier = (0, import_dom_event.isModifiedEvent)(event);
|
|
149
|
-
const isSingleKey = event.key.length === 1;
|
|
150
|
-
if (isModifier || !isSingleKey)
|
|
151
|
-
return true;
|
|
152
|
-
return ctx.validateCharacter?.(event.key) ?? utils.isFloatingPoint(event.key);
|
|
153
|
-
},
|
|
154
|
-
isFloatingPoint: (v) => /^[0-9+\-.]$/.test(v),
|
|
155
|
-
sanitize: (ctx, value) => {
|
|
156
|
-
return value.split("").filter(ctx.validateCharacter ?? utils.isFloatingPoint).join("");
|
|
157
|
-
},
|
|
158
|
-
increment: (ctx, step) => {
|
|
159
|
-
const value = (0, import_number_utils2.increment)(ctx.value, step ?? ctx.step);
|
|
160
|
-
return (0, import_number_utils2.formatDecimal)((0, import_number_utils2.clamp)(value, ctx), ctx);
|
|
161
|
-
},
|
|
162
|
-
decrement: (ctx, step) => {
|
|
163
|
-
const value = (0, import_number_utils2.decrement)(ctx.value, step ?? ctx.step);
|
|
164
|
-
return (0, import_number_utils2.formatDecimal)((0, import_number_utils2.clamp)(value, ctx), ctx);
|
|
165
|
-
},
|
|
166
|
-
clamp: (ctx) => {
|
|
167
|
-
return (0, import_number_utils2.formatDecimal)((0, import_number_utils2.clamp)(ctx.value, ctx), ctx);
|
|
168
|
-
},
|
|
169
|
-
parse: (ctx, value) => {
|
|
170
|
-
return ctx.parse?.(value) ?? value;
|
|
171
|
-
},
|
|
172
|
-
format: (ctx, value) => {
|
|
173
|
-
const _val = value.toString();
|
|
174
|
-
return ctx.format?.(_val) ?? _val;
|
|
175
|
-
},
|
|
176
|
-
round: (ctx) => {
|
|
177
|
-
return (0, import_number_utils2.formatDecimal)(ctx.value, ctx);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
// src/number-input.connect.ts
|
|
182
12
|
function connect(state, send, normalize) {
|
|
183
13
|
const isFocused = state.hasTag("focus");
|
|
184
14
|
const isInvalid = state.context.isOutOfRange || !!state.context.invalid;
|
|
@@ -248,47 +78,47 @@ function connect(state, send, normalize) {
|
|
|
248
78
|
* Function to focus the input.
|
|
249
79
|
*/
|
|
250
80
|
focus() {
|
|
251
|
-
dom.getInputEl(state.context)?.focus();
|
|
81
|
+
numberInput_dom.dom.getInputEl(state.context)?.focus();
|
|
252
82
|
},
|
|
253
83
|
/**
|
|
254
84
|
* Function to blur the input.
|
|
255
85
|
*/
|
|
256
86
|
blur() {
|
|
257
|
-
dom.getInputEl(state.context)?.blur();
|
|
87
|
+
numberInput_dom.dom.getInputEl(state.context)?.blur();
|
|
258
88
|
},
|
|
259
89
|
rootProps: normalize.element({
|
|
260
|
-
id: dom.getRootId(state.context),
|
|
261
|
-
...parts.root.attrs,
|
|
262
|
-
"data-disabled":
|
|
90
|
+
id: numberInput_dom.dom.getRootId(state.context),
|
|
91
|
+
...numberInput_anatomy.parts.root.attrs,
|
|
92
|
+
"data-disabled": domQuery.dataAttr(isDisabled)
|
|
263
93
|
}),
|
|
264
94
|
labelProps: normalize.label({
|
|
265
|
-
...parts.label.attrs,
|
|
266
|
-
"data-disabled":
|
|
267
|
-
"data-invalid":
|
|
268
|
-
id: dom.getLabelId(state.context),
|
|
269
|
-
htmlFor: dom.getInputId(state.context)
|
|
95
|
+
...numberInput_anatomy.parts.label.attrs,
|
|
96
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
97
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
98
|
+
id: numberInput_dom.dom.getLabelId(state.context),
|
|
99
|
+
htmlFor: numberInput_dom.dom.getInputId(state.context)
|
|
270
100
|
}),
|
|
271
101
|
controlProps: normalize.element({
|
|
272
|
-
...parts.control.attrs,
|
|
102
|
+
...numberInput_anatomy.parts.control.attrs,
|
|
273
103
|
role: "group",
|
|
274
104
|
"aria-disabled": isDisabled,
|
|
275
|
-
"data-disabled":
|
|
276
|
-
"data-invalid":
|
|
277
|
-
"aria-invalid":
|
|
105
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
106
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
107
|
+
"aria-invalid": domQuery.ariaAttr(state.context.invalid)
|
|
278
108
|
}),
|
|
279
109
|
inputProps: normalize.input({
|
|
280
|
-
...parts.input.attrs,
|
|
110
|
+
...numberInput_anatomy.parts.input.attrs,
|
|
281
111
|
name: state.context.name,
|
|
282
112
|
form: state.context.form,
|
|
283
|
-
id: dom.getInputId(state.context),
|
|
113
|
+
id: numberInput_dom.dom.getInputId(state.context),
|
|
284
114
|
role: "spinbutton",
|
|
285
115
|
defaultValue: state.context.formattedValue,
|
|
286
116
|
pattern: state.context.pattern,
|
|
287
117
|
inputMode: state.context.inputMode,
|
|
288
|
-
"aria-invalid":
|
|
289
|
-
"data-invalid":
|
|
118
|
+
"aria-invalid": domQuery.ariaAttr(isInvalid),
|
|
119
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
290
120
|
disabled: isDisabled,
|
|
291
|
-
"data-disabled":
|
|
121
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
292
122
|
readOnly: !!state.context.readOnly,
|
|
293
123
|
autoComplete: "off",
|
|
294
124
|
autoCorrect: "off",
|
|
@@ -309,13 +139,13 @@ function connect(state, send, normalize) {
|
|
|
309
139
|
send({ type: "CHANGE", target: event.currentTarget, hint: "set" });
|
|
310
140
|
},
|
|
311
141
|
onKeyDown(event) {
|
|
312
|
-
const evt =
|
|
142
|
+
const evt = domEvent.getNativeEvent(event);
|
|
313
143
|
if (evt.isComposing)
|
|
314
144
|
return;
|
|
315
|
-
if (!utils.isValidNumericEvent(state.context, event)) {
|
|
145
|
+
if (!numberInput_utils.utils.isValidNumericEvent(state.context, event)) {
|
|
316
146
|
event.preventDefault();
|
|
317
147
|
}
|
|
318
|
-
const step =
|
|
148
|
+
const step = domEvent.getEventStep(event) * state.context.step;
|
|
319
149
|
const keyMap = {
|
|
320
150
|
ArrowUp() {
|
|
321
151
|
send({ type: "ARROW_UP", step });
|
|
@@ -338,18 +168,18 @@ function connect(state, send, normalize) {
|
|
|
338
168
|
}
|
|
339
169
|
}),
|
|
340
170
|
decrementTriggerProps: normalize.button({
|
|
341
|
-
...parts.decrementTrigger.attrs,
|
|
342
|
-
id: dom.getDecrementTriggerId(state.context),
|
|
171
|
+
...numberInput_anatomy.parts.decrementTrigger.attrs,
|
|
172
|
+
id: numberInput_dom.dom.getDecrementTriggerId(state.context),
|
|
343
173
|
disabled: isDecrementDisabled,
|
|
344
|
-
"data-disabled":
|
|
174
|
+
"data-disabled": domQuery.dataAttr(isDecrementDisabled),
|
|
345
175
|
"aria-label": translations.decrementLabel,
|
|
346
176
|
type: "button",
|
|
347
177
|
tabIndex: -1,
|
|
348
|
-
"aria-controls": dom.getInputId(state.context),
|
|
178
|
+
"aria-controls": numberInput_dom.dom.getInputId(state.context),
|
|
349
179
|
onPointerDown(event) {
|
|
350
180
|
if (isDecrementDisabled)
|
|
351
181
|
return;
|
|
352
|
-
send(
|
|
182
|
+
send(domEvent.isLeftClick(event) ? { type: "PRESS_DOWN", hint: "decrement" } : { type: "FOCUS" });
|
|
353
183
|
event.preventDefault();
|
|
354
184
|
},
|
|
355
185
|
onPointerUp() {
|
|
@@ -362,18 +192,18 @@ function connect(state, send, normalize) {
|
|
|
362
192
|
}
|
|
363
193
|
}),
|
|
364
194
|
incrementTriggerProps: normalize.button({
|
|
365
|
-
...parts.incrementTrigger.attrs,
|
|
366
|
-
id: dom.getIncrementTriggerId(state.context),
|
|
195
|
+
...numberInput_anatomy.parts.incrementTrigger.attrs,
|
|
196
|
+
id: numberInput_dom.dom.getIncrementTriggerId(state.context),
|
|
367
197
|
disabled: isIncrementDisabled,
|
|
368
|
-
"data-disabled":
|
|
198
|
+
"data-disabled": domQuery.dataAttr(isIncrementDisabled),
|
|
369
199
|
"aria-label": translations.incrementLabel,
|
|
370
200
|
type: "button",
|
|
371
201
|
tabIndex: -1,
|
|
372
|
-
"aria-controls": dom.getInputId(state.context),
|
|
202
|
+
"aria-controls": numberInput_dom.dom.getInputId(state.context),
|
|
373
203
|
onPointerDown(event) {
|
|
374
204
|
if (isIncrementDisabled)
|
|
375
205
|
return;
|
|
376
|
-
send(
|
|
206
|
+
send(domEvent.isLeftClick(event) ? { type: "PRESS_DOWN", hint: "increment" } : { type: "FOCUS" });
|
|
377
207
|
event.preventDefault();
|
|
378
208
|
},
|
|
379
209
|
onPointerUp() {
|
|
@@ -384,17 +214,17 @@ function connect(state, send, normalize) {
|
|
|
384
214
|
}
|
|
385
215
|
}),
|
|
386
216
|
scrubberProps: normalize.element({
|
|
387
|
-
...parts.scrubber.attrs,
|
|
388
|
-
"data-disabled":
|
|
389
|
-
id: dom.getScrubberId(state.context),
|
|
217
|
+
...numberInput_anatomy.parts.scrubber.attrs,
|
|
218
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
219
|
+
id: numberInput_dom.dom.getScrubberId(state.context),
|
|
390
220
|
role: "presentation",
|
|
391
221
|
onMouseDown(event) {
|
|
392
222
|
if (isDisabled)
|
|
393
223
|
return;
|
|
394
|
-
const evt =
|
|
395
|
-
const point =
|
|
396
|
-
point.x = point.x -
|
|
397
|
-
point.y = point.y -
|
|
224
|
+
const evt = domEvent.getNativeEvent(event);
|
|
225
|
+
const point = domEvent.getEventPoint(evt);
|
|
226
|
+
point.x = point.x - numberUtils.roundToDevicePixel(7.5);
|
|
227
|
+
point.y = point.y - numberUtils.roundToDevicePixel(7.5);
|
|
398
228
|
send({ type: "PRESS_DOWN_SCRUBBER", point });
|
|
399
229
|
event.preventDefault();
|
|
400
230
|
},
|
|
@@ -404,7 +234,5 @@ function connect(state, send, normalize) {
|
|
|
404
234
|
})
|
|
405
235
|
};
|
|
406
236
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
connect
|
|
410
|
-
});
|
|
237
|
+
|
|
238
|
+
exports.connect = connect;
|