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