@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
@@ -3,28 +3,24 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
10
  };
11
11
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
19
  };
20
20
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
22
- value: true
23
- }), mod);
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
22
  var index_exports = {};
25
- __export(index_exports, {
26
- useToggleGroupItem: () => import_context.useToggleGroupItem
27
- });
23
+ __export(index_exports, { useToggleGroupItem: () => import_context.useToggleGroupItem });
28
24
  module.exports = __toCommonJS(index_exports);
29
25
  __reExport(index_exports, require("./ToggleGroup.cjs"), module.exports);
30
- var import_context = require("./context.cjs");
26
+ var import_context = require("./context.cjs");
@@ -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":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","useToggleGroupItem","import_context","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAC,cAAA,CAAAD;AAAA;AAAAE,MAAA,CAAAC,OAAA,GAAAV,YAAc,CAAAK,aAAA;AACdM,UAAA,CAAAN,aAAmC,EAAAO,OAAA,6BAAAH,MAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["cjs/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"}
@@ -3,16 +3,14 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
- get: () => from[key],
9
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
- });
11
- }
12
- return to;
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
+ get: () => from[key],
9
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
+ });
11
+ }
12
+ return to;
13
13
  };
14
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
15
- value: true
16
- }), mod);
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
17
15
  var types_exports = {};
18
- module.exports = __toCommonJS(types_exports);
16
+ module.exports = __toCommonJS(types_exports);
@@ -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":["__toCommonJS","mod","__copyProps","__defProp","value","types_exports"],"sources":["../../src/types.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA","ignoreList":[]}
1
+ {"version":3,"file":"types.native.js","names":[],"sources":["cjs/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"}
@@ -1,113 +1,56 @@
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 { styled, View } from "@tamagui/web";
4
- import * as React from "react";
5
+ import { View, styled } from "@tamagui/web";
5
6
  import { context } from "./context.mjs";
6
7
  import { jsx } from "react/jsx-runtime";
8
+
7
9
  const NAME = "Toggle";
8
10
  const ToggleFrame = styled(View, {
9
- name: NAME,
10
- render: "button",
11
- context,
12
- variants: {
13
- unstyled: {
14
- false: {
15
- size: "$true",
16
- alignItems: "center",
17
- justifyContent: "center",
18
- display: "flex",
19
- backgroundColor: "$background",
20
- borderColor: "$borderColor",
21
- borderWidth: 1,
22
- margin: -1,
23
- hoverStyle: {
24
- backgroundColor: "$backgroundHover",
25
- borderColor: "$borderColorHover"
26
- },
27
- pressStyle: {
28
- backgroundColor: "$backgroundPress",
29
- borderColor: "$borderColorPress"
30
- },
31
- focusVisibleStyle: {
32
- outlineColor: "$outlineColor",
33
- outlineWidth: 2,
34
- outlineStyle: "solid",
35
- zIndex: 10
36
- }
37
- }
38
- },
39
- size: {
40
- "...size": (val, {
41
- tokens
42
- }) => {
43
- if (!val) return;
44
- return {
45
- width: tokens.size[val],
46
- height: tokens.size[val]
47
- };
48
- },
49
- ":number": val => ({
50
- width: val,
51
- height: val
52
- })
53
- },
54
- defaultActiveStyle: {
55
- true: {
56
- backgroundColor: "$backgroundActive",
57
- hoverStyle: {
58
- backgroundColor: "$backgroundActive"
59
- },
60
- focusStyle: {
61
- backgroundColor: "$backgroundActive"
62
- }
63
- }
64
- }
65
- },
66
- defaultVariants: {
67
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
68
- }
69
- }, {
70
- accept: {
71
- activeStyle: "style"
72
- }
11
+ displayName: NAME,
12
+ render: "button",
13
+ context,
14
+ size: true,
15
+ alignItems: "center",
16
+ justifyContent: "center",
17
+ variants: {
18
+ size: styled.dynamic((val, env) => {
19
+ if (!val) return;
20
+ const { frame, controlHeight } = resolveSize(val, env);
21
+ const side = controlHeight + 2;
22
+ return {
23
+ width: side,
24
+ height: side,
25
+ borderRadius: frame.borderRadius
26
+ };
27
+ }),
28
+ defaultActiveStyle: { true: {} }
29
+ }
73
30
  });
74
- const Toggle = React.forwardRef(function Toggle2(props, forwardedRef) {
75
- const {
76
- active: activeProp,
77
- activeStyle,
78
- defaultActive = false,
79
- onActiveChange,
80
- activeTheme,
81
- unstyled = false,
82
- ...buttonProps
83
- } = props;
84
- const [active = false, setActive] = useControllableState({
85
- prop: activeProp,
86
- onChange: onActiveChange,
87
- defaultProp: defaultActive
88
- });
89
- return /* @__PURE__ */jsx(ToggleFrame, {
90
- theme: activeTheme ?? null,
91
- "aria-pressed": active,
92
- "data-state": active ? "on" : "off",
93
- "data-disabled": props.disabled ? "" : void 0,
94
- unstyled,
95
- ...(active && !activeStyle && !unstyled && {
96
- defaultActiveStyle: true
97
- }),
98
- ...buttonProps,
99
- ...(active && activeStyle && {
100
- ...activeStyle,
101
- hoverStyle: activeStyle,
102
- focusStyle: activeStyle
103
- }),
104
- ref: forwardedRef,
105
- onPress: composeEventHandlers(props.onPress ?? void 0, () => {
106
- if (!props.disabled) {
107
- setActive(prev => !prev);
108
- }
109
- })
110
- });
31
+ const Toggle = createRefComponent(function Toggle2(props, forwardedRef) {
32
+ const { active: activeProp, activeStyle, defaultActive = false, onActiveChange, activeTheme, ...buttonProps } = props;
33
+ const [active = false, setActive] = useControllableState({
34
+ prop: activeProp,
35
+ onChange: onActiveChange,
36
+ defaultProp: defaultActive
37
+ });
38
+ return /* @__PURE__ */ jsx(ToggleFrame, {
39
+ theme: activeTheme ?? null,
40
+ "aria-pressed": active,
41
+ "data-state": active ? "on" : "off",
42
+ "data-disabled": props.disabled ? "" : void 0,
43
+ ...active && !activeStyle && { defaultActiveStyle: true },
44
+ ...buttonProps,
45
+ style: [buttonProps.style, active && activeStyle],
46
+ ref: forwardedRef,
47
+ onPress: composeEventHandlers(props.onPress ?? void 0, () => {
48
+ if (!props.disabled) {
49
+ setActive((prev) => !prev);
50
+ }
51
+ })
52
+ });
111
53
  });
54
+
112
55
  export { Toggle, ToggleFrame };
113
56
  //# sourceMappingURL=Toggle.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["composeEventHandlers","useControllableState","styled","View","React","context","jsx","NAME","ToggleFrame","name","render","variants","unstyled","false","size","alignItems","justifyContent","display","backgroundColor","borderColor","borderWidth","margin","hoverStyle","pressStyle","focusVisibleStyle","outlineColor","outlineWidth","outlineStyle","zIndex","...size","val","tokens","width","height","defaultActiveStyle","true","focusStyle","defaultVariants","process","env","TAMAGUI_HEADLESS","accept","activeStyle","Toggle","forwardRef","props","forwardedRef","active","activeProp","defaultActive","onActiveChange","activeTheme","buttonProps","setActive","prop","onChange","defaultProp","theme","disabled","ref","onPress","prev"],"sources":["../../src/Toggle.tsx"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"Toggle.js","names":[],"sources":["esm/Toggle.js"],"sourcesContent":["import { createRefComponent } from \"@tamagui/compose-refs\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport { resolveSize } from \"@tamagui/size\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport { styled, View } from \"@tamagui/web\";\nimport { context } from \"./context\";\nimport { jsx } from \"react/jsx-runtime\";\nconst NAME = \"Toggle\";\nconst ToggleFrame = styled(View, {\n displayName: NAME,\n render: \"button\",\n context,\n size: true,\n alignItems: \"center\",\n justifyContent: \"center\",\n variants: {\n size: styled.dynamic((val, env) => {\n if (!val) return;\n const { frame, controlHeight } = resolveSize(val, env);\n const side = controlHeight + 2;\n return {\n width: side,\n height: side,\n borderRadius: frame.borderRadius\n };\n }),\n defaultActiveStyle: {\n true: {}\n }\n }\n});\nconst Toggle = createRefComponent(\n function Toggle2(props, forwardedRef) {\n const {\n active: activeProp,\n activeStyle,\n defaultActive = false,\n onActiveChange,\n activeTheme,\n ...buttonProps\n } = props;\n const [active = false, setActive] = useControllableState({\n prop: activeProp,\n onChange: onActiveChange,\n defaultProp: defaultActive\n });\n return /* @__PURE__ */ jsx(\n ToggleFrame,\n {\n theme: activeTheme ?? null,\n \"aria-pressed\": active,\n \"data-state\": active ? \"on\" : \"off\",\n \"data-disabled\": props.disabled ? \"\" : void 0,\n ...active && !activeStyle && { defaultActiveStyle: true },\n ...buttonProps,\n style: [buttonProps.style, active && activeStyle],\n ref: forwardedRef,\n onPress: composeEventHandlers(props.onPress ?? void 0, () => {\n if (!props.disabled) {\n setActive((prev) => !prev);\n }\n })\n }\n );\n }\n);\nexport {\n Toggle,\n ToggleFrame\n};\n//# sourceMappingURL=Toggle.js.map\n"],"mappings":";;;;;;;;;AAOA,MAAM,OAAO;AACb,MAAM,cAAc,OAAO,MAAM;CAC/B,aAAa;CACb,QAAQ;CACR;CACA,MAAM;CACN,YAAY;CACZ,gBAAgB;CAChB,UAAU;EACR,MAAM,OAAO,SAAS,KAAK,QAAQ;GACjC,IAAI,CAAC,KAAK;GACV,MAAM,EAAE,OAAO,kBAAkB,YAAY,KAAK,GAAG;GACrD,MAAM,OAAO,gBAAgB;GAC7B,OAAO;IACL,OAAO;IACP,QAAQ;IACR,cAAc,MAAM;GACtB;EACF,CAAC;EACD,oBAAoB,EAClB,MAAM,CAAC,EACT;CACF;AACF,CAAC;AACD,MAAM,SAAS,mBACb,SAAS,QAAQ,OAAO,cAAc;CACpC,MAAM,EACJ,QAAQ,YACR,aACA,gBAAgB,OAChB,gBACA,aACA,GAAG,gBACD;CACJ,MAAM,CAAC,SAAS,OAAO,aAAa,qBAAqB;EACvD,MAAM;EACN,UAAU;EACV,aAAa;CACf,CAAC;CACD,OAAuB,oBACrB,aACA;EACE,OAAO,eAAe;EACtB,gBAAgB;EAChB,cAAc,SAAS,OAAO;EAC9B,iBAAiB,MAAM,WAAW,KAAK,KAAK;EAC5C,GAAG,UAAU,CAAC,eAAe,EAAE,oBAAoB,KAAK;EACxD,GAAG;EACH,OAAO,CAAC,YAAY,OAAO,UAAU,WAAW;EAChD,KAAK;EACL,SAAS,qBAAqB,MAAM,WAAW,KAAK,SAAS;GAC3D,IAAI,CAAC,MAAM,UAAU;IACnB,WAAW,SAAS,CAAC,IAAI;GAC3B;EACF,CAAC;CACH,CACF;AACF,CACF"}
@@ -1,123 +1,60 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createRefComponent } from "@tamagui/compose-refs";
2
3
  import { composeEventHandlers } from "@tamagui/helpers";
4
+ import { resolveSize } from "@tamagui/size";
3
5
  import { useControllableState } from "@tamagui/use-controllable-state";
4
- import { styled, View } from "@tamagui/web";
5
- import * as React from "react";
6
+ import { View, styled } from "@tamagui/web";
7
+ import "react";
6
8
  import { context } from "./context.native.js";
9
+
7
10
  var NAME = "Toggle";
8
11
  var ToggleFrame = styled(View, {
9
- name: NAME,
10
- render: "button",
11
- context,
12
- variants: {
13
- unstyled: {
14
- false: {
15
- size: "$true",
16
- alignItems: "center",
17
- justifyContent: "center",
18
- display: "flex",
19
- backgroundColor: "$background",
20
- borderColor: "$borderColor",
21
- borderWidth: 1,
22
- margin: -1,
23
- hoverStyle: {
24
- backgroundColor: "$backgroundHover",
25
- borderColor: "$borderColorHover"
26
- },
27
- pressStyle: {
28
- backgroundColor: "$backgroundPress",
29
- borderColor: "$borderColorPress"
30
- },
31
- focusVisibleStyle: {
32
- outlineColor: "$outlineColor",
33
- outlineWidth: 2,
34
- outlineStyle: "solid",
35
- zIndex: 10
36
- }
37
- }
38
- },
39
- size: {
40
- "...size": function (val, param) {
41
- var {
42
- tokens
43
- } = param;
44
- if (!val) return;
45
- return {
46
- width: tokens.size[val],
47
- height: tokens.size[val]
48
- };
49
- },
50
- ":number": function (val) {
51
- return {
52
- width: val,
53
- height: val
54
- };
55
- }
56
- },
57
- defaultActiveStyle: {
58
- true: {
59
- backgroundColor: "$backgroundActive",
60
- hoverStyle: {
61
- backgroundColor: "$backgroundActive"
62
- },
63
- focusStyle: {
64
- backgroundColor: "$backgroundActive"
65
- }
66
- }
67
- }
68
- },
69
- defaultVariants: {
70
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
71
- }
72
- }, {
73
- accept: {
74
- activeStyle: "style"
75
- }
12
+ displayName: NAME,
13
+ render: "button",
14
+ context,
15
+ size: true,
16
+ alignItems: "center",
17
+ justifyContent: "center",
18
+ variants: {
19
+ size: styled.dynamic(function(val, env) {
20
+ if (!val) return;
21
+ var { frame, controlHeight } = resolveSize(val, env);
22
+ var side = controlHeight + 2;
23
+ return {
24
+ width: side,
25
+ height: side,
26
+ borderRadius: frame.borderRadius
27
+ };
28
+ }),
29
+ defaultActiveStyle: { true: {} }
30
+ }
76
31
  });
77
- var Toggle = /* @__PURE__ */React.forwardRef(function Toggle2(props, forwardedRef) {
78
- var {
79
- active: activeProp,
80
- activeStyle,
81
- defaultActive = false,
82
- onActiveChange,
83
- activeTheme,
84
- unstyled = false,
85
- ...buttonProps
86
- } = props;
87
- var [active = false, setActive] = useControllableState({
88
- prop: activeProp,
89
- onChange: onActiveChange,
90
- defaultProp: defaultActive
91
- });
92
- var _props_onPress;
93
- return /* @__PURE__ */_jsx(ToggleFrame, {
94
- theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,
95
- "aria-pressed": active,
96
- "data-state": active ? "on" : "off",
97
- "data-disabled": props.disabled ? "" : void 0,
98
- unstyled,
99
- ...(active && !activeStyle && !unstyled && {
100
- defaultActiveStyle: true
101
- }),
102
- ...buttonProps,
103
- // spread activeStyle after buttonProps so it wins when active: a styled()
104
- // variant (e.g. a resting `backgroundColor`) forwards that value as a plain
105
- // prop into buttonProps, which would otherwise clobber the activeStyle merge
106
- // on overlapping keys and leave the active item stuck at its resting style.
107
- ...(active && activeStyle && {
108
- ...activeStyle,
109
- hoverStyle: activeStyle,
110
- focusStyle: activeStyle
111
- }),
112
- ref: forwardedRef,
113
- onPress: composeEventHandlers((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function () {
114
- if (!props.disabled) {
115
- setActive(function (prev) {
116
- return !prev;
117
- });
118
- }
119
- })
120
- });
32
+ var Toggle = createRefComponent(function Toggle2(props, forwardedRef) {
33
+ var { active: activeProp, activeStyle, defaultActive = false, onActiveChange, activeTheme, ...buttonProps } = props;
34
+ var [active = false, setActive] = useControllableState({
35
+ prop: activeProp,
36
+ onChange: onActiveChange,
37
+ defaultProp: defaultActive
38
+ });
39
+ var _props_onPress;
40
+ return /* @__PURE__ */ jsx(ToggleFrame, {
41
+ theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,
42
+ "aria-pressed": active,
43
+ "data-state": active ? "on" : "off",
44
+ "data-disabled": props.disabled ? "" : void 0,
45
+ ...active && !activeStyle && { defaultActiveStyle: true },
46
+ ...buttonProps,
47
+ style: [buttonProps.style, active && activeStyle],
48
+ ref: forwardedRef,
49
+ onPress: composeEventHandlers((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function() {
50
+ if (!props.disabled) {
51
+ setActive(function(prev) {
52
+ return !prev;
53
+ });
54
+ }
55
+ })
56
+ });
121
57
  });
58
+
122
59
  export { Toggle, ToggleFrame };
123
60
  //# sourceMappingURL=Toggle.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["jsx","_jsx","composeEventHandlers","useControllableState","styled","View","React","context","NAME","ToggleFrame","name","render","variants","unstyled","false","size","alignItems","justifyContent","display","backgroundColor","borderColor","borderWidth","margin","hoverStyle","pressStyle","focusVisibleStyle","outlineColor","outlineWidth","outlineStyle","zIndex","...size","val","param","tokens","width","height",":number","defaultActiveStyle","true","focusStyle","defaultVariants","process","env","TAMAGUI_HEADLESS","accept","activeStyle","Toggle","forwardRef","Toggle2","props","forwardedRef","active","activeProp","defaultActive","onActiveChange","activeTheme","buttonProps","setActive","prop","onChange","defaultProp","_props_onPress","theme","disabled","ref","onPress","prev"],"sources":["../../src/Toggle.tsx"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"Toggle.native.js","names":[],"sources":["esm/Toggle.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { createRefComponent } from \"@tamagui/compose-refs\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport { resolveSize } from \"@tamagui/size\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport { styled, View } from \"@tamagui/web\";\nimport * as React from \"react\";\nimport { context } from \"./context\";\nvar NAME = \"Toggle\";\nvar ToggleFrame = styled(View, {\n displayName: NAME,\n render: \"button\",\n context,\n size: true,\n alignItems: \"center\",\n justifyContent: \"center\",\n variants: {\n size: styled.dynamic(function(val, env) {\n if (!val) return;\n var { frame, controlHeight } = resolveSize(val, env);\n var side = controlHeight + 2;\n return {\n width: side,\n height: side,\n borderRadius: frame.borderRadius\n };\n }),\n defaultActiveStyle: {\n true: {}\n }\n }\n});\nvar Toggle = createRefComponent(function Toggle2(props, forwardedRef) {\n var { active: activeProp, activeStyle, defaultActive = false, onActiveChange, activeTheme, ...buttonProps } = props;\n var [active = false, setActive] = useControllableState({\n prop: activeProp,\n onChange: onActiveChange,\n defaultProp: defaultActive\n });\n var _props_onPress;\n return /* @__PURE__ */ _jsx(ToggleFrame, {\n theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,\n \"aria-pressed\": active,\n \"data-state\": active ? \"on\" : \"off\",\n \"data-disabled\": props.disabled ? \"\" : void 0,\n ...active && !activeStyle && {\n defaultActiveStyle: true\n },\n ...buttonProps,\n style: [\n buttonProps.style,\n active && activeStyle\n ],\n ref: forwardedRef,\n onPress: composeEventHandlers((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function() {\n if (!props.disabled) {\n setActive(function(prev) {\n return !prev;\n });\n }\n })\n });\n});\nexport {\n Toggle,\n ToggleFrame\n};\n//# sourceMappingURL=Toggle.js.map\n"],"mappings":";;;;;;;;;;AAQA,IAAI,OAAO;AACX,IAAI,cAAc,OAAO,MAAM;CAC7B,aAAa;CACb,QAAQ;CACR;CACA,MAAM;CACN,YAAY;CACZ,gBAAgB;CAChB,UAAU;EACR,MAAM,OAAO,QAAQ,SAAS,KAAK,KAAK;GACtC,IAAI,CAAC,KAAK;GACV,IAAI,EAAE,OAAO,kBAAkB,YAAY,KAAK,GAAG;GACnD,IAAI,OAAO,gBAAgB;GAC3B,OAAO;IACL,OAAO;IACP,QAAQ;IACR,cAAc,MAAM;GACtB;EACF,CAAC;EACD,oBAAoB,EAClB,MAAM,CAAC,EACT;CACF;AACF,CAAC;AACD,IAAI,SAAS,mBAAmB,SAAS,QAAQ,OAAO,cAAc;CACpE,IAAI,EAAE,QAAQ,YAAY,aAAa,gBAAgB,OAAO,gBAAgB,aAAa,GAAG,gBAAgB;CAC9G,IAAI,CAAC,SAAS,OAAO,aAAa,qBAAqB;EACrD,MAAM;EACN,UAAU;EACV,aAAa;CACf,CAAC;CACD,IAAI;CACJ,OAAuB,oBAAK,aAAa;EACvC,OAAO,gBAAgB,QAAQ,gBAAgB,KAAK,IAAI,cAAc;EACtE,gBAAgB;EAChB,cAAc,SAAS,OAAO;EAC9B,iBAAiB,MAAM,WAAW,KAAK,KAAK;EAC5C,GAAG,UAAU,CAAC,eAAe,EAC3B,oBAAoB,KACtB;EACA,GAAG;EACH,OAAO,CACL,YAAY,OACZ,UAAU,WACZ;EACA,KAAK;EACL,SAAS,sBAAsB,iBAAiB,MAAM,aAAa,QAAQ,mBAAmB,KAAK,IAAI,iBAAiB,KAAK,GAAG,WAAW;GACzI,IAAI,CAAC,MAAM,UAAU;IACnB,UAAU,SAAS,MAAM;KACvB,OAAO,CAAC;IACV,CAAC;GACH;EACF,CAAC;CACH,CAAC;AACH,CAAC"}