@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.
- package/dist/index.d.mts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +16 -38
- package/dist/index.mjs +2 -7
- package/dist/slider.anatomy.d.mts +2 -6
- package/dist/slider.anatomy.d.ts +2 -6
- package/dist/slider.anatomy.js +8 -44
- package/dist/slider.anatomy.mjs +4 -18
- package/dist/slider.connect.d.mts +3 -7
- package/dist/slider.connect.d.ts +3 -7
- package/dist/slider.connect.js +403 -372
- package/dist/slider.connect.mjs +399 -352
- package/dist/slider.dom.d.mts +15 -30
- package/dist/slider.dom.d.ts +15 -30
- package/dist/slider.dom.js +56 -141
- package/dist/slider.dom.mjs +40 -97
- package/dist/slider.machine.d.mts +2 -7
- package/dist/slider.machine.d.ts +2 -7
- package/dist/slider.machine.js +372 -368
- package/dist/slider.machine.mjs +368 -352
- package/dist/slider.props.d.mts +7 -12
- package/dist/slider.props.d.ts +7 -12
- package/dist/slider.props.js +49 -73
- package/dist/slider.props.mjs +40 -43
- package/dist/slider.style.d.mts +15 -17
- package/dist/slider.style.d.ts +15 -17
- package/dist/slider.style.js +103 -157
- package/dist/slider.style.mjs +91 -124
- package/dist/slider.types.d.mts +402 -377
- package/dist/slider.types.d.ts +402 -377
- package/dist/slider.types.js +4 -18
- package/dist/slider.types.mjs +1 -0
- package/dist/slider.utils.d.mts +23 -27
- package/dist/slider.utils.d.ts +23 -27
- package/dist/slider.utils.js +196 -205
- package/dist/slider.utils.mjs +180 -176
- package/package.json +7 -7
package/dist/slider.dom.d.mts
CHANGED
|
@@ -1,30 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
declare const
|
|
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 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;
|
package/dist/slider.dom.d.ts
CHANGED
|
@@ -1,30 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Point } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
declare const
|
|
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 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;
|
package/dist/slider.dom.js
CHANGED
|
@@ -1,145 +1,60 @@
|
|
|
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/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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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;
|
package/dist/slider.dom.mjs
CHANGED
|
@@ -1,102 +1,45 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
|
2
|
-
|
|
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>;
|
package/dist/slider.machine.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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>;
|