@tamagui/slider 1.0.1-beta.26
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/cjs/Slider.js +390 -0
- package/dist/cjs/Slider.js.map +7 -0
- package/dist/cjs/SliderImpl.js +133 -0
- package/dist/cjs/SliderImpl.js.map +7 -0
- package/dist/cjs/context.js +50 -0
- package/dist/cjs/context.js.map +7 -0
- package/dist/cjs/helpers.js +120 -0
- package/dist/cjs/helpers.js.map +7 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/esm/Slider.js +338 -0
- package/dist/esm/Slider.js.map +7 -0
- package/dist/esm/SliderImpl.js +69 -0
- package/dist/esm/SliderImpl.js.map +7 -0
- package/dist/esm/context.js +21 -0
- package/dist/esm/context.js.map +7 -0
- package/dist/esm/helpers.js +89 -0
- package/dist/esm/helpers.js.map +7 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/jsx/Slider.js +248 -0
- package/dist/jsx/SliderImpl.js +59 -0
- package/dist/jsx/context.js +20 -0
- package/dist/jsx/helpers.js +88 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/types.js +0 -0
- package/package.json +44 -0
- package/types/Slider.d.ts +29 -0
- package/types/Slider.d.ts.map +1 -0
- package/types/SliderImpl.d.ts +54 -0
- package/types/SliderImpl.d.ts.map +1 -0
- package/types/context.d.ts +50 -0
- package/types/context.d.ts.map +1 -0
- package/types/helpers.d.ts +12 -0
- package/types/helpers.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts +70 -0
- package/types/types.d.ts.map +1 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
50
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
51
|
+
var Slider_exports = {};
|
|
52
|
+
__export(Slider_exports, {
|
|
53
|
+
Range: () => Range,
|
|
54
|
+
Slider: () => Slider,
|
|
55
|
+
SliderThumb: () => SliderThumb,
|
|
56
|
+
SliderTrack: () => SliderTrack,
|
|
57
|
+
SliderTrackActive: () => SliderTrackActive,
|
|
58
|
+
Thumb: () => Thumb,
|
|
59
|
+
Track: () => Track
|
|
60
|
+
});
|
|
61
|
+
module.exports = __toCommonJS(Slider_exports);
|
|
62
|
+
var import_react_use_previous = require("@radix-ui/react-use-previous");
|
|
63
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
64
|
+
var import_core = require("@tamagui/core");
|
|
65
|
+
var import_helpers = require("@tamagui/helpers");
|
|
66
|
+
var import_stacks = require("@tamagui/stacks");
|
|
67
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
68
|
+
var import_use_direction = require("@tamagui/use-direction");
|
|
69
|
+
var React = __toESM(require("react"));
|
|
70
|
+
var import_context = require("./context");
|
|
71
|
+
var import_helpers2 = require("./helpers");
|
|
72
|
+
var import_SliderImpl = require("./SliderImpl");
|
|
73
|
+
const PAGE_KEYS = ["PageUp", "PageDown"];
|
|
74
|
+
const ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
|
|
75
|
+
const BACK_KEYS = {
|
|
76
|
+
ltr: ["ArrowDown", "Home", "ArrowLeft", "PageDown"],
|
|
77
|
+
rtl: ["ArrowDown", "Home", "ArrowRight", "PageDown"]
|
|
78
|
+
};
|
|
79
|
+
const SliderHorizontal = React.forwardRef((props, forwardedRef) => {
|
|
80
|
+
const _a = props, { min, max, dir, onSlideStart, onSlideMove, onStepKeyDown } = _a, sliderProps = __objRest(_a, ["min", "max", "dir", "onSlideStart", "onSlideMove", "onStepKeyDown"]);
|
|
81
|
+
const layoutRef = React.useRef(null);
|
|
82
|
+
const direction = (0, import_use_direction.useDirection)(dir);
|
|
83
|
+
const isDirectionLTR = direction === "ltr";
|
|
84
|
+
const [size, setSize] = React.useState(0);
|
|
85
|
+
function getValueFromPointer(pointerPosition) {
|
|
86
|
+
const layout = layoutRef.current;
|
|
87
|
+
if (!layout)
|
|
88
|
+
return;
|
|
89
|
+
const input = [0, layout.width];
|
|
90
|
+
const output = isDirectionLTR ? [min, max] : [max, min];
|
|
91
|
+
const value = (0, import_helpers2.linearScale)(input, output);
|
|
92
|
+
return value(pointerPosition - layout.x);
|
|
93
|
+
}
|
|
94
|
+
__name(getValueFromPointer, "getValueFromPointer");
|
|
95
|
+
return /* @__PURE__ */ React.createElement(import_context.SliderOrientationProvider, {
|
|
96
|
+
scope: props.__scopeSlider,
|
|
97
|
+
startEdge: isDirectionLTR ? "left" : "right",
|
|
98
|
+
endEdge: isDirectionLTR ? "right" : "left",
|
|
99
|
+
direction: isDirectionLTR ? 1 : -1,
|
|
100
|
+
sizeProp: "width",
|
|
101
|
+
size
|
|
102
|
+
}, /* @__PURE__ */ React.createElement(import_SliderImpl.SliderImpl, __spreadProps(__spreadValues({
|
|
103
|
+
dir: direction,
|
|
104
|
+
orientation: "horizontal"
|
|
105
|
+
}, sliderProps), {
|
|
106
|
+
onLayout: (e) => {
|
|
107
|
+
const layout = e.nativeEvent.layout;
|
|
108
|
+
layoutRef.current = layout;
|
|
109
|
+
setSize(layout.height);
|
|
110
|
+
},
|
|
111
|
+
ref: forwardedRef,
|
|
112
|
+
onSlideStart: (event) => {
|
|
113
|
+
const value = getValueFromPointer(event.nativeEvent.pageX);
|
|
114
|
+
if (value) {
|
|
115
|
+
onSlideStart == null ? void 0 : onSlideStart(value);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
onSlideMove: (event) => {
|
|
119
|
+
const value = getValueFromPointer(event.nativeEvent.pageX);
|
|
120
|
+
if (value) {
|
|
121
|
+
onSlideMove == null ? void 0 : onSlideMove(value);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
onSlideEnd: () => {
|
|
125
|
+
},
|
|
126
|
+
onStepKeyDown: (event) => {
|
|
127
|
+
const isBackKey = BACK_KEYS[direction].includes(event.key);
|
|
128
|
+
onStepKeyDown == null ? void 0 : onStepKeyDown({ event, direction: isBackKey ? -1 : 1 });
|
|
129
|
+
}
|
|
130
|
+
})));
|
|
131
|
+
});
|
|
132
|
+
const SliderVertical = React.forwardRef((props, forwardedRef) => {
|
|
133
|
+
const _a = props, { min, max, onSlideStart, onSlideMove, onStepKeyDown } = _a, sliderProps = __objRest(_a, ["min", "max", "onSlideStart", "onSlideMove", "onStepKeyDown"]);
|
|
134
|
+
const sliderRef = React.useRef(null);
|
|
135
|
+
const ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, sliderRef);
|
|
136
|
+
const rectRef = React.useRef();
|
|
137
|
+
function getValueFromPointer(pointerPosition) {
|
|
138
|
+
const rect = rectRef.current || sliderRef.current.getBoundingClientRect();
|
|
139
|
+
const input = [0, rect.height];
|
|
140
|
+
const output = [max, min];
|
|
141
|
+
const value = (0, import_helpers2.linearScale)(input, output);
|
|
142
|
+
rectRef.current = rect;
|
|
143
|
+
return value(pointerPosition - rect.top);
|
|
144
|
+
}
|
|
145
|
+
__name(getValueFromPointer, "getValueFromPointer");
|
|
146
|
+
return /* @__PURE__ */ React.createElement(import_context.SliderOrientationProvider, {
|
|
147
|
+
scope: props.__scopeSlider,
|
|
148
|
+
startEdge: "bottom",
|
|
149
|
+
endEdge: "top",
|
|
150
|
+
sizeProp: "height",
|
|
151
|
+
size: 0,
|
|
152
|
+
direction: 1
|
|
153
|
+
}, /* @__PURE__ */ React.createElement(import_SliderImpl.SliderImpl, __spreadProps(__spreadValues({}, sliderProps), {
|
|
154
|
+
orientation: "vertical",
|
|
155
|
+
ref,
|
|
156
|
+
onSlideStart: (event) => {
|
|
157
|
+
const value = getValueFromPointer(event.nativeEvent.locationY);
|
|
158
|
+
onSlideStart == null ? void 0 : onSlideStart(value);
|
|
159
|
+
},
|
|
160
|
+
onSlideMove: (event) => {
|
|
161
|
+
const value = getValueFromPointer(event.nativeEvent.locationY);
|
|
162
|
+
onSlideMove == null ? void 0 : onSlideMove(value);
|
|
163
|
+
},
|
|
164
|
+
onSlideEnd: () => rectRef.current = void 0,
|
|
165
|
+
onStepKeyDown: (event) => {
|
|
166
|
+
const isBackKey = BACK_KEYS.ltr.includes(event.key);
|
|
167
|
+
onStepKeyDown == null ? void 0 : onStepKeyDown({ event, direction: isBackKey ? -1 : 1 });
|
|
168
|
+
}
|
|
169
|
+
})));
|
|
170
|
+
});
|
|
171
|
+
const TRACK_NAME = "SliderTrack";
|
|
172
|
+
const SliderTrackFrame = (0, import_core.styled)(import_SliderImpl.SliderFrame, {
|
|
173
|
+
name: "SliderTrackFrame"
|
|
174
|
+
});
|
|
175
|
+
const SliderTrack = React.forwardRef((props, forwardedRef) => {
|
|
176
|
+
const _a = props, { __scopeSlider } = _a, trackProps = __objRest(_a, ["__scopeSlider"]);
|
|
177
|
+
const context = (0, import_context.useSliderContext)(TRACK_NAME, __scopeSlider);
|
|
178
|
+
return /* @__PURE__ */ React.createElement(SliderTrackFrame, __spreadProps(__spreadValues({
|
|
179
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
180
|
+
"data-orientation": context.orientation,
|
|
181
|
+
orientation: context.orientation
|
|
182
|
+
}, trackProps), {
|
|
183
|
+
ref: forwardedRef
|
|
184
|
+
}));
|
|
185
|
+
});
|
|
186
|
+
SliderTrack.displayName = TRACK_NAME;
|
|
187
|
+
const RANGE_NAME = "SliderTrackActive";
|
|
188
|
+
const SliderTrackActiveFrame = (0, import_core.styled)(import_SliderImpl.SliderFrame, {
|
|
189
|
+
name: "SliderTrackActive"
|
|
190
|
+
});
|
|
191
|
+
const SliderTrackActive = React.forwardRef((props, forwardedRef) => {
|
|
192
|
+
const _a = props, { __scopeSlider } = _a, rangeProps = __objRest(_a, ["__scopeSlider"]);
|
|
193
|
+
const context = (0, import_context.useSliderContext)(RANGE_NAME, __scopeSlider);
|
|
194
|
+
const orientation = (0, import_context.useSliderOrientationContext)(RANGE_NAME, __scopeSlider);
|
|
195
|
+
const ref = React.useRef(null);
|
|
196
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
197
|
+
const valuesCount = context.values.length;
|
|
198
|
+
const percentages = context.values.map((value) => (0, import_helpers2.convertValueToPercentage)(value, context.min, context.max));
|
|
199
|
+
const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0;
|
|
200
|
+
const offsetEnd = 100 - Math.max(...percentages);
|
|
201
|
+
return /* @__PURE__ */ React.createElement(SliderTrackActiveFrame, __spreadValues(__spreadProps(__spreadValues({
|
|
202
|
+
orientation: context.orientation,
|
|
203
|
+
"data-orientation": context.orientation,
|
|
204
|
+
"data-disabled": context.disabled ? "" : void 0
|
|
205
|
+
}, rangeProps), {
|
|
206
|
+
ref: composedRefs
|
|
207
|
+
}), {
|
|
208
|
+
[orientation.startEdge]: offsetStart + "%",
|
|
209
|
+
[orientation.endEdge]: offsetEnd + "%"
|
|
210
|
+
}));
|
|
211
|
+
});
|
|
212
|
+
SliderTrackActive.displayName = RANGE_NAME;
|
|
213
|
+
const THUMB_NAME = "SliderThumb";
|
|
214
|
+
const SliderThumbFrame = (0, import_core.styled)(import_stacks.SizableStack, {
|
|
215
|
+
name: "SliderThumb",
|
|
216
|
+
position: "absolute"
|
|
217
|
+
});
|
|
218
|
+
const SliderThumb = React.forwardRef((props, forwardedRef) => {
|
|
219
|
+
const _a = props, { __scopeSlider, index, size: sizeProp } = _a, thumbProps = __objRest(_a, ["__scopeSlider", "index", "size"]);
|
|
220
|
+
const context = (0, import_context.useSliderContext)(THUMB_NAME, __scopeSlider);
|
|
221
|
+
const orientation = (0, import_context.useSliderOrientationContext)(THUMB_NAME, __scopeSlider);
|
|
222
|
+
const value = context.values[index];
|
|
223
|
+
const percent = value === void 0 ? 0 : (0, import_helpers2.convertValueToPercentage)(value, context.min, context.max);
|
|
224
|
+
const label = (0, import_helpers2.getLabel)(index, context.values.length);
|
|
225
|
+
const [size, setSize] = React.useState(0);
|
|
226
|
+
const thumbInBoundsOffset = size ? (0, import_helpers2.getThumbInBoundsOffset)(size, percent, orientation.direction) : 0;
|
|
227
|
+
console.log("thumbInBoundsOffset", thumbInBoundsOffset, size, percent);
|
|
228
|
+
return /* @__PURE__ */ React.createElement(SliderThumbFrame, __spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
229
|
+
ref: forwardedRef,
|
|
230
|
+
"aria-label": props["aria-label"] || label,
|
|
231
|
+
"aria-valuemin": context.min,
|
|
232
|
+
"aria-valuenow": value,
|
|
233
|
+
"aria-valuemax": context.max,
|
|
234
|
+
"aria-orientation": context.orientation,
|
|
235
|
+
"data-orientation": context.orientation,
|
|
236
|
+
"data-disabled": context.disabled ? "" : void 0
|
|
237
|
+
}, thumbProps), {
|
|
238
|
+
x: thumbInBoundsOffset,
|
|
239
|
+
y: -size / 2,
|
|
240
|
+
size: sizeProp ?? context.size ?? 30,
|
|
241
|
+
onLayout: (e) => {
|
|
242
|
+
setSize(e.nativeEvent.layout[orientation.sizeProp]);
|
|
243
|
+
}
|
|
244
|
+
}), {
|
|
245
|
+
[orientation.startEdge]: `${percent}%`
|
|
246
|
+
}), {
|
|
247
|
+
style: value === void 0 ? { display: "none" } : props.style,
|
|
248
|
+
onFocus: (0, import_helpers.composeEventHandlers)(props.onFocus, () => {
|
|
249
|
+
context.valueIndexToChangeRef.current = index;
|
|
250
|
+
})
|
|
251
|
+
}));
|
|
252
|
+
});
|
|
253
|
+
SliderThumb.displayName = THUMB_NAME;
|
|
254
|
+
const Slider = (0, import_core.withStaticProperties)(React.forwardRef((props, forwardedRef) => {
|
|
255
|
+
const _a = props, {
|
|
256
|
+
name,
|
|
257
|
+
min = 0,
|
|
258
|
+
max = 100,
|
|
259
|
+
step = 1,
|
|
260
|
+
orientation = "horizontal",
|
|
261
|
+
disabled = false,
|
|
262
|
+
minStepsBetweenThumbs = 0,
|
|
263
|
+
defaultValue = [min],
|
|
264
|
+
value,
|
|
265
|
+
onValueChange = /* @__PURE__ */ __name(() => {
|
|
266
|
+
}, "onValueChange"),
|
|
267
|
+
size: sizeProp
|
|
268
|
+
} = _a, sliderProps = __objRest(_a, [
|
|
269
|
+
"name",
|
|
270
|
+
"min",
|
|
271
|
+
"max",
|
|
272
|
+
"step",
|
|
273
|
+
"orientation",
|
|
274
|
+
"disabled",
|
|
275
|
+
"minStepsBetweenThumbs",
|
|
276
|
+
"defaultValue",
|
|
277
|
+
"value",
|
|
278
|
+
"onValueChange",
|
|
279
|
+
"size"
|
|
280
|
+
]);
|
|
281
|
+
const thumbRefs = React.useRef(/* @__PURE__ */ new Set());
|
|
282
|
+
const valueIndexToChangeRef = React.useRef(0);
|
|
283
|
+
const isHorizontal = orientation === "horizontal";
|
|
284
|
+
const [values = [], setValues] = (0, import_use_controllable_state.useControllableState)({
|
|
285
|
+
prop: value,
|
|
286
|
+
defaultProp: defaultValue,
|
|
287
|
+
onChange: (value2) => {
|
|
288
|
+
onValueChange(value2);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
function handleSlideStart(value2) {
|
|
292
|
+
const closestIndex = (0, import_helpers2.getClosestValueIndex)(values, value2);
|
|
293
|
+
updateValues(value2, closestIndex);
|
|
294
|
+
}
|
|
295
|
+
__name(handleSlideStart, "handleSlideStart");
|
|
296
|
+
function handleSlideMove(value2) {
|
|
297
|
+
updateValues(value2, valueIndexToChangeRef.current);
|
|
298
|
+
}
|
|
299
|
+
__name(handleSlideMove, "handleSlideMove");
|
|
300
|
+
function updateValues(value2, atIndex) {
|
|
301
|
+
const decimalCount = (0, import_helpers2.getDecimalCount)(step);
|
|
302
|
+
const snapToStep = (0, import_helpers2.roundValue)(Math.round((value2 - min) / step) * step + min, decimalCount);
|
|
303
|
+
const nextValue = (0, import_helpers.clamp)(snapToStep, [min, max]);
|
|
304
|
+
setValues((prevValues = []) => {
|
|
305
|
+
const nextValues = (0, import_helpers2.getNextSortedValues)(prevValues, nextValue, atIndex);
|
|
306
|
+
if ((0, import_helpers2.hasMinStepsBetweenValues)(nextValues, minStepsBetweenThumbs * step)) {
|
|
307
|
+
valueIndexToChangeRef.current = nextValues.indexOf(nextValue);
|
|
308
|
+
return String(nextValues) === String(prevValues) ? prevValues : nextValues;
|
|
309
|
+
} else {
|
|
310
|
+
return prevValues;
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
__name(updateValues, "updateValues");
|
|
315
|
+
const SliderOriented = isHorizontal ? SliderHorizontal : SliderVertical;
|
|
316
|
+
return /* @__PURE__ */ React.createElement(import_context.SliderProvider, {
|
|
317
|
+
scope: props.__scopeSlider,
|
|
318
|
+
disabled,
|
|
319
|
+
min,
|
|
320
|
+
max,
|
|
321
|
+
valueIndexToChangeRef,
|
|
322
|
+
thumbs: thumbRefs.current,
|
|
323
|
+
values,
|
|
324
|
+
orientation,
|
|
325
|
+
size: sizeProp || 20
|
|
326
|
+
}, /* @__PURE__ */ React.createElement(SliderOriented, __spreadProps(__spreadValues({
|
|
327
|
+
"aria-disabled": disabled,
|
|
328
|
+
"data-disabled": disabled ? "" : void 0
|
|
329
|
+
}, sliderProps), {
|
|
330
|
+
ref: forwardedRef,
|
|
331
|
+
min,
|
|
332
|
+
max,
|
|
333
|
+
onSlideStart: disabled ? void 0 : handleSlideStart,
|
|
334
|
+
onSlideMove: disabled ? void 0 : handleSlideMove,
|
|
335
|
+
onHomeKeyDown: () => !disabled && updateValues(min, 0),
|
|
336
|
+
onEndKeyDown: () => !disabled && updateValues(max, values.length - 1),
|
|
337
|
+
onStepKeyDown: ({ event, direction: stepDirection }) => {
|
|
338
|
+
if (!disabled) {
|
|
339
|
+
const isPageKey = PAGE_KEYS.includes(event.key);
|
|
340
|
+
const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.includes(event.key);
|
|
341
|
+
const multiplier = isSkipKey ? 10 : 1;
|
|
342
|
+
const atIndex = valueIndexToChangeRef.current;
|
|
343
|
+
const value2 = values[atIndex];
|
|
344
|
+
const stepInDirection = step * multiplier * stepDirection;
|
|
345
|
+
updateValues(value2 + stepInDirection, atIndex);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
})));
|
|
349
|
+
}), {
|
|
350
|
+
Track: SliderTrack,
|
|
351
|
+
TrackActive: SliderTrackActive,
|
|
352
|
+
Thumb: SliderThumb
|
|
353
|
+
});
|
|
354
|
+
Slider.displayName = import_context.SLIDER_NAME;
|
|
355
|
+
const BubbleInput = /* @__PURE__ */ __name((props) => {
|
|
356
|
+
const _a = props, { value } = _a, inputProps = __objRest(_a, ["value"]);
|
|
357
|
+
const ref = React.useRef(null);
|
|
358
|
+
const prevValue = (0, import_react_use_previous.usePrevious)(value);
|
|
359
|
+
React.useEffect(() => {
|
|
360
|
+
const input = ref.current;
|
|
361
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
362
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputProto, "value");
|
|
363
|
+
const setValue = descriptor.set;
|
|
364
|
+
if (prevValue !== value && setValue) {
|
|
365
|
+
const event = new Event("input", { bubbles: true });
|
|
366
|
+
setValue.call(input, value);
|
|
367
|
+
input.dispatchEvent(event);
|
|
368
|
+
}
|
|
369
|
+
}, [prevValue, value]);
|
|
370
|
+
return /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({
|
|
371
|
+
style: { display: "none" }
|
|
372
|
+
}, inputProps), {
|
|
373
|
+
ref,
|
|
374
|
+
defaultValue: value
|
|
375
|
+
}));
|
|
376
|
+
}, "BubbleInput");
|
|
377
|
+
const Track = SliderTrack;
|
|
378
|
+
const Range = SliderTrackActive;
|
|
379
|
+
const Thumb = SliderThumb;
|
|
380
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
381
|
+
0 && (module.exports = {
|
|
382
|
+
Range,
|
|
383
|
+
Slider,
|
|
384
|
+
SliderThumb,
|
|
385
|
+
SliderTrack,
|
|
386
|
+
SliderTrackActive,
|
|
387
|
+
Thumb,
|
|
388
|
+
Track
|
|
389
|
+
});
|
|
390
|
+
//# sourceMappingURL=Slider.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Slider.tsx"],
|
|
4
|
+
"sourcesContent": ["// forked from radix-ui\n\nimport { usePrevious } from '@radix-ui/react-use-previous'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport { getVariantExtras, styled, withStaticProperties } from '@tamagui/core'\nimport { clamp, composeEventHandlers } from '@tamagui/helpers'\n// import { useSize } from '@tamagui/react-use-size'\nimport { SizableStack, SizableStackProps, YStackProps, getCircleSize } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport * as React from 'react'\nimport { LayoutRectangle, View } from 'react-native'\n\nimport {\n SLIDER_NAME,\n SliderOrientationProvider,\n SliderProvider,\n useSliderContext,\n useSliderOrientationContext,\n} from './context'\nimport {\n convertValueToPercentage,\n getClosestValueIndex,\n getDecimalCount,\n getLabel,\n getNextSortedValues,\n getSize,\n getThumbInBoundsOffset,\n hasMinStepsBetweenValues,\n linearScale,\n roundValue,\n} from './helpers'\nimport { SliderFrame, SliderImpl } from './SliderImpl'\nimport {\n Direction,\n ScopedProps,\n SliderContextValue,\n SliderHorizontalProps,\n SliderImplElement,\n SliderProps,\n SliderTrackProps,\n SliderVerticalProps,\n} from './types'\n\nconst PAGE_KEYS = ['PageUp', 'PageDown']\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']\nconst BACK_KEYS: Record<Direction, string[]> = {\n ltr: ['ArrowDown', 'Home', 'ArrowLeft', 'PageDown'],\n rtl: ['ArrowDown', 'Home', 'ArrowRight', 'PageDown'],\n}\n\n/* -------------------------------------------------------------------------------------------------\n * SliderHorizontal\n * -----------------------------------------------------------------------------------------------*/\n\ntype SliderHorizontalElement = SliderImplElement\n\nconst SliderHorizontal = React.forwardRef<SliderHorizontalElement, SliderHorizontalProps>(\n (props: ScopedProps<SliderHorizontalProps>, forwardedRef) => {\n const { min, max, dir, onSlideStart, onSlideMove, onStepKeyDown, ...sliderProps } = props\n const layoutRef = React.useRef<LayoutRectangle | null>(null)\n const direction = useDirection(dir)\n const isDirectionLTR = direction === 'ltr'\n const [size, setSize] = React.useState(0)\n\n function getValueFromPointer(pointerPosition: number) {\n const layout = layoutRef.current\n if (!layout) return\n const input: [number, number] = [0, layout.width]\n const output: [number, number] = isDirectionLTR ? [min, max] : [max, min]\n const value = linearScale(input, output)\n return value(pointerPosition - layout.x)\n }\n\n return (\n <SliderOrientationProvider\n scope={props.__scopeSlider}\n startEdge={isDirectionLTR ? 'left' : 'right'}\n endEdge={isDirectionLTR ? 'right' : 'left'}\n direction={isDirectionLTR ? 1 : -1}\n sizeProp=\"width\"\n size={size}\n >\n <SliderImpl\n dir={direction}\n orientation=\"horizontal\"\n {...sliderProps}\n onLayout={(e) => {\n const layout = e.nativeEvent.layout\n layoutRef.current = layout\n setSize(layout.height)\n }}\n ref={forwardedRef}\n onSlideStart={(event) => {\n const value = getValueFromPointer(event.nativeEvent.pageX)\n if (value) {\n onSlideStart?.(value)\n }\n }}\n onSlideMove={(event) => {\n const value = getValueFromPointer(event.nativeEvent.pageX)\n if (value) {\n onSlideMove?.(value)\n }\n }}\n onSlideEnd={() => {}}\n onStepKeyDown={(event) => {\n const isBackKey = BACK_KEYS[direction].includes(event.key)\n onStepKeyDown?.({ event, direction: isBackKey ? -1 : 1 })\n }}\n />\n </SliderOrientationProvider>\n )\n }\n)\n\n/* -------------------------------------------------------------------------------------------------\n * SliderVertical\n * -----------------------------------------------------------------------------------------------*/\n\ntype SliderVerticalElement = SliderImplElement\n\nconst SliderVertical = React.forwardRef<SliderVerticalElement, SliderVerticalProps>(\n (props: ScopedProps<SliderVerticalProps>, forwardedRef) => {\n const { min, max, onSlideStart, onSlideMove, onStepKeyDown, ...sliderProps } = props\n const sliderRef = React.useRef<SliderImplElement>(null)\n const ref = useComposedRefs(forwardedRef, sliderRef)\n const rectRef = React.useRef<ClientRect>()\n\n function getValueFromPointer(pointerPosition: number) {\n // @ts-ignore\n const rect = rectRef.current || sliderRef.current!.getBoundingClientRect()\n const input: [number, number] = [0, rect.height]\n const output: [number, number] = [max, min]\n const value = linearScale(input, output)\n rectRef.current = rect\n return value(pointerPosition - rect.top)\n }\n\n return (\n <SliderOrientationProvider\n scope={props.__scopeSlider}\n startEdge=\"bottom\"\n endEdge=\"top\"\n sizeProp=\"height\"\n size={0}\n direction={1}\n >\n <SliderImpl\n {...sliderProps}\n orientation=\"vertical\"\n ref={ref}\n onSlideStart={(event) => {\n const value = getValueFromPointer(event.nativeEvent.locationY)\n onSlideStart?.(value)\n }}\n onSlideMove={(event) => {\n const value = getValueFromPointer(event.nativeEvent.locationY)\n onSlideMove?.(value)\n }}\n onSlideEnd={() => (rectRef.current = undefined)}\n onStepKeyDown={(event) => {\n const isBackKey = BACK_KEYS.ltr.includes(event.key)\n onStepKeyDown?.({ event, direction: isBackKey ? -1 : 1 })\n }}\n />\n </SliderOrientationProvider>\n )\n }\n)\n\n/* -------------------------------------------------------------------------------------------------\n * SliderTrack\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRACK_NAME = 'SliderTrack'\n\ntype SliderTrackElement = HTMLElement | View\n\nconst SliderTrackFrame = styled(SliderFrame, {\n name: 'SliderTrackFrame',\n})\n\nconst SliderTrack = React.forwardRef<SliderTrackElement, SliderTrackProps>(\n (props: ScopedProps<SliderTrackProps>, forwardedRef) => {\n const { __scopeSlider, ...trackProps } = props\n const context = useSliderContext(TRACK_NAME, __scopeSlider)\n return (\n <SliderTrackFrame\n data-disabled={context.disabled ? '' : undefined}\n data-orientation={context.orientation}\n orientation={context.orientation}\n {...trackProps}\n ref={forwardedRef}\n />\n )\n }\n)\n\nSliderTrack.displayName = TRACK_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SliderTrackActive\n * -----------------------------------------------------------------------------------------------*/\n\nconst RANGE_NAME = 'SliderTrackActive'\n\ntype SliderTrackActiveElement = HTMLElement | View\ninterface SliderTrackActiveProps extends YStackProps {}\n\nconst SliderTrackActiveFrame = styled(SliderFrame, {\n name: 'SliderTrackActive',\n})\n\nconst SliderTrackActive = React.forwardRef<SliderTrackActiveElement, SliderTrackActiveProps>(\n (props: ScopedProps<SliderTrackActiveProps>, forwardedRef) => {\n const { __scopeSlider, ...rangeProps } = props\n const context = useSliderContext(RANGE_NAME, __scopeSlider)\n const orientation = useSliderOrientationContext(RANGE_NAME, __scopeSlider)\n const ref = React.useRef<HTMLSpanElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref)\n const valuesCount = context.values.length\n const percentages = context.values.map((value) =>\n convertValueToPercentage(value, context.min, context.max)\n )\n const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0\n const offsetEnd = 100 - Math.max(...percentages)\n\n return (\n <SliderTrackActiveFrame\n orientation={context.orientation}\n data-orientation={context.orientation}\n data-disabled={context.disabled ? '' : undefined}\n {...rangeProps}\n ref={composedRefs}\n {...{\n [orientation.startEdge]: offsetStart + '%',\n [orientation.endEdge]: offsetEnd + '%',\n }}\n />\n )\n }\n)\n\nSliderTrackActive.displayName = RANGE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * SliderThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SliderThumb'\n\nconst SliderThumbFrame = styled(SizableStack, {\n name: 'SliderThumb',\n position: 'absolute',\n})\n\ntype SliderThumbElement = HTMLElement | View\ninterface SliderThumbProps extends SizableStackProps {\n index: number\n}\n\nconst SliderThumb = React.forwardRef<SliderThumbElement, SliderThumbProps>(\n (props: ScopedProps<SliderThumbProps>, forwardedRef) => {\n const { __scopeSlider, index, size: sizeProp, ...thumbProps } = props\n const context = useSliderContext(THUMB_NAME, __scopeSlider)\n const orientation = useSliderOrientationContext(THUMB_NAME, __scopeSlider)\n // const [thumb, setThumb] = React.useState<HTMLSpanElement | null>(null)\n // const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node))\n\n // We cast because index could be `-1` which would return undefined\n const value = context.values[index] as number | undefined\n const percent =\n value === undefined ? 0 : convertValueToPercentage(value, context.min, context.max)\n const label = getLabel(index, context.values.length)\n const [size, setSize] = React.useState(0)\n\n const thumbInBoundsOffset = size\n ? getThumbInBoundsOffset(size, percent, orientation.direction)\n : 0\n\n console.log('thumbInBoundsOffset', thumbInBoundsOffset, size, percent)\n\n // React.useEffect(() => {\n // if (thumb) {\n // context.thumbs.add(thumb)\n // return () => {\n // context.thumbs.delete(thumb)\n // }\n // }\n // }, [thumb, context.thumbs])\n\n return (\n <SliderThumbFrame\n ref={forwardedRef}\n // role=\"slider\"\n aria-label={props['aria-label'] || label}\n aria-valuemin={context.min}\n aria-valuenow={value}\n aria-valuemax={context.max}\n aria-orientation={context.orientation}\n data-orientation={context.orientation}\n data-disabled={context.disabled ? '' : undefined}\n // tabIndex={context.disabled ? undefined : 0}\n {...thumbProps}\n x={thumbInBoundsOffset}\n y={-size / 2}\n size={sizeProp ?? context.size ?? 30}\n onLayout={(e) => {\n setSize(e.nativeEvent.layout[orientation.sizeProp])\n }}\n {...{\n [orientation.startEdge]: `${percent}%`,\n }}\n /**\n * There will be no value on initial render while we work out the index so we hide thumbs\n * without a value, otherwise SSR will render them in the wrong position before they\n * snap into the correct position during hydration which would be visually jarring for\n * slower connections.\n */\n style={value === undefined ? { display: 'none' } : props.style}\n onFocus={composeEventHandlers(props.onFocus, () => {\n context.valueIndexToChangeRef.current = index\n })}\n />\n )\n }\n)\n\nSliderThumb.displayName = THUMB_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Slider\n * -----------------------------------------------------------------------------------------------*/\n\ntype SliderElement = SliderHorizontalElement | SliderVerticalElement\n\nconst Slider = withStaticProperties(\n React.forwardRef<SliderElement, SliderProps>((props: ScopedProps<SliderProps>, forwardedRef) => {\n const {\n name,\n min = 0,\n max = 100,\n step = 1,\n orientation = 'horizontal',\n disabled = false,\n minStepsBetweenThumbs = 0,\n defaultValue = [min],\n value,\n onValueChange = () => {},\n size: sizeProp,\n ...sliderProps\n } = props\n // const [slider, setSlider] = React.useState<HTMLElement | View | null>(null)\n // const composedRefs = useComposedRefs(forwardedRef, (node) => setSlider(node))\n const thumbRefs = React.useRef<SliderContextValue['thumbs']>(new Set())\n const valueIndexToChangeRef = React.useRef<number>(0)\n const isHorizontal = orientation === 'horizontal'\n // We set this to true by default so that events bubble to forms without JS (SSR)\n // TODO\n // const isFormControl = slider ? Boolean(slider.closest('form')) : true\n\n const [values = [], setValues] = useControllableState({\n prop: value,\n defaultProp: defaultValue,\n onChange: (value) => {\n // const thumbs = [...thumbRefs.current]\n // thumbs[valueIndexToChangeRef.current]?.focus()\n onValueChange(value)\n },\n })\n\n function handleSlideStart(value: number) {\n const closestIndex = getClosestValueIndex(values, value)\n updateValues(value, closestIndex)\n }\n\n function handleSlideMove(value: number) {\n updateValues(value, valueIndexToChangeRef.current)\n }\n\n function updateValues(value: number, atIndex: number) {\n const decimalCount = getDecimalCount(step)\n const snapToStep = roundValue(Math.round((value - min) / step) * step + min, decimalCount)\n const nextValue = clamp(snapToStep, [min, max])\n setValues((prevValues = []) => {\n const nextValues = getNextSortedValues(prevValues, nextValue, atIndex)\n if (hasMinStepsBetweenValues(nextValues, minStepsBetweenThumbs * step)) {\n valueIndexToChangeRef.current = nextValues.indexOf(nextValue)\n return String(nextValues) === String(prevValues) ? prevValues : nextValues\n } else {\n return prevValues\n }\n })\n }\n\n const SliderOriented = isHorizontal ? SliderHorizontal : SliderVertical\n\n return (\n <SliderProvider\n scope={props.__scopeSlider}\n disabled={disabled}\n min={min}\n max={max}\n valueIndexToChangeRef={valueIndexToChangeRef}\n thumbs={thumbRefs.current}\n values={values}\n orientation={orientation}\n // @ts-ignore\n size={sizeProp || 20}\n >\n <SliderOriented\n aria-disabled={disabled}\n data-disabled={disabled ? '' : undefined}\n {...sliderProps}\n ref={forwardedRef}\n min={min}\n max={max}\n onSlideStart={disabled ? undefined : handleSlideStart}\n onSlideMove={disabled ? undefined : handleSlideMove}\n onHomeKeyDown={() => !disabled && updateValues(min, 0)}\n onEndKeyDown={() => !disabled && updateValues(max, values.length - 1)}\n onStepKeyDown={({ event, direction: stepDirection }) => {\n if (!disabled) {\n const isPageKey = PAGE_KEYS.includes(event.key)\n const isSkipKey = isPageKey || (event.shiftKey && ARROW_KEYS.includes(event.key))\n const multiplier = isSkipKey ? 10 : 1\n const atIndex = valueIndexToChangeRef.current\n const value = values[atIndex]\n const stepInDirection = step * multiplier * stepDirection\n updateValues(value + stepInDirection, atIndex)\n }\n }}\n />\n {/* {isFormControl &&\n values.map((value, index) => (\n <BubbleInput\n key={index}\n name={name ? name + (values.length > 1 ? '[]' : '') : undefined}\n value={value}\n />\n ))} */}\n </SliderProvider>\n )\n }),\n {\n Track: SliderTrack,\n TrackActive: SliderTrackActive,\n Thumb: SliderThumb,\n }\n)\n\nSlider.displayName = SLIDER_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\n// TODO\nconst BubbleInput = (props: any) => {\n const { value, ...inputProps } = props\n const ref = React.useRef<HTMLInputElement>(null)\n const prevValue = usePrevious(value)\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!\n const inputProto = window.HTMLInputElement.prototype\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'value') as PropertyDescriptor\n const setValue = descriptor.set\n if (prevValue !== value && setValue) {\n const event = new Event('input', { bubbles: true })\n setValue.call(input, value)\n input.dispatchEvent(event)\n }\n }, [prevValue, value])\n\n /**\n * We purposefully do not use `type=\"hidden\"` here otherwise forms that\n * wrap it will not be able to access its value via the FormData API.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n */\n return <input style={{ display: 'none' }} {...inputProps} ref={ref} defaultValue={value} />\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Track = SliderTrack\nconst Range = SliderTrackActive\nconst Thumb = SliderThumb\n\nexport {\n Slider,\n SliderTrack,\n SliderTrackActive,\n SliderThumb,\n //\n Track,\n Range,\n Thumb,\n}\nexport type { SliderProps, SliderTrackProps, SliderTrackActiveProps, SliderThumbProps }\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAA4B;AAC5B,0BAAgC;AAChC,kBAA+D;AAC/D,qBAA4C;AAE5C,oBAA4E;AAC5E,oCAAqC;AACrC,2BAA6B;AAC7B,YAAuB;AAGvB,qBAMO;AACP,sBAWO;AACP,wBAAwC;AAYxC,MAAM,YAAY,CAAC,UAAU,UAAU;AACvC,MAAM,aAAa,CAAC,WAAW,aAAa,aAAa,YAAY;AACrE,MAAM,YAAyC;AAAA,EAC7C,KAAK,CAAC,aAAa,QAAQ,aAAa,UAAU;AAAA,EAClD,K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qBAAa,SAAQ,iBAAiB,OAAO;AAAA,MAC/C;AAAA,IACF;AAAA,IACF,CASF;AAEJ,CAAC,GACD;AAAA,EACE,OAAO;AAAA,EACP,aAAa;AAAA,EACb,OAAO;AACT,CACF;AAEA,OAAO,cAAc;AAKrB,MAAM,cAAc,wBAAC,UAAe;AAClC,QAAiC,YAAzB,YAAyB,IAAf,uBAAe,IAAf,CAAV;AACR,QAAM,MAAM,MAAM,OAAyB,IAAI;AAC/C,QAAM,YAAY,2CAAY,KAAK;AAGnC,QAAM,UAAU,MAAM;AACpB,UAAM,QAAQ,IAAI;AAClB,UAAM,aAAa,OAAO,iBAAiB;AAC3C,UAAM,aAAa,OAAO,yBAAyB,YAAY,OAAO;AACtE,UAAM,WAAW,WAAW;AAC5B,QAAI,cAAc,SAAS,UAAU;AACnC,YAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC;AAClD,eAAS,KAAK,OAAO,KAAK;AAC1B,YAAM,cAAc,KAAK;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,WAAW,KAAK,CAAC;AAWrB,SAAO,oCAAC;AAAA,IAAM,OAAO,EAAE,SAAS,OAAO;AAAA,KAAO,aAAtC;AAAA,IAAkD;AAAA,IAAU,cAAc;AAAA,IAAO;AAC3F,GA5BoB;AAgCpB,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,MAAM,QAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __export = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
39
|
+
};
|
|
40
|
+
var __copyProps = (to, from, except, desc) => {
|
|
41
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
42
|
+
for (let key of __getOwnPropNames(from))
|
|
43
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
44
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
49
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
50
|
+
var SliderImpl_exports = {};
|
|
51
|
+
__export(SliderImpl_exports, {
|
|
52
|
+
DirectionalYStack: () => DirectionalYStack,
|
|
53
|
+
SliderFrame: () => SliderFrame,
|
|
54
|
+
SliderImpl: () => SliderImpl
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(SliderImpl_exports);
|
|
57
|
+
var import_core = require("@tamagui/core");
|
|
58
|
+
var import_stacks = require("@tamagui/stacks");
|
|
59
|
+
var React = __toESM(require("react"));
|
|
60
|
+
var import_context = require("./context");
|
|
61
|
+
const DirectionalYStack = (0, import_core.styled)(import_stacks.YStack, {
|
|
62
|
+
variants: {
|
|
63
|
+
orientation: {
|
|
64
|
+
horizontal: {},
|
|
65
|
+
vertical: {}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const SliderFrame = (0, import_core.styled)(DirectionalYStack, {
|
|
70
|
+
name: "Slider",
|
|
71
|
+
position: "relative",
|
|
72
|
+
variants: {
|
|
73
|
+
size: (val, extras) => {
|
|
74
|
+
const orientation = extras.props.orientation;
|
|
75
|
+
const circleSize = (0, import_stacks.getCircleSize)(val, extras);
|
|
76
|
+
const size = circleSize / 4;
|
|
77
|
+
if (orientation === "horizontal") {
|
|
78
|
+
return {
|
|
79
|
+
height: size,
|
|
80
|
+
width: 100
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
width: size,
|
|
85
|
+
height: 100
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const SliderImpl = React.forwardRef((props, forwardedRef) => {
|
|
91
|
+
const _a = props, {
|
|
92
|
+
__scopeSlider,
|
|
93
|
+
onSlideStart,
|
|
94
|
+
onSlideMove,
|
|
95
|
+
onSlideEnd,
|
|
96
|
+
onHomeKeyDown,
|
|
97
|
+
onEndKeyDown,
|
|
98
|
+
onStepKeyDown
|
|
99
|
+
} = _a, sliderProps = __objRest(_a, [
|
|
100
|
+
"__scopeSlider",
|
|
101
|
+
"onSlideStart",
|
|
102
|
+
"onSlideMove",
|
|
103
|
+
"onSlideEnd",
|
|
104
|
+
"onHomeKeyDown",
|
|
105
|
+
"onEndKeyDown",
|
|
106
|
+
"onStepKeyDown"
|
|
107
|
+
]);
|
|
108
|
+
const context = (0, import_context.useSliderContext)(import_context.SLIDER_NAME, __scopeSlider);
|
|
109
|
+
return /* @__PURE__ */ React.createElement(SliderFrame, __spreadProps(__spreadValues({
|
|
110
|
+
size: "$4"
|
|
111
|
+
}, sliderProps), {
|
|
112
|
+
"data-orientation": sliderProps.orientation,
|
|
113
|
+
ref: forwardedRef,
|
|
114
|
+
onStartShouldSetResponder: () => true,
|
|
115
|
+
onResponderGrant: (0, import_core.composeEventHandlers)(props.onResponderGrant, (event) => {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
onSlideStart(event);
|
|
118
|
+
}),
|
|
119
|
+
onResponderMove: (0, import_core.composeEventHandlers)(props.onResponderMove, (event) => {
|
|
120
|
+
onSlideMove(event);
|
|
121
|
+
}),
|
|
122
|
+
onResponderRelease: (0, import_core.composeEventHandlers)(props.onResponderRelease, (event) => {
|
|
123
|
+
onSlideEnd(event);
|
|
124
|
+
})
|
|
125
|
+
}));
|
|
126
|
+
});
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
DirectionalYStack,
|
|
130
|
+
SliderFrame,
|
|
131
|
+
SliderImpl
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=SliderImpl.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SliderImpl.tsx"],
|
|
4
|
+
"sourcesContent": ["/* -------------------------------------------------------------------------------------------------\n * SliderImpl\n * -----------------------------------------------------------------------------------------------*/\n\nimport { composeEventHandlers, styled } from '@tamagui/core'\nimport { YStack, getCircleSize } from '@tamagui/stacks'\nimport * as React from 'react'\n\nimport { SLIDER_NAME, useSliderContext } from './context'\nimport { ScopedProps, SliderImplElement, SliderImplProps } from './types'\n\nexport const DirectionalYStack = styled(YStack, {\n variants: {\n orientation: {\n horizontal: {},\n vertical: {},\n },\n },\n})\n\nexport const SliderFrame = styled(DirectionalYStack, {\n name: 'Slider',\n position: 'relative',\n\n variants: {\n size: (val, extras) => {\n const orientation = extras.props.orientation\n const circleSize = getCircleSize(val, extras)\n const size = circleSize / 4\n if (orientation === 'horizontal') {\n return {\n height: size,\n width: 100,\n }\n }\n return {\n width: size,\n height: 100,\n }\n },\n },\n})\n\nexport const SliderImpl = React.forwardRef<SliderImplElement, SliderImplProps>(\n (props: ScopedProps<SliderImplProps>, forwardedRef) => {\n const {\n __scopeSlider,\n onSlideStart,\n onSlideMove,\n onSlideEnd,\n onHomeKeyDown,\n onEndKeyDown,\n onStepKeyDown,\n ...sliderProps\n } = props\n const context = useSliderContext(SLIDER_NAME, __scopeSlider)\n\n return (\n <SliderFrame\n size=\"$4\"\n {...sliderProps}\n data-orientation={sliderProps.orientation}\n ref={forwardedRef}\n // onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n // if (event.key === 'Home') {\n // onHomeKeyDown(event)\n // // Prevent scrolling to page start\n // event.preventDefault()\n // } else if (event.key === 'End') {\n // onEndKeyDown(event)\n // // Prevent scrolling to page end\n // event.preventDefault()\n // } else if (PAGE_KEYS.concat(ARROW_KEYS).includes(event.key)) {\n // onStepKeyDown(event)\n // // Prevent scrolling for directional key presses\n // event.preventDefault()\n // }\n // })}\n onStartShouldSetResponder={() => true}\n onResponderGrant={composeEventHandlers(props.onResponderGrant, (event) => {\n // const target = event.target as HTMLElement\n // console.log('wut', target)\n // target.setPointerCapture(event.pointerId)\n // // Prevent browser focus behaviour because we focus a thumb manually when values change.\n event.preventDefault()\n // Touch devices have a delay before focusing so won't focus if touch immediately moves\n // away from target (sliding). We want thumb to focus regardless.\n // if (context.thumbs.has(target)) {\n // target.focus()\n // } else {\n onSlideStart(event)\n // }\n })}\n onResponderMove={composeEventHandlers(props.onResponderMove, (event) => {\n // const target = event.target as HTMLElement\n onSlideMove(event)\n })}\n onResponderRelease={composeEventHandlers(props.onResponderRelease, (event) => {\n // const target = event.target as HTMLElement\n onSlideEnd(event)\n })}\n />\n )\n }\n)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAA6C;AAC7C,oBAAsC;AACtC,YAAuB;AAEvB,qBAA8C;AAGvC,MAAM,oBAAoB,wBAAO,sBAAQ;AAAA,EAC9C,UAAU;AAAA,IACR,aAAa;AAAA,MACX,YAAY,CAAC;AAAA,MACb,UAAU,CAAC;AAAA,IACb;AAAA,EACF;AACF,CAAC;AAEM,MAAM,cAAc,wBAAO,mBAAmB;AAAA,EACnD,MAAM;AAAA,EACN,UAAU;AAAA,EAEV,UAAU;AAAA,IACR,MAAM,CAAC,KAAK,WAAW;AACrB,YAAM,cAAc,OAAO,MAAM;AACjC,YAAM,aAAa,iCAAc,KAAK,MAAM;AAC5C,YAAM,OAAO,aAAa;AAC1B,UAAI,gBAAgB,cAAc;AAChC,eAAO;AAAA,UACL,QAAQ;AAAA,UACR,OAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAEM,MAAM,aAAa,MAAM,WAC9B,CAAC,OAAqC,iBAAiB;AACrD,QASI,YARF;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEE,IADC,wBACD,IADC;AAAA,IAPH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGF,QAAM,UAAU,qCAAiB,4BAAa,aAAa;AAE3D,SACE,oCAAC;AAAA,IACC,MAAK;AAAA,KACD,cAFL;AAAA,IAGC,oBAAkB,YAAY;AAAA,IAC9B,KAAK;AAAA,IAgBL,2BAA2B,MAAM;AAAA,IACjC,kBAAkB,sCAAqB,MAAM,kBAAkB,CAAC,UAAU;AAKxE,YAAM,eAAe;AAMrB,mBAAa,KAAK;AAAA,IAEpB,CAAC;AAAA,IACD,iBAAiB,sCAAqB,MAAM,iBAAiB,CAAC,UAAU;AAEtE,kBAAY,KAAK;AAAA,IACnB,CAAC;AAAA,IACD,oBAAoB,sCAAqB,MAAM,oBAAoB,CAAC,UAAU;AAE5E,iBAAW,KAAK;AAAA,IAClB,CAAC;AAAA,IACH;AAEJ,CACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var context_exports = {};
|
|
19
|
+
__export(context_exports, {
|
|
20
|
+
SLIDER_NAME: () => SLIDER_NAME,
|
|
21
|
+
SliderOrientationProvider: () => SliderOrientationProvider,
|
|
22
|
+
SliderProvider: () => SliderProvider,
|
|
23
|
+
createSliderContext: () => createSliderContext,
|
|
24
|
+
createSliderScope: () => createSliderScope,
|
|
25
|
+
useSliderContext: () => useSliderContext,
|
|
26
|
+
useSliderOrientationContext: () => useSliderOrientationContext
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(context_exports);
|
|
29
|
+
var import_create_context = require("@tamagui/create-context");
|
|
30
|
+
const SLIDER_NAME = "Slider";
|
|
31
|
+
const [createSliderContext, createSliderScope] = (0, import_create_context.createContextScope)(SLIDER_NAME);
|
|
32
|
+
const [SliderProvider, useSliderContext] = createSliderContext(SLIDER_NAME);
|
|
33
|
+
const [SliderOrientationProvider, useSliderOrientationContext] = createSliderContext(SLIDER_NAME, {
|
|
34
|
+
startEdge: "left",
|
|
35
|
+
endEdge: "right",
|
|
36
|
+
sizeProp: "width",
|
|
37
|
+
size: 0,
|
|
38
|
+
direction: 1
|
|
39
|
+
});
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
SLIDER_NAME,
|
|
43
|
+
SliderOrientationProvider,
|
|
44
|
+
SliderProvider,
|
|
45
|
+
createSliderContext,
|
|
46
|
+
createSliderScope,
|
|
47
|
+
useSliderContext,
|
|
48
|
+
useSliderOrientationContext
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/context.tsx"],
|
|
4
|
+
"sourcesContent": ["import { SizeTokens } from '@tamagui/core'\nimport { createContextScope } from '@tamagui/create-context'\n\nimport { SliderContextValue } from './types'\n\nexport const SLIDER_NAME = 'Slider'\n\nexport const [createSliderContext, createSliderScope] = createContextScope(SLIDER_NAME)\n\nexport const [SliderProvider, useSliderContext] =\n createSliderContext<SliderContextValue>(SLIDER_NAME)\n\nexport const [SliderOrientationProvider, useSliderOrientationContext] = createSliderContext<{\n startEdge: 'bottom' | 'left' | 'right'\n endEdge: 'top' | 'right' | 'left'\n sizeProp: 'width' | 'height'\n size: number | SizeTokens\n direction: number\n}>(SLIDER_NAME, {\n startEdge: 'left',\n endEdge: 'right',\n sizeProp: 'width',\n size: 0,\n direction: 1,\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAAmC;AAI5B,MAAM,cAAc;AAEpB,MAAM,CAAC,qBAAqB,qBAAqB,8CAAmB,WAAW;AAE/E,MAAM,CAAC,gBAAgB,oBAC5B,oBAAwC,WAAW;AAE9C,MAAM,CAAC,2BAA2B,+BAA+B,oBAMrE,aAAa;AAAA,EACd,WAAW;AAAA,EACX,SAAS;AAAA,EACT,UAAU;AAAA,EACV,MAAM;AAAA,EACN,WAAW;AACb,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|