@sprawlify/primitives 0.0.111 → 0.0.113
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/collection.d.cts +2 -2
- package/dist/collection.d.mts +2 -2
- package/dist/{date-utils-Dz9DZPcZ.cjs → date-utils-B-dqorZV.cjs} +48 -13
- package/dist/{date-utils-BqOQP2-U.mjs → date-utils-BdeeOQRI.mjs} +43 -14
- package/dist/date-utils.cjs +2 -1
- package/dist/date-utils.d.cts +6 -5
- package/dist/date-utils.d.mts +2 -2
- package/dist/date-utils.mjs +2 -2
- package/dist/{focus-visible-GXKbbuiq.mjs → focus-visible-BuLf8M9F.mjs} +10 -9
- package/dist/{focus-visible-JdJXqMic.cjs → focus-visible-Co_9bW09.cjs} +14 -7
- package/dist/focus-visible.cjs +2 -1
- package/dist/focus-visible.d.cts +2 -1
- package/dist/focus-visible.d.mts +2 -1
- package/dist/focus-visible.mjs +2 -2
- package/dist/{index-6cEVkXqi.d.mts → index-BfUngXif.d.mts} +6 -5
- package/dist/{list-collection-Cjgbx_9l.d.cts → list-collection-B_8BN0XB.d.cts} +1 -1
- package/dist/{list-collection-IF510iNl.d.mts → list-collection-DkRA5LOq.d.mts} +1 -1
- package/dist/machines/accordion/index.d.cts +1 -1
- package/dist/machines/accordion/index.d.mts +1 -1
- package/dist/machines/angle-slider/index.cjs +64 -24
- package/dist/machines/angle-slider/index.d.cts +1 -1
- package/dist/machines/angle-slider/index.d.mts +1 -1
- package/dist/machines/angle-slider/index.mjs +65 -25
- package/dist/machines/carousel/index.d.cts +1 -1
- package/dist/machines/carousel/index.d.mts +1 -1
- package/dist/machines/cascade-select/index.cjs +50 -20
- package/dist/machines/cascade-select/index.d.cts +13 -10
- package/dist/machines/cascade-select/index.d.mts +13 -10
- package/dist/machines/cascade-select/index.mjs +50 -20
- package/dist/machines/checkbox/index.cjs +1 -1
- package/dist/machines/checkbox/index.mjs +1 -1
- package/dist/machines/clipboard/index.d.cts +1 -1
- package/dist/machines/clipboard/index.d.mts +1 -1
- package/dist/machines/collapsible/index.d.cts +1 -1
- package/dist/machines/collapsible/index.d.mts +1 -1
- package/dist/machines/color-picker/index.d.cts +1 -1
- package/dist/machines/color-picker/index.d.mts +1 -1
- package/dist/machines/combobox/index.cjs +21 -13
- package/dist/machines/combobox/index.d.cts +2 -2
- package/dist/machines/combobox/index.d.mts +2 -2
- package/dist/machines/combobox/index.mjs +21 -13
- package/dist/machines/date-picker/index.cjs +46 -25
- package/dist/machines/date-picker/index.d.cts +3 -2
- package/dist/machines/date-picker/index.d.mts +4 -3
- package/dist/machines/date-picker/index.mjs +47 -26
- package/dist/machines/dialog/index.d.cts +1 -1
- package/dist/machines/dialog/index.d.mts +1 -1
- package/dist/machines/drawer/index.d.cts +1 -1
- package/dist/machines/drawer/index.d.mts +1 -1
- package/dist/machines/dropdown-menu/index.cjs +7 -2
- package/dist/machines/dropdown-menu/index.d.cts +1 -1
- package/dist/machines/dropdown-menu/index.d.mts +1 -1
- package/dist/machines/dropdown-menu/index.mjs +7 -2
- package/dist/machines/editable/index.d.cts +1 -1
- package/dist/machines/editable/index.d.mts +1 -1
- package/dist/machines/file-upload/index.d.cts +1 -1
- package/dist/machines/file-upload/index.d.mts +1 -1
- package/dist/machines/floating-panel/index.d.cts +1 -1
- package/dist/machines/floating-panel/index.d.mts +1 -1
- package/dist/machines/hover-card/index.d.cts +1 -1
- package/dist/machines/hover-card/index.d.mts +1 -1
- package/dist/machines/listbox/index.cjs +1 -1
- package/dist/machines/listbox/index.d.cts +3 -3
- package/dist/machines/listbox/index.d.mts +3 -3
- package/dist/machines/listbox/index.mjs +1 -1
- package/dist/machines/marquee/index.d.cts +3 -3
- package/dist/machines/marquee/index.d.mts +3 -3
- package/dist/machines/navigation-menu/index.d.cts +1 -1
- package/dist/machines/navigation-menu/index.d.mts +1 -1
- package/dist/machines/number-input/index.d.cts +1 -1
- package/dist/machines/number-input/index.d.mts +1 -1
- package/dist/machines/password-input/index.d.cts +1 -1
- package/dist/machines/password-input/index.d.mts +1 -1
- package/dist/machines/popover/index.d.cts +1 -1
- package/dist/machines/popover/index.d.mts +1 -1
- package/dist/machines/progress/index.d.cts +1 -1
- package/dist/machines/progress/index.d.mts +1 -1
- package/dist/machines/radio-group/index.cjs +1 -1
- package/dist/machines/radio-group/index.d.cts +1 -1
- package/dist/machines/radio-group/index.d.mts +1 -1
- package/dist/machines/radio-group/index.mjs +1 -1
- package/dist/machines/scroll-area/index.d.cts +1 -1
- package/dist/machines/scroll-area/index.d.mts +1 -1
- package/dist/machines/select/index.cjs +7 -2
- package/dist/machines/select/index.d.cts +2 -2
- package/dist/machines/select/index.d.mts +2 -2
- package/dist/machines/select/index.mjs +7 -2
- package/dist/machines/slider/index.d.cts +1 -1
- package/dist/machines/slider/index.d.mts +1 -1
- package/dist/machines/steps/index.d.cts +1 -1
- package/dist/machines/steps/index.d.mts +1 -1
- package/dist/machines/switch/index.cjs +1 -1
- package/dist/machines/switch/index.d.cts +1 -1
- package/dist/machines/switch/index.d.mts +1 -1
- package/dist/machines/switch/index.mjs +1 -1
- package/dist/machines/tabs/index.d.cts +1 -1
- package/dist/machines/tabs/index.d.mts +1 -1
- package/dist/machines/tags-input/index.d.cts +1 -1
- package/dist/machines/tags-input/index.d.mts +1 -1
- package/dist/machines/timer/index.d.cts +1 -1
- package/dist/machines/timer/index.d.mts +1 -1
- package/dist/machines/toast/index.d.cts +3 -3
- package/dist/machines/toast/index.d.mts +3 -3
- package/dist/machines/tooltip/index.cjs +6 -6
- package/dist/machines/tooltip/index.d.cts +1 -1
- package/dist/machines/tooltip/index.d.mts +1 -1
- package/dist/machines/tooltip/index.mjs +7 -7
- package/dist/machines/tour/index.d.cts +1 -1
- package/dist/machines/tour/index.d.mts +1 -1
- package/dist/machines/tree-view/index.d.cts +1 -1
- package/dist/machines/tree-view/index.d.mts +1 -1
- package/dist/{selection-BmS2RDMq.d.cts → selection-Bb_ZSVxe.d.cts} +1 -1
- package/dist/{selection-6urf-c8j.d.mts → selection-DdNvrKbj.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -19,11 +19,24 @@ const getLabelId = (ctx) => ctx.ids?.label ?? `angle-slider:${ctx.id}:label`;
|
|
|
19
19
|
const getHiddenInputEl = (ctx) => ctx.getById(getHiddenInputId(ctx));
|
|
20
20
|
const getControlEl = (ctx) => ctx.getById(getControlId(ctx));
|
|
21
21
|
const getThumbEl = (ctx) => ctx.getById(getThumbId(ctx));
|
|
22
|
-
function
|
|
23
|
-
|
|
22
|
+
function mirrorAngle(angle) {
|
|
23
|
+
return (360 - angle) % 360;
|
|
24
|
+
}
|
|
25
|
+
function getAngle(controlEl, point, angularOffset, dir) {
|
|
26
|
+
let angle = require_rect_utils.getPointAngle(require_rect_utils.createRect(controlEl.getBoundingClientRect()), point);
|
|
24
27
|
if (angularOffset != null) return angle - angularOffset;
|
|
28
|
+
if (dir === "rtl") angle = mirrorAngle(angle);
|
|
25
29
|
return angle;
|
|
26
30
|
}
|
|
31
|
+
function getPointerValue(controlEl, point, angularOffset, value, dir) {
|
|
32
|
+
if (angularOffset == null) return getAngle(controlEl, point, null, dir);
|
|
33
|
+
const angle = getAngle(controlEl, point);
|
|
34
|
+
const clickAngle = value + angularOffset;
|
|
35
|
+
return dir === "rtl" ? value + clickAngle - angle : angle - angularOffset;
|
|
36
|
+
}
|
|
37
|
+
function getDisplayAngle(value, dir) {
|
|
38
|
+
return dir === "rtl" ? mirrorAngle(value) : value;
|
|
39
|
+
}
|
|
27
40
|
function clampAngle(degree) {
|
|
28
41
|
return Math.min(Math.max(degree, 0), 359);
|
|
29
42
|
}
|
|
@@ -43,6 +56,8 @@ function connect(service, normalize) {
|
|
|
43
56
|
const dragging = state.matches("dragging");
|
|
44
57
|
const value = context.get("value");
|
|
45
58
|
const valueAsDegree = computed("valueAsDegree");
|
|
59
|
+
const dir = prop("dir");
|
|
60
|
+
const displayAngle = getDisplayAngle(value, dir);
|
|
46
61
|
const disabled = prop("disabled");
|
|
47
62
|
const invalid = prop("invalid");
|
|
48
63
|
const readOnly = prop("readOnly");
|
|
@@ -63,12 +78,13 @@ function connect(service, normalize) {
|
|
|
63
78
|
return normalize.element({
|
|
64
79
|
...parts.root.attrs,
|
|
65
80
|
id: getRootId(scope),
|
|
81
|
+
dir: prop("dir"),
|
|
66
82
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
67
83
|
"data-invalid": require_dom_query.dataAttr(invalid),
|
|
68
84
|
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
69
85
|
style: {
|
|
70
86
|
"--value": value,
|
|
71
|
-
"--angle":
|
|
87
|
+
"--angle": `${displayAngle}deg`
|
|
72
88
|
}
|
|
73
89
|
});
|
|
74
90
|
},
|
|
@@ -77,6 +93,7 @@ function connect(service, normalize) {
|
|
|
77
93
|
...parts.label.attrs,
|
|
78
94
|
id: getLabelId(scope),
|
|
79
95
|
htmlFor: getHiddenInputId(scope),
|
|
96
|
+
dir: prop("dir"),
|
|
80
97
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
81
98
|
"data-invalid": require_dom_query.dataAttr(invalid),
|
|
82
99
|
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
@@ -92,7 +109,8 @@ function connect(service, normalize) {
|
|
|
92
109
|
type: "hidden",
|
|
93
110
|
value,
|
|
94
111
|
name: prop("name"),
|
|
95
|
-
id: getHiddenInputId(scope)
|
|
112
|
+
id: getHiddenInputId(scope),
|
|
113
|
+
dir: prop("dir")
|
|
96
114
|
});
|
|
97
115
|
},
|
|
98
116
|
getControlProps() {
|
|
@@ -100,6 +118,7 @@ function connect(service, normalize) {
|
|
|
100
118
|
...parts.control.attrs,
|
|
101
119
|
role: "presentation",
|
|
102
120
|
id: getControlId(scope),
|
|
121
|
+
dir: prop("dir"),
|
|
103
122
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
104
123
|
"data-invalid": require_dom_query.dataAttr(invalid),
|
|
105
124
|
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
@@ -132,6 +151,7 @@ function connect(service, normalize) {
|
|
|
132
151
|
...parts.thumb.attrs,
|
|
133
152
|
id: getThumbId(scope),
|
|
134
153
|
role: "slider",
|
|
154
|
+
dir: prop("dir"),
|
|
135
155
|
"aria-label": ariaLabel,
|
|
136
156
|
"aria-labelledby": ariaLabelledBy ?? getLabelId(scope),
|
|
137
157
|
"aria-valuemax": 360,
|
|
@@ -150,32 +170,44 @@ function connect(service, normalize) {
|
|
|
150
170
|
onKeyDown(event) {
|
|
151
171
|
if (!interactive) return;
|
|
152
172
|
const step = require_dom_query.getEventStep(event) * prop("step");
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
173
|
+
const exec = {
|
|
174
|
+
ArrowLeft() {
|
|
175
|
+
send({
|
|
176
|
+
type: "THUMB.ARROW_DEC",
|
|
177
|
+
step
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
ArrowUp() {
|
|
157
181
|
send({
|
|
158
182
|
type: "THUMB.ARROW_DEC",
|
|
159
183
|
step
|
|
160
184
|
});
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
case "ArrowDown":
|
|
164
|
-
event.preventDefault();
|
|
185
|
+
},
|
|
186
|
+
ArrowRight() {
|
|
165
187
|
send({
|
|
166
188
|
type: "THUMB.ARROW_INC",
|
|
167
189
|
step
|
|
168
190
|
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
191
|
+
},
|
|
192
|
+
ArrowDown() {
|
|
193
|
+
send({
|
|
194
|
+
type: "THUMB.ARROW_INC",
|
|
195
|
+
step
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
Home() {
|
|
172
199
|
send({ type: "THUMB.HOME" });
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
event.preventDefault();
|
|
200
|
+
},
|
|
201
|
+
End() {
|
|
176
202
|
send({ type: "THUMB.END" });
|
|
177
|
-
|
|
178
|
-
|
|
203
|
+
}
|
|
204
|
+
}[require_dom_query.getEventKey(event, {
|
|
205
|
+
dir: prop("dir"),
|
|
206
|
+
orientation: "horizontal"
|
|
207
|
+
})];
|
|
208
|
+
if (exec) {
|
|
209
|
+
exec(event);
|
|
210
|
+
event.preventDefault();
|
|
179
211
|
}
|
|
180
212
|
},
|
|
181
213
|
style: { rotate: `var(--angle)` }
|
|
@@ -184,25 +216,32 @@ function connect(service, normalize) {
|
|
|
184
216
|
getValueTextProps() {
|
|
185
217
|
return normalize.element({
|
|
186
218
|
...parts.valueText.attrs,
|
|
187
|
-
id: getValueTextId(scope)
|
|
219
|
+
id: getValueTextId(scope),
|
|
220
|
+
dir: prop("dir")
|
|
188
221
|
});
|
|
189
222
|
},
|
|
190
223
|
getMarkerGroupProps() {
|
|
191
|
-
return normalize.element({
|
|
224
|
+
return normalize.element({
|
|
225
|
+
...parts.markerGroup.attrs,
|
|
226
|
+
dir: prop("dir")
|
|
227
|
+
});
|
|
192
228
|
},
|
|
193
229
|
getMarkerProps(props) {
|
|
194
230
|
let markerState;
|
|
195
231
|
if (props.value < value) markerState = "under-value";
|
|
196
232
|
else if (props.value > value) markerState = "over-value";
|
|
197
233
|
else markerState = "at-value";
|
|
234
|
+
const markerDisplayAngle = getDisplayAngle(props.value, dir);
|
|
198
235
|
return normalize.element({
|
|
199
236
|
...parts.marker.attrs,
|
|
237
|
+
dir: prop("dir"),
|
|
200
238
|
"data-value": props.value,
|
|
201
239
|
"data-state": markerState,
|
|
202
240
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
203
241
|
style: {
|
|
204
242
|
"--marker-value": props.value,
|
|
205
|
-
|
|
243
|
+
"--marker-display-value": markerDisplayAngle,
|
|
244
|
+
rotate: `calc(var(--marker-display-value) * 1deg)`
|
|
206
245
|
}
|
|
207
246
|
});
|
|
208
247
|
}
|
|
@@ -313,7 +352,8 @@ const machine = require_core.createMachine({
|
|
|
313
352
|
const controlEl = getControlEl(scope);
|
|
314
353
|
if (!controlEl) return;
|
|
315
354
|
const angularOffset = refs.get("thumbDragOffset");
|
|
316
|
-
const
|
|
355
|
+
const value = context.get("value");
|
|
356
|
+
const deg = getPointerValue(controlEl, event.point, angularOffset, value, prop("dir"));
|
|
317
357
|
context.set("value", constrainAngle(deg, prop("step")));
|
|
318
358
|
},
|
|
319
359
|
setValueToMin({ context }) {
|
|
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-B24gMT
|
|
|
3
3
|
import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-CLRsezW5.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/machines/angle-slider/angle-slider.anatomy.d.ts
|
|
6
|
-
declare const anatomy: AnatomyInstance<"root" | "label" | "
|
|
6
|
+
declare const anatomy: AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "track" | "control" | "markerGroup" | "marker">;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/machines/angle-slider/angle-slider.types.d.ts
|
|
9
9
|
interface ValueChangeDetails {
|
|
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-DUM9rz
|
|
|
3
3
|
import { b as NormalizeProps, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BVFlU3b9.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/machines/angle-slider/angle-slider.anatomy.d.ts
|
|
6
|
-
declare const anatomy: AnatomyInstance<"root" | "label" | "
|
|
6
|
+
declare const anatomy: AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "track" | "control" | "markerGroup" | "marker">;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/machines/angle-slider/angle-slider.types.d.ts
|
|
9
9
|
interface ValueChangeDetails {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as createAnatomy } from "../../create-anatomy-Dr0evdYy.mjs";
|
|
2
|
-
import { E as trackPointerMove, St as isLeftClick, W as raf, ct as setElementValue, gt as getNativeEvent, mt as getEventStep, pt as getEventPoint, xn as dataAttr } from "../../dom-query-BFuRs3l4.mjs";
|
|
2
|
+
import { E as trackPointerMove, St as isLeftClick, W as raf, ct as setElementValue, ft as getEventKey, gt as getNativeEvent, mt as getEventStep, pt as getEventPoint, xn as dataAttr } from "../../dom-query-BFuRs3l4.mjs";
|
|
3
3
|
import { B as snapValueToStep, u as createSplitProps } from "../../utils-VVoZ_v29.mjs";
|
|
4
4
|
import { a as createMachine } from "../../core-Ci9Yu6QI.mjs";
|
|
5
5
|
import { R as createRect, q as getPointAngle } from "../../rect-utils-B5xqFvKC.mjs";
|
|
@@ -18,11 +18,24 @@ const getLabelId = (ctx) => ctx.ids?.label ?? `angle-slider:${ctx.id}:label`;
|
|
|
18
18
|
const getHiddenInputEl = (ctx) => ctx.getById(getHiddenInputId(ctx));
|
|
19
19
|
const getControlEl = (ctx) => ctx.getById(getControlId(ctx));
|
|
20
20
|
const getThumbEl = (ctx) => ctx.getById(getThumbId(ctx));
|
|
21
|
-
function
|
|
22
|
-
|
|
21
|
+
function mirrorAngle(angle) {
|
|
22
|
+
return (360 - angle) % 360;
|
|
23
|
+
}
|
|
24
|
+
function getAngle(controlEl, point, angularOffset, dir) {
|
|
25
|
+
let angle = getPointAngle(createRect(controlEl.getBoundingClientRect()), point);
|
|
23
26
|
if (angularOffset != null) return angle - angularOffset;
|
|
27
|
+
if (dir === "rtl") angle = mirrorAngle(angle);
|
|
24
28
|
return angle;
|
|
25
29
|
}
|
|
30
|
+
function getPointerValue(controlEl, point, angularOffset, value, dir) {
|
|
31
|
+
if (angularOffset == null) return getAngle(controlEl, point, null, dir);
|
|
32
|
+
const angle = getAngle(controlEl, point);
|
|
33
|
+
const clickAngle = value + angularOffset;
|
|
34
|
+
return dir === "rtl" ? value + clickAngle - angle : angle - angularOffset;
|
|
35
|
+
}
|
|
36
|
+
function getDisplayAngle(value, dir) {
|
|
37
|
+
return dir === "rtl" ? mirrorAngle(value) : value;
|
|
38
|
+
}
|
|
26
39
|
function clampAngle(degree) {
|
|
27
40
|
return Math.min(Math.max(degree, 0), 359);
|
|
28
41
|
}
|
|
@@ -42,6 +55,8 @@ function connect(service, normalize) {
|
|
|
42
55
|
const dragging = state.matches("dragging");
|
|
43
56
|
const value = context.get("value");
|
|
44
57
|
const valueAsDegree = computed("valueAsDegree");
|
|
58
|
+
const dir = prop("dir");
|
|
59
|
+
const displayAngle = getDisplayAngle(value, dir);
|
|
45
60
|
const disabled = prop("disabled");
|
|
46
61
|
const invalid = prop("invalid");
|
|
47
62
|
const readOnly = prop("readOnly");
|
|
@@ -62,12 +77,13 @@ function connect(service, normalize) {
|
|
|
62
77
|
return normalize.element({
|
|
63
78
|
...parts.root.attrs,
|
|
64
79
|
id: getRootId(scope),
|
|
80
|
+
dir: prop("dir"),
|
|
65
81
|
"data-disabled": dataAttr(disabled),
|
|
66
82
|
"data-invalid": dataAttr(invalid),
|
|
67
83
|
"data-readonly": dataAttr(readOnly),
|
|
68
84
|
style: {
|
|
69
85
|
"--value": value,
|
|
70
|
-
"--angle":
|
|
86
|
+
"--angle": `${displayAngle}deg`
|
|
71
87
|
}
|
|
72
88
|
});
|
|
73
89
|
},
|
|
@@ -76,6 +92,7 @@ function connect(service, normalize) {
|
|
|
76
92
|
...parts.label.attrs,
|
|
77
93
|
id: getLabelId(scope),
|
|
78
94
|
htmlFor: getHiddenInputId(scope),
|
|
95
|
+
dir: prop("dir"),
|
|
79
96
|
"data-disabled": dataAttr(disabled),
|
|
80
97
|
"data-invalid": dataAttr(invalid),
|
|
81
98
|
"data-readonly": dataAttr(readOnly),
|
|
@@ -91,7 +108,8 @@ function connect(service, normalize) {
|
|
|
91
108
|
type: "hidden",
|
|
92
109
|
value,
|
|
93
110
|
name: prop("name"),
|
|
94
|
-
id: getHiddenInputId(scope)
|
|
111
|
+
id: getHiddenInputId(scope),
|
|
112
|
+
dir: prop("dir")
|
|
95
113
|
});
|
|
96
114
|
},
|
|
97
115
|
getControlProps() {
|
|
@@ -99,6 +117,7 @@ function connect(service, normalize) {
|
|
|
99
117
|
...parts.control.attrs,
|
|
100
118
|
role: "presentation",
|
|
101
119
|
id: getControlId(scope),
|
|
120
|
+
dir: prop("dir"),
|
|
102
121
|
"data-disabled": dataAttr(disabled),
|
|
103
122
|
"data-invalid": dataAttr(invalid),
|
|
104
123
|
"data-readonly": dataAttr(readOnly),
|
|
@@ -131,6 +150,7 @@ function connect(service, normalize) {
|
|
|
131
150
|
...parts.thumb.attrs,
|
|
132
151
|
id: getThumbId(scope),
|
|
133
152
|
role: "slider",
|
|
153
|
+
dir: prop("dir"),
|
|
134
154
|
"aria-label": ariaLabel,
|
|
135
155
|
"aria-labelledby": ariaLabelledBy ?? getLabelId(scope),
|
|
136
156
|
"aria-valuemax": 360,
|
|
@@ -149,32 +169,44 @@ function connect(service, normalize) {
|
|
|
149
169
|
onKeyDown(event) {
|
|
150
170
|
if (!interactive) return;
|
|
151
171
|
const step = getEventStep(event) * prop("step");
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
172
|
+
const exec = {
|
|
173
|
+
ArrowLeft() {
|
|
174
|
+
send({
|
|
175
|
+
type: "THUMB.ARROW_DEC",
|
|
176
|
+
step
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
ArrowUp() {
|
|
156
180
|
send({
|
|
157
181
|
type: "THUMB.ARROW_DEC",
|
|
158
182
|
step
|
|
159
183
|
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
case "ArrowDown":
|
|
163
|
-
event.preventDefault();
|
|
184
|
+
},
|
|
185
|
+
ArrowRight() {
|
|
164
186
|
send({
|
|
165
187
|
type: "THUMB.ARROW_INC",
|
|
166
188
|
step
|
|
167
189
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
190
|
+
},
|
|
191
|
+
ArrowDown() {
|
|
192
|
+
send({
|
|
193
|
+
type: "THUMB.ARROW_INC",
|
|
194
|
+
step
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
Home() {
|
|
171
198
|
send({ type: "THUMB.HOME" });
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
event.preventDefault();
|
|
199
|
+
},
|
|
200
|
+
End() {
|
|
175
201
|
send({ type: "THUMB.END" });
|
|
176
|
-
|
|
177
|
-
|
|
202
|
+
}
|
|
203
|
+
}[getEventKey(event, {
|
|
204
|
+
dir: prop("dir"),
|
|
205
|
+
orientation: "horizontal"
|
|
206
|
+
})];
|
|
207
|
+
if (exec) {
|
|
208
|
+
exec(event);
|
|
209
|
+
event.preventDefault();
|
|
178
210
|
}
|
|
179
211
|
},
|
|
180
212
|
style: { rotate: `var(--angle)` }
|
|
@@ -183,25 +215,32 @@ function connect(service, normalize) {
|
|
|
183
215
|
getValueTextProps() {
|
|
184
216
|
return normalize.element({
|
|
185
217
|
...parts.valueText.attrs,
|
|
186
|
-
id: getValueTextId(scope)
|
|
218
|
+
id: getValueTextId(scope),
|
|
219
|
+
dir: prop("dir")
|
|
187
220
|
});
|
|
188
221
|
},
|
|
189
222
|
getMarkerGroupProps() {
|
|
190
|
-
return normalize.element({
|
|
223
|
+
return normalize.element({
|
|
224
|
+
...parts.markerGroup.attrs,
|
|
225
|
+
dir: prop("dir")
|
|
226
|
+
});
|
|
191
227
|
},
|
|
192
228
|
getMarkerProps(props) {
|
|
193
229
|
let markerState;
|
|
194
230
|
if (props.value < value) markerState = "under-value";
|
|
195
231
|
else if (props.value > value) markerState = "over-value";
|
|
196
232
|
else markerState = "at-value";
|
|
233
|
+
const markerDisplayAngle = getDisplayAngle(props.value, dir);
|
|
197
234
|
return normalize.element({
|
|
198
235
|
...parts.marker.attrs,
|
|
236
|
+
dir: prop("dir"),
|
|
199
237
|
"data-value": props.value,
|
|
200
238
|
"data-state": markerState,
|
|
201
239
|
"data-disabled": dataAttr(disabled),
|
|
202
240
|
style: {
|
|
203
241
|
"--marker-value": props.value,
|
|
204
|
-
|
|
242
|
+
"--marker-display-value": markerDisplayAngle,
|
|
243
|
+
rotate: `calc(var(--marker-display-value) * 1deg)`
|
|
205
244
|
}
|
|
206
245
|
});
|
|
207
246
|
}
|
|
@@ -312,7 +351,8 @@ const machine = createMachine({
|
|
|
312
351
|
const controlEl = getControlEl(scope);
|
|
313
352
|
if (!controlEl) return;
|
|
314
353
|
const angularOffset = refs.get("thumbDragOffset");
|
|
315
|
-
const
|
|
354
|
+
const value = context.get("value");
|
|
355
|
+
const deg = getPointerValue(controlEl, event.point, angularOffset, value, prop("dir"));
|
|
316
356
|
context.set("value", constrainAngle(deg, prop("step")));
|
|
317
357
|
},
|
|
318
358
|
setValueToMin({ context }) {
|
|
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-B24gMT
|
|
|
3
3
|
import { b as NormalizeProps, d as Orientation, f as OrientationProperty, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-CLRsezW5.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/machines/carousel/carousel.anatomy.d.ts
|
|
6
|
-
declare const anatomy: AnatomyInstance<"root" | "control" | "
|
|
6
|
+
declare const anatomy: AnatomyInstance<"root" | "control" | "item" | "indicator" | "nextTrigger" | "prevTrigger" | "itemGroup" | "indicatorGroup" | "autoplayTrigger" | "progressText">;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/machines/carousel/carousel.types.d.ts
|
|
9
9
|
interface PageChangeDetails {
|
|
@@ -3,7 +3,7 @@ import { p as Machine, u as EventObject, y as Service } from "../../types-DUM9rz
|
|
|
3
3
|
import { b as NormalizeProps, d as Orientation, f as OrientationProperty, g as RequiredBy, r as DirectionProperty, t as CommonProperties, x as PropTypes } from "../../index-BVFlU3b9.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/machines/carousel/carousel.anatomy.d.ts
|
|
6
|
-
declare const anatomy: AnatomyInstance<"root" | "control" | "
|
|
6
|
+
declare const anatomy: AnatomyInstance<"root" | "control" | "item" | "indicator" | "nextTrigger" | "prevTrigger" | "itemGroup" | "indicatorGroup" | "autoplayTrigger" | "progressText">;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/machines/carousel/carousel.types.d.ts
|
|
9
9
|
interface PageChangeDetails {
|
|
@@ -6,6 +6,7 @@ const require_collection = require("../../collection-BBgC8xCb.cjs");
|
|
|
6
6
|
const require_core = require("../../core-DwdPztGA.cjs");
|
|
7
7
|
require("../../interact-outside-Bg-QSXqp.cjs");
|
|
8
8
|
const require_dismissable = require("../../dismissable-DxjbwsOf.cjs");
|
|
9
|
+
const require_focus_visible = require("../../focus-visible-Co_9bW09.cjs");
|
|
9
10
|
const require_popper = require("../../popper-viCrafLC.cjs");
|
|
10
11
|
const require_rect_utils = require("../../rect-utils-D3RkAaHK.cjs");
|
|
11
12
|
const require_create_props = require("../../create-props-DP39rHnH.cjs");
|
|
@@ -69,7 +70,7 @@ function connect(service, normalize) {
|
|
|
69
70
|
const disabled = prop("disabled") || context.get("fieldsetDisabled");
|
|
70
71
|
const interactive = computed("isInteractive");
|
|
71
72
|
const valueAsString = computed("valueAsString");
|
|
72
|
-
const
|
|
73
|
+
const highlightedItems = context.get("highlightedItems");
|
|
73
74
|
const selectedItems = context.get("selectedItems");
|
|
74
75
|
const popperStyles = require_popper.getPlacementStyles({
|
|
75
76
|
...prop("positioning"),
|
|
@@ -94,6 +95,7 @@ function connect(service, normalize) {
|
|
|
94
95
|
};
|
|
95
96
|
};
|
|
96
97
|
const hasSelectedItems = value.length > 0;
|
|
98
|
+
const empty = value.length === 0;
|
|
97
99
|
return {
|
|
98
100
|
collection,
|
|
99
101
|
open,
|
|
@@ -102,9 +104,10 @@ function connect(service, normalize) {
|
|
|
102
104
|
disabled,
|
|
103
105
|
value,
|
|
104
106
|
highlightedValue,
|
|
105
|
-
|
|
107
|
+
highlightedItems,
|
|
106
108
|
selectedItems,
|
|
107
109
|
hasSelectedItems,
|
|
110
|
+
empty,
|
|
108
111
|
valueAsString,
|
|
109
112
|
reposition(options = {}) {
|
|
110
113
|
send({
|
|
@@ -119,12 +122,15 @@ function connect(service, normalize) {
|
|
|
119
122
|
if (nextOpen === open) return;
|
|
120
123
|
send({ type: nextOpen ? "OPEN" : "CLOSE" });
|
|
121
124
|
},
|
|
122
|
-
|
|
125
|
+
setHighlightValue(value) {
|
|
123
126
|
send({
|
|
124
127
|
type: "HIGHLIGHTED_VALUE.SET",
|
|
125
128
|
value
|
|
126
129
|
});
|
|
127
130
|
},
|
|
131
|
+
clearHighlightValue() {
|
|
132
|
+
send({ type: "HIGHLIGHTED_VALUE.CLEAR" });
|
|
133
|
+
},
|
|
128
134
|
setValue(value) {
|
|
129
135
|
send({
|
|
130
136
|
type: "VALUE.SET",
|
|
@@ -178,7 +184,7 @@ function connect(service, normalize) {
|
|
|
178
184
|
dir: prop("dir"),
|
|
179
185
|
id: dom.getControlId(scope),
|
|
180
186
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
181
|
-
"data-
|
|
187
|
+
"data-focus": require_dom_query.dataAttr(focused),
|
|
182
188
|
"data-readonly": require_dom_query.dataAttr(prop("readOnly")),
|
|
183
189
|
"data-invalid": require_dom_query.dataAttr(prop("invalid")),
|
|
184
190
|
"data-state": open ? "open" : "closed"
|
|
@@ -199,8 +205,9 @@ function connect(service, normalize) {
|
|
|
199
205
|
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
200
206
|
"data-readonly": require_dom_query.dataAttr(prop("readOnly")),
|
|
201
207
|
"data-invalid": require_dom_query.dataAttr(prop("invalid")),
|
|
202
|
-
"data-
|
|
208
|
+
"data-focus": require_dom_query.dataAttr(focused),
|
|
203
209
|
"data-placement": currentPlacement,
|
|
210
|
+
"data-placeholder-shown": require_dom_query.dataAttr(!hasSelectedItems),
|
|
204
211
|
disabled,
|
|
205
212
|
onClick(event) {
|
|
206
213
|
if (event.defaultPrevented) return;
|
|
@@ -448,6 +455,15 @@ function connect(service, normalize) {
|
|
|
448
455
|
hidden: !itemState.selected
|
|
449
456
|
});
|
|
450
457
|
},
|
|
458
|
+
getValueTextProps() {
|
|
459
|
+
return normalize.element({
|
|
460
|
+
...parts.valueText.attrs,
|
|
461
|
+
dir: prop("dir"),
|
|
462
|
+
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
463
|
+
"data-invalid": require_dom_query.dataAttr(prop("invalid")),
|
|
464
|
+
"data-focus": require_dom_query.dataAttr(focused)
|
|
465
|
+
});
|
|
466
|
+
},
|
|
451
467
|
getHiddenInputProps() {
|
|
452
468
|
const defaultValue = context.hash("value");
|
|
453
469
|
return normalize.input({
|
|
@@ -575,7 +591,7 @@ const machine = require_core.createMachine({
|
|
|
575
591
|
const value = prop("highlightedValue") ?? prop("defaultHighlightedValue") ?? null;
|
|
576
592
|
return { defaultValue: value ? prop("collection").getIndexPath(value) : [] };
|
|
577
593
|
}),
|
|
578
|
-
|
|
594
|
+
highlightedItems: bindable(() => ({ defaultValue: [] })),
|
|
579
595
|
selectedItems: bindable(() => ({ defaultValue: [] })),
|
|
580
596
|
currentPlacement: bindable(() => ({ defaultValue: void 0 })),
|
|
581
597
|
fieldsetDisabled: bindable(() => ({ defaultValue: false })),
|
|
@@ -615,6 +631,7 @@ const machine = require_core.createMachine({
|
|
|
615
631
|
"VALUE.CLEAR": { actions: ["clearValue"] },
|
|
616
632
|
"CLEAR_TRIGGER.CLICK": { actions: ["clearValue", "focusTriggerEl"] },
|
|
617
633
|
"HIGHLIGHTED_VALUE.SET": { actions: ["setHighlightedValue"] },
|
|
634
|
+
"HIGHLIGHTED_VALUE.CLEAR": { actions: ["clearHighlightedValue"] },
|
|
618
635
|
"ITEM.SELECT": { actions: ["selectItem"] },
|
|
619
636
|
"ITEM.CLEAR": { actions: ["clearItem"] }
|
|
620
637
|
},
|
|
@@ -749,6 +766,7 @@ const machine = require_core.createMachine({
|
|
|
749
766
|
exit: ["clearHighlightedValue", "scrollContentToTop"],
|
|
750
767
|
effects: [
|
|
751
768
|
"trackDismissableElement",
|
|
769
|
+
"trackFocusVisible",
|
|
752
770
|
"computePlacement",
|
|
753
771
|
"scrollToHighlightedItems"
|
|
754
772
|
],
|
|
@@ -900,8 +918,8 @@ const machine = require_core.createMachine({
|
|
|
900
918
|
},
|
|
901
919
|
shouldCloseOnSelectHighlighted: ({ prop, context }) => {
|
|
902
920
|
const collection = prop("collection");
|
|
903
|
-
const node = context.get("
|
|
904
|
-
return prop("closeOnSelect") && !collection.isBranchNode(node);
|
|
921
|
+
const node = require_utils.last(context.get("highlightedItems"));
|
|
922
|
+
return prop("closeOnSelect") && node != null && !collection.isBranchNode(node);
|
|
905
923
|
},
|
|
906
924
|
canSelectItem: ({ prop, event }) => {
|
|
907
925
|
const collection = prop("collection");
|
|
@@ -973,6 +991,9 @@ const machine = require_core.createMachine({
|
|
|
973
991
|
}
|
|
974
992
|
});
|
|
975
993
|
},
|
|
994
|
+
trackFocusVisible({ scope }) {
|
|
995
|
+
return require_focus_visible.trackFocusVisible({ root: scope.getRootNode?.() });
|
|
996
|
+
},
|
|
976
997
|
trackDismissableElement({ scope, send, prop }) {
|
|
977
998
|
const contentEl = () => dom.getContentEl(scope);
|
|
978
999
|
let restoreFocus = true;
|
|
@@ -1004,13 +1025,13 @@ const machine = require_core.createMachine({
|
|
|
1004
1025
|
}
|
|
1005
1026
|
});
|
|
1006
1027
|
},
|
|
1007
|
-
scrollToHighlightedItems({ context, prop, scope
|
|
1028
|
+
scrollToHighlightedItems({ context, prop, scope }) {
|
|
1008
1029
|
let cleanups = [];
|
|
1009
1030
|
const exec = (immediate) => {
|
|
1010
1031
|
const highlightedValue = context.get("highlightedValue");
|
|
1011
1032
|
const highlightedIndexPath = context.get("highlightedIndexPath");
|
|
1012
1033
|
if (!highlightedIndexPath.length) return;
|
|
1013
|
-
if (
|
|
1034
|
+
if (require_focus_visible.getInteractionModality() === "pointer") return;
|
|
1014
1035
|
dom.getListEls(scope).forEach((listEl, index) => {
|
|
1015
1036
|
const itemPath = highlightedIndexPath.slice(0, index + 1);
|
|
1016
1037
|
const itemEl = dom.getItemEl(scope, highlightedValue.toString());
|
|
@@ -1033,7 +1054,10 @@ const machine = require_core.createMachine({
|
|
|
1033
1054
|
cleanups.push(raf_cleanup);
|
|
1034
1055
|
});
|
|
1035
1056
|
};
|
|
1036
|
-
require_dom_query.raf(() =>
|
|
1057
|
+
require_dom_query.raf(() => {
|
|
1058
|
+
require_focus_visible.setInteractionModality("virtual");
|
|
1059
|
+
exec(true);
|
|
1060
|
+
});
|
|
1037
1061
|
const rafCleanup = require_dom_query.raf(() => exec(true));
|
|
1038
1062
|
cleanups.push(rafCleanup);
|
|
1039
1063
|
const observerCleanup = require_dom_query.observeAttributes(dom.getContentEl(scope), {
|
|
@@ -1214,11 +1238,17 @@ const machine = require_core.createMachine({
|
|
|
1214
1238
|
dom.getTriggerEl(scope)?.focus({ preventScroll: true });
|
|
1215
1239
|
});
|
|
1216
1240
|
},
|
|
1217
|
-
invokeOnOpen({ prop }) {
|
|
1218
|
-
prop("onOpenChange")?.({
|
|
1241
|
+
invokeOnOpen({ prop, context }) {
|
|
1242
|
+
prop("onOpenChange")?.({
|
|
1243
|
+
open: true,
|
|
1244
|
+
value: context.get("value")
|
|
1245
|
+
});
|
|
1219
1246
|
},
|
|
1220
|
-
invokeOnClose({ prop }) {
|
|
1221
|
-
prop("onOpenChange")?.({
|
|
1247
|
+
invokeOnClose({ prop, context }) {
|
|
1248
|
+
prop("onOpenChange")?.({
|
|
1249
|
+
open: false,
|
|
1250
|
+
value: context.get("value")
|
|
1251
|
+
});
|
|
1222
1252
|
},
|
|
1223
1253
|
toggleVisibility({ send, prop }) {
|
|
1224
1254
|
if (prop("open") != null) send({ type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE" });
|
|
@@ -1304,16 +1334,16 @@ const set = {
|
|
|
1304
1334
|
highlightedValue({ context, prop }, value) {
|
|
1305
1335
|
const collection = prop("collection");
|
|
1306
1336
|
context.set("highlightedValue", value);
|
|
1307
|
-
const highlightedIndexPath = value == null ? [] : collection.getIndexPath(value);
|
|
1337
|
+
const highlightedIndexPath = (value == null ? [] : collection.getIndexPath(value)) ?? [];
|
|
1308
1338
|
context.set("highlightedIndexPath", highlightedIndexPath);
|
|
1309
|
-
const
|
|
1339
|
+
const highlightedItems = highlightedIndexPath.map((_, index) => {
|
|
1310
1340
|
const partialPath = highlightedIndexPath.slice(0, index + 1);
|
|
1311
1341
|
return collection.at(partialPath);
|
|
1312
1342
|
});
|
|
1313
|
-
context.set("
|
|
1343
|
+
context.set("highlightedItems", highlightedItems);
|
|
1314
1344
|
prop("onHighlightChange")?.({
|
|
1315
|
-
value,
|
|
1316
|
-
|
|
1345
|
+
highlightedValue: value,
|
|
1346
|
+
highlightedItems
|
|
1317
1347
|
});
|
|
1318
1348
|
}
|
|
1319
1349
|
};
|