@zag-js/slider 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.
- 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 +371 -351
- package/dist/slider.connect.mjs +366 -330
- package/dist/slider.dom.d.mts +27 -30
- package/dist/slider.dom.d.ts +27 -30
- package/dist/slider.dom.js +93 -137
- package/dist/slider.dom.mjs +70 -93
- package/dist/slider.machine.d.mts +2 -7
- package/dist/slider.machine.d.ts +2 -7
- package/dist/slider.machine.js +322 -367
- package/dist/slider.machine.mjs +318 -351
- package/dist/slider.props.d.mts +7 -12
- package/dist/slider.props.d.ts +7 -12
- package/dist/slider.props.js +45 -73
- package/dist/slider.props.mjs +36 -43
- package/dist/slider.style.d.mts +15 -17
- package/dist/slider.style.d.ts +15 -17
- package/dist/slider.style.js +126 -156
- package/dist/slider.style.mjs +114 -123
- package/dist/slider.types.d.mts +307 -309
- package/dist/slider.types.d.ts +307 -309
- package/dist/slider.types.js +4 -18
- package/dist/slider.types.mjs +1 -0
- package/dist/slider.utils.d.mts +18 -21
- package/dist/slider.utils.d.ts +18 -21
- package/dist/slider.utils.js +144 -168
- package/dist/slider.utils.mjs +132 -135
- package/package.json +8 -8
package/dist/slider.props.d.mts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const splitThumbProps: <Props extends ThumbProps>(props: Props) => [ThumbProps, Omit<Props, keyof ThumbProps>];
|
|
9
|
-
declare const markerProps: "value"[];
|
|
10
|
-
declare const splitMarkerProps: <Props extends MarkerProps>(props: Props) => [MarkerProps, Omit<Props, "value">];
|
|
11
|
-
|
|
12
|
-
export { markerProps, props, splitMarkerProps, splitProps, splitThumbProps, thumbProps };
|
|
1
|
+
import { MarkerProps, SliderProps, ThumbProps } from "./slider.types.mjs";
|
|
2
|
+
export declare const props: (keyof SliderProps)[];
|
|
3
|
+
export declare const splitProps: <Props extends Partial<SliderProps>>(props: Props) => [Partial<SliderProps>, Omit<Props, keyof SliderProps>];
|
|
4
|
+
export declare const thumbProps: (keyof ThumbProps)[];
|
|
5
|
+
export declare const splitThumbProps: <Props extends ThumbProps>(props: Props) => [ThumbProps, Omit<Props, keyof ThumbProps>];
|
|
6
|
+
export declare const markerProps: "value"[];
|
|
7
|
+
export declare const splitMarkerProps: <Props extends MarkerProps>(props: Props) => [MarkerProps, Omit<Props, "value">];
|
package/dist/slider.props.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const splitThumbProps: <Props extends ThumbProps>(props: Props) => [ThumbProps, Omit<Props, keyof ThumbProps>];
|
|
9
|
-
declare const markerProps: "value"[];
|
|
10
|
-
declare const splitMarkerProps: <Props extends MarkerProps>(props: Props) => [MarkerProps, Omit<Props, "value">];
|
|
11
|
-
|
|
12
|
-
export { markerProps, props, splitMarkerProps, splitProps, splitThumbProps, thumbProps };
|
|
1
|
+
import { MarkerProps, SliderProps, ThumbProps } from "./slider.types.js";
|
|
2
|
+
export declare const props: (keyof SliderProps)[];
|
|
3
|
+
export declare const splitProps: <Props extends Partial<SliderProps>>(props: Props) => [Partial<SliderProps>, Omit<Props, keyof SliderProps>];
|
|
4
|
+
export declare const thumbProps: (keyof ThumbProps)[];
|
|
5
|
+
export declare const splitThumbProps: <Props extends ThumbProps>(props: Props) => [ThumbProps, Omit<Props, keyof ThumbProps>];
|
|
6
|
+
export declare const markerProps: "value"[];
|
|
7
|
+
export declare const splitMarkerProps: <Props extends MarkerProps>(props: Props) => [MarkerProps, Omit<Props, "value">];
|
package/dist/slider.props.js
CHANGED
|
@@ -1,75 +1,47 @@
|
|
|
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.props.ts
|
|
21
|
-
var slider_props_exports = {};
|
|
22
|
-
__export(slider_props_exports, {
|
|
23
|
-
markerProps: () => markerProps,
|
|
24
|
-
props: () => props,
|
|
25
|
-
splitMarkerProps: () => splitMarkerProps,
|
|
26
|
-
splitProps: () => splitProps,
|
|
27
|
-
splitThumbProps: () => splitThumbProps,
|
|
28
|
-
thumbProps: () => thumbProps
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
29
4
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
5
|
+
let _zag_js_utils = require("@zag-js/utils");
|
|
6
|
+
let _zag_js_types = require("@zag-js/types");
|
|
7
|
+
// src/slider.props.ts
|
|
8
|
+
const props = (0, _zag_js_types.createProps)()([
|
|
9
|
+
"aria-label",
|
|
10
|
+
"aria-labelledby",
|
|
11
|
+
"dir",
|
|
12
|
+
"disabled",
|
|
13
|
+
"form",
|
|
14
|
+
"getAriaValueText",
|
|
15
|
+
"getRootNode",
|
|
16
|
+
"id",
|
|
17
|
+
"ids",
|
|
18
|
+
"invalid",
|
|
19
|
+
"largeStep",
|
|
20
|
+
"max",
|
|
21
|
+
"min",
|
|
22
|
+
"minStepsBetweenThumbs",
|
|
23
|
+
"name",
|
|
24
|
+
"onFocusChange",
|
|
25
|
+
"onValueChange",
|
|
26
|
+
"onValueChangeEnd",
|
|
27
|
+
"orientation",
|
|
28
|
+
"origin",
|
|
29
|
+
"readOnly",
|
|
30
|
+
"step",
|
|
31
|
+
"thumbAlignment",
|
|
32
|
+
"thumbCollisionBehavior",
|
|
33
|
+
"thumbSize",
|
|
34
|
+
"value",
|
|
35
|
+
"defaultValue"
|
|
61
36
|
]);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
splitThumbProps,
|
|
74
|
-
thumbProps
|
|
75
|
-
});
|
|
37
|
+
const splitProps = (0, _zag_js_utils.createSplitProps)(props);
|
|
38
|
+
const thumbProps = (0, _zag_js_types.createProps)()(["index", "name"]);
|
|
39
|
+
const splitThumbProps = (0, _zag_js_utils.createSplitProps)(thumbProps);
|
|
40
|
+
const markerProps = (0, _zag_js_types.createProps)()(["value"]);
|
|
41
|
+
const splitMarkerProps = (0, _zag_js_utils.createSplitProps)(markerProps);
|
|
42
|
+
exports.markerProps = markerProps;
|
|
43
|
+
exports.props = props;
|
|
44
|
+
exports.splitMarkerProps = splitMarkerProps;
|
|
45
|
+
exports.splitProps = splitProps;
|
|
46
|
+
exports.splitThumbProps = splitThumbProps;
|
|
47
|
+
exports.thumbProps = thumbProps;
|
package/dist/slider.props.mjs
CHANGED
|
@@ -1,45 +1,38 @@
|
|
|
1
|
-
// src/slider.props.ts
|
|
2
|
-
import { createProps } from "@zag-js/types";
|
|
3
1
|
import { createSplitProps } from "@zag-js/utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import { createProps } from "@zag-js/types";
|
|
3
|
+
// src/slider.props.ts
|
|
4
|
+
const props = createProps()([
|
|
5
|
+
"aria-label",
|
|
6
|
+
"aria-labelledby",
|
|
7
|
+
"dir",
|
|
8
|
+
"disabled",
|
|
9
|
+
"form",
|
|
10
|
+
"getAriaValueText",
|
|
11
|
+
"getRootNode",
|
|
12
|
+
"id",
|
|
13
|
+
"ids",
|
|
14
|
+
"invalid",
|
|
15
|
+
"largeStep",
|
|
16
|
+
"max",
|
|
17
|
+
"min",
|
|
18
|
+
"minStepsBetweenThumbs",
|
|
19
|
+
"name",
|
|
20
|
+
"onFocusChange",
|
|
21
|
+
"onValueChange",
|
|
22
|
+
"onValueChangeEnd",
|
|
23
|
+
"orientation",
|
|
24
|
+
"origin",
|
|
25
|
+
"readOnly",
|
|
26
|
+
"step",
|
|
27
|
+
"thumbAlignment",
|
|
28
|
+
"thumbCollisionBehavior",
|
|
29
|
+
"thumbSize",
|
|
30
|
+
"value",
|
|
31
|
+
"defaultValue"
|
|
32
32
|
]);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
markerProps,
|
|
40
|
-
props,
|
|
41
|
-
splitMarkerProps,
|
|
42
|
-
splitProps,
|
|
43
|
-
splitThumbProps,
|
|
44
|
-
thumbProps
|
|
45
|
-
};
|
|
33
|
+
const splitProps = createSplitProps(props);
|
|
34
|
+
const thumbProps = createProps()(["index", "name"]);
|
|
35
|
+
const splitThumbProps = createSplitProps(thumbProps);
|
|
36
|
+
const markerProps = createProps()(["value"]);
|
|
37
|
+
const splitMarkerProps = createSplitProps(markerProps);
|
|
38
|
+
export { markerProps, props, splitMarkerProps, splitProps, splitThumbProps, thumbProps };
|
package/dist/slider.style.d.mts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { SliderSchema } from "./slider.types.mjs";
|
|
2
|
+
import { Params } from "@zag-js/core";
|
|
3
|
+
import { Style } from "@zag-js/types";
|
|
5
4
|
type Ctx = Params<SliderSchema>;
|
|
6
|
-
declare function getRangeOffsets(params: Pick<Ctx, "prop" | "computed">): {
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export declare function getRangeOffsets(params: Pick<Ctx, "prop" | "computed">): {
|
|
6
|
+
start: string;
|
|
7
|
+
end: string;
|
|
9
8
|
};
|
|
10
|
-
declare function getRangeStyle(params: Pick<Ctx, "computed">): Style;
|
|
11
|
-
declare function getThumbOffset(params: Pick<Ctx, "computed" | "context" | "prop">, value: number): string;
|
|
12
|
-
declare function getVisibility(params: Pick<Ctx, "computed" | "prop">): "hidden" | "visible";
|
|
13
|
-
declare function getThumbStyle(params: Pick<Ctx, "computed" | "context" | "prop">, index: number): Style;
|
|
14
|
-
declare function getControlStyle(): Style;
|
|
15
|
-
declare function getRootStyle(params: Pick<Ctx, "context" | "computed" | "prop">): Style;
|
|
16
|
-
declare function getMarkerStyle(params: Pick<Ctx, "computed" | "context" | "prop">, value: number): Style;
|
|
17
|
-
declare function getMarkerGroupStyle(): Style;
|
|
18
|
-
|
|
19
|
-
export { getControlStyle, getMarkerGroupStyle, getMarkerStyle, getRangeOffsets, getRangeStyle, getRootStyle, getThumbOffset, getThumbStyle, getVisibility };
|
|
9
|
+
export declare function getRangeStyle(params: Pick<Ctx, "computed">): Style;
|
|
10
|
+
export declare function getThumbOffset(params: Pick<Ctx, "computed" | "context" | "prop">, value: number): string;
|
|
11
|
+
export declare function getVisibility(params: Pick<Ctx, "computed" | "prop">): "hidden" | "visible";
|
|
12
|
+
export declare function getThumbStyle(params: Pick<Ctx, "computed" | "context" | "prop">, index: number): Style;
|
|
13
|
+
export declare function getControlStyle(): Style;
|
|
14
|
+
export declare function getRootStyle(params: Pick<Ctx, "context" | "computed" | "prop">): Style;
|
|
15
|
+
export declare function getMarkerStyle(params: Pick<Ctx, "computed" | "context" | "prop">, value: number): Style;
|
|
16
|
+
export declare function getMarkerGroupStyle(): Style;
|
|
17
|
+
export {};
|
package/dist/slider.style.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Style } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { SliderSchema } from "./slider.types.js";
|
|
2
|
+
import { Style } from "@zag-js/types";
|
|
3
|
+
import { Params } from "@zag-js/core";
|
|
5
4
|
type Ctx = Params<SliderSchema>;
|
|
6
|
-
declare function getRangeOffsets(params: Pick<Ctx, "prop" | "computed">): {
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export declare function getRangeOffsets(params: Pick<Ctx, "prop" | "computed">): {
|
|
6
|
+
start: string;
|
|
7
|
+
end: string;
|
|
9
8
|
};
|
|
10
|
-
declare function getRangeStyle(params: Pick<Ctx, "computed">): Style;
|
|
11
|
-
declare function getThumbOffset(params: Pick<Ctx, "computed" | "context" | "prop">, value: number): string;
|
|
12
|
-
declare function getVisibility(params: Pick<Ctx, "computed" | "prop">): "hidden" | "visible";
|
|
13
|
-
declare function getThumbStyle(params: Pick<Ctx, "computed" | "context" | "prop">, index: number): Style;
|
|
14
|
-
declare function getControlStyle(): Style;
|
|
15
|
-
declare function getRootStyle(params: Pick<Ctx, "context" | "computed" | "prop">): Style;
|
|
16
|
-
declare function getMarkerStyle(params: Pick<Ctx, "computed" | "context" | "prop">, value: number): Style;
|
|
17
|
-
declare function getMarkerGroupStyle(): Style;
|
|
18
|
-
|
|
19
|
-
export { getControlStyle, getMarkerGroupStyle, getMarkerStyle, getRangeOffsets, getRangeStyle, getRootStyle, getThumbOffset, getThumbStyle, getVisibility };
|
|
9
|
+
export declare function getRangeStyle(params: Pick<Ctx, "computed">): Style;
|
|
10
|
+
export declare function getThumbOffset(params: Pick<Ctx, "computed" | "context" | "prop">, value: number): string;
|
|
11
|
+
export declare function getVisibility(params: Pick<Ctx, "computed" | "prop">): "hidden" | "visible";
|
|
12
|
+
export declare function getThumbStyle(params: Pick<Ctx, "computed" | "context" | "prop">, index: number): Style;
|
|
13
|
+
export declare function getControlStyle(): Style;
|
|
14
|
+
export declare function getRootStyle(params: Pick<Ctx, "context" | "computed" | "prop">): Style;
|
|
15
|
+
export declare function getMarkerStyle(params: Pick<Ctx, "computed" | "context" | "prop">, value: number): Style;
|
|
16
|
+
export declare function getMarkerGroupStyle(): Style;
|
|
17
|
+
export {};
|
package/dist/slider.style.js
CHANGED
|
@@ -1,183 +1,153 @@
|
|
|
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.style.ts
|
|
21
|
-
var slider_style_exports = {};
|
|
22
|
-
__export(slider_style_exports, {
|
|
23
|
-
getControlStyle: () => getControlStyle,
|
|
24
|
-
getMarkerGroupStyle: () => getMarkerGroupStyle,
|
|
25
|
-
getMarkerStyle: () => getMarkerStyle,
|
|
26
|
-
getRangeOffsets: () => getRangeOffsets,
|
|
27
|
-
getRangeStyle: () => getRangeStyle,
|
|
28
|
-
getRootStyle: () => getRootStyle,
|
|
29
|
-
getThumbOffset: () => getThumbOffset,
|
|
30
|
-
getThumbStyle: () => getThumbStyle,
|
|
31
|
-
getVisibility: () => getVisibility
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
32
4
|
});
|
|
33
|
-
|
|
34
|
-
|
|
5
|
+
let _zag_js_utils = require("@zag-js/utils");
|
|
6
|
+
// src/slider.style.ts
|
|
35
7
|
function getBounds(value) {
|
|
36
|
-
|
|
37
|
-
const lastThumb = value[value.length - 1];
|
|
38
|
-
return [firstValue, lastThumb];
|
|
8
|
+
return [value[0], value[value.length - 1]];
|
|
39
9
|
}
|
|
40
10
|
function getRangeOffsets(params) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
11
|
+
const { prop, computed } = params;
|
|
12
|
+
const valuePercent = computed("valuePercent");
|
|
13
|
+
const [firstPercent, lastPercent] = getBounds(valuePercent);
|
|
14
|
+
if (valuePercent.length === 1) {
|
|
15
|
+
if (prop("origin") === "center") {
|
|
16
|
+
const isNegative = valuePercent[0] < 50;
|
|
17
|
+
return {
|
|
18
|
+
start: isNegative ? `${valuePercent[0]}%` : "50%",
|
|
19
|
+
end: isNegative ? "50%" : `${100 - valuePercent[0]}%`
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (prop("origin") === "end") return {
|
|
23
|
+
start: `${lastPercent}%`,
|
|
24
|
+
end: "0%"
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
start: "0%",
|
|
28
|
+
end: `${100 - lastPercent}%`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
start: `${firstPercent}%`,
|
|
33
|
+
end: `${100 - lastPercent}%`
|
|
34
|
+
};
|
|
57
35
|
}
|
|
58
36
|
function getRangeStyle(params) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
[isRtl ? "left" : "right"]: "var(--slider-range-end)"
|
|
73
|
-
};
|
|
37
|
+
const { computed } = params;
|
|
38
|
+
const isVertical = computed("isVertical");
|
|
39
|
+
const isRtl = computed("isRtl");
|
|
40
|
+
if (isVertical) return {
|
|
41
|
+
position: "absolute",
|
|
42
|
+
bottom: "var(--slider-range-start)",
|
|
43
|
+
top: "var(--slider-range-end)"
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
position: "absolute",
|
|
47
|
+
[isRtl ? "right" : "left"]: "var(--slider-range-start)",
|
|
48
|
+
[isRtl ? "left" : "right"]: "var(--slider-range-end)"
|
|
49
|
+
};
|
|
74
50
|
}
|
|
75
51
|
function getVerticalThumbOffset(params, value) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
52
|
+
const { context, prop } = params;
|
|
53
|
+
const { height = 0 } = context.get("thumbSize") ?? {};
|
|
54
|
+
const getValue = (0, _zag_js_utils.getValueTransformer)([prop("min"), prop("max")], [-height / 2, height / 2]);
|
|
55
|
+
return parseFloat(getValue(value).toFixed(2));
|
|
80
56
|
}
|
|
81
57
|
function getHorizontalThumbOffset(params, value) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return parseFloat(getValue(value).toFixed(2));
|
|
58
|
+
const { computed, context, prop } = params;
|
|
59
|
+
const { width = 0 } = context.get("thumbSize") ?? {};
|
|
60
|
+
if (computed("isRtl")) {
|
|
61
|
+
const getValue = (0, _zag_js_utils.getValueTransformer)([prop("max"), prop("min")], [-width / 2, width / 2]);
|
|
62
|
+
return -1 * parseFloat(getValue(value).toFixed(2));
|
|
63
|
+
}
|
|
64
|
+
const getValue = (0, _zag_js_utils.getValueTransformer)([prop("min"), prop("max")], [-width / 2, width / 2]);
|
|
65
|
+
return parseFloat(getValue(value).toFixed(2));
|
|
91
66
|
}
|
|
92
67
|
function getOffset(params, percent, value) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return `calc(${percent}% - ${offset}px)`;
|
|
68
|
+
const { computed, prop } = params;
|
|
69
|
+
if (prop("thumbAlignment") === "center") return `${percent}%`;
|
|
70
|
+
return `calc(${percent}% - ${computed("isVertical") ? getVerticalThumbOffset(params, value) : getHorizontalThumbOffset(params, value)}px)`;
|
|
97
71
|
}
|
|
98
72
|
function getThumbOffset(params, value) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return getOffset(params, percent, value);
|
|
73
|
+
const { prop } = params;
|
|
74
|
+
return getOffset(params, (0, _zag_js_utils.getValuePercent)(value, prop("min"), prop("max")) * 100, value);
|
|
102
75
|
}
|
|
103
76
|
function getVisibility(params) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
return visibility;
|
|
77
|
+
const { computed, prop } = params;
|
|
78
|
+
let visibility = "visible";
|
|
79
|
+
if (prop("thumbAlignment") === "contain" && !computed("hasMeasuredThumbSize")) visibility = "hidden";
|
|
80
|
+
return visibility;
|
|
110
81
|
}
|
|
111
82
|
function getThumbStyle(params, index) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
83
|
+
const { computed, context } = params;
|
|
84
|
+
const placementProp = computed("isVertical") ? "bottom" : "insetInlineStart";
|
|
85
|
+
const focusedIndex = context.get("focusedIndex");
|
|
86
|
+
return {
|
|
87
|
+
visibility: getVisibility(params),
|
|
88
|
+
position: "absolute",
|
|
89
|
+
transform: "var(--slider-thumb-transform)",
|
|
90
|
+
[placementProp]: `var(--slider-thumb-offset-${index})`,
|
|
91
|
+
zIndex: focusedIndex === index ? 1 : void 0
|
|
92
|
+
};
|
|
122
93
|
}
|
|
123
94
|
function getControlStyle() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
95
|
+
return {
|
|
96
|
+
touchAction: "none",
|
|
97
|
+
userSelect: "none",
|
|
98
|
+
WebkitUserSelect: "none",
|
|
99
|
+
position: "relative"
|
|
100
|
+
};
|
|
130
101
|
}
|
|
131
102
|
function getRootStyle(params) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
103
|
+
const { context, computed } = params;
|
|
104
|
+
const isVertical = computed("isVertical");
|
|
105
|
+
const isRtl = computed("isRtl");
|
|
106
|
+
const range = getRangeOffsets(params);
|
|
107
|
+
const thumbSize = context.get("thumbSize");
|
|
108
|
+
return {
|
|
109
|
+
...context.get("value").reduce((styles, value, index) => {
|
|
110
|
+
const offset = getThumbOffset(params, value);
|
|
111
|
+
return {
|
|
112
|
+
...styles,
|
|
113
|
+
[`--slider-thumb-offset-${index}`]: offset
|
|
114
|
+
};
|
|
115
|
+
}, {}),
|
|
116
|
+
"--slider-thumb-width": (0, _zag_js_utils.toPx)(thumbSize?.width),
|
|
117
|
+
"--slider-thumb-height": (0, _zag_js_utils.toPx)(thumbSize?.height),
|
|
118
|
+
"--slider-thumb-transform": isVertical ? "translateY(50%)" : isRtl ? "translateX(50%)" : "translateX(-50%)",
|
|
119
|
+
"--slider-range-start": range.start,
|
|
120
|
+
"--slider-range-end": range.end
|
|
121
|
+
};
|
|
149
122
|
}
|
|
150
123
|
function getMarkerStyle(params, value) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
124
|
+
const { computed } = params;
|
|
125
|
+
const isHorizontal = computed("isHorizontal");
|
|
126
|
+
const isRtl = computed("isRtl");
|
|
127
|
+
return {
|
|
128
|
+
visibility: getVisibility(params),
|
|
129
|
+
position: "absolute",
|
|
130
|
+
pointerEvents: "none",
|
|
131
|
+
[isHorizontal ? "insetInlineStart" : "bottom"]: getThumbOffset(params, value),
|
|
132
|
+
translate: "var(--translate-x) var(--translate-y)",
|
|
133
|
+
"--translate-x": isHorizontal ? isRtl ? "50%" : "-50%" : "0%",
|
|
134
|
+
"--translate-y": !isHorizontal ? "50%" : "0%"
|
|
135
|
+
};
|
|
163
136
|
}
|
|
164
137
|
function getMarkerGroupStyle() {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
138
|
+
return {
|
|
139
|
+
userSelect: "none",
|
|
140
|
+
WebkitUserSelect: "none",
|
|
141
|
+
pointerEvents: "none",
|
|
142
|
+
position: "relative"
|
|
143
|
+
};
|
|
171
144
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
getThumbStyle,
|
|
182
|
-
getVisibility
|
|
183
|
-
});
|
|
145
|
+
exports.getControlStyle = getControlStyle;
|
|
146
|
+
exports.getMarkerGroupStyle = getMarkerGroupStyle;
|
|
147
|
+
exports.getMarkerStyle = getMarkerStyle;
|
|
148
|
+
exports.getRangeOffsets = getRangeOffsets;
|
|
149
|
+
exports.getRangeStyle = getRangeStyle;
|
|
150
|
+
exports.getRootStyle = getRootStyle;
|
|
151
|
+
exports.getThumbOffset = getThumbOffset;
|
|
152
|
+
exports.getThumbStyle = getThumbStyle;
|
|
153
|
+
exports.getVisibility = getVisibility;
|