@zag-js/slider 0.10.2 → 0.10.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.ts +5 -8
- package/dist/index.js +10 -674
- package/dist/index.mjs +4 -20
- package/dist/slider.anatomy.d.ts +3 -6
- package/dist/slider.anatomy.js +10 -33
- package/dist/slider.anatomy.mjs +17 -8
- package/dist/slider.connect.d.ts +3 -7
- package/dist/slider.connect.js +72 -261
- package/dist/slider.connect.mjs +251 -9
- package/dist/slider.dom.d.ts +26 -30
- package/dist/slider.dom.js +14 -149
- package/dist/slider.dom.mjs +39 -7
- package/dist/slider.machine.d.ts +3 -7
- package/dist/slider.machine.js +27 -225
- package/dist/slider.machine.mjs +203 -9
- package/dist/slider.style.d.ts +5 -8
- package/dist/slider.style.js +12 -34
- package/dist/slider.style.mjs +112 -5
- package/dist/slider.types.d.ts +10 -12
- package/dist/slider.utils.d.ts +5 -10
- package/dist/slider.utils.js +13 -42
- package/dist/slider.utils.mjs +26 -12
- package/package.json +11 -16
- package/dist/chunk-3Y7IIPR5.mjs +0 -20
- package/dist/chunk-IJAAAKZQ.mjs +0 -115
- package/dist/chunk-NYN3VIY4.mjs +0 -44
- package/dist/chunk-OCT2YBMN.mjs +0 -212
- package/dist/chunk-T6GXNUP7.mjs +0 -265
- package/dist/chunk-YGFSMEUO.mjs +0 -34
- package/dist/slider.types.js +0 -18
- package/dist/slider.types.mjs +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
} from
|
|
4
|
-
|
|
5
|
-
anatomy
|
|
6
|
-
} from "./chunk-3Y7IIPR5.mjs";
|
|
7
|
-
import {
|
|
8
|
-
machine
|
|
9
|
-
} from "./chunk-OCT2YBMN.mjs";
|
|
10
|
-
import {
|
|
11
|
-
dom
|
|
12
|
-
} from "./chunk-NYN3VIY4.mjs";
|
|
13
|
-
import "./chunk-IJAAAKZQ.mjs";
|
|
14
|
-
import "./chunk-YGFSMEUO.mjs";
|
|
15
|
-
export {
|
|
16
|
-
anatomy,
|
|
17
|
-
connect,
|
|
18
|
-
machine,
|
|
19
|
-
dom as unstable__dom
|
|
20
|
-
};
|
|
1
|
+
export { anatomy } from './slider.anatomy.mjs';
|
|
2
|
+
export { connect } from './slider.connect.mjs';
|
|
3
|
+
export { dom as unstable__dom } from './slider.dom.mjs';
|
|
4
|
+
export { machine } from './slider.machine.mjs';
|
package/dist/slider.anatomy.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const parts: Record<"root" | "label" | "thumb" | "hiddenInput" | "output" | "track" | "range" | "control" | "markerGroup" | "marker", _zag_js_anatomy.AnatomyPart>;
|
|
5
|
-
|
|
6
|
-
export { anatomy, parts };
|
|
1
|
+
import { AnatomyInstance, AnatomyPart } from '@zag-js/anatomy';
|
|
2
|
+
export declare const anatomy: AnatomyInstance<"root" | "label" | "thumb" | "hiddenInput" | "output" | "track" | "range" | "control" | "markerGroup" | "marker">;
|
|
3
|
+
export declare const parts: Record<"root" | "label" | "thumb" | "hiddenInput" | "output" | "track" | "range" | "control" | "markerGroup" | "marker", AnatomyPart>;
|
package/dist/slider.anatomy.js
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(slider_anatomy_exports);
|
|
27
|
-
var import_anatomy = require("@zag-js/anatomy");
|
|
28
|
-
var anatomy = (0, import_anatomy.createAnatomy)("slider").parts(
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const anatomy$1 = require('@zag-js/anatomy');
|
|
6
|
+
|
|
7
|
+
const anatomy = anatomy$1.createAnatomy("slider").parts(
|
|
29
8
|
"root",
|
|
30
9
|
"label",
|
|
31
10
|
"thumb",
|
|
@@ -37,9 +16,7 @@ var anatomy = (0, import_anatomy.createAnatomy)("slider").parts(
|
|
|
37
16
|
"markerGroup",
|
|
38
17
|
"marker"
|
|
39
18
|
);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
parts
|
|
45
|
-
});
|
|
19
|
+
const parts = anatomy.build();
|
|
20
|
+
|
|
21
|
+
exports.anatomy = anatomy;
|
|
22
|
+
exports.parts = parts;
|
package/dist/slider.anatomy.mjs
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { createAnatomy } from '@zag-js/anatomy';
|
|
2
|
+
|
|
3
|
+
const anatomy = createAnatomy("slider").parts(
|
|
4
|
+
"root",
|
|
5
|
+
"label",
|
|
6
|
+
"thumb",
|
|
7
|
+
"hiddenInput",
|
|
8
|
+
"output",
|
|
9
|
+
"track",
|
|
10
|
+
"range",
|
|
11
|
+
"control",
|
|
12
|
+
"markerGroup",
|
|
13
|
+
"marker"
|
|
14
|
+
);
|
|
15
|
+
const parts = anatomy.build();
|
|
16
|
+
|
|
17
|
+
export { anatomy, parts };
|
package/dist/slider.connect.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
1
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
2
|
+
import type { Send, State } from "./slider.types";
|
|
3
|
+
export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
6
4
|
/**
|
|
7
5
|
* Whether the slider is focused.
|
|
8
6
|
*/
|
|
@@ -56,5 +54,3 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
|
|
|
56
54
|
value: number;
|
|
57
55
|
}): T["element"];
|
|
58
56
|
};
|
|
59
|
-
|
|
60
|
-
export { connect };
|
package/dist/slider.connect.js
CHANGED
|
@@ -1,200 +1,13 @@
|
|
|
1
|
-
|
|
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.connect.ts
|
|
21
|
-
var slider_connect_exports = {};
|
|
22
|
-
__export(slider_connect_exports, {
|
|
23
|
-
connect: () => connect
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(slider_connect_exports);
|
|
26
|
-
var import_dom_event2 = require("@zag-js/dom-event");
|
|
27
|
-
var import_dom_query2 = require("@zag-js/dom-query");
|
|
28
|
-
var import_numeric_range3 = require("@zag-js/numeric-range");
|
|
29
|
-
|
|
30
|
-
// src/slider.anatomy.ts
|
|
31
|
-
var import_anatomy = require("@zag-js/anatomy");
|
|
32
|
-
var anatomy = (0, import_anatomy.createAnatomy)("slider").parts(
|
|
33
|
-
"root",
|
|
34
|
-
"label",
|
|
35
|
-
"thumb",
|
|
36
|
-
"hiddenInput",
|
|
37
|
-
"output",
|
|
38
|
-
"track",
|
|
39
|
-
"range",
|
|
40
|
-
"control",
|
|
41
|
-
"markerGroup",
|
|
42
|
-
"marker"
|
|
43
|
-
);
|
|
44
|
-
var parts = anatomy.build();
|
|
1
|
+
'use strict';
|
|
45
2
|
|
|
46
|
-
|
|
47
|
-
var import_dom_event = require("@zag-js/dom-event");
|
|
48
|
-
var import_dom_query = require("@zag-js/dom-query");
|
|
49
|
-
var import_form_utils = require("@zag-js/form-utils");
|
|
50
|
-
var import_numeric_range2 = require("@zag-js/numeric-range");
|
|
51
|
-
|
|
52
|
-
// src/slider.style.ts
|
|
53
|
-
var import_numeric_range = require("@zag-js/numeric-range");
|
|
54
|
-
function getVerticalThumbOffset(ctx) {
|
|
55
|
-
const { height = 0 } = ctx.thumbSize ?? {};
|
|
56
|
-
const getValue = (0, import_numeric_range.getValueTransformer)([ctx.min, ctx.max], [-height / 2, height / 2]);
|
|
57
|
-
return parseFloat(getValue(ctx.value).toFixed(2));
|
|
58
|
-
}
|
|
59
|
-
function getHorizontalThumbOffset(ctx) {
|
|
60
|
-
const { width = 0 } = ctx.thumbSize ?? {};
|
|
61
|
-
if (ctx.isRtl) {
|
|
62
|
-
const getValue2 = (0, import_numeric_range.getValueTransformer)([ctx.max, ctx.min], [-width * 1.5, -width / 2]);
|
|
63
|
-
return -1 * parseFloat(getValue2(ctx.value).toFixed(2));
|
|
64
|
-
}
|
|
65
|
-
const getValue = (0, import_numeric_range.getValueTransformer)([ctx.min, ctx.max], [-width / 2, width / 2]);
|
|
66
|
-
return parseFloat(getValue(ctx.value).toFixed(2));
|
|
67
|
-
}
|
|
68
|
-
function getThumbOffset(ctx) {
|
|
69
|
-
const percent = (0, import_numeric_range.getValuePercent)(ctx.value, ctx.min, ctx.max) * 100;
|
|
70
|
-
if (ctx.thumbAlignment === "center") {
|
|
71
|
-
return `${percent}%`;
|
|
72
|
-
}
|
|
73
|
-
const offset = ctx.isVertical ? getVerticalThumbOffset(ctx) : getHorizontalThumbOffset(ctx);
|
|
74
|
-
return `calc(${percent}% - ${offset}px)`;
|
|
75
|
-
}
|
|
76
|
-
function getVisibility(ctx) {
|
|
77
|
-
let visibility = "visible";
|
|
78
|
-
if (ctx.thumbAlignment === "contain" && !ctx.hasMeasuredThumbSize) {
|
|
79
|
-
visibility = "hidden";
|
|
80
|
-
}
|
|
81
|
-
return visibility;
|
|
82
|
-
}
|
|
83
|
-
function getThumbStyle(ctx) {
|
|
84
|
-
const placementProp = ctx.isVertical ? "bottom" : ctx.isRtl ? "right" : "left";
|
|
85
|
-
return {
|
|
86
|
-
visibility: getVisibility(ctx),
|
|
87
|
-
position: "absolute",
|
|
88
|
-
transform: "var(--slider-thumb-transform)",
|
|
89
|
-
[placementProp]: "var(--slider-thumb-offset)"
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
function getRangeOffsets(ctx) {
|
|
93
|
-
let start = "0%";
|
|
94
|
-
let end = `${100 - ctx.valuePercent}%`;
|
|
95
|
-
if (ctx.origin === "center") {
|
|
96
|
-
const isNegative = ctx.valuePercent < 50;
|
|
97
|
-
start = isNegative ? `${ctx.valuePercent}%` : "50%";
|
|
98
|
-
end = isNegative ? "50%" : end;
|
|
99
|
-
}
|
|
100
|
-
return { start, end };
|
|
101
|
-
}
|
|
102
|
-
function getRangeStyle(ctx) {
|
|
103
|
-
if (ctx.isVertical) {
|
|
104
|
-
return {
|
|
105
|
-
position: "absolute",
|
|
106
|
-
bottom: "var(--slider-range-start)",
|
|
107
|
-
top: "var(--slider-range-end)"
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
position: "absolute",
|
|
112
|
-
[ctx.isRtl ? "right" : "left"]: "var(--slider-range-start)",
|
|
113
|
-
[ctx.isRtl ? "left" : "right"]: "var(--slider-range-end)"
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function getControlStyle() {
|
|
117
|
-
return {
|
|
118
|
-
touchAction: "none",
|
|
119
|
-
userSelect: "none",
|
|
120
|
-
position: "relative"
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function getRootStyle(ctx) {
|
|
124
|
-
const range = getRangeOffsets(ctx);
|
|
125
|
-
return {
|
|
126
|
-
"--slider-thumb-transform": ctx.isVertical ? "translateY(50%)" : "translateX(-50%)",
|
|
127
|
-
"--slider-thumb-offset": getThumbOffset(ctx),
|
|
128
|
-
"--slider-range-start": range.start,
|
|
129
|
-
"--slider-range-end": range.end
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function getMarkerStyle(ctx, percent) {
|
|
133
|
-
return {
|
|
134
|
-
position: "absolute",
|
|
135
|
-
pointerEvents: "none",
|
|
136
|
-
[ctx.isHorizontal ? "left" : "bottom"]: `${(ctx.isRtl ? 1 - percent : percent) * 100}%`
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function getLabelStyle() {
|
|
140
|
-
return { userSelect: "none" };
|
|
141
|
-
}
|
|
142
|
-
function getTrackStyle() {
|
|
143
|
-
return { position: "relative" };
|
|
144
|
-
}
|
|
145
|
-
function getMarkerGroupStyle() {
|
|
146
|
-
return {
|
|
147
|
-
userSelect: "none",
|
|
148
|
-
pointerEvents: "none",
|
|
149
|
-
position: "relative"
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
var styles = {
|
|
153
|
-
getThumbOffset,
|
|
154
|
-
getControlStyle,
|
|
155
|
-
getThumbStyle,
|
|
156
|
-
getRangeStyle,
|
|
157
|
-
getRootStyle,
|
|
158
|
-
getMarkerStyle,
|
|
159
|
-
getLabelStyle,
|
|
160
|
-
getTrackStyle,
|
|
161
|
-
getMarkerGroupStyle
|
|
162
|
-
};
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
163
4
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
getControlId: (ctx) => ctx.ids?.control ?? `slider:${ctx.id}:control`,
|
|
170
|
-
getHiddenInputId: (ctx) => ctx.ids?.hiddenInput ?? `slider:${ctx.id}:input`,
|
|
171
|
-
getOutputId: (ctx) => ctx.ids?.output ?? `slider:${ctx.id}:output`,
|
|
172
|
-
getTrackId: (ctx) => ctx.ids?.track ?? `slider:${ctx.id}track`,
|
|
173
|
-
getRangeId: (ctx) => ctx.ids?.track ?? `slider:${ctx.id}:range`,
|
|
174
|
-
getLabelId: (ctx) => ctx.ids?.label ?? `slider:${ctx.id}:label`,
|
|
175
|
-
getMarkerId: (ctx, value) => `slider:${ctx.id}:marker:${value}`,
|
|
176
|
-
getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
|
|
177
|
-
getThumbEl: (ctx) => dom.getById(ctx, dom.getThumbId(ctx)),
|
|
178
|
-
getControlEl: (ctx) => dom.queryById(ctx, dom.getControlId(ctx)),
|
|
179
|
-
getHiddenInputEl: (ctx) => dom.getById(ctx, dom.getHiddenInputId(ctx)),
|
|
180
|
-
getValueFromPoint(ctx, point) {
|
|
181
|
-
const relativePoint = (0, import_dom_event.getRelativePoint)(point, dom.getControlEl(ctx));
|
|
182
|
-
const percent = relativePoint.getPercentValue({
|
|
183
|
-
orientation: ctx.orientation,
|
|
184
|
-
dir: ctx.dir,
|
|
185
|
-
inverted: { y: true }
|
|
186
|
-
});
|
|
187
|
-
return (0, import_numeric_range2.getPercentValue)(percent, ctx.min, ctx.max, ctx.step);
|
|
188
|
-
},
|
|
189
|
-
dispatchChangeEvent(ctx) {
|
|
190
|
-
const input = dom.getHiddenInputEl(ctx);
|
|
191
|
-
if (!input)
|
|
192
|
-
return;
|
|
193
|
-
(0, import_form_utils.dispatchInputValueEvent)(input, { value: ctx.value });
|
|
194
|
-
}
|
|
195
|
-
});
|
|
5
|
+
const domEvent = require('@zag-js/dom-event');
|
|
6
|
+
const domQuery = require('@zag-js/dom-query');
|
|
7
|
+
const numericRange = require('@zag-js/numeric-range');
|
|
8
|
+
const slider_anatomy = require('./slider.anatomy.js');
|
|
9
|
+
const slider_dom = require('./slider.dom.js');
|
|
196
10
|
|
|
197
|
-
// src/slider.connect.ts
|
|
198
11
|
function connect(state, send, normalize) {
|
|
199
12
|
const ariaLabel = state.context["aria-label"];
|
|
200
13
|
const ariaLabelledBy = state.context["aria-labelledby"];
|
|
@@ -205,10 +18,10 @@ function connect(state, send, normalize) {
|
|
|
205
18
|
const isInteractive = state.context.isInteractive;
|
|
206
19
|
const isInvalid = state.context.invalid;
|
|
207
20
|
function getPercentValueFn(percent) {
|
|
208
|
-
return
|
|
21
|
+
return numericRange.getPercentValue(percent, state.context.min, state.context.max, state.context.step);
|
|
209
22
|
}
|
|
210
23
|
function getValuePercentFn(value) {
|
|
211
|
-
return
|
|
24
|
+
return numericRange.getValuePercent(value, state.context.min, state.context.max);
|
|
212
25
|
}
|
|
213
26
|
return {
|
|
214
27
|
/**
|
|
@@ -226,7 +39,7 @@ function connect(state, send, normalize) {
|
|
|
226
39
|
/**
|
|
227
40
|
* The value of the slider as a percent.
|
|
228
41
|
*/
|
|
229
|
-
percent:
|
|
42
|
+
percent: numericRange.getValuePercent(state.context.value, state.context.min, state.context.max),
|
|
230
43
|
/**
|
|
231
44
|
* Function to set the value of the slider.
|
|
232
45
|
*/
|
|
@@ -245,7 +58,7 @@ function connect(state, send, normalize) {
|
|
|
245
58
|
* Function to focus the slider.
|
|
246
59
|
*/
|
|
247
60
|
focus() {
|
|
248
|
-
dom.getThumbEl(state.context)?.focus();
|
|
61
|
+
slider_dom.dom.getThumbEl(state.context)?.focus();
|
|
249
62
|
},
|
|
250
63
|
/**
|
|
251
64
|
* Function to increment the value of the slider by the step.
|
|
@@ -260,42 +73,42 @@ function connect(state, send, normalize) {
|
|
|
260
73
|
send("DECREMENT");
|
|
261
74
|
},
|
|
262
75
|
rootProps: normalize.element({
|
|
263
|
-
...parts.root.attrs,
|
|
264
|
-
"data-disabled":
|
|
265
|
-
"data-focus":
|
|
76
|
+
...slider_anatomy.parts.root.attrs,
|
|
77
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
78
|
+
"data-focus": domQuery.dataAttr(isFocused),
|
|
266
79
|
"data-orientation": state.context.orientation,
|
|
267
|
-
"data-invalid":
|
|
268
|
-
id: dom.getRootId(state.context),
|
|
80
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
81
|
+
id: slider_dom.dom.getRootId(state.context),
|
|
269
82
|
dir: state.context.dir,
|
|
270
|
-
style: dom.getRootStyle(state.context)
|
|
83
|
+
style: slider_dom.dom.getRootStyle(state.context)
|
|
271
84
|
}),
|
|
272
85
|
labelProps: normalize.label({
|
|
273
|
-
...parts.label.attrs,
|
|
274
|
-
"data-disabled":
|
|
275
|
-
"data-invalid":
|
|
276
|
-
"data-focus":
|
|
277
|
-
id: dom.getLabelId(state.context),
|
|
278
|
-
htmlFor: dom.getHiddenInputId(state.context),
|
|
86
|
+
...slider_anatomy.parts.label.attrs,
|
|
87
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
88
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
89
|
+
"data-focus": domQuery.dataAttr(isFocused),
|
|
90
|
+
id: slider_dom.dom.getLabelId(state.context),
|
|
91
|
+
htmlFor: slider_dom.dom.getHiddenInputId(state.context),
|
|
279
92
|
onClick(event) {
|
|
280
93
|
if (!isInteractive)
|
|
281
94
|
return;
|
|
282
95
|
event.preventDefault();
|
|
283
|
-
dom.getThumbEl(state.context)?.focus();
|
|
96
|
+
slider_dom.dom.getThumbEl(state.context)?.focus();
|
|
284
97
|
},
|
|
285
|
-
style: dom.getLabelStyle()
|
|
98
|
+
style: slider_dom.dom.getLabelStyle()
|
|
286
99
|
}),
|
|
287
100
|
thumbProps: normalize.element({
|
|
288
|
-
...parts.thumb.attrs,
|
|
289
|
-
id: dom.getThumbId(state.context),
|
|
290
|
-
"data-disabled":
|
|
101
|
+
...slider_anatomy.parts.thumb.attrs,
|
|
102
|
+
id: slider_dom.dom.getThumbId(state.context),
|
|
103
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
291
104
|
"data-orientation": state.context.orientation,
|
|
292
|
-
"data-focus":
|
|
105
|
+
"data-focus": domQuery.dataAttr(isFocused),
|
|
293
106
|
draggable: false,
|
|
294
|
-
"aria-invalid":
|
|
295
|
-
"data-invalid":
|
|
296
|
-
"aria-disabled":
|
|
107
|
+
"aria-invalid": domQuery.ariaAttr(isInvalid),
|
|
108
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
109
|
+
"aria-disabled": domQuery.ariaAttr(isDisabled),
|
|
297
110
|
"aria-label": ariaLabel,
|
|
298
|
-
"aria-labelledby": ariaLabel ? void 0 : ariaLabelledBy ?? dom.getLabelId(state.context),
|
|
111
|
+
"aria-labelledby": ariaLabel ? void 0 : ariaLabelledBy ?? slider_dom.dom.getLabelId(state.context),
|
|
299
112
|
"aria-orientation": state.context.orientation,
|
|
300
113
|
"aria-valuemax": state.context.max,
|
|
301
114
|
"aria-valuemin": state.context.min,
|
|
@@ -316,7 +129,7 @@ function connect(state, send, normalize) {
|
|
|
316
129
|
onKeyDown(event) {
|
|
317
130
|
if (!isInteractive)
|
|
318
131
|
return;
|
|
319
|
-
const step =
|
|
132
|
+
const step = domEvent.getEventStep(event) * state.context.step;
|
|
320
133
|
let prevent = true;
|
|
321
134
|
const keyMap = {
|
|
322
135
|
ArrowUp() {
|
|
@@ -348,7 +161,7 @@ function connect(state, send, normalize) {
|
|
|
348
161
|
send("END");
|
|
349
162
|
}
|
|
350
163
|
};
|
|
351
|
-
const key =
|
|
164
|
+
const key = domEvent.getEventKey(event, state.context);
|
|
352
165
|
const exec = keyMap[key];
|
|
353
166
|
if (!exec)
|
|
354
167
|
return;
|
|
@@ -357,88 +170,86 @@ function connect(state, send, normalize) {
|
|
|
357
170
|
event.preventDefault();
|
|
358
171
|
}
|
|
359
172
|
},
|
|
360
|
-
style: dom.getThumbStyle(state.context)
|
|
173
|
+
style: slider_dom.dom.getThumbStyle(state.context)
|
|
361
174
|
}),
|
|
362
175
|
hiddenInputProps: normalize.input({
|
|
363
|
-
...parts.hiddenInput.attrs,
|
|
176
|
+
...slider_anatomy.parts.hiddenInput.attrs,
|
|
364
177
|
type: "text",
|
|
365
178
|
defaultValue: state.context.value,
|
|
366
179
|
name: state.context.name,
|
|
367
180
|
form: state.context.form,
|
|
368
|
-
id: dom.getHiddenInputId(state.context),
|
|
181
|
+
id: slider_dom.dom.getHiddenInputId(state.context),
|
|
369
182
|
hidden: true
|
|
370
183
|
}),
|
|
371
184
|
outputProps: normalize.output({
|
|
372
|
-
...parts.output.attrs,
|
|
373
|
-
"data-disabled":
|
|
374
|
-
"data-invalid":
|
|
375
|
-
id: dom.getOutputId(state.context),
|
|
376
|
-
htmlFor: dom.getHiddenInputId(state.context),
|
|
185
|
+
...slider_anatomy.parts.output.attrs,
|
|
186
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
187
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
188
|
+
id: slider_dom.dom.getOutputId(state.context),
|
|
189
|
+
htmlFor: slider_dom.dom.getHiddenInputId(state.context),
|
|
377
190
|
"aria-live": "off"
|
|
378
191
|
}),
|
|
379
192
|
trackProps: normalize.element({
|
|
380
|
-
...parts.track.attrs,
|
|
381
|
-
id: dom.getTrackId(state.context),
|
|
382
|
-
"data-disabled":
|
|
383
|
-
"data-focus":
|
|
384
|
-
"data-invalid":
|
|
193
|
+
...slider_anatomy.parts.track.attrs,
|
|
194
|
+
id: slider_dom.dom.getTrackId(state.context),
|
|
195
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
196
|
+
"data-focus": domQuery.dataAttr(isFocused),
|
|
197
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
385
198
|
"data-orientation": state.context.orientation,
|
|
386
|
-
style: dom.getTrackStyle()
|
|
199
|
+
style: slider_dom.dom.getTrackStyle()
|
|
387
200
|
}),
|
|
388
201
|
rangeProps: normalize.element({
|
|
389
|
-
...parts.range.attrs,
|
|
390
|
-
id: dom.getRangeId(state.context),
|
|
391
|
-
"data-focus":
|
|
392
|
-
"data-invalid":
|
|
393
|
-
"data-disabled":
|
|
202
|
+
...slider_anatomy.parts.range.attrs,
|
|
203
|
+
id: slider_dom.dom.getRangeId(state.context),
|
|
204
|
+
"data-focus": domQuery.dataAttr(isFocused),
|
|
205
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
206
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
394
207
|
"data-orientation": state.context.orientation,
|
|
395
|
-
style: dom.getRangeStyle(state.context)
|
|
208
|
+
style: slider_dom.dom.getRangeStyle(state.context)
|
|
396
209
|
}),
|
|
397
210
|
controlProps: normalize.element({
|
|
398
|
-
...parts.control.attrs,
|
|
399
|
-
id: dom.getControlId(state.context),
|
|
400
|
-
"data-disabled":
|
|
401
|
-
"data-invalid":
|
|
211
|
+
...slider_anatomy.parts.control.attrs,
|
|
212
|
+
id: slider_dom.dom.getControlId(state.context),
|
|
213
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
214
|
+
"data-invalid": domQuery.dataAttr(isInvalid),
|
|
402
215
|
"data-orientation": state.context.orientation,
|
|
403
|
-
"data-focus":
|
|
216
|
+
"data-focus": domQuery.dataAttr(isFocused),
|
|
404
217
|
onPointerDown(event) {
|
|
405
218
|
if (!isInteractive)
|
|
406
219
|
return;
|
|
407
|
-
const evt =
|
|
408
|
-
if (!
|
|
220
|
+
const evt = domEvent.getNativeEvent(event);
|
|
221
|
+
if (!domEvent.isLeftClick(evt) || domEvent.isModifiedEvent(evt))
|
|
409
222
|
return;
|
|
410
|
-
const point =
|
|
223
|
+
const point = domEvent.getEventPoint(evt);
|
|
411
224
|
send({ type: "POINTER_DOWN", point });
|
|
412
225
|
event.preventDefault();
|
|
413
226
|
event.stopPropagation();
|
|
414
227
|
},
|
|
415
|
-
style: dom.getControlStyle()
|
|
228
|
+
style: slider_dom.dom.getControlStyle()
|
|
416
229
|
}),
|
|
417
230
|
markerGroupProps: normalize.element({
|
|
418
|
-
...parts.markerGroup.attrs,
|
|
231
|
+
...slider_anatomy.parts.markerGroup.attrs,
|
|
419
232
|
role: "presentation",
|
|
420
233
|
"aria-hidden": true,
|
|
421
234
|
"data-orientation": state.context.orientation,
|
|
422
|
-
style: dom.getMarkerGroupStyle()
|
|
235
|
+
style: slider_dom.dom.getMarkerGroupStyle()
|
|
423
236
|
}),
|
|
424
237
|
getMarkerProps({ value }) {
|
|
425
238
|
const percent = getValuePercentFn(value);
|
|
426
|
-
const style = dom.getMarkerStyle(state.context, percent);
|
|
239
|
+
const style = slider_dom.dom.getMarkerStyle(state.context, percent);
|
|
427
240
|
const markerState = value > state.context.value ? "over-value" : value < state.context.value ? "under-value" : "at-value";
|
|
428
241
|
return normalize.element({
|
|
429
|
-
...parts.marker.attrs,
|
|
430
|
-
id: dom.getMarkerId(state.context, value),
|
|
242
|
+
...slider_anatomy.parts.marker.attrs,
|
|
243
|
+
id: slider_dom.dom.getMarkerId(state.context, value),
|
|
431
244
|
role: "presentation",
|
|
432
245
|
"data-orientation": state.context.orientation,
|
|
433
246
|
"data-value": value,
|
|
434
|
-
"data-disabled":
|
|
247
|
+
"data-disabled": domQuery.dataAttr(isDisabled),
|
|
435
248
|
"data-state": markerState,
|
|
436
249
|
style
|
|
437
250
|
});
|
|
438
251
|
}
|
|
439
252
|
};
|
|
440
253
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
connect
|
|
444
|
-
});
|
|
254
|
+
|
|
255
|
+
exports.connect = connect;
|