@zag-js/number-input 1.46.0 → 1.48.0
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/cursor.d.mts +8 -10
- package/dist/cursor.d.ts +8 -10
- package/dist/cursor.js +65 -104
- package/dist/cursor.mjs +59 -77
- package/dist/index.d.mts +6 -9
- package/dist/index.d.ts +6 -9
- package/dist/index.js +12 -38
- package/dist/index.mjs +2 -7
- package/dist/number-input.anatomy.d.mts +2 -6
- package/dist/number-input.anatomy.d.ts +2 -6
- package/dist/number-input.anatomy.js +8 -42
- package/dist/number-input.anatomy.mjs +4 -16
- package/dist/number-input.connect.d.mts +3 -8
- package/dist/number-input.connect.d.ts +3 -8
- package/dist/number-input.connect.js +310 -310
- package/dist/number-input.connect.mjs +304 -284
- package/dist/number-input.dom.d.mts +28 -32
- package/dist/number-input.dom.d.ts +28 -32
- package/dist/number-input.dom.js +96 -138
- package/dist/number-input.dom.mjs +76 -97
- package/dist/number-input.machine.d.mts +2 -8
- package/dist/number-input.machine.d.ts +2 -8
- package/dist/number-input.machine.js +484 -460
- package/dist/number-input.machine.mjs +478 -440
- package/dist/number-input.props.d.mts +3 -9
- package/dist/number-input.props.d.ts +3 -9
- package/dist/number-input.props.js +40 -65
- package/dist/number-input.props.mjs +36 -39
- package/dist/number-input.translations.d.mts +3 -8
- package/dist/number-input.translations.d.ts +3 -8
- package/dist/number-input.translations.js +8 -31
- package/dist/number-input.translations.mjs +4 -6
- package/dist/number-input.types.d.mts +298 -300
- package/dist/number-input.types.d.ts +298 -300
- package/dist/number-input.types.js +4 -18
- package/dist/number-input.types.mjs +1 -0
- package/dist/number-input.utils.d.mts +9 -12
- package/dist/number-input.utils.d.ts +9 -12
- package/dist/number-input.utils.js +28 -57
- package/dist/number-input.utils.mjs +20 -28
- package/package.json +8 -8
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
10
|
-
declare const
|
|
11
|
-
declare const
|
|
12
|
-
declare const
|
|
13
|
-
declare const
|
|
14
|
-
declare const
|
|
15
|
-
declare const
|
|
16
|
-
declare const
|
|
17
|
-
declare const
|
|
18
|
-
declare const
|
|
19
|
-
declare const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
isRtl: boolean;
|
|
24
|
-
event: MouseEvent;
|
|
1
|
+
import { HintValue } from "./number-input.types.mjs";
|
|
2
|
+
import { Scope } from "@zag-js/core";
|
|
3
|
+
import { Point } from "@zag-js/types";
|
|
4
|
+
export declare const getRootId: (ctx: Scope) => any;
|
|
5
|
+
export declare const getInputId: (ctx: Scope) => any;
|
|
6
|
+
export declare const getIncrementTriggerId: (ctx: Scope) => any;
|
|
7
|
+
export declare const getDecrementTriggerId: (ctx: Scope) => any;
|
|
8
|
+
export declare const getScrubberId: (ctx: Scope) => any;
|
|
9
|
+
export declare const getCursorId: (ctx: Scope) => string;
|
|
10
|
+
export declare const getLabelId: (ctx: Scope) => any;
|
|
11
|
+
export declare const getInputEl: (ctx: Scope) => HTMLInputElement | null;
|
|
12
|
+
export declare const getIncrementTriggerEl: (ctx: Scope) => HTMLButtonElement | null;
|
|
13
|
+
export declare const getDecrementTriggerEl: (ctx: Scope) => HTMLButtonElement | null;
|
|
14
|
+
export declare const getScrubberEl: (ctx: Scope) => HTMLElement | null;
|
|
15
|
+
export declare const getCursorEl: (ctx: Scope) => HTMLElement | null;
|
|
16
|
+
export declare const getPressedTriggerEl: (ctx: Scope, hint: HintValue | null) => HTMLButtonElement | null;
|
|
17
|
+
export declare const setupVirtualCursor: (ctx: Scope, point: Point | null) => (() => void) | undefined;
|
|
18
|
+
export declare const preventTextSelection: (ctx: Scope) => () => void;
|
|
19
|
+
export declare const getMousemoveValue: (ctx: Scope, opts: {
|
|
20
|
+
point: Point | null;
|
|
21
|
+
isRtl: boolean;
|
|
22
|
+
event: MouseEvent;
|
|
25
23
|
}) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
hint: string | null;
|
|
25
|
+
point: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
31
29
|
};
|
|
32
|
-
declare const createVirtualCursor: (ctx: Scope, point: Point | null) => void;
|
|
33
|
-
|
|
34
|
-
export { createVirtualCursor, getCursorEl, getCursorId, getDecrementTriggerEl, getDecrementTriggerId, getIncrementTriggerEl, getIncrementTriggerId, getInputEl, getInputId, getLabelId, getMousemoveValue, getPressedTriggerEl, getRootId, getScrubberEl, getScrubberId, preventTextSelection, setupVirtualCursor };
|
|
30
|
+
export declare const createVirtualCursor: (ctx: Scope, point: Point | null) => void;
|
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
10
|
-
declare const
|
|
11
|
-
declare const
|
|
12
|
-
declare const
|
|
13
|
-
declare const
|
|
14
|
-
declare const
|
|
15
|
-
declare const
|
|
16
|
-
declare const
|
|
17
|
-
declare const
|
|
18
|
-
declare const
|
|
19
|
-
declare const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
isRtl: boolean;
|
|
24
|
-
event: MouseEvent;
|
|
1
|
+
import { HintValue } from "./number-input.types.js";
|
|
2
|
+
import { Scope } from "@zag-js/core";
|
|
3
|
+
import { Point } from "@zag-js/types";
|
|
4
|
+
export declare const getRootId: (ctx: Scope) => any;
|
|
5
|
+
export declare const getInputId: (ctx: Scope) => any;
|
|
6
|
+
export declare const getIncrementTriggerId: (ctx: Scope) => any;
|
|
7
|
+
export declare const getDecrementTriggerId: (ctx: Scope) => any;
|
|
8
|
+
export declare const getScrubberId: (ctx: Scope) => any;
|
|
9
|
+
export declare const getCursorId: (ctx: Scope) => string;
|
|
10
|
+
export declare const getLabelId: (ctx: Scope) => any;
|
|
11
|
+
export declare const getInputEl: (ctx: Scope) => HTMLInputElement | null;
|
|
12
|
+
export declare const getIncrementTriggerEl: (ctx: Scope) => HTMLButtonElement | null;
|
|
13
|
+
export declare const getDecrementTriggerEl: (ctx: Scope) => HTMLButtonElement | null;
|
|
14
|
+
export declare const getScrubberEl: (ctx: Scope) => HTMLElement | null;
|
|
15
|
+
export declare const getCursorEl: (ctx: Scope) => HTMLElement | null;
|
|
16
|
+
export declare const getPressedTriggerEl: (ctx: Scope, hint: HintValue | null) => HTMLButtonElement | null;
|
|
17
|
+
export declare const setupVirtualCursor: (ctx: Scope, point: Point | null) => (() => void) | undefined;
|
|
18
|
+
export declare const preventTextSelection: (ctx: Scope) => () => void;
|
|
19
|
+
export declare const getMousemoveValue: (ctx: Scope, opts: {
|
|
20
|
+
point: Point | null;
|
|
21
|
+
isRtl: boolean;
|
|
22
|
+
event: MouseEvent;
|
|
25
23
|
}) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
hint: string | null;
|
|
25
|
+
point: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
31
29
|
};
|
|
32
|
-
declare const createVirtualCursor: (ctx: Scope, point: Point | null) => void;
|
|
33
|
-
|
|
34
|
-
export { createVirtualCursor, getCursorEl, getCursorId, getDecrementTriggerEl, getDecrementTriggerId, getIncrementTriggerEl, getIncrementTriggerId, getInputEl, getInputId, getLabelId, getMousemoveValue, getPressedTriggerEl, getRootId, getScrubberEl, getScrubberId, preventTextSelection, setupVirtualCursor };
|
|
30
|
+
export declare const createVirtualCursor: (ctx: Scope, point: Point | null) => void;
|
package/dist/number-input.dom.js
CHANGED
|
@@ -1,150 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/number-input.dom.ts
|
|
21
|
-
var number_input_dom_exports = {};
|
|
22
|
-
__export(number_input_dom_exports, {
|
|
23
|
-
createVirtualCursor: () => createVirtualCursor,
|
|
24
|
-
getCursorEl: () => getCursorEl,
|
|
25
|
-
getCursorId: () => getCursorId,
|
|
26
|
-
getDecrementTriggerEl: () => getDecrementTriggerEl,
|
|
27
|
-
getDecrementTriggerId: () => getDecrementTriggerId,
|
|
28
|
-
getIncrementTriggerEl: () => getIncrementTriggerEl,
|
|
29
|
-
getIncrementTriggerId: () => getIncrementTriggerId,
|
|
30
|
-
getInputEl: () => getInputEl,
|
|
31
|
-
getInputId: () => getInputId,
|
|
32
|
-
getLabelId: () => getLabelId,
|
|
33
|
-
getMousemoveValue: () => getMousemoveValue,
|
|
34
|
-
getPressedTriggerEl: () => getPressedTriggerEl,
|
|
35
|
-
getRootId: () => getRootId,
|
|
36
|
-
getScrubberEl: () => getScrubberEl,
|
|
37
|
-
getScrubberId: () => getScrubberId,
|
|
38
|
-
preventTextSelection: () => preventTextSelection,
|
|
39
|
-
setupVirtualCursor: () => setupVirtualCursor
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
40
4
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (hint === "decrement") {
|
|
62
|
-
btnEl = getDecrementTriggerEl(ctx);
|
|
63
|
-
}
|
|
64
|
-
return btnEl;
|
|
5
|
+
let _zag_js_dom_query = require("@zag-js/dom-query");
|
|
6
|
+
let _zag_js_utils = require("@zag-js/utils");
|
|
7
|
+
// src/number-input.dom.ts
|
|
8
|
+
const getRootId = (ctx) => ctx.ids?.root ?? `number-input:${ctx.id}`;
|
|
9
|
+
const getInputId = (ctx) => ctx.ids?.input ?? `number-input:${ctx.id}:input`;
|
|
10
|
+
const getIncrementTriggerId = (ctx) => ctx.ids?.incrementTrigger ?? `number-input:${ctx.id}:inc`;
|
|
11
|
+
const getDecrementTriggerId = (ctx) => ctx.ids?.decrementTrigger ?? `number-input:${ctx.id}:dec`;
|
|
12
|
+
const getScrubberId = (ctx) => ctx.ids?.scrubber ?? `number-input:${ctx.id}:scrubber`;
|
|
13
|
+
const getCursorId = (ctx) => `number-input:${ctx.id}:cursor`;
|
|
14
|
+
const getLabelId = (ctx) => ctx.ids?.label ?? `number-input:${ctx.id}:label`;
|
|
15
|
+
const getInputEl = (ctx) => ctx.getById(getInputId(ctx));
|
|
16
|
+
const getIncrementTriggerEl = (ctx) => ctx.getById(getIncrementTriggerId(ctx));
|
|
17
|
+
const getDecrementTriggerEl = (ctx) => ctx.getById(getDecrementTriggerId(ctx));
|
|
18
|
+
const getScrubberEl = (ctx) => ctx.getById(getScrubberId(ctx));
|
|
19
|
+
const getCursorEl = (ctx) => ctx.getDoc().getElementById(getCursorId(ctx));
|
|
20
|
+
const getPressedTriggerEl = (ctx, hint) => {
|
|
21
|
+
let btnEl = null;
|
|
22
|
+
if (hint === "increment") btnEl = getIncrementTriggerEl(ctx);
|
|
23
|
+
if (hint === "decrement") btnEl = getDecrementTriggerEl(ctx);
|
|
24
|
+
return btnEl;
|
|
65
25
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
26
|
+
const setupVirtualCursor = (ctx, point) => {
|
|
27
|
+
if ((0, _zag_js_dom_query.isSafari)()) return;
|
|
28
|
+
createVirtualCursor(ctx, point);
|
|
29
|
+
return () => {
|
|
30
|
+
getCursorEl(ctx)?.remove();
|
|
31
|
+
};
|
|
72
32
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!body.style.length) {
|
|
88
|
-
body.removeAttribute("style");
|
|
89
|
-
}
|
|
90
|
-
};
|
|
33
|
+
const preventTextSelection = (ctx) => {
|
|
34
|
+
const doc = ctx.getDoc();
|
|
35
|
+
const html = doc.documentElement;
|
|
36
|
+
const body = doc.body;
|
|
37
|
+
body.style.pointerEvents = "none";
|
|
38
|
+
html.style.userSelect = "none";
|
|
39
|
+
html.style.cursor = "ew-resize";
|
|
40
|
+
return () => {
|
|
41
|
+
body.style.pointerEvents = "";
|
|
42
|
+
html.style.userSelect = "";
|
|
43
|
+
html.style.cursor = "";
|
|
44
|
+
if (!html.style.length) html.removeAttribute("style");
|
|
45
|
+
if (!body.style.length) body.removeAttribute("style");
|
|
46
|
+
};
|
|
91
47
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
48
|
+
const getMousemoveValue = (ctx, opts) => {
|
|
49
|
+
const { point, isRtl, event } = opts;
|
|
50
|
+
const win = ctx.getWin();
|
|
51
|
+
const x = (0, _zag_js_utils.roundToDpr)(event.movementX, win.devicePixelRatio);
|
|
52
|
+
const y = (0, _zag_js_utils.roundToDpr)(event.movementY, win.devicePixelRatio);
|
|
53
|
+
let hint = x > 0 ? "increment" : x < 0 ? "decrement" : null;
|
|
54
|
+
if (isRtl && hint) hint = hint === "increment" ? "decrement" : "increment";
|
|
55
|
+
const newPoint = {
|
|
56
|
+
x: point.x + x,
|
|
57
|
+
y: point.y + y
|
|
58
|
+
};
|
|
59
|
+
const width = win.innerWidth;
|
|
60
|
+
const half = (0, _zag_js_utils.roundToDpr)(7.5, win.devicePixelRatio);
|
|
61
|
+
newPoint.x = (0, _zag_js_utils.wrap)(newPoint.x + half, width) - half;
|
|
62
|
+
return {
|
|
63
|
+
hint,
|
|
64
|
+
point: newPoint
|
|
65
|
+
};
|
|
105
66
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
67
|
+
const createVirtualCursor = (ctx, point) => {
|
|
68
|
+
const doc = ctx.getDoc();
|
|
69
|
+
const el = doc.createElement("div");
|
|
70
|
+
el.className = "scrubber--cursor";
|
|
71
|
+
el.id = getCursorId(ctx);
|
|
72
|
+
Object.assign(el.style, {
|
|
73
|
+
width: "15px",
|
|
74
|
+
height: "15px",
|
|
75
|
+
position: "fixed",
|
|
76
|
+
pointerEvents: "none",
|
|
77
|
+
left: "0px",
|
|
78
|
+
top: "0px",
|
|
79
|
+
zIndex: _zag_js_dom_query.MAX_Z_INDEX,
|
|
80
|
+
transform: point ? `translate3d(${point.x}px, ${point.y}px, 0px)` : void 0,
|
|
81
|
+
willChange: "transform"
|
|
82
|
+
});
|
|
83
|
+
el.innerHTML = `
|
|
123
84
|
<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);">
|
|
124
85
|
<g transform="translate(2 3)">
|
|
125
86
|
<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>
|
|
126
87
|
<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>
|
|
127
88
|
</g>
|
|
128
89
|
</svg>`;
|
|
129
|
-
|
|
90
|
+
doc.body.appendChild(el);
|
|
130
91
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
preventTextSelection,
|
|
149
|
-
setupVirtualCursor
|
|
150
|
-
});
|
|
92
|
+
exports.createVirtualCursor = createVirtualCursor;
|
|
93
|
+
exports.getCursorEl = getCursorEl;
|
|
94
|
+
exports.getCursorId = getCursorId;
|
|
95
|
+
exports.getDecrementTriggerEl = getDecrementTriggerEl;
|
|
96
|
+
exports.getDecrementTriggerId = getDecrementTriggerId;
|
|
97
|
+
exports.getIncrementTriggerEl = getIncrementTriggerEl;
|
|
98
|
+
exports.getIncrementTriggerId = getIncrementTriggerId;
|
|
99
|
+
exports.getInputEl = getInputEl;
|
|
100
|
+
exports.getInputId = getInputId;
|
|
101
|
+
exports.getLabelId = getLabelId;
|
|
102
|
+
exports.getMousemoveValue = getMousemoveValue;
|
|
103
|
+
exports.getPressedTriggerEl = getPressedTriggerEl;
|
|
104
|
+
exports.getRootId = getRootId;
|
|
105
|
+
exports.getScrubberEl = getScrubberEl;
|
|
106
|
+
exports.getScrubberId = getScrubberId;
|
|
107
|
+
exports.preventTextSelection = preventTextSelection;
|
|
108
|
+
exports.setupVirtualCursor = setupVirtualCursor;
|
|
@@ -1,109 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
import { isSafari, MAX_Z_INDEX } from "@zag-js/dom-query";
|
|
1
|
+
import { MAX_Z_INDEX, isSafari } from "@zag-js/dom-query";
|
|
3
2
|
import { roundToDpr, wrap } from "@zag-js/utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
btnEl = getDecrementTriggerEl(ctx);
|
|
23
|
-
}
|
|
24
|
-
return btnEl;
|
|
3
|
+
// src/number-input.dom.ts
|
|
4
|
+
const getRootId = (ctx) => ctx.ids?.root ?? `number-input:${ctx.id}`;
|
|
5
|
+
const getInputId = (ctx) => ctx.ids?.input ?? `number-input:${ctx.id}:input`;
|
|
6
|
+
const getIncrementTriggerId = (ctx) => ctx.ids?.incrementTrigger ?? `number-input:${ctx.id}:inc`;
|
|
7
|
+
const getDecrementTriggerId = (ctx) => ctx.ids?.decrementTrigger ?? `number-input:${ctx.id}:dec`;
|
|
8
|
+
const getScrubberId = (ctx) => ctx.ids?.scrubber ?? `number-input:${ctx.id}:scrubber`;
|
|
9
|
+
const getCursorId = (ctx) => `number-input:${ctx.id}:cursor`;
|
|
10
|
+
const getLabelId = (ctx) => ctx.ids?.label ?? `number-input:${ctx.id}:label`;
|
|
11
|
+
const getInputEl = (ctx) => ctx.getById(getInputId(ctx));
|
|
12
|
+
const getIncrementTriggerEl = (ctx) => ctx.getById(getIncrementTriggerId(ctx));
|
|
13
|
+
const getDecrementTriggerEl = (ctx) => ctx.getById(getDecrementTriggerId(ctx));
|
|
14
|
+
const getScrubberEl = (ctx) => ctx.getById(getScrubberId(ctx));
|
|
15
|
+
const getCursorEl = (ctx) => ctx.getDoc().getElementById(getCursorId(ctx));
|
|
16
|
+
const getPressedTriggerEl = (ctx, hint) => {
|
|
17
|
+
let btnEl = null;
|
|
18
|
+
if (hint === "increment") btnEl = getIncrementTriggerEl(ctx);
|
|
19
|
+
if (hint === "decrement") btnEl = getDecrementTriggerEl(ctx);
|
|
20
|
+
return btnEl;
|
|
25
21
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
const setupVirtualCursor = (ctx, point) => {
|
|
23
|
+
if (isSafari()) return;
|
|
24
|
+
createVirtualCursor(ctx, point);
|
|
25
|
+
return () => {
|
|
26
|
+
getCursorEl(ctx)?.remove();
|
|
27
|
+
};
|
|
32
28
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!body.style.length) {
|
|
48
|
-
body.removeAttribute("style");
|
|
49
|
-
}
|
|
50
|
-
};
|
|
29
|
+
const preventTextSelection = (ctx) => {
|
|
30
|
+
const doc = ctx.getDoc();
|
|
31
|
+
const html = doc.documentElement;
|
|
32
|
+
const body = doc.body;
|
|
33
|
+
body.style.pointerEvents = "none";
|
|
34
|
+
html.style.userSelect = "none";
|
|
35
|
+
html.style.cursor = "ew-resize";
|
|
36
|
+
return () => {
|
|
37
|
+
body.style.pointerEvents = "";
|
|
38
|
+
html.style.userSelect = "";
|
|
39
|
+
html.style.cursor = "";
|
|
40
|
+
if (!html.style.length) html.removeAttribute("style");
|
|
41
|
+
if (!body.style.length) body.removeAttribute("style");
|
|
42
|
+
};
|
|
51
43
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
const getMousemoveValue = (ctx, opts) => {
|
|
45
|
+
const { point, isRtl, event } = opts;
|
|
46
|
+
const win = ctx.getWin();
|
|
47
|
+
const x = roundToDpr(event.movementX, win.devicePixelRatio);
|
|
48
|
+
const y = roundToDpr(event.movementY, win.devicePixelRatio);
|
|
49
|
+
let hint = x > 0 ? "increment" : x < 0 ? "decrement" : null;
|
|
50
|
+
if (isRtl && hint) hint = hint === "increment" ? "decrement" : "increment";
|
|
51
|
+
const newPoint = {
|
|
52
|
+
x: point.x + x,
|
|
53
|
+
y: point.y + y
|
|
54
|
+
};
|
|
55
|
+
const width = win.innerWidth;
|
|
56
|
+
const half = roundToDpr(7.5, win.devicePixelRatio);
|
|
57
|
+
newPoint.x = wrap(newPoint.x + half, width) - half;
|
|
58
|
+
return {
|
|
59
|
+
hint,
|
|
60
|
+
point: newPoint
|
|
61
|
+
};
|
|
65
62
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
const createVirtualCursor = (ctx, point) => {
|
|
64
|
+
const doc = ctx.getDoc();
|
|
65
|
+
const el = doc.createElement("div");
|
|
66
|
+
el.className = "scrubber--cursor";
|
|
67
|
+
el.id = getCursorId(ctx);
|
|
68
|
+
Object.assign(el.style, {
|
|
69
|
+
width: "15px",
|
|
70
|
+
height: "15px",
|
|
71
|
+
position: "fixed",
|
|
72
|
+
pointerEvents: "none",
|
|
73
|
+
left: "0px",
|
|
74
|
+
top: "0px",
|
|
75
|
+
zIndex: MAX_Z_INDEX,
|
|
76
|
+
transform: point ? `translate3d(${point.x}px, ${point.y}px, 0px)` : void 0,
|
|
77
|
+
willChange: "transform"
|
|
78
|
+
});
|
|
79
|
+
el.innerHTML = `
|
|
83
80
|
<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);">
|
|
84
81
|
<g transform="translate(2 3)">
|
|
85
82
|
<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>
|
|
86
83
|
<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>
|
|
87
84
|
</g>
|
|
88
85
|
</svg>`;
|
|
89
|
-
|
|
90
|
-
};
|
|
91
|
-
export {
|
|
92
|
-
createVirtualCursor,
|
|
93
|
-
getCursorEl,
|
|
94
|
-
getCursorId,
|
|
95
|
-
getDecrementTriggerEl,
|
|
96
|
-
getDecrementTriggerId,
|
|
97
|
-
getIncrementTriggerEl,
|
|
98
|
-
getIncrementTriggerId,
|
|
99
|
-
getInputEl,
|
|
100
|
-
getInputId,
|
|
101
|
-
getLabelId,
|
|
102
|
-
getMousemoveValue,
|
|
103
|
-
getPressedTriggerEl,
|
|
104
|
-
getRootId,
|
|
105
|
-
getScrubberEl,
|
|
106
|
-
getScrubberId,
|
|
107
|
-
preventTextSelection,
|
|
108
|
-
setupVirtualCursor
|
|
86
|
+
doc.body.appendChild(el);
|
|
109
87
|
};
|
|
88
|
+
export { createVirtualCursor, getCursorEl, getCursorId, getDecrementTriggerEl, getDecrementTriggerId, getIncrementTriggerEl, getIncrementTriggerId, getInputEl, getInputId, getLabelId, getMousemoveValue, getPressedTriggerEl, getRootId, getScrubberEl, getScrubberId, preventTextSelection, setupVirtualCursor };
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import '@internationalized/number';
|
|
4
|
-
import '@zag-js/types';
|
|
5
|
-
|
|
6
|
-
declare const machine: _zag_js_core.Machine<NumberInputSchema>;
|
|
7
|
-
|
|
8
|
-
export { machine };
|
|
1
|
+
import { NumberInputSchema } from "./number-input.types.mjs";
|
|
2
|
+
export declare const machine: import("@zag-js/core").Machine<NumberInputSchema>;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import '@internationalized/number';
|
|
4
|
-
import '@zag-js/types';
|
|
5
|
-
|
|
6
|
-
declare const machine: _zag_js_core.Machine<NumberInputSchema>;
|
|
7
|
-
|
|
8
|
-
export { machine };
|
|
1
|
+
import { NumberInputSchema } from "./number-input.types.js";
|
|
2
|
+
export declare const machine: import("@zag-js/core").Machine<NumberInputSchema>;
|