@tamagui/toggle-group 2.7.7 → 3.0.0-beta.1091.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.
Files changed (78) hide show
  1. package/dist/cjs/Toggle.cjs +58 -130
  2. package/dist/cjs/Toggle.native.cjs +90 -0
  3. package/dist/cjs/Toggle.native.js +64 -135
  4. package/dist/cjs/Toggle.native.js.map +1 -1
  5. package/dist/cjs/ToggleGroup.cjs +157 -211
  6. package/dist/cjs/ToggleGroup.native.cjs +207 -0
  7. package/dist/cjs/ToggleGroup.native.js +172 -225
  8. package/dist/cjs/ToggleGroup.native.js.map +1 -1
  9. package/dist/cjs/context.cjs +18 -20
  10. package/dist/cjs/context.native.cjs +36 -0
  11. package/dist/cjs/context.native.js +19 -20
  12. package/dist/cjs/context.native.js.map +1 -1
  13. package/dist/cjs/index.cjs +14 -18
  14. package/dist/cjs/index.native.cjs +28 -0
  15. package/dist/cjs/index.native.js +14 -17
  16. package/dist/cjs/index.native.js.map +1 -1
  17. package/dist/cjs/types.cjs +9 -11
  18. package/dist/cjs/types.native.cjs +18 -0
  19. package/dist/cjs/types.native.js +9 -10
  20. package/dist/cjs/types.native.js.map +1 -1
  21. package/dist/esm/Toggle.mjs +46 -103
  22. package/dist/esm/Toggle.mjs.map +1 -1
  23. package/dist/esm/Toggle.native.js +51 -114
  24. package/dist/esm/Toggle.native.js.map +1 -1
  25. package/dist/esm/ToggleGroup.mjs +145 -188
  26. package/dist/esm/ToggleGroup.mjs.map +1 -1
  27. package/dist/esm/ToggleGroup.native.js +160 -203
  28. package/dist/esm/ToggleGroup.native.js.map +1 -1
  29. package/dist/esm/context.mjs +5 -3
  30. package/dist/esm/context.mjs.map +1 -1
  31. package/dist/esm/context.native.js +6 -4
  32. package/dist/esm/context.native.js.map +1 -1
  33. package/dist/esm/index.js +4 -3
  34. package/dist/esm/index.mjs +4 -3
  35. package/dist/esm/index.native.js +4 -3
  36. package/dist/esm/types.mjs +0 -2
  37. package/dist/esm/types.native.js +0 -2
  38. package/dist/jsx/Toggle.mjs +46 -103
  39. package/dist/jsx/Toggle.mjs.map +1 -1
  40. package/dist/jsx/Toggle.native.cjs +90 -0
  41. package/dist/jsx/Toggle.native.js +64 -135
  42. package/dist/jsx/Toggle.native.js.map +1 -1
  43. package/dist/jsx/ToggleGroup.mjs +145 -188
  44. package/dist/jsx/ToggleGroup.mjs.map +1 -1
  45. package/dist/jsx/ToggleGroup.native.cjs +207 -0
  46. package/dist/jsx/ToggleGroup.native.js +172 -225
  47. package/dist/jsx/ToggleGroup.native.js.map +1 -1
  48. package/dist/jsx/context.mjs +5 -3
  49. package/dist/jsx/context.mjs.map +1 -1
  50. package/dist/jsx/context.native.cjs +36 -0
  51. package/dist/jsx/context.native.js +19 -20
  52. package/dist/jsx/context.native.js.map +1 -1
  53. package/dist/jsx/index.js +4 -3
  54. package/dist/jsx/index.mjs +4 -3
  55. package/dist/jsx/index.native.cjs +28 -0
  56. package/dist/jsx/index.native.js +14 -17
  57. package/dist/jsx/index.native.js.map +1 -1
  58. package/dist/jsx/types.mjs +0 -2
  59. package/dist/jsx/types.native.cjs +18 -0
  60. package/dist/jsx/types.native.js +9 -10
  61. package/dist/jsx/types.native.js.map +1 -1
  62. package/package.json +18 -16
  63. package/src/Toggle.tsx +37 -89
  64. package/src/ToggleGroup.tsx +20 -11
  65. package/types/Toggle.d.ts +19 -59
  66. package/types/Toggle.d.ts.map +1 -1
  67. package/types/ToggleGroup.d.ts +31 -125
  68. package/types/ToggleGroup.d.ts.map +1 -1
  69. package/types/context.d.ts +1 -1
  70. package/types/context.d.ts.map +1 -1
  71. package/dist/esm/index.js.map +0 -1
  72. package/dist/esm/index.mjs.map +0 -1
  73. package/dist/esm/index.native.js.map +0 -1
  74. package/dist/esm/types.mjs.map +0 -1
  75. package/dist/esm/types.native.js.map +0 -1
  76. package/dist/jsx/index.js.map +0 -1
  77. package/dist/jsx/index.mjs.map +0 -1
  78. 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");
@@ -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
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
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
- 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;
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,"names":["__defProp","Object","defineProperty"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;AACA,IAAAA,SAAS,GAAAC,MAAA,CAAAC,cAA0B","ignoreList":[]}
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"}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=types.mjs.map
@@ -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);
@@ -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
- 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;
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":[],"mappings":"","ignoreList":[]}
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": "2.7.7",
3
+ "version": "3.0.0-beta.1091.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/constants": "2.7.7",
38
- "@tamagui/create-context": "2.7.7",
39
- "@tamagui/focusable": "2.7.7",
40
- "@tamagui/get-token": "2.7.7",
41
- "@tamagui/helpers": "2.7.7",
42
- "@tamagui/helpers-tamagui": "2.7.7",
43
- "@tamagui/roving-focus": "2.7.7",
44
- "@tamagui/sizable-context": "2.7.7",
45
- "@tamagui/stacks": "2.7.7",
46
- "@tamagui/use-controllable-state": "2.7.7",
47
- "@tamagui/use-direction": "2.7.7",
48
- "@tamagui/font-size": "2.7.7",
49
- "@tamagui/web": "2.7.7"
38
+ "@tamagui/compose-refs": "3.0.0-beta.1091.1",
39
+ "@tamagui/constants": "3.0.0-beta.1091.1",
40
+ "@tamagui/create-context": "3.0.0-beta.1091.1",
41
+ "@tamagui/focusable": "3.0.0-beta.1091.1",
42
+ "@tamagui/font-size": "3.0.0-beta.1091.1",
43
+ "@tamagui/get-token": "3.0.0-beta.1091.1",
44
+ "@tamagui/helpers": "3.0.0-beta.1091.1",
45
+ "@tamagui/helpers-tamagui": "3.0.0-beta.1091.1",
46
+ "@tamagui/roving-focus": "3.0.0-beta.1091.1",
47
+ "@tamagui/size": "3.0.0-beta.1091.1",
48
+ "@tamagui/stacks": "3.0.0-beta.1091.1",
49
+ "@tamagui/use-controllable-state": "3.0.0-beta.1091.1",
50
+ "@tamagui/use-direction": "3.0.0-beta.1091.1",
51
+ "@tamagui/web": "3.0.0-beta.1091.1"
50
52
  },
51
53
  "devDependencies": {
52
- "@tamagui/build": "2.7.7",
53
- "react": ">=19"
54
+ "@tamagui/build": "3.0.0-beta.1091.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, TamaguiElement, ViewStyle } from '@tamagui/web'
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
- export const ToggleFrame = styled(
15
- View,
16
- {
17
- name: NAME,
18
- render: 'button',
19
- context,
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
- variants: {
22
- unstyled: {
23
- false: {
24
- size: '$true',
25
- alignItems: 'center',
26
- justifyContent: 'center',
27
- display: 'flex',
28
- backgroundColor: '$background',
29
- borderColor: '$borderColor',
30
- borderWidth: 1,
31
- margin: -1,
32
- hoverStyle: {
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
- size: {
50
- '...size': (val, { tokens }) => {
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?: ViewStyle | null
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 = React.forwardRef<TamaguiElement, ToggleProps>(
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
- unstyled={unstyled}
127
- {...(active &&
128
- !activeStyle &&
129
- !unstyled && {
130
- defaultActiveStyle: true,
131
- })}
88
+ {...(active && !activeStyle && { defaultActiveStyle: true })}
132
89
  {...buttonProps}
133
- // spread activeStyle after buttonProps so it wins when active: a styled()
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) {
@@ -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 = ToggleFrame.styleable<ScopedProps<ToggleGroupItemProps>>(
38
- (props, forwardedRef) => {
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
- tabIndex={disabled ? -1 : 0}
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
- focusable={!disabled}
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 = React.forwardRef<
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
- React.forwardRef<TamaguiElement, ScopedProps<ToggleGroupProps>>(
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 = React.forwardRef<
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 = React.forwardRef<
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
- name: TOGGLE_GROUP_NAME,
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 = ToggleGroupFrame.styleable<TamaguiElement, ToggleGroupImplProps>(
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, TamaguiElement, ViewStyle } from '@tamagui/web';
1
+ import type { GetProps, StylePiece, TamaguiElement } from '@tamagui/web';
2
2
  import * as React from 'react';
3
- export declare const ToggleFrame: import("@tamagui/web").TamaguiComponent<import("@tamagui/web").TamaDefer, TamaguiElement, import("@tamagui/web").StackNonStyleProps, import("@tamagui/web").StackStyleBase & {
4
- readonly activeStyle?: Partial<import("@tamagui/web").InferStyleProps<import("@tamagui/web").TamaguiComponent<import("@tamagui/web").ViewProps, TamaguiElement, import("@tamagui/web").StackNonStyleProps, import("@tamagui/web").StackStyleBase, {}, {}>, {
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
- accept: {
15
- readonly activeStyle: "style";
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?: ViewStyle | null;
28
+ activeStyle?: StylePiece | null;
27
29
  activeTheme?: string | null;
28
30
  };
29
31
  export type ToggleProps = ToggleFrameProps & ToggleItemExtraProps;
30
- export declare const Toggle: React.ForwardRefExoticComponent<Omit<import("@tamagui/web").StackNonStyleProps, "unstyled" | keyof import("@tamagui/web").StackStyleBase | "size" | "activeStyle" | "defaultActiveStyle"> & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase & {
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
@@ -1 +1 @@
1
- {"version":3,"file":"Toggle.d.ts","sourceRoot":"","sources":["../src/Toggle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEvE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,eAAO,MAAM,WAAW;;;;;;;;;;;;;;EAuEvB,CAAA;AAED,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,SAAS,GAAG,IAAI,CAAA;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,oBAAoB,CAAA;AAEjE,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEAkDlB,CAAA"}
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"}