@tamagui/slider 2.7.7 → 3.0.0-beta.643.1
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.cjs +455 -512
- package/dist/cjs/Slider.native.cjs +469 -0
- package/dist/cjs/Slider.native.js +424 -498
- package/dist/cjs/Slider.native.js.map +1 -1
- package/dist/cjs/SliderImpl.cjs +111 -128
- package/dist/cjs/SliderImpl.native.cjs +154 -0
- package/dist/cjs/SliderImpl.native.js +127 -143
- package/dist/cjs/SliderImpl.native.js.map +1 -1
- package/dist/cjs/constants.cjs +59 -45
- package/dist/cjs/constants.native.cjs +79 -0
- package/dist/cjs/constants.native.js +59 -44
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/helpers.cjs +59 -60
- package/dist/cjs/helpers.native.cjs +99 -0
- package/dist/cjs/helpers.native.js +66 -68
- package/dist/cjs/helpers.native.js.map +1 -1
- package/dist/cjs/index.cjs +16 -17
- package/dist/cjs/index.native.cjs +33 -0
- package/dist/cjs/index.native.js +16 -16
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +10 -11
- package/dist/cjs/types.native.cjs +19 -0
- package/dist/cjs/types.native.js +10 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Slider.mjs +427 -474
- package/dist/esm/Slider.mjs.map +1 -1
- package/dist/esm/Slider.native.js +396 -463
- package/dist/esm/Slider.native.js.map +1 -1
- package/dist/esm/SliderImpl.mjs +92 -102
- package/dist/esm/SliderImpl.mjs.map +1 -1
- package/dist/esm/SliderImpl.native.js +109 -119
- package/dist/esm/SliderImpl.native.js.map +1 -1
- package/dist/esm/constants.mjs +38 -21
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +38 -21
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/helpers.mjs +37 -36
- package/dist/esm/helpers.mjs.map +1 -1
- package/dist/esm/helpers.native.js +44 -45
- package/dist/esm/helpers.native.js.map +1 -1
- package/dist/esm/index.js +4 -3
- package/dist/esm/index.mjs +4 -3
- package/dist/esm/index.native.js +4 -3
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/dist/jsx/Slider.mjs +427 -474
- package/dist/jsx/Slider.mjs.map +1 -1
- package/dist/jsx/Slider.native.cjs +469 -0
- package/dist/jsx/Slider.native.js +424 -498
- package/dist/jsx/Slider.native.js.map +1 -1
- package/dist/jsx/SliderImpl.mjs +92 -102
- package/dist/jsx/SliderImpl.mjs.map +1 -1
- package/dist/jsx/SliderImpl.native.cjs +154 -0
- package/dist/jsx/SliderImpl.native.js +127 -143
- package/dist/jsx/SliderImpl.native.js.map +1 -1
- package/dist/jsx/constants.mjs +38 -21
- package/dist/jsx/constants.mjs.map +1 -1
- package/dist/jsx/constants.native.cjs +79 -0
- package/dist/jsx/constants.native.js +59 -44
- package/dist/jsx/constants.native.js.map +1 -1
- package/dist/jsx/helpers.mjs +37 -36
- package/dist/jsx/helpers.mjs.map +1 -1
- package/dist/jsx/helpers.native.cjs +99 -0
- package/dist/jsx/helpers.native.js +66 -68
- package/dist/jsx/helpers.native.js.map +1 -1
- package/dist/jsx/index.js +4 -3
- package/dist/jsx/index.mjs +4 -3
- package/dist/jsx/index.native.cjs +33 -0
- package/dist/jsx/index.native.js +16 -16
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +19 -0
- package/dist/jsx/types.native.js +10 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +15 -14
- package/src/Slider.tsx +126 -171
- package/src/SliderImpl.tsx +3 -2
- package/src/constants.tsx +16 -6
- package/src/types.ts +6 -4
- package/types/Slider.d.ts +218 -200
- package/types/Slider.d.ts.map +1 -1
- package/types/SliderImpl.d.ts +16 -5
- package/types/SliderImpl.d.ts.map +1 -1
- package/types/constants.d.ts +10 -10
- package/types/constants.d.ts.map +1 -1
- package/types/helpers.d.ts.map +1 -1
- package/types/types.d.ts +6 -4
- package/types/types.d.ts.map +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/types.mjs.map +0 -1
|
@@ -1,67 +1,66 @@
|
|
|
1
1
|
function getNextSortedValues() {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return a - b;
|
|
9
|
-
});
|
|
2
|
+
var prevValues = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], nextValue = arguments.length > 1 ? arguments[1] : void 0, atIndex = arguments.length > 2 ? arguments[2] : void 0;
|
|
3
|
+
var nextValues = [...prevValues];
|
|
4
|
+
nextValues[atIndex] = nextValue;
|
|
5
|
+
return nextValues.sort(function(a, b) {
|
|
6
|
+
return a - b;
|
|
7
|
+
});
|
|
10
8
|
}
|
|
11
9
|
function convertValueToPercentage(value, min, max) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
var maxSteps = max - min;
|
|
11
|
+
var percentPerStep = 100 / maxSteps;
|
|
12
|
+
return percentPerStep * (value - min);
|
|
15
13
|
}
|
|
16
14
|
function getLabel(index, totalValues) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
if (totalValues > 2) {
|
|
16
|
+
return `Value ${index + 1} of ${totalValues}`;
|
|
17
|
+
}
|
|
18
|
+
if (totalValues === 2) {
|
|
19
|
+
return ["Minimum", "Maximum"][index];
|
|
20
|
+
}
|
|
21
|
+
return void 0;
|
|
24
22
|
}
|
|
25
23
|
function getClosestValueIndex(values, nextValue) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
if (values.length === 1) return 0;
|
|
25
|
+
var distances = values.map(function(value) {
|
|
26
|
+
return Math.abs(value - nextValue);
|
|
27
|
+
});
|
|
28
|
+
var closestDistance = Math.min(...distances);
|
|
29
|
+
return distances.indexOf(closestDistance);
|
|
32
30
|
}
|
|
33
31
|
function getThumbInBoundsOffset(width, left, direction) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
var quarterWidth = width / 4;
|
|
33
|
+
var halfPercent = 50;
|
|
34
|
+
var offset = linearScale([0, halfPercent], [0, quarterWidth]);
|
|
35
|
+
return (quarterWidth - offset(left)) * direction;
|
|
38
36
|
}
|
|
39
37
|
function getStepsBetweenValues(values) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
return values.slice(0, -1).map(function(value, index) {
|
|
39
|
+
return values[index + 1] - value;
|
|
40
|
+
});
|
|
43
41
|
}
|
|
44
42
|
function hasMinStepsBetweenValues(values, minStepsBetweenValues) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
if (minStepsBetweenValues > 0) {
|
|
44
|
+
var stepsBetweenValues = getStepsBetweenValues(values);
|
|
45
|
+
var actualMinStepsBetweenValues = Math.min(...stepsBetweenValues);
|
|
46
|
+
return actualMinStepsBetweenValues >= minStepsBetweenValues;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
51
49
|
}
|
|
52
50
|
function linearScale(input, output) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
return function(value) {
|
|
52
|
+
if (input[0] === input[1] || output[0] === output[1]) return output[0];
|
|
53
|
+
var ratio = (output[1] - output[0]) / (input[1] - input[0]);
|
|
54
|
+
return output[0] + ratio * (value - input[0]);
|
|
55
|
+
};
|
|
58
56
|
}
|
|
59
57
|
function getDecimalCount(value) {
|
|
60
|
-
|
|
58
|
+
return (String(value).split(".")[1] || "").length;
|
|
61
59
|
}
|
|
62
60
|
function roundValue(value, decimalCount) {
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
var rounder = Math.pow(10, decimalCount);
|
|
62
|
+
return Math.round(value * rounder) / rounder;
|
|
65
63
|
}
|
|
64
|
+
|
|
66
65
|
export { convertValueToPercentage, getClosestValueIndex, getDecimalCount, getLabel, getNextSortedValues, getThumbInBoundsOffset, hasMinStepsBetweenValues, linearScale, roundValue };
|
|
67
66
|
//# sourceMappingURL=helpers.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"helpers.native.js","names":[],"sources":["esm/helpers.native.js"],"sourcesContent":["function getNextSortedValues() {\n var prevValues = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], nextValue = arguments.length > 1 ? arguments[1] : void 0, atIndex = arguments.length > 2 ? arguments[2] : void 0;\n var nextValues = [\n ...prevValues\n ];\n nextValues[atIndex] = nextValue;\n return nextValues.sort(function(a, b) {\n return a - b;\n });\n}\nfunction convertValueToPercentage(value, min, max) {\n var maxSteps = max - min;\n var percentPerStep = 100 / maxSteps;\n return percentPerStep * (value - min);\n}\nfunction getLabel(index, totalValues) {\n if (totalValues > 2) {\n return `Value ${index + 1} of ${totalValues}`;\n }\n if (totalValues === 2) {\n return [\n \"Minimum\",\n \"Maximum\"\n ][index];\n }\n return void 0;\n}\nfunction getClosestValueIndex(values, nextValue) {\n if (values.length === 1) return 0;\n var distances = values.map(function(value) {\n return Math.abs(value - nextValue);\n });\n var closestDistance = Math.min(...distances);\n return distances.indexOf(closestDistance);\n}\nfunction getThumbInBoundsOffset(width, left, direction) {\n var quarterWidth = width / 4;\n var halfPercent = 50;\n var offset = linearScale([\n 0,\n halfPercent\n ], [\n 0,\n quarterWidth\n ]);\n return (quarterWidth - offset(left)) * direction;\n}\nfunction getStepsBetweenValues(values) {\n return values.slice(0, -1).map(function(value, index) {\n return values[index + 1] - value;\n });\n}\nfunction hasMinStepsBetweenValues(values, minStepsBetweenValues) {\n if (minStepsBetweenValues > 0) {\n var stepsBetweenValues = getStepsBetweenValues(values);\n var actualMinStepsBetweenValues = Math.min(...stepsBetweenValues);\n return actualMinStepsBetweenValues >= minStepsBetweenValues;\n }\n return true;\n}\nfunction linearScale(input, output) {\n return function(value) {\n if (input[0] === input[1] || output[0] === output[1]) return output[0];\n var ratio = (output[1] - output[0]) / (input[1] - input[0]);\n return output[0] + ratio * (value - input[0]);\n };\n}\nfunction getDecimalCount(value) {\n return (String(value).split(\".\")[1] || \"\").length;\n}\nfunction roundValue(value, decimalCount) {\n var rounder = Math.pow(10, decimalCount);\n return Math.round(value * rounder) / rounder;\n}\nexport {\n convertValueToPercentage,\n getClosestValueIndex,\n getDecimalCount,\n getLabel,\n getNextSortedValues,\n getThumbInBoundsOffset,\n hasMinStepsBetweenValues,\n linearScale,\n roundValue\n};\n//# sourceMappingURL=helpers.js.map\n"],"mappings":";AAAA,SAAS,sBAAsB;CAC7B,IAAI,aAAa,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK,CAAC,GAAG,YAAY,UAAU,SAAS,IAAI,UAAU,KAAK,KAAK,GAAG,UAAU,UAAU,SAAS,IAAI,UAAU,KAAK,KAAK;CACrM,IAAI,aAAa,CACf,GAAG,UACL;CACA,WAAW,WAAW;CACtB,OAAO,WAAW,KAAK,SAAS,GAAG,GAAG;EACpC,OAAO,IAAI;CACb,CAAC;AACH;AACA,SAAS,yBAAyB,OAAO,KAAK,KAAK;CACjD,IAAI,WAAW,MAAM;CACrB,IAAI,iBAAiB,MAAM;CAC3B,OAAO,kBAAkB,QAAQ;AACnC;AACA,SAAS,SAAS,OAAO,aAAa;CACpC,IAAI,cAAc,GAAG;EACnB,OAAO,SAAS,QAAQ,EAAE,MAAM;CAClC;CACA,IAAI,gBAAgB,GAAG;EACrB,OAAO,CACL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O,KAAK,MAAM,QAAQ,OAAO,IAAI;AACvC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from "./Slider.mjs";
|
|
2
1
|
import { SliderContext } from "./constants.mjs";
|
|
3
2
|
import { SliderFrame } from "./SliderImpl.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
export * from "./Slider.mjs"
|
|
5
|
+
|
|
6
|
+
export { SliderContext, SliderFrame };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from "./Slider.mjs";
|
|
2
1
|
import { SliderContext } from "./constants.mjs";
|
|
3
2
|
import { SliderFrame } from "./SliderImpl.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
export * from "./Slider.mjs"
|
|
5
|
+
|
|
6
|
+
export { SliderContext, SliderFrame };
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from "./Slider.native.js";
|
|
2
1
|
import { SliderContext } from "./constants.native.js";
|
|
3
2
|
import { SliderFrame } from "./SliderImpl.native.js";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
export * from "./Slider.native.js"
|
|
5
|
+
|
|
6
|
+
export { SliderContext, SliderFrame };
|
package/dist/esm/types.mjs
CHANGED
package/dist/esm/types.native.js
CHANGED