@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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var index_exports = {};
|
|
26
|
+
__export(index_exports, {
|
|
27
|
+
SliderContext: () => import_constants.SliderContext,
|
|
28
|
+
SliderFrame: () => import_SliderImpl.SliderFrame
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(index_exports);
|
|
31
|
+
__reExport(index_exports, require("./Slider.native.js"), module.exports);
|
|
32
|
+
var import_constants = require("./constants.native.js");
|
|
33
|
+
var import_SliderImpl = require("./SliderImpl.native.js");
|
package/dist/jsx/index.native.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
23
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
24
|
-
value: true
|
|
25
|
-
}), mod);
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
25
|
var index_exports = {};
|
|
27
26
|
__export(index_exports, {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
SliderContext: () => import_constants.SliderContext,
|
|
28
|
+
SliderFrame: () => import_SliderImpl.SliderFrame
|
|
30
29
|
});
|
|
31
30
|
module.exports = __toCommonJS(index_exports);
|
|
32
31
|
__reExport(index_exports, require("./Slider.native.js"), module.exports);
|
|
33
32
|
var import_constants = require("./constants.native.js");
|
|
34
33
|
var import_SliderImpl = require("./SliderImpl.native.js");
|
|
34
|
+
|
|
35
35
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["jsx/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n SliderContext: () => import_constants.SliderContext,\n SliderFrame: () => import_SliderImpl.SliderFrame\n});\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./Slider\"), module.exports);\nvar import_constants = require(\"./constants\");\nvar import_SliderImpl = require(\"./SliderImpl\");\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe;CACtB,qBAAqB,iBAAiB;CACtC,mBAAmB,kBAAkB;AACvC,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,oBAAU,GAAG,OAAO,OAAO;AAC7D,IAAI,mBAAmB,QAAQ,uBAAa;AAC5C,IAAI,oBAAoB,QAAQ,wBAAc"}
|
package/dist/jsx/types.mjs
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var types_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/jsx/types.native.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
15
16
|
};
|
|
16
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
}), mod);
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
18
|
var types_exports = {};
|
|
20
19
|
module.exports = __toCommonJS(types_exports);
|
|
20
|
+
|
|
21
21
|
//# sourceMappingURL=types.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":[],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"types.native.js","names":[],"sources":["jsx/types.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar types_exports = {};\nmodule.exports = __toCommonJS(types_exports);\n//# sourceMappingURL=types.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/slider",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.643.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -34,24 +34,25 @@
|
|
|
34
34
|
"clean:build": "tamagui-build clean:build"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tamagui/compose-refs": "
|
|
38
|
-
"@tamagui/constants": "
|
|
39
|
-
"@tamagui/core": "
|
|
40
|
-
"@tamagui/create-context": "
|
|
41
|
-
"@tamagui/get-token": "
|
|
42
|
-
"@tamagui/helpers": "
|
|
43
|
-
"@tamagui/stacks": "
|
|
44
|
-
"@tamagui/use-controllable-state": "
|
|
45
|
-
"@tamagui/use-debounce": "
|
|
46
|
-
"@tamagui/use-direction": "
|
|
37
|
+
"@tamagui/compose-refs": "3.0.0-beta.643.1",
|
|
38
|
+
"@tamagui/constants": "3.0.0-beta.643.1",
|
|
39
|
+
"@tamagui/core": "3.0.0-beta.643.1",
|
|
40
|
+
"@tamagui/create-context": "3.0.0-beta.643.1",
|
|
41
|
+
"@tamagui/get-token": "3.0.0-beta.643.1",
|
|
42
|
+
"@tamagui/helpers": "3.0.0-beta.643.1",
|
|
43
|
+
"@tamagui/stacks": "3.0.0-beta.643.1",
|
|
44
|
+
"@tamagui/use-controllable-state": "3.0.0-beta.643.1",
|
|
45
|
+
"@tamagui/use-debounce": "3.0.0-beta.643.1",
|
|
46
|
+
"@tamagui/use-direction": "3.0.0-beta.643.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@tamagui/build": "
|
|
49
|
+
"@tamagui/build": "3.0.0-beta.643.1",
|
|
50
50
|
"react": ">=19",
|
|
51
|
-
"react-native": "0.
|
|
51
|
+
"react-native": "0.86.2"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"react": ">=19"
|
|
54
|
+
"react": ">=19",
|
|
55
|
+
"react-native-web": "*"
|
|
55
56
|
},
|
|
56
57
|
"module:jsx": "dist/jsx",
|
|
57
58
|
"repository": {
|
package/src/Slider.tsx
CHANGED
|
@@ -9,16 +9,17 @@ import type {
|
|
|
9
9
|
TamaguiElement,
|
|
10
10
|
} from '@tamagui/core'
|
|
11
11
|
import {
|
|
12
|
+
createStyledHOC,
|
|
13
|
+
createRefComponent,
|
|
12
14
|
getTokens,
|
|
13
15
|
getVariableValue,
|
|
16
|
+
resolveSizeToken,
|
|
14
17
|
styled,
|
|
15
18
|
useConfiguration,
|
|
16
19
|
useCreateShallowSetState,
|
|
17
20
|
} from '@tamagui/core'
|
|
18
|
-
import { getSize } from '@tamagui/get-token'
|
|
19
21
|
import { clamp, composeEventHandlers, withStaticProperties } from '@tamagui/helpers'
|
|
20
|
-
import
|
|
21
|
-
import { ThemeableStack } from '@tamagui/stacks'
|
|
22
|
+
import { YStack } from '@tamagui/stacks'
|
|
22
23
|
import { useControllableState } from '@tamagui/use-controllable-state'
|
|
23
24
|
import { useDirection } from '@tamagui/use-direction'
|
|
24
25
|
import * as React from 'react'
|
|
@@ -56,19 +57,34 @@ import type {
|
|
|
56
57
|
} from './types'
|
|
57
58
|
|
|
58
59
|
const activeSliderMeasureListeners = new Set<Function>()
|
|
60
|
+
let activeSliderMeasureInterval: ReturnType<typeof setInterval> | undefined
|
|
59
61
|
|
|
60
62
|
// run an interval on web as using translate can move things at any moment
|
|
61
63
|
// without triggering layout or intersection observers
|
|
64
|
+
function startSliderMeasureInterval() {
|
|
65
|
+
if (
|
|
66
|
+
process.env.TAMAGUI_TARGET !== 'web' ||
|
|
67
|
+
activeSliderMeasureInterval !== undefined ||
|
|
68
|
+
process.env.TAMAGUI_DISABLE_SLIDER_INTERVAL
|
|
69
|
+
) {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
62
72
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
activeSliderMeasureInterval = setInterval(() => {
|
|
74
|
+
activeSliderMeasureListeners.forEach((cb) => cb())
|
|
75
|
+
}, 1000)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function addActiveSliderMeasureListener(listener: Function) {
|
|
79
|
+
activeSliderMeasureListeners.add(listener)
|
|
80
|
+
startSliderMeasureInterval()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function removeActiveSliderMeasureListener(listener: Function) {
|
|
84
|
+
activeSliderMeasureListeners.delete(listener)
|
|
85
|
+
if (!activeSliderMeasureListeners.size && activeSliderMeasureInterval !== undefined) {
|
|
86
|
+
clearInterval(activeSliderMeasureInterval)
|
|
87
|
+
activeSliderMeasureInterval = undefined
|
|
72
88
|
}
|
|
73
89
|
}
|
|
74
90
|
|
|
@@ -76,7 +92,7 @@ if (process.env.TAMAGUI_TARGET === 'web') {
|
|
|
76
92
|
* SliderHorizontal
|
|
77
93
|
* -----------------------------------------------------------------------------------------------*/
|
|
78
94
|
|
|
79
|
-
const SliderHorizontal =
|
|
95
|
+
const SliderHorizontal = createRefComponent<View, SliderHorizontalProps>(
|
|
80
96
|
(props: ScopedProps<SliderHorizontalProps>, forwardedRef) => {
|
|
81
97
|
const {
|
|
82
98
|
min,
|
|
@@ -191,9 +207,9 @@ function useSliderMeasure(sliderRef: React.RefObject<View | null>, measure: () =
|
|
|
191
207
|
(entries) => {
|
|
192
208
|
debouncedMeasure()
|
|
193
209
|
if (entries?.[0].isIntersecting) {
|
|
194
|
-
|
|
210
|
+
addActiveSliderMeasureListener(debouncedMeasure)
|
|
195
211
|
} else {
|
|
196
|
-
|
|
212
|
+
removeActiveSliderMeasureListener(debouncedMeasure)
|
|
197
213
|
}
|
|
198
214
|
},
|
|
199
215
|
{
|
|
@@ -206,7 +222,7 @@ function useSliderMeasure(sliderRef: React.RefObject<View | null>, measure: () =
|
|
|
206
222
|
io.observe(node)
|
|
207
223
|
|
|
208
224
|
return () => {
|
|
209
|
-
|
|
225
|
+
removeActiveSliderMeasureListener(debouncedMeasure)
|
|
210
226
|
io.disconnect()
|
|
211
227
|
}
|
|
212
228
|
}, [])
|
|
@@ -216,7 +232,7 @@ function useSliderMeasure(sliderRef: React.RefObject<View | null>, measure: () =
|
|
|
216
232
|
* SliderVertical
|
|
217
233
|
* -----------------------------------------------------------------------------------------------*/
|
|
218
234
|
|
|
219
|
-
const SliderVertical =
|
|
235
|
+
const SliderVertical = createRefComponent<View, SliderVerticalProps>(
|
|
220
236
|
(props: ScopedProps<SliderVerticalProps>, forwardedRef) => {
|
|
221
237
|
const {
|
|
222
238
|
min,
|
|
@@ -301,28 +317,20 @@ const SliderVertical = React.forwardRef<View, SliderVerticalProps>(
|
|
|
301
317
|
|
|
302
318
|
type SliderTrackElement = TamaguiElement
|
|
303
319
|
|
|
320
|
+
// Unstyled track frame: fill + clip only. Track color and radius live in the
|
|
321
|
+
// tamagui skin (code/ui/tamagui/src/components/Slider.tsx).
|
|
304
322
|
export const SliderTrackFrame = styled(SliderFrame, {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
height: '100%',
|
|
311
|
-
width: '100%',
|
|
312
|
-
backgroundColor: '$background',
|
|
313
|
-
position: 'relative',
|
|
314
|
-
borderRadius: 100_000,
|
|
315
|
-
overflow: 'hidden',
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
} as const,
|
|
319
|
-
|
|
320
|
-
defaultVariants: {
|
|
321
|
-
unstyled: process.env.TAMAGUI_HEADLESS === '1',
|
|
322
|
-
},
|
|
323
|
+
displayName: 'Slider',
|
|
324
|
+
height: '100%',
|
|
325
|
+
width: '100%',
|
|
326
|
+
position: 'relative',
|
|
327
|
+
overflow: 'hidden',
|
|
323
328
|
})
|
|
324
329
|
|
|
325
|
-
|
|
330
|
+
// createStyledHOC (not createRefComponent) so the tamagui skin can layer track
|
|
331
|
+
// color/radius via styled(Slider.Track, { ... }); the render body is unchanged.
|
|
332
|
+
const SliderTrack = createStyledHOC(
|
|
333
|
+
SliderTrackFrame,
|
|
326
334
|
function SliderTrack(props: ScopedProps<SliderTrackProps>, forwardedRef) {
|
|
327
335
|
const { __scopeSlider, ...trackProps } = props
|
|
328
336
|
const context = useSliderContext(__scopeSlider)
|
|
@@ -343,67 +351,58 @@ const SliderTrack = React.forwardRef<SliderTrackElement, SliderTrackProps>(
|
|
|
343
351
|
* SliderActive
|
|
344
352
|
* -----------------------------------------------------------------------------------------------*/
|
|
345
353
|
|
|
354
|
+
// Unstyled active-range frame: positioning only. Fill color and radius live in
|
|
355
|
+
// the tamagui skin.
|
|
346
356
|
export const SliderActiveFrame = styled(SliderFrame, {
|
|
347
|
-
|
|
357
|
+
displayName: 'SliderActive',
|
|
348
358
|
position: 'absolute',
|
|
349
359
|
pointerEvents: 'box-none',
|
|
350
|
-
|
|
351
|
-
variants: {
|
|
352
|
-
unstyled: {
|
|
353
|
-
false: {
|
|
354
|
-
backgroundColor: '$background',
|
|
355
|
-
borderRadius: 100_000,
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
} as const,
|
|
359
|
-
|
|
360
|
-
defaultVariants: {
|
|
361
|
-
unstyled: process.env.TAMAGUI_HEADLESS === '1',
|
|
362
|
-
},
|
|
363
360
|
})
|
|
364
361
|
|
|
365
362
|
type SliderActiveProps = GetProps<typeof SliderActiveFrame>
|
|
366
363
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
364
|
+
// createStyledHOC so the tamagui skin can layer active-range color/radius via
|
|
365
|
+
// styled(Slider.TrackActive, { ... }); the render body is unchanged.
|
|
366
|
+
const SliderActive = createStyledHOC(
|
|
367
|
+
SliderActiveFrame,
|
|
368
|
+
function SliderActive(props: ScopedProps<SliderActiveProps>, forwardedRef) {
|
|
369
|
+
const { __scopeSlider, ...rangeProps } = props
|
|
370
|
+
const context = useSliderContext(__scopeSlider)
|
|
371
|
+
const orientation = useSliderOrientationContext(__scopeSlider)
|
|
372
|
+
const ref = React.useRef<View>(null)
|
|
373
|
+
const composedRefs = useComposedRefs(forwardedRef, ref)
|
|
374
|
+
const valuesCount = context.values.length
|
|
375
|
+
const percentages = context.values.map((value) =>
|
|
376
|
+
convertValueToPercentage(value, context.min, context.max)
|
|
377
|
+
)
|
|
378
|
+
const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0
|
|
379
|
+
const offsetEnd = 100 - Math.max(...percentages)
|
|
380
|
+
|
|
381
|
+
return (
|
|
382
|
+
<SliderActiveFrame
|
|
383
|
+
orientation={context.orientation}
|
|
384
|
+
data-orientation={context.orientation}
|
|
385
|
+
data-disabled={context.disabled ? '' : undefined}
|
|
386
|
+
size={context.size}
|
|
387
|
+
animateOnly={['left', 'top', 'right', 'bottom']}
|
|
388
|
+
{...rangeProps}
|
|
389
|
+
ref={composedRefs}
|
|
390
|
+
{...{
|
|
391
|
+
[orientation.startEdge]: `${offsetStart}%`,
|
|
392
|
+
[orientation.endEdge]: `${offsetEnd}%`,
|
|
393
|
+
}}
|
|
394
|
+
{...(orientation.sizeProp === 'width'
|
|
395
|
+
? {
|
|
396
|
+
height: '100%',
|
|
397
|
+
}
|
|
398
|
+
: {
|
|
399
|
+
left: 0,
|
|
400
|
+
right: 0,
|
|
401
|
+
})}
|
|
402
|
+
/>
|
|
403
|
+
)
|
|
404
|
+
}
|
|
405
|
+
)
|
|
407
406
|
|
|
408
407
|
/* -------------------------------------------------------------------------------------------------
|
|
409
408
|
* SliderThumb
|
|
@@ -411,14 +410,11 @@ const SliderActive = React.forwardRef<View, SliderActiveProps>(function SliderAc
|
|
|
411
410
|
|
|
412
411
|
// TODO make this customizable through tamagui
|
|
413
412
|
// so we can accurately use it for estimatedSize below
|
|
414
|
-
const getThumbSize = (val?: SizeTokens | number) => {
|
|
413
|
+
const getThumbSize = (val?: SizeTokens | number | true) => {
|
|
415
414
|
const tokens = getTokens()
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
: getSize(tokens.size[val as any] as any, {
|
|
420
|
-
shift: -1,
|
|
421
|
-
})
|
|
415
|
+
const sizeToken = resolveSizeToken(val ?? true, 'size')
|
|
416
|
+
const resolved = typeof sizeToken === 'number' ? sizeToken : tokens.size[sizeToken]
|
|
417
|
+
const size = typeof val === 'number' ? val : getVariableValue(resolved) * 0.86
|
|
422
418
|
return {
|
|
423
419
|
width: size,
|
|
424
420
|
height: size,
|
|
@@ -427,50 +423,47 @@ const getThumbSize = (val?: SizeTokens | number) => {
|
|
|
427
423
|
}
|
|
428
424
|
}
|
|
429
425
|
|
|
430
|
-
|
|
431
|
-
|
|
426
|
+
// Unstyled thumb frame: positioning + the size mechanism (hit-target
|
|
427
|
+
// dimensions) + the circular shape modifier (opt-in, off by default). Border,
|
|
428
|
+
// background, and hover/press/focus color styling live in the tamagui skin.
|
|
429
|
+
export const SliderThumbFrame = styled(YStack, {
|
|
430
|
+
displayName: 'SliderThumb',
|
|
431
|
+
position: 'absolute',
|
|
432
432
|
|
|
433
433
|
variants: {
|
|
434
434
|
size: {
|
|
435
|
-
|
|
436
|
-
|
|
435
|
+
number: getThumbSize,
|
|
436
|
+
Size: getThumbSize,
|
|
437
437
|
},
|
|
438
438
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
borderColor: '$borderColor',
|
|
444
|
-
backgroundColor: '$background',
|
|
445
|
-
pressStyle: {
|
|
446
|
-
backgroundColor: '$backgroundPress',
|
|
447
|
-
borderColor: '$borderColorPress',
|
|
448
|
-
},
|
|
449
|
-
hoverStyle: {
|
|
450
|
-
backgroundColor: '$backgroundHover',
|
|
451
|
-
borderColor: '$borderColorHover',
|
|
452
|
-
},
|
|
453
|
-
focusVisibleStyle: {
|
|
454
|
-
outlineStyle: 'solid',
|
|
455
|
-
outlineWidth: 2,
|
|
456
|
-
outlineColor: '$outlineColor',
|
|
457
|
-
},
|
|
439
|
+
circular: {
|
|
440
|
+
true: {
|
|
441
|
+
borderRadius: 100_000,
|
|
442
|
+
padding: 0,
|
|
458
443
|
},
|
|
459
444
|
},
|
|
460
|
-
} as const,
|
|
461
445
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
446
|
+
// opt-in v2-compat elevate (formerly from ThemeableStack), off by default.
|
|
447
|
+
// On the frame (the animated node), not a skin wrapper — a variant block on a
|
|
448
|
+
// wrapper breaks the native animation driver's interpolation.
|
|
449
|
+
elevate: {
|
|
450
|
+
true: {
|
|
451
|
+
shadowColor: 'shadow-color',
|
|
452
|
+
shadowRadius: 4,
|
|
453
|
+
shadowOffset: { width: 0, height: 2 },
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
} as const,
|
|
465
457
|
})
|
|
466
458
|
|
|
467
459
|
export interface SliderThumbExtraProps {
|
|
468
460
|
index?: number
|
|
469
461
|
}
|
|
470
462
|
|
|
471
|
-
export
|
|
463
|
+
export type SliderThumbProps = GetProps<typeof SliderThumbFrame> & SliderThumbExtraProps
|
|
472
464
|
|
|
473
|
-
const SliderThumb =
|
|
465
|
+
const SliderThumb = createStyledHOC(
|
|
466
|
+
SliderThumbFrame,
|
|
474
467
|
function SliderThumb(props: ScopedProps<SliderThumbProps>, forwardedRef) {
|
|
475
468
|
const { __scopeSlider, index = 0, circular, size: sizeProp, ...thumbProps } = props
|
|
476
469
|
const context = useSliderContext(__scopeSlider)
|
|
@@ -483,7 +476,7 @@ const SliderThumb = SliderThumbFrame.styleable<SliderThumbExtraProps>(
|
|
|
483
476
|
const percent =
|
|
484
477
|
value === undefined ? 0 : convertValueToPercentage(value, context.min, context.max)
|
|
485
478
|
const label = getLabel(index, context.values.length)
|
|
486
|
-
const sizeIn = sizeProp ?? context.size ??
|
|
479
|
+
const sizeIn = (sizeProp ?? context.size ?? true) as SizeTokens | number | true
|
|
487
480
|
const [size, setSize] = React.useState(() => {
|
|
488
481
|
// for SSR
|
|
489
482
|
const estimatedSize = getVariableValue(getThumbSize(sizeIn).width) as number
|
|
@@ -571,7 +564,7 @@ const SliderThumb = SliderThumbFrame.styleable<SliderThumbExtraProps>(
|
|
|
571
564
|
* Slider
|
|
572
565
|
* -----------------------------------------------------------------------------------------------*/
|
|
573
566
|
|
|
574
|
-
const SliderComponent =
|
|
567
|
+
const SliderComponent = createRefComponent(
|
|
575
568
|
(props: ScopedProps<SliderProps>, forwardedRef) => {
|
|
576
569
|
const {
|
|
577
570
|
name,
|
|
@@ -709,14 +702,11 @@ const SliderComponent = React.forwardRef(
|
|
|
709
702
|
}
|
|
710
703
|
}}
|
|
711
704
|
/>
|
|
712
|
-
{
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
key={index}
|
|
716
|
-
|
|
717
|
-
value={value}
|
|
718
|
-
/>
|
|
719
|
-
))} */}
|
|
705
|
+
{isWeb &&
|
|
706
|
+
name &&
|
|
707
|
+
values.map((value, index) => (
|
|
708
|
+
<input key={index} type="hidden" name={name} value={value} />
|
|
709
|
+
))}
|
|
720
710
|
</SliderProvider>
|
|
721
711
|
)
|
|
722
712
|
}
|
|
@@ -730,41 +720,6 @@ const Slider = withStaticProperties(SliderComponent, {
|
|
|
730
720
|
|
|
731
721
|
Slider.displayName = SLIDER_NAME
|
|
732
722
|
|
|
733
|
-
/* -----------------------------------------------------------------------------------------------*/
|
|
734
|
-
|
|
735
|
-
// // TODO
|
|
736
|
-
// const BubbleInput = (props: any) => {
|
|
737
|
-
// const { value, ...inputProps } = props
|
|
738
|
-
// const ref = React.useRef<HTMLInputElement>(null)
|
|
739
|
-
// const prevValue = usePrevious(value)
|
|
740
|
-
|
|
741
|
-
// // Bubble value change to parents (e.g form change event)
|
|
742
|
-
// React.useEffect(() => {
|
|
743
|
-
// const input = ref.current!
|
|
744
|
-
// const inputProto = window.HTMLInputElement.prototype
|
|
745
|
-
// const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'value') as PropertyDescriptor
|
|
746
|
-
// const setValue = descriptor.set
|
|
747
|
-
// if (prevValue !== value && setValue) {
|
|
748
|
-
// const event = new Event('input', { bubbles: true })
|
|
749
|
-
// setValue.call(input, value)
|
|
750
|
-
// input.dispatchEvent(event)
|
|
751
|
-
// }
|
|
752
|
-
// }, [prevValue, value])
|
|
753
|
-
|
|
754
|
-
// /**
|
|
755
|
-
// * We purposefully do not use `type="hidden"` here otherwise forms that
|
|
756
|
-
// * wrap it will not be able to access its value via the FormData API.
|
|
757
|
-
// *
|
|
758
|
-
// * We purposefully do not add the `value` attribute here to allow the value
|
|
759
|
-
// * to be set programatically and bubble to any parent form `onChange` event.
|
|
760
|
-
// * Adding the `value` will cause React to consider the programatic
|
|
761
|
-
// * dispatch a duplicate and it will get swallowed.
|
|
762
|
-
// */
|
|
763
|
-
// return <input style={{ display: 'none' }} {...inputProps} ref={ref} defaultValue={value} />
|
|
764
|
-
// }
|
|
765
|
-
|
|
766
|
-
/* -----------------------------------------------------------------------------------------------*/
|
|
767
|
-
|
|
768
723
|
const Track = SliderTrack
|
|
769
724
|
const Range = SliderActive
|
|
770
725
|
const Thumb = SliderThumb
|
package/src/SliderImpl.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRefComponent } from '@tamagui/core'
|
|
1
2
|
/* -------------------------------------------------------------------------------------------------
|
|
2
3
|
* SliderImpl
|
|
3
4
|
* -----------------------------------------------------------------------------------------------*/
|
|
@@ -44,7 +45,7 @@ export const SliderFrame = styled(YStack, {
|
|
|
44
45
|
} as const,
|
|
45
46
|
})
|
|
46
47
|
|
|
47
|
-
export const SliderImpl =
|
|
48
|
+
export const SliderImpl = createRefComponent<View, SliderImplProps>(
|
|
48
49
|
(props: ScopedProps<SliderImplProps>, forwardedRef) => {
|
|
49
50
|
const {
|
|
50
51
|
__scopeSlider,
|
|
@@ -107,7 +108,7 @@ export const SliderImpl = React.forwardRef<View, SliderImplProps>(
|
|
|
107
108
|
// wrap with plain RN View for responder events - tamagui views no longer handle responder events on web
|
|
108
109
|
|
|
109
110
|
<SliderFrame
|
|
110
|
-
size="
|
|
111
|
+
size="4"
|
|
111
112
|
ref={forwardedRef as any}
|
|
112
113
|
{...sliderProps}
|
|
113
114
|
data-orientation={sliderProps.orientation}
|