@tamagui/toggle-group 2.7.7 → 3.0.0-beta.1093.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/Toggle.cjs +58 -130
- package/dist/cjs/Toggle.native.cjs +90 -0
- package/dist/cjs/Toggle.native.js +64 -135
- package/dist/cjs/Toggle.native.js.map +1 -1
- package/dist/cjs/ToggleGroup.cjs +157 -211
- package/dist/cjs/ToggleGroup.native.cjs +207 -0
- package/dist/cjs/ToggleGroup.native.js +172 -225
- package/dist/cjs/ToggleGroup.native.js.map +1 -1
- package/dist/cjs/context.cjs +18 -20
- package/dist/cjs/context.native.cjs +36 -0
- package/dist/cjs/context.native.js +19 -20
- package/dist/cjs/context.native.js.map +1 -1
- package/dist/cjs/index.cjs +14 -18
- package/dist/cjs/index.native.cjs +28 -0
- package/dist/cjs/index.native.js +14 -17
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +9 -11
- package/dist/cjs/types.native.cjs +18 -0
- package/dist/cjs/types.native.js +9 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Toggle.mjs +46 -103
- package/dist/esm/Toggle.mjs.map +1 -1
- package/dist/esm/Toggle.native.js +51 -114
- package/dist/esm/Toggle.native.js.map +1 -1
- package/dist/esm/ToggleGroup.mjs +145 -188
- package/dist/esm/ToggleGroup.mjs.map +1 -1
- package/dist/esm/ToggleGroup.native.js +160 -203
- package/dist/esm/ToggleGroup.native.js.map +1 -1
- package/dist/esm/context.mjs +5 -3
- package/dist/esm/context.mjs.map +1 -1
- package/dist/esm/context.native.js +6 -4
- package/dist/esm/context.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/Toggle.mjs +46 -103
- package/dist/jsx/Toggle.mjs.map +1 -1
- package/dist/jsx/Toggle.native.cjs +90 -0
- package/dist/jsx/Toggle.native.js +64 -135
- package/dist/jsx/Toggle.native.js.map +1 -1
- package/dist/jsx/ToggleGroup.mjs +145 -188
- package/dist/jsx/ToggleGroup.mjs.map +1 -1
- package/dist/jsx/ToggleGroup.native.cjs +207 -0
- package/dist/jsx/ToggleGroup.native.js +172 -225
- package/dist/jsx/ToggleGroup.native.js.map +1 -1
- package/dist/jsx/context.mjs +5 -3
- package/dist/jsx/context.mjs.map +1 -1
- package/dist/jsx/context.native.cjs +36 -0
- package/dist/jsx/context.native.js +19 -20
- package/dist/jsx/context.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 +28 -0
- package/dist/jsx/index.native.js +14 -17
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +18 -0
- package/dist/jsx/types.native.js +9 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +18 -16
- package/src/Toggle.tsx +37 -89
- package/src/ToggleGroup.tsx +20 -11
- package/types/Toggle.d.ts +19 -59
- package/types/Toggle.d.ts.map +1 -1
- package/types/ToggleGroup.d.ts +31 -125
- package/types/ToggleGroup.d.ts.map +1 -1
- package/types/context.d.ts +1 -1
- package/types/context.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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var index_exports = {};
|
|
25
|
+
__export(index_exports, { useToggleGroupItem: () => import_context.useToggleGroupItem });
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
__reExport(index_exports, require("./ToggleGroup.native.js"), module.exports);
|
|
28
|
+
var import_context = require("./context.native.js");
|
package/dist/jsx/index.native.js
CHANGED
|
@@ -5,29 +5,26 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
21
|
};
|
|
22
22
|
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);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
24
|
var index_exports = {};
|
|
27
|
-
__export(index_exports, {
|
|
28
|
-
useToggleGroupItem: () => import_context.useToggleGroupItem
|
|
29
|
-
});
|
|
25
|
+
__export(index_exports, { useToggleGroupItem: () => import_context.useToggleGroupItem });
|
|
30
26
|
module.exports = __toCommonJS(index_exports);
|
|
31
27
|
__reExport(index_exports, require("./ToggleGroup.native.js"), module.exports);
|
|
32
28
|
var import_context = require("./context.native.js");
|
|
29
|
+
|
|
33
30
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 useToggleGroupItem: () => import_context.useToggleGroupItem\n});\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./ToggleGroup\"), module.exports);\nvar import_context = require(\"./context\");\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,EACtB,0BAA0B,eAAe,mBAC3C,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,yBAAe,GAAG,OAAO,OAAO;AAClE,IAAI,iBAAiB,QAAQ,qBAAW"}
|
package/dist/jsx/types.mjs
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/jsx/types.native.js
CHANGED
|
@@ -5,17 +5,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
15
|
};
|
|
16
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
}), mod);
|
|
16
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
17
|
var types_exports = {};
|
|
20
18
|
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
|
|
21
20
|
//# 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,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/toggle-group",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1093.1",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"source": "src/index.ts",
|
|
5
6
|
"files": [
|
|
6
7
|
"src",
|
|
@@ -34,23 +35,24 @@
|
|
|
34
35
|
"clean:build": "tamagui-build clean:build"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@tamagui/
|
|
38
|
-
"@tamagui/
|
|
39
|
-
"@tamagui/
|
|
40
|
-
"@tamagui/
|
|
41
|
-
"@tamagui/
|
|
42
|
-
"@tamagui/
|
|
43
|
-
"@tamagui/
|
|
44
|
-
"@tamagui/
|
|
45
|
-
"@tamagui/
|
|
46
|
-
"@tamagui/
|
|
47
|
-
"@tamagui/
|
|
48
|
-
"@tamagui/
|
|
49
|
-
"@tamagui/
|
|
38
|
+
"@tamagui/compose-refs": "3.0.0-beta.1093.1",
|
|
39
|
+
"@tamagui/constants": "3.0.0-beta.1093.1",
|
|
40
|
+
"@tamagui/create-context": "3.0.0-beta.1093.1",
|
|
41
|
+
"@tamagui/focusable": "3.0.0-beta.1093.1",
|
|
42
|
+
"@tamagui/font-size": "3.0.0-beta.1093.1",
|
|
43
|
+
"@tamagui/get-token": "3.0.0-beta.1093.1",
|
|
44
|
+
"@tamagui/helpers": "3.0.0-beta.1093.1",
|
|
45
|
+
"@tamagui/helpers-tamagui": "3.0.0-beta.1093.1",
|
|
46
|
+
"@tamagui/roving-focus": "3.0.0-beta.1093.1",
|
|
47
|
+
"@tamagui/size": "3.0.0-beta.1093.1",
|
|
48
|
+
"@tamagui/stacks": "3.0.0-beta.1093.1",
|
|
49
|
+
"@tamagui/use-controllable-state": "3.0.0-beta.1093.1",
|
|
50
|
+
"@tamagui/use-direction": "3.0.0-beta.1093.1",
|
|
51
|
+
"@tamagui/web": "3.0.0-beta.1093.1"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
|
-
"@tamagui/build": "
|
|
53
|
-
"react": "
|
|
54
|
+
"@tamagui/build": "3.0.0-beta.1093.1",
|
|
55
|
+
"react": "19.2.3"
|
|
54
56
|
},
|
|
55
57
|
"peerDependencies": {
|
|
56
58
|
"react": ">=19"
|
package/src/Toggle.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { createRefComponent } from '@tamagui/compose-refs'
|
|
1
2
|
import { composeEventHandlers } from '@tamagui/helpers'
|
|
3
|
+
import { resolveSize } from '@tamagui/size'
|
|
2
4
|
import { useControllableState } from '@tamagui/use-controllable-state'
|
|
3
|
-
import type { GetProps,
|
|
5
|
+
import type { GetProps, StylePiece, TamaguiElement } from '@tamagui/web'
|
|
4
6
|
import { styled, View } from '@tamagui/web'
|
|
5
7
|
import * as React from 'react'
|
|
6
8
|
import { context } from './context'
|
|
@@ -11,78 +13,39 @@ import { context } from './context'
|
|
|
11
13
|
|
|
12
14
|
const NAME = 'Toggle'
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
// Unstyled Toggle behavior frame: structural layout, the size mechanism
|
|
17
|
+
// (hit-target dimensions), the native button render, and focus reset only. All
|
|
18
|
+
// theme decoration (palette, border, hover/press/focus color styling) and the
|
|
19
|
+
// default "active" appearance live in the tamagui skin
|
|
20
|
+
// (code/ui/tamagui/src/components/ToggleGroup.tsx). The frame still emits the
|
|
21
|
+
// discrete state (aria-pressed / data-state) via the Toggle component below; the
|
|
22
|
+
// skins can supply a plain style prop object that is applied while active.
|
|
23
|
+
export const ToggleFrame = styled(View, {
|
|
24
|
+
displayName: NAME,
|
|
25
|
+
render: 'button',
|
|
26
|
+
context,
|
|
27
|
+
size: true,
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
justifyContent: 'center',
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
backgroundColor: '$backgroundHover',
|
|
34
|
-
borderColor: '$borderColorHover',
|
|
35
|
-
},
|
|
36
|
-
pressStyle: {
|
|
37
|
-
backgroundColor: '$backgroundPress',
|
|
38
|
-
borderColor: '$borderColorPress',
|
|
39
|
-
},
|
|
40
|
-
focusVisibleStyle: {
|
|
41
|
-
outlineColor: '$outlineColor',
|
|
42
|
-
outlineWidth: 2,
|
|
43
|
-
outlineStyle: 'solid',
|
|
44
|
-
zIndex: 10,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
31
|
+
variants: {
|
|
32
|
+
size: styled.dynamic<any>((val, env) => {
|
|
33
|
+
if (!val) return
|
|
34
|
+
// a square hit target: the control height plus the skin's 1px border
|
|
35
|
+
const { frame, controlHeight } = resolveSize(val, env)
|
|
36
|
+
const side = controlHeight + 2
|
|
37
|
+
return {
|
|
38
|
+
width: side,
|
|
39
|
+
height: side,
|
|
40
|
+
borderRadius: frame.borderRadius,
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!val) return
|
|
52
|
-
return {
|
|
53
|
-
width: tokens.size[val],
|
|
54
|
-
height: tokens.size[val],
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
':number': (val) => ({
|
|
58
|
-
width: val,
|
|
59
|
-
height: val,
|
|
60
|
-
}),
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
defaultActiveStyle: {
|
|
64
|
-
true: {
|
|
65
|
-
backgroundColor: '$backgroundActive',
|
|
66
|
-
hoverStyle: {
|
|
67
|
-
backgroundColor: '$backgroundActive',
|
|
68
|
-
},
|
|
69
|
-
focusStyle: {
|
|
70
|
-
backgroundColor: '$backgroundActive',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
} as const,
|
|
75
|
-
|
|
76
|
-
defaultVariants: {
|
|
77
|
-
unstyled: process.env.TAMAGUI_HEADLESS === '1',
|
|
44
|
+
defaultActiveStyle: {
|
|
45
|
+
true: {},
|
|
78
46
|
},
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
accept: {
|
|
82
|
-
activeStyle: 'style',
|
|
83
|
-
} as const,
|
|
84
|
-
}
|
|
85
|
-
)
|
|
47
|
+
} as const,
|
|
48
|
+
})
|
|
86
49
|
|
|
87
50
|
type ToggleFrameProps = GetProps<typeof ToggleFrame>
|
|
88
51
|
|
|
@@ -93,13 +56,13 @@ type ToggleItemExtraProps = {
|
|
|
93
56
|
active?: boolean
|
|
94
57
|
defaultActive?: boolean
|
|
95
58
|
onActiveChange?(active: boolean): void
|
|
96
|
-
activeStyle?:
|
|
59
|
+
activeStyle?: StylePiece | null
|
|
97
60
|
activeTheme?: string | null
|
|
98
61
|
}
|
|
99
62
|
|
|
100
63
|
export type ToggleProps = ToggleFrameProps & ToggleItemExtraProps
|
|
101
64
|
|
|
102
|
-
export const Toggle =
|
|
65
|
+
export const Toggle = createRefComponent<TamaguiElement, ToggleProps>(
|
|
103
66
|
function Toggle(props, forwardedRef) {
|
|
104
67
|
const {
|
|
105
68
|
active: activeProp,
|
|
@@ -107,7 +70,6 @@ export const Toggle = React.forwardRef<TamaguiElement, ToggleProps>(
|
|
|
107
70
|
defaultActive = false,
|
|
108
71
|
onActiveChange,
|
|
109
72
|
activeTheme,
|
|
110
|
-
unstyled = false,
|
|
111
73
|
...buttonProps
|
|
112
74
|
} = props
|
|
113
75
|
|
|
@@ -123,23 +85,9 @@ export const Toggle = React.forwardRef<TamaguiElement, ToggleProps>(
|
|
|
123
85
|
aria-pressed={active}
|
|
124
86
|
data-state={active ? 'on' : 'off'}
|
|
125
87
|
data-disabled={props.disabled ? '' : undefined}
|
|
126
|
-
|
|
127
|
-
{...(active &&
|
|
128
|
-
!activeStyle &&
|
|
129
|
-
!unstyled && {
|
|
130
|
-
defaultActiveStyle: true,
|
|
131
|
-
})}
|
|
88
|
+
{...(active && !activeStyle && { defaultActiveStyle: true })}
|
|
132
89
|
{...buttonProps}
|
|
133
|
-
|
|
134
|
-
// variant (e.g. a resting `backgroundColor`) forwards that value as a plain
|
|
135
|
-
// prop into buttonProps, which would otherwise clobber the activeStyle merge
|
|
136
|
-
// on overlapping keys and leave the active item stuck at its resting style.
|
|
137
|
-
{...(active &&
|
|
138
|
-
activeStyle && {
|
|
139
|
-
...(activeStyle as any),
|
|
140
|
-
hoverStyle: activeStyle,
|
|
141
|
-
focusStyle: activeStyle,
|
|
142
|
-
})}
|
|
90
|
+
style={[buttonProps.style, active && activeStyle]}
|
|
143
91
|
ref={forwardedRef}
|
|
144
92
|
onPress={composeEventHandlers(props.onPress ?? undefined, () => {
|
|
145
93
|
if (!props.disabled) {
|
package/src/ToggleGroup.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRefComponent } from '@tamagui/compose-refs'
|
|
1
2
|
import { isWeb } from '@tamagui/constants'
|
|
2
3
|
import { registerFocusable } from '@tamagui/focusable'
|
|
3
4
|
import { withStaticProperties } from '@tamagui/helpers'
|
|
@@ -5,7 +6,7 @@ import { RovingFocusGroup } from '@tamagui/roving-focus'
|
|
|
5
6
|
import { useControllableState } from '@tamagui/use-controllable-state'
|
|
6
7
|
import { useDirection } from '@tamagui/use-direction'
|
|
7
8
|
import type { GetProps, TamaguiElement } from '@tamagui/web'
|
|
8
|
-
import { createStyledContext, styled, View } from '@tamagui/web'
|
|
9
|
+
import { createStyledHOC, createStyledContext, styled, View } from '@tamagui/web'
|
|
9
10
|
import React from 'react'
|
|
10
11
|
|
|
11
12
|
import type { ToggleProps } from './Toggle'
|
|
@@ -29,13 +30,16 @@ const { Provider: ToggleGroupContext, useStyledContext: useToggleGroupContext }
|
|
|
29
30
|
createStyledContext<ToggleGroupContextValue>({})
|
|
30
31
|
|
|
31
32
|
type ToggleGroupItemProps = GetProps<typeof ToggleFrame> & {
|
|
33
|
+
activeStyle?: ToggleProps['activeStyle']
|
|
34
|
+
activeTheme?: ToggleProps['activeTheme']
|
|
32
35
|
value: string
|
|
33
36
|
id?: string
|
|
34
37
|
disabled?: boolean
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
const ToggleGroupItem =
|
|
38
|
-
|
|
40
|
+
const ToggleGroupItem = createStyledHOC(
|
|
41
|
+
ToggleFrame,
|
|
42
|
+
(props: ScopedProps<ToggleGroupItemProps>, forwardedRef) => {
|
|
39
43
|
const valueContext = useToggleGroupValueContext(props.__scopeToggleGroup)
|
|
40
44
|
const context = useToggleGroupContext(props.__scopeToggleGroup)
|
|
41
45
|
const toggleContext = ToggleContext.useStyledContext(props.__scopeToggleGroup)
|
|
@@ -46,7 +50,11 @@ const ToggleGroupItem = ToggleFrame.styleable<ScopedProps<ToggleGroupItemProps>>
|
|
|
46
50
|
const inner = (
|
|
47
51
|
<ToggleGroupItemImpl
|
|
48
52
|
ref={forwardedRef}
|
|
49
|
-
|
|
53
|
+
// on the roving path the group owns the tab order, so the item carries no
|
|
54
|
+
// tabIndex of its own: Slot overlays child props over the roving Item's,
|
|
55
|
+
// so a tabIndex here wins the merge and puts every toggle back in the tab
|
|
56
|
+
// order. off that path nothing else makes the toggle focusable.
|
|
57
|
+
{...(context.rovingFocus ? null : { tabIndex: disabled ? -1 : 0 })}
|
|
50
58
|
{...(props as any)}
|
|
51
59
|
active={active}
|
|
52
60
|
disabled={disabled}
|
|
@@ -60,7 +68,7 @@ const ToggleGroupItem = ToggleFrame.styleable<ScopedProps<ToggleGroupItemProps>>
|
|
|
60
68
|
<RovingFocusGroup.Item
|
|
61
69
|
asChild="except-style"
|
|
62
70
|
__scopeRovingFocusGroup={props.__scopeToggleGroup || TOGGLE_GROUP_CONTEXT}
|
|
63
|
-
|
|
71
|
+
tabIndex={disabled ? -1 : 0}
|
|
64
72
|
active={active}
|
|
65
73
|
>
|
|
66
74
|
{inner}
|
|
@@ -81,7 +89,7 @@ type ToggleGroupItemImplProps = Omit<ToggleProps, 'defaultActive' | 'onActiveCha
|
|
|
81
89
|
value: string
|
|
82
90
|
}
|
|
83
91
|
|
|
84
|
-
const ToggleGroupItemImpl =
|
|
92
|
+
const ToggleGroupItemImpl = createRefComponent<
|
|
85
93
|
TamaguiElement,
|
|
86
94
|
ScopedProps<ToggleGroupItemImplProps>
|
|
87
95
|
>((props, forwardedRef) => {
|
|
@@ -123,7 +131,7 @@ interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
|
|
|
123
131
|
type ToggleGroupProps = ToggleGroupSingleProps | ToggleGroupMultipleProps
|
|
124
132
|
|
|
125
133
|
const ToggleGroup = withStaticProperties(
|
|
126
|
-
|
|
134
|
+
createRefComponent<TamaguiElement, ScopedProps<ToggleGroupProps>>(
|
|
127
135
|
(props, forwardedRef) => {
|
|
128
136
|
const { type, ...toggleGroupProps } = props
|
|
129
137
|
|
|
@@ -182,7 +190,7 @@ interface ToggleGroupImplSingleProps extends ToggleGroupImplProps {
|
|
|
182
190
|
disableDeactivation?: boolean
|
|
183
191
|
}
|
|
184
192
|
|
|
185
|
-
const ToggleGroupImplSingle =
|
|
193
|
+
const ToggleGroupImplSingle = createRefComponent<
|
|
186
194
|
TamaguiElement,
|
|
187
195
|
ScopedProps<ToggleGroupImplSingleProps>
|
|
188
196
|
>((props: ScopedProps<ToggleGroupImplSingleProps>, forwardedRef) => {
|
|
@@ -230,7 +238,7 @@ interface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {
|
|
|
230
238
|
disableDeactivation?: never
|
|
231
239
|
}
|
|
232
240
|
|
|
233
|
-
const ToggleGroupImplMultiple =
|
|
241
|
+
const ToggleGroupImplMultiple = createRefComponent<
|
|
234
242
|
TamaguiElement,
|
|
235
243
|
ToggleGroupImplMultipleProps
|
|
236
244
|
>((props: ScopedProps<ToggleGroupImplMultipleProps>, forwardedRef) => {
|
|
@@ -286,7 +294,7 @@ type ToggleGroupContextValue = {
|
|
|
286
294
|
type RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>
|
|
287
295
|
|
|
288
296
|
const ToggleGroupFrame = styled(View, {
|
|
289
|
-
|
|
297
|
+
displayName: TOGGLE_GROUP_NAME,
|
|
290
298
|
})
|
|
291
299
|
|
|
292
300
|
type ToggleGroupImplProps = GetProps<typeof ToggleGroupFrame> & {
|
|
@@ -297,7 +305,8 @@ type ToggleGroupImplProps = GetProps<typeof ToggleGroupFrame> & {
|
|
|
297
305
|
color?: string
|
|
298
306
|
}
|
|
299
307
|
|
|
300
|
-
const ToggleGroupImpl =
|
|
308
|
+
const ToggleGroupImpl = createStyledHOC(
|
|
309
|
+
ToggleGroupFrame,
|
|
301
310
|
(props: ScopedProps<ToggleGroupImplProps>, forwardedRef) => {
|
|
302
311
|
const {
|
|
303
312
|
__scopeToggleGroup,
|
package/types/Toggle.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import type { GetProps,
|
|
1
|
+
import type { GetProps, StylePiece, TamaguiElement } from '@tamagui/web';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
export declare const ToggleFrame: import("@tamagui/web").
|
|
4
|
-
|
|
5
|
-
accept: {
|
|
6
|
-
readonly activeStyle: "style";
|
|
7
|
-
};
|
|
8
|
-
}>> | undefined;
|
|
9
|
-
}, {
|
|
10
|
-
unstyled?: boolean | undefined;
|
|
11
|
-
size?: number | import("@tamagui/web").SizeTokens | undefined;
|
|
3
|
+
export declare const ToggleFrame: React.FunctionComponent<Omit<import("@tamagui/web").StackNonStyleProps, "active" | "defaultActiveStyle" | "size" | keyof import("@tamagui/web").StackStyleBase> & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase> & import("@tamagui/web").WithFlatVariantValues<{
|
|
4
|
+
active?: boolean | undefined;
|
|
12
5
|
defaultActiveStyle?: boolean | undefined;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
size?: any;
|
|
7
|
+
}> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase>> & {
|
|
8
|
+
ref?: React.Ref<TamaguiElement> | undefined;
|
|
9
|
+
}> & import("@tamagui/web").StaticComponentObject<import("@tamagui/web").TamaDefer, TamaguiElement, import("@tamagui/web").StackNonStyleProps, import("@tamagui/web").StackStyleBase, {
|
|
10
|
+
active?: boolean | undefined;
|
|
11
|
+
defaultActiveStyle?: boolean | undefined;
|
|
12
|
+
size?: any;
|
|
13
|
+
}, import("@tamagui/web").StaticConfigPublic> & Omit<import("@tamagui/web").StaticConfigPublic, "staticConfig"> & {
|
|
14
|
+
__tama: [import("@tamagui/web").TamaDefer, TamaguiElement, import("@tamagui/web").StackNonStyleProps, import("@tamagui/web").StackStyleBase, {
|
|
15
|
+
active?: boolean | undefined;
|
|
16
|
+
defaultActiveStyle?: boolean | undefined;
|
|
17
|
+
size?: any;
|
|
18
|
+
}, import("@tamagui/web").StaticConfigPublic];
|
|
19
|
+
};
|
|
18
20
|
type ToggleFrameProps = GetProps<typeof ToggleFrame>;
|
|
19
21
|
type ToggleItemExtraProps = {
|
|
20
22
|
orientation?: 'horizontal' | 'vertical';
|
|
@@ -23,52 +25,10 @@ type ToggleItemExtraProps = {
|
|
|
23
25
|
active?: boolean;
|
|
24
26
|
defaultActive?: boolean;
|
|
25
27
|
onActiveChange?(active: boolean): void;
|
|
26
|
-
activeStyle?:
|
|
28
|
+
activeStyle?: StylePiece | null;
|
|
27
29
|
activeTheme?: string | null;
|
|
28
30
|
};
|
|
29
31
|
export type ToggleProps = ToggleFrameProps & ToggleItemExtraProps;
|
|
30
|
-
export declare const Toggle:
|
|
31
|
-
readonly activeStyle?: Partial<import("@tamagui/web").InferStyleProps<import("@tamagui/web").TamaguiComponent<import("@tamagui/web").ViewProps, TamaguiElement, import("@tamagui/web").StackNonStyleProps, import("@tamagui/web").StackStyleBase, {}, {}>, {
|
|
32
|
-
accept: {
|
|
33
|
-
readonly activeStyle: "style";
|
|
34
|
-
};
|
|
35
|
-
}>> | undefined;
|
|
36
|
-
}> & {
|
|
37
|
-
unstyled?: boolean | undefined;
|
|
38
|
-
size?: number | import("@tamagui/web").SizeTokens | undefined;
|
|
39
|
-
defaultActiveStyle?: boolean | undefined;
|
|
40
|
-
} & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase & {
|
|
41
|
-
readonly activeStyle?: Partial<import("@tamagui/web").InferStyleProps<import("@tamagui/web").TamaguiComponent<import("@tamagui/web").ViewProps, TamaguiElement, import("@tamagui/web").StackNonStyleProps, import("@tamagui/web").StackStyleBase, {}, {}>, {
|
|
42
|
-
accept: {
|
|
43
|
-
readonly activeStyle: "style";
|
|
44
|
-
};
|
|
45
|
-
}>> | undefined;
|
|
46
|
-
}>> & import("@tamagui/web").WithPseudoProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase & {
|
|
47
|
-
readonly activeStyle?: Partial<import("@tamagui/web").InferStyleProps<import("@tamagui/web").TamaguiComponent<import("@tamagui/web").ViewProps, TamaguiElement, import("@tamagui/web").StackNonStyleProps, import("@tamagui/web").StackStyleBase, {}, {}>, {
|
|
48
|
-
accept: {
|
|
49
|
-
readonly activeStyle: "style";
|
|
50
|
-
};
|
|
51
|
-
}>> | undefined;
|
|
52
|
-
}> & {
|
|
53
|
-
unstyled?: boolean | undefined;
|
|
54
|
-
size?: number | import("@tamagui/web").SizeTokens | undefined;
|
|
55
|
-
defaultActiveStyle?: boolean | undefined;
|
|
56
|
-
} & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase & {
|
|
57
|
-
readonly activeStyle?: Partial<import("@tamagui/web").InferStyleProps<import("@tamagui/web").TamaguiComponent<import("@tamagui/web").ViewProps, TamaguiElement, import("@tamagui/web").StackNonStyleProps, import("@tamagui/web").StackStyleBase, {}, {}>, {
|
|
58
|
-
accept: {
|
|
59
|
-
readonly activeStyle: "style";
|
|
60
|
-
};
|
|
61
|
-
}>> | undefined;
|
|
62
|
-
}>>> & import("@tamagui/web").WithMediaProps<import("@tamagui/web").WithThemeShorthandsAndPseudos<import("@tamagui/web").StackStyleBase & {
|
|
63
|
-
readonly activeStyle?: Partial<import("@tamagui/web").InferStyleProps<import("@tamagui/web").TamaguiComponent<import("@tamagui/web").ViewProps, TamaguiElement, import("@tamagui/web").StackNonStyleProps, import("@tamagui/web").StackStyleBase, {}, {}>, {
|
|
64
|
-
accept: {
|
|
65
|
-
readonly activeStyle: "style";
|
|
66
|
-
};
|
|
67
|
-
}>> | undefined;
|
|
68
|
-
}, {
|
|
69
|
-
unstyled?: boolean | undefined;
|
|
70
|
-
size?: number | import("@tamagui/web").SizeTokens | undefined;
|
|
71
|
-
defaultActiveStyle?: boolean | undefined;
|
|
72
|
-
}>> & ToggleItemExtraProps & React.RefAttributes<TamaguiElement>>;
|
|
32
|
+
export declare const Toggle: import("@tamagui/compose-refs").RefComponent<TamaguiElement, ToggleProps>;
|
|
73
33
|
export {};
|
|
74
34
|
//# sourceMappingURL=Toggle.d.ts.map
|
package/types/Toggle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toggle.d.ts","sourceRoot":"","sources":["../src/Toggle.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toggle.d.ts","sourceRoot":"","sources":["../src/Toggle.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAExE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAgB9B,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;CAyBtB,CAAA;AAEF,KAAK,gBAAgB,GAAG,QAAQ,CAAC,OAAO,WAAW,CAAC,CAAA;AAEpD,KAAK,oBAAoB,GAAG;IAC1B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IACvC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;IACtC,WAAW,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,oBAAoB,CAAA;AAEjE,eAAO,MAAM,MAAM,2EAmClB,CAAA"}
|