@zag-js/slider 2.0.0-next.2 → 2.0.0-next.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.
@@ -1,30 +1,15 @@
1
- import { Scope, Params } from '@zag-js/core';
2
- import { Point } from '@zag-js/types';
3
- import { SliderSchema } from './slider.types.mjs';
4
-
5
- declare const getRootId: (ctx: Scope) => any;
6
- declare const getThumbId: (ctx: Scope, index: number) => any;
7
- declare const getHiddenInputId: (ctx: Scope, index: number) => any;
8
- declare const getControlId: (ctx: Scope) => any;
9
- declare const getTrackId: (ctx: Scope) => any;
10
- declare const getRangeId: (ctx: Scope) => any;
11
- declare const getLabelId: (ctx: Scope) => any;
12
- declare const getValueTextId: (ctx: Scope) => any;
13
- declare const getMarkerId: (ctx: Scope, value: number) => any;
14
- declare const getRootEl: (ctx: Scope) => HTMLElement | null;
15
- declare const getThumbEl: (ctx: Scope, index: number) => HTMLElement | null;
16
- declare const getThumbEls: (ctx: Scope) => HTMLElement[];
17
- declare const getFirstThumbEl: (ctx: Scope) => HTMLElement;
18
- declare const getHiddenInputEl: (ctx: Scope, index: number) => HTMLInputElement | null;
19
- declare const getControlEl: (ctx: Scope) => HTMLElement | null;
20
- declare const getRangeEl: (ctx: Scope) => HTMLElement | null;
21
- declare const getPointValue: (params: Params<SliderSchema>, point: Point) => number | undefined;
22
- declare const dispatchChangeEvent: (ctx: Scope, value: number[]) => void;
23
- declare const getOffsetRect: (el: HTMLElement | undefined) => {
24
- left: number;
25
- top: number;
26
- width: number;
27
- height: number;
28
- };
29
-
30
- export { dispatchChangeEvent, getControlEl, getControlId, getFirstThumbEl, getHiddenInputEl, getHiddenInputId, getLabelId, getMarkerId, getOffsetRect, getPointValue, getRangeEl, getRangeId, getRootEl, getRootId, getThumbEl, getThumbEls, getThumbId, getTrackId, getValueTextId };
1
+ import { SliderSchema } from "./slider.types.mjs";
2
+ import { Params, Scope } from "@zag-js/core";
3
+ import { Point } from "@zag-js/types";
4
+ export declare const getHiddenInputId: (ctx: Scope, index: number) => any;
5
+ export declare const getLabelId: (ctx: Scope) => any;
6
+ export declare const getRootEl: (ctx: Scope) => HTMLElement | null;
7
+ export declare const getThumbEl: (ctx: Scope, index: number) => HTMLElement | null;
8
+ export declare const getThumbEls: (ctx: Scope) => HTMLElement[];
9
+ export declare const isThumbDisabled: (el: Element | null | undefined) => boolean;
10
+ export declare const getFirstEnabledThumbEl: (ctx: Scope) => HTMLElement | undefined;
11
+ export declare const getDisabledThumbIndices: (ctx: Scope) => Set<number>;
12
+ export declare const getHiddenInputEl: (ctx: Scope, index: number) => HTMLInputElement | null;
13
+ export declare const getControlEl: (ctx: Scope) => HTMLElement | null;
14
+ export declare const getPointValue: (params: Params<SliderSchema>, point: Point) => number | undefined;
15
+ export declare const dispatchChangeEvent: (ctx: Scope, value: number[]) => void;
@@ -1,30 +1,15 @@
1
- import { Scope, Params } from '@zag-js/core';
2
- import { Point } from '@zag-js/types';
3
- import { SliderSchema } from './slider.types.js';
4
-
5
- declare const getRootId: (ctx: Scope) => any;
6
- declare const getThumbId: (ctx: Scope, index: number) => any;
7
- declare const getHiddenInputId: (ctx: Scope, index: number) => any;
8
- declare const getControlId: (ctx: Scope) => any;
9
- declare const getTrackId: (ctx: Scope) => any;
10
- declare const getRangeId: (ctx: Scope) => any;
11
- declare const getLabelId: (ctx: Scope) => any;
12
- declare const getValueTextId: (ctx: Scope) => any;
13
- declare const getMarkerId: (ctx: Scope, value: number) => any;
14
- declare const getRootEl: (ctx: Scope) => HTMLElement | null;
15
- declare const getThumbEl: (ctx: Scope, index: number) => HTMLElement | null;
16
- declare const getThumbEls: (ctx: Scope) => HTMLElement[];
17
- declare const getFirstThumbEl: (ctx: Scope) => HTMLElement;
18
- declare const getHiddenInputEl: (ctx: Scope, index: number) => HTMLInputElement | null;
19
- declare const getControlEl: (ctx: Scope) => HTMLElement | null;
20
- declare const getRangeEl: (ctx: Scope) => HTMLElement | null;
21
- declare const getPointValue: (params: Params<SliderSchema>, point: Point) => number | undefined;
22
- declare const dispatchChangeEvent: (ctx: Scope, value: number[]) => void;
23
- declare const getOffsetRect: (el: HTMLElement | undefined) => {
24
- left: number;
25
- top: number;
26
- width: number;
27
- height: number;
28
- };
29
-
30
- export { dispatchChangeEvent, getControlEl, getControlId, getFirstThumbEl, getHiddenInputEl, getHiddenInputId, getLabelId, getMarkerId, getOffsetRect, getPointValue, getRangeEl, getRangeId, getRootEl, getRootId, getThumbEl, getThumbEls, getThumbId, getTrackId, getValueTextId };
1
+ import { SliderSchema } from "./slider.types.js";
2
+ import { Point } from "@zag-js/types";
3
+ import { Params, Scope } from "@zag-js/core";
4
+ export declare const getHiddenInputId: (ctx: Scope, index: number) => any;
5
+ export declare const getLabelId: (ctx: Scope) => any;
6
+ export declare const getRootEl: (ctx: Scope) => HTMLElement | null;
7
+ export declare const getThumbEl: (ctx: Scope, index: number) => HTMLElement | null;
8
+ export declare const getThumbEls: (ctx: Scope) => HTMLElement[];
9
+ export declare const isThumbDisabled: (el: Element | null | undefined) => boolean;
10
+ export declare const getFirstEnabledThumbEl: (ctx: Scope) => HTMLElement | undefined;
11
+ export declare const getDisabledThumbIndices: (ctx: Scope) => Set<number>;
12
+ export declare const getHiddenInputEl: (ctx: Scope, index: number) => HTMLInputElement | null;
13
+ export declare const getControlEl: (ctx: Scope) => HTMLElement | null;
14
+ export declare const getPointValue: (params: Params<SliderSchema>, point: Point) => number | undefined;
15
+ export declare const dispatchChangeEvent: (ctx: Scope, value: number[]) => void;
@@ -1,145 +1,60 @@
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/slider.dom.ts
21
- var slider_dom_exports = {};
22
- __export(slider_dom_exports, {
23
- dispatchChangeEvent: () => dispatchChangeEvent,
24
- getControlEl: () => getControlEl,
25
- getControlId: () => getControlId,
26
- getFirstThumbEl: () => getFirstThumbEl,
27
- getHiddenInputEl: () => getHiddenInputEl,
28
- getHiddenInputId: () => getHiddenInputId,
29
- getLabelId: () => getLabelId,
30
- getMarkerId: () => getMarkerId,
31
- getOffsetRect: () => getOffsetRect,
32
- getPointValue: () => getPointValue,
33
- getRangeEl: () => getRangeEl,
34
- getRangeId: () => getRangeId,
35
- getRootEl: () => getRootEl,
36
- getRootId: () => getRootId,
37
- getThumbEl: () => getThumbEl,
38
- getThumbEls: () => getThumbEls,
39
- getThumbId: () => getThumbId,
40
- getTrackId: () => getTrackId,
41
- getValueTextId: () => getValueTextId
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
42
4
  });
43
- module.exports = __toCommonJS(slider_dom_exports);
44
- var import_dom_query = require("@zag-js/dom-query");
45
- var import_utils = require("@zag-js/utils");
46
- var import_slider = require("./slider.anatomy.js");
47
- var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
48
- var getThumbId = (ctx, index) => ctx.ids?.thumb?.(index) ?? `${ctx.id}:thumb:${index}`;
49
- var getHiddenInputId = (ctx, index) => ctx.ids?.hiddenInput?.(index) ?? `${ctx.id}:input:${index}`;
50
- var getControlId = (ctx) => ctx.ids?.control ?? `${ctx.id}:control`;
51
- var getTrackId = (ctx) => ctx.ids?.track ?? `${ctx.id}:track`;
52
- var getRangeId = (ctx) => ctx.ids?.range ?? `${ctx.id}:range`;
53
- var getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
54
- var getValueTextId = (ctx) => ctx.ids?.valueText ?? `${ctx.id}:value-text`;
55
- var getMarkerId = (ctx, value) => ctx.ids?.marker?.(value) ?? `${ctx.id}:marker:${value}`;
56
- var getRootEl = (ctx) => ctx.query(ctx.selector(import_slider.parts.root));
57
- var getThumbEl = (ctx, index) => ctx.query(`${ctx.selector(import_slider.parts.thumb)}[data-index="${index}"]`);
58
- var getThumbEls = (ctx) => ctx.queryAll(ctx.selector(import_slider.parts.thumb));
59
- var getFirstThumbEl = (ctx) => getThumbEls(ctx)[0];
60
- var getHiddenInputEl = (ctx, index) => ctx.getById(getHiddenInputId(ctx, index));
61
- var getControlEl = (ctx) => ctx.query(ctx.selector(import_slider.parts.control));
62
- var getRangeEl = (ctx) => ctx.query(ctx.selector(import_slider.parts.range));
63
- var getThumbInset = (thumbSize, thumbAlignment, orientation) => {
64
- const isContain = thumbAlignment === "contain";
65
- const isVertical = orientation === "vertical";
66
- return isContain ? (isVertical ? thumbSize?.height ?? 0 : thumbSize?.width ?? 0) / 2 : 0;
5
+ const require_slider_anatomy = require("./slider.anatomy.js");
6
+ const require_slider_utils = require("./slider.utils.js");
7
+ let _zag_js_dom_query = require("@zag-js/dom-query");
8
+ let _zag_js_utils = require("@zag-js/utils");
9
+ // src/slider.dom.ts
10
+ const getHiddenInputId = (ctx, index) => ctx.ids?.hiddenInput?.(index) ?? `${ctx.id}:input:${index}`;
11
+ const getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
12
+ const getRootEl = (ctx) => ctx.query(ctx.selector(require_slider_anatomy.parts.root));
13
+ const getThumbEl = (ctx, index) => ctx.query(`${ctx.selector(require_slider_anatomy.parts.thumb)}[data-index="${index}"]`);
14
+ const getThumbEls = (ctx) => ctx.queryAll(ctx.selector(require_slider_anatomy.parts.thumb));
15
+ const isThumbDisabled = (el) => !!el?.hasAttribute("data-disabled");
16
+ const getFirstEnabledThumbEl = (ctx) => getThumbEls(ctx).find((el) => !isThumbDisabled(el));
17
+ const getDisabledThumbIndices = (ctx) => {
18
+ const indices = /* @__PURE__ */ new Set();
19
+ for (const el of getThumbEls(ctx)) if (isThumbDisabled(el)) indices.add(Number(el.getAttribute("data-index")));
20
+ return indices;
67
21
  };
68
- var getPointValue = (params, point) => {
69
- const { context, prop, scope, refs } = params;
70
- const controlEl = getControlEl(scope);
71
- if (!controlEl) return;
72
- const offset = refs.get("thumbDragOffset");
73
- const adjustedPoint = {
74
- x: point.x - (offset?.x ?? 0),
75
- y: point.y - (offset?.y ?? 0)
76
- };
77
- const thumbInset = getThumbInset(context.get("thumbSize"), prop("thumbAlignment"), prop("orientation"));
78
- const relativePoint = getRelativePointWithInset(adjustedPoint, controlEl, thumbInset);
79
- const percent = relativePoint.getPercentValue({
80
- orientation: prop("orientation"),
81
- dir: prop("dir"),
82
- inverted: { y: true }
83
- });
84
- return (0, import_utils.getPercentValue)(percent, prop("min"), prop("max"), prop("step"));
22
+ const getHiddenInputEl = (ctx, index) => ctx.getById(getHiddenInputId(ctx, index));
23
+ const getControlEl = (ctx) => ctx.query(ctx.selector(require_slider_anatomy.parts.control));
24
+ const getPointValue = (params, point) => {
25
+ const { prop, scope, refs } = params;
26
+ const controlEl = getControlEl(scope);
27
+ if (!controlEl) return;
28
+ const offset = refs.get("thumbDragOffset");
29
+ const rect = controlEl.getBoundingClientRect();
30
+ const inset = require_slider_utils.getThumbExtent(params) / 2;
31
+ let percent;
32
+ if (prop("orientation") === "vertical") {
33
+ const length = rect.height - inset * 2;
34
+ percent = length > 0 ? 1 - (0, _zag_js_utils.clampPercent)((point.y - (offset?.y ?? 0) - rect.top - inset) / length) : 0;
35
+ } else {
36
+ const length = rect.width - inset * 2;
37
+ const x = length > 0 ? (0, _zag_js_utils.clampPercent)((point.x - (offset?.x ?? 0) - rect.left - inset) / length) : 0;
38
+ percent = prop("dir") === "rtl" ? 1 - x : x;
39
+ }
40
+ return (0, _zag_js_utils.getPercentValue)(percent, prop("min"), prop("max"), prop("step"));
85
41
  };
86
- function getRelativePointWithInset(point, element, inset) {
87
- const { left, top, width, height } = element.getBoundingClientRect();
88
- const effectiveWidth = width - inset * 2;
89
- const effectiveHeight = height - inset * 2;
90
- const effectiveLeft = left + inset;
91
- const effectiveTop = top + inset;
92
- const offset = {
93
- x: point.x - effectiveLeft,
94
- y: point.y - effectiveTop
95
- };
96
- const percent = {
97
- x: effectiveWidth > 0 ? (0, import_utils.clampPercent)(offset.x / effectiveWidth) : 0,
98
- y: effectiveHeight > 0 ? (0, import_utils.clampPercent)(offset.y / effectiveHeight) : 0
99
- };
100
- function getPercentValue2(options = {}) {
101
- const { dir = "ltr", orientation = "horizontal", inverted } = options;
102
- const invertX = typeof inverted === "object" ? inverted.x : inverted;
103
- const invertY = typeof inverted === "object" ? inverted.y : inverted;
104
- if (orientation === "horizontal") {
105
- return dir === "rtl" || invertX ? 1 - percent.x : percent.x;
106
- }
107
- return invertY ? 1 - percent.y : percent.y;
108
- }
109
- return { offset, percent, getPercentValue: getPercentValue2 };
110
- }
111
- var dispatchChangeEvent = (ctx, value) => {
112
- value.forEach((value2, index) => {
113
- const inputEl = getHiddenInputEl(ctx, index);
114
- if (!inputEl) return;
115
- (0, import_dom_query.dispatchInputValueEvent)(inputEl, { value: value2 });
116
- });
42
+ const dispatchChangeEvent = (ctx, value) => {
43
+ value.forEach((value, index) => {
44
+ const inputEl = getHiddenInputEl(ctx, index);
45
+ if (!inputEl) return;
46
+ (0, _zag_js_dom_query.dispatchInputValueEvent)(inputEl, { value });
47
+ });
117
48
  };
118
- var getOffsetRect = (el) => ({
119
- left: el?.offsetLeft ?? 0,
120
- top: el?.offsetTop ?? 0,
121
- width: el?.offsetWidth ?? 0,
122
- height: el?.offsetHeight ?? 0
123
- });
124
- // Annotate the CommonJS export names for ESM import in node:
125
- 0 && (module.exports = {
126
- dispatchChangeEvent,
127
- getControlEl,
128
- getControlId,
129
- getFirstThumbEl,
130
- getHiddenInputEl,
131
- getHiddenInputId,
132
- getLabelId,
133
- getMarkerId,
134
- getOffsetRect,
135
- getPointValue,
136
- getRangeEl,
137
- getRangeId,
138
- getRootEl,
139
- getRootId,
140
- getThumbEl,
141
- getThumbEls,
142
- getThumbId,
143
- getTrackId,
144
- getValueTextId
145
- });
49
+ exports.dispatchChangeEvent = dispatchChangeEvent;
50
+ exports.getControlEl = getControlEl;
51
+ exports.getDisabledThumbIndices = getDisabledThumbIndices;
52
+ exports.getFirstEnabledThumbEl = getFirstEnabledThumbEl;
53
+ exports.getHiddenInputEl = getHiddenInputEl;
54
+ exports.getHiddenInputId = getHiddenInputId;
55
+ exports.getLabelId = getLabelId;
56
+ exports.getPointValue = getPointValue;
57
+ exports.getRootEl = getRootEl;
58
+ exports.getThumbEl = getThumbEl;
59
+ exports.getThumbEls = getThumbEls;
60
+ exports.isThumbDisabled = isThumbDisabled;
@@ -1,102 +1,45 @@
1
- // src/slider.dom.ts
1
+ import { parts } from "./slider.anatomy.mjs";
2
+ import { getThumbExtent } from "./slider.utils.mjs";
2
3
  import { dispatchInputValueEvent } from "@zag-js/dom-query";
3
4
  import { clampPercent, getPercentValue } from "@zag-js/utils";
4
- import { parts } from "./slider.anatomy.mjs";
5
- var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
6
- var getThumbId = (ctx, index) => ctx.ids?.thumb?.(index) ?? `${ctx.id}:thumb:${index}`;
7
- var getHiddenInputId = (ctx, index) => ctx.ids?.hiddenInput?.(index) ?? `${ctx.id}:input:${index}`;
8
- var getControlId = (ctx) => ctx.ids?.control ?? `${ctx.id}:control`;
9
- var getTrackId = (ctx) => ctx.ids?.track ?? `${ctx.id}:track`;
10
- var getRangeId = (ctx) => ctx.ids?.range ?? `${ctx.id}:range`;
11
- var getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
12
- var getValueTextId = (ctx) => ctx.ids?.valueText ?? `${ctx.id}:value-text`;
13
- var getMarkerId = (ctx, value) => ctx.ids?.marker?.(value) ?? `${ctx.id}:marker:${value}`;
14
- var getRootEl = (ctx) => ctx.query(ctx.selector(parts.root));
15
- var getThumbEl = (ctx, index) => ctx.query(`${ctx.selector(parts.thumb)}[data-index="${index}"]`);
16
- var getThumbEls = (ctx) => ctx.queryAll(ctx.selector(parts.thumb));
17
- var getFirstThumbEl = (ctx) => getThumbEls(ctx)[0];
18
- var getHiddenInputEl = (ctx, index) => ctx.getById(getHiddenInputId(ctx, index));
19
- var getControlEl = (ctx) => ctx.query(ctx.selector(parts.control));
20
- var getRangeEl = (ctx) => ctx.query(ctx.selector(parts.range));
21
- var getThumbInset = (thumbSize, thumbAlignment, orientation) => {
22
- const isContain = thumbAlignment === "contain";
23
- const isVertical = orientation === "vertical";
24
- return isContain ? (isVertical ? thumbSize?.height ?? 0 : thumbSize?.width ?? 0) / 2 : 0;
25
- };
26
- var getPointValue = (params, point) => {
27
- const { context, prop, scope, refs } = params;
28
- const controlEl = getControlEl(scope);
29
- if (!controlEl) return;
30
- const offset = refs.get("thumbDragOffset");
31
- const adjustedPoint = {
32
- x: point.x - (offset?.x ?? 0),
33
- y: point.y - (offset?.y ?? 0)
34
- };
35
- const thumbInset = getThumbInset(context.get("thumbSize"), prop("thumbAlignment"), prop("orientation"));
36
- const relativePoint = getRelativePointWithInset(adjustedPoint, controlEl, thumbInset);
37
- const percent = relativePoint.getPercentValue({
38
- orientation: prop("orientation"),
39
- dir: prop("dir"),
40
- inverted: { y: true }
41
- });
42
- return getPercentValue(percent, prop("min"), prop("max"), prop("step"));
5
+ // src/slider.dom.ts
6
+ const getHiddenInputId = (ctx, index) => ctx.ids?.hiddenInput?.(index) ?? `${ctx.id}:input:${index}`;
7
+ const getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
8
+ const getRootEl = (ctx) => ctx.query(ctx.selector(parts.root));
9
+ const getThumbEl = (ctx, index) => ctx.query(`${ctx.selector(parts.thumb)}[data-index="${index}"]`);
10
+ const getThumbEls = (ctx) => ctx.queryAll(ctx.selector(parts.thumb));
11
+ const isThumbDisabled = (el) => !!el?.hasAttribute("data-disabled");
12
+ const getFirstEnabledThumbEl = (ctx) => getThumbEls(ctx).find((el) => !isThumbDisabled(el));
13
+ const getDisabledThumbIndices = (ctx) => {
14
+ const indices = /* @__PURE__ */ new Set();
15
+ for (const el of getThumbEls(ctx)) if (isThumbDisabled(el)) indices.add(Number(el.getAttribute("data-index")));
16
+ return indices;
43
17
  };
44
- function getRelativePointWithInset(point, element, inset) {
45
- const { left, top, width, height } = element.getBoundingClientRect();
46
- const effectiveWidth = width - inset * 2;
47
- const effectiveHeight = height - inset * 2;
48
- const effectiveLeft = left + inset;
49
- const effectiveTop = top + inset;
50
- const offset = {
51
- x: point.x - effectiveLeft,
52
- y: point.y - effectiveTop
53
- };
54
- const percent = {
55
- x: effectiveWidth > 0 ? clampPercent(offset.x / effectiveWidth) : 0,
56
- y: effectiveHeight > 0 ? clampPercent(offset.y / effectiveHeight) : 0
57
- };
58
- function getPercentValue2(options = {}) {
59
- const { dir = "ltr", orientation = "horizontal", inverted } = options;
60
- const invertX = typeof inverted === "object" ? inverted.x : inverted;
61
- const invertY = typeof inverted === "object" ? inverted.y : inverted;
62
- if (orientation === "horizontal") {
63
- return dir === "rtl" || invertX ? 1 - percent.x : percent.x;
64
- }
65
- return invertY ? 1 - percent.y : percent.y;
66
- }
67
- return { offset, percent, getPercentValue: getPercentValue2 };
68
- }
69
- var dispatchChangeEvent = (ctx, value) => {
70
- value.forEach((value2, index) => {
71
- const inputEl = getHiddenInputEl(ctx, index);
72
- if (!inputEl) return;
73
- dispatchInputValueEvent(inputEl, { value: value2 });
74
- });
18
+ const getHiddenInputEl = (ctx, index) => ctx.getById(getHiddenInputId(ctx, index));
19
+ const getControlEl = (ctx) => ctx.query(ctx.selector(parts.control));
20
+ const getPointValue = (params, point) => {
21
+ const { prop, scope, refs } = params;
22
+ const controlEl = getControlEl(scope);
23
+ if (!controlEl) return;
24
+ const offset = refs.get("thumbDragOffset");
25
+ const rect = controlEl.getBoundingClientRect();
26
+ const inset = getThumbExtent(params) / 2;
27
+ let percent;
28
+ if (prop("orientation") === "vertical") {
29
+ const length = rect.height - inset * 2;
30
+ percent = length > 0 ? 1 - clampPercent((point.y - (offset?.y ?? 0) - rect.top - inset) / length) : 0;
31
+ } else {
32
+ const length = rect.width - inset * 2;
33
+ const x = length > 0 ? clampPercent((point.x - (offset?.x ?? 0) - rect.left - inset) / length) : 0;
34
+ percent = prop("dir") === "rtl" ? 1 - x : x;
35
+ }
36
+ return getPercentValue(percent, prop("min"), prop("max"), prop("step"));
75
37
  };
76
- var getOffsetRect = (el) => ({
77
- left: el?.offsetLeft ?? 0,
78
- top: el?.offsetTop ?? 0,
79
- width: el?.offsetWidth ?? 0,
80
- height: el?.offsetHeight ?? 0
81
- });
82
- export {
83
- dispatchChangeEvent,
84
- getControlEl,
85
- getControlId,
86
- getFirstThumbEl,
87
- getHiddenInputEl,
88
- getHiddenInputId,
89
- getLabelId,
90
- getMarkerId,
91
- getOffsetRect,
92
- getPointValue,
93
- getRangeEl,
94
- getRangeId,
95
- getRootEl,
96
- getRootId,
97
- getThumbEl,
98
- getThumbEls,
99
- getThumbId,
100
- getTrackId,
101
- getValueTextId
38
+ const dispatchChangeEvent = (ctx, value) => {
39
+ value.forEach((value, index) => {
40
+ const inputEl = getHiddenInputEl(ctx, index);
41
+ if (!inputEl) return;
42
+ dispatchInputValueEvent(inputEl, { value });
43
+ });
102
44
  };
45
+ export { dispatchChangeEvent, getControlEl, getDisabledThumbIndices, getFirstEnabledThumbEl, getHiddenInputEl, getHiddenInputId, getLabelId, getPointValue, getRootEl, getThumbEl, getThumbEls, isThumbDisabled };
@@ -1,7 +1,2 @@
1
- import * as _zag_js_core from '@zag-js/core';
2
- import { SliderSchema } from './slider.types.mjs';
3
- import '@zag-js/types';
4
-
5
- declare const machine: _zag_js_core.Machine<SliderSchema>;
6
-
7
- export { machine };
1
+ import { SliderSchema } from "./slider.types.mjs";
2
+ export declare const machine: import("@zag-js/core").Machine<SliderSchema>;
@@ -1,7 +1,2 @@
1
- import * as _zag_js_core from '@zag-js/core';
2
- import { SliderSchema } from './slider.types.js';
3
- import '@zag-js/types';
4
-
5
- declare const machine: _zag_js_core.Machine<SliderSchema>;
6
-
7
- export { machine };
1
+ import { SliderSchema } from "./slider.types.js";
2
+ export declare const machine: import("@zag-js/core").Machine<SliderSchema>;