@radix-ui/react-toggle 1.1.3 → 1.1.4-rc.1744259191780
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/LICENSE +21 -0
- package/README.md +0 -10
- package/dist/index.js +6 -5
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +5 -4
- package/dist/index.mjs.map +2 -2
- package/package.json +14 -29
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 WorkOS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
));
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
30
|
|
|
31
|
-
//
|
|
31
|
+
// src/index.ts
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
34
|
Root: () => Root,
|
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(index_exports);
|
|
38
38
|
|
|
39
|
-
//
|
|
39
|
+
// src/toggle.tsx
|
|
40
40
|
var React = __toESM(require("react"));
|
|
41
41
|
var import_primitive = require("@radix-ui/primitive");
|
|
42
42
|
var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
|
|
@@ -44,11 +44,12 @@ var import_react_primitive = require("@radix-ui/react-primitive");
|
|
|
44
44
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
45
|
var NAME = "Toggle";
|
|
46
46
|
var Toggle = React.forwardRef((props, forwardedRef) => {
|
|
47
|
-
const { pressed: pressedProp, defaultPressed
|
|
48
|
-
const [pressed
|
|
47
|
+
const { pressed: pressedProp, defaultPressed, onPressedChange, ...buttonProps } = props;
|
|
48
|
+
const [pressed, setPressed] = (0, import_react_use_controllable_state.useControllableState)({
|
|
49
49
|
prop: pressedProp,
|
|
50
50
|
onChange: onPressedChange,
|
|
51
|
-
defaultProp: defaultPressed
|
|
51
|
+
defaultProp: defaultPressed ?? false,
|
|
52
|
+
caller: NAME
|
|
52
53
|
});
|
|
53
54
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
54
55
|
import_react_primitive.Primitive.button,
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/toggle.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nexport {\n Toggle,\n //\n Root,\n} from './toggle';\nexport type { ToggleProps } from './toggle';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Toggle\n * -----------------------------------------------------------------------------------------------*/\n\nconst NAME = 'Toggle';\n\ntype ToggleElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface ToggleProps extends PrimitiveButtonProps {\n /**\n * The controlled state of the toggle.\n */\n pressed?: boolean;\n /**\n * The state of the toggle when initially rendered. Use `defaultPressed`\n * if you do not need to control the state of the toggle.\n * @defaultValue false\n */\n defaultPressed?: boolean;\n /**\n * The callback that fires when the state of the toggle changes.\n */\n onPressedChange?(pressed: boolean): void;\n}\n\nconst Toggle = React.forwardRef<ToggleElement, ToggleProps>((props, forwardedRef) => {\n const { pressed: pressedProp, defaultPressed
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,uBAAqC;AACrC,0CAAqC;AACrC,6BAA0B;
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n Toggle,\n //\n Root,\n} from './toggle';\nexport type { ToggleProps } from './toggle';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Toggle\n * -----------------------------------------------------------------------------------------------*/\n\nconst NAME = 'Toggle';\n\ntype ToggleElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface ToggleProps extends PrimitiveButtonProps {\n /**\n * The controlled state of the toggle.\n */\n pressed?: boolean;\n /**\n * The state of the toggle when initially rendered. Use `defaultPressed`\n * if you do not need to control the state of the toggle.\n * @defaultValue false\n */\n defaultPressed?: boolean;\n /**\n * The callback that fires when the state of the toggle changes.\n */\n onPressedChange?(pressed: boolean): void;\n}\n\nconst Toggle = React.forwardRef<ToggleElement, ToggleProps>((props, forwardedRef) => {\n const { pressed: pressedProp, defaultPressed, onPressedChange, ...buttonProps } = props;\n\n const [pressed, setPressed] = useControllableState({\n prop: pressedProp,\n onChange: onPressedChange,\n defaultProp: defaultPressed ?? false,\n caller: NAME,\n });\n\n return (\n <Primitive.button\n type=\"button\"\n aria-pressed={pressed}\n data-state={pressed ? 'on' : 'off'}\n data-disabled={props.disabled ? '' : undefined}\n {...buttonProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => {\n if (!props.disabled) {\n setPressed(!pressed);\n }\n })}\n />\n );\n});\n\nToggle.displayName = NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst Root = Toggle;\n\nexport {\n Toggle,\n //\n Root,\n};\nexport type { ToggleProps };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,uBAAqC;AACrC,0CAAqC;AACrC,6BAA0B;AAsCtB;AAhCJ,IAAM,OAAO;AAqBb,IAAM,SAAe,iBAAuC,CAAC,OAAO,iBAAiB;AACnF,QAAM,EAAE,SAAS,aAAa,gBAAgB,iBAAiB,GAAG,YAAY,IAAI;AAElF,QAAM,CAAC,SAAS,UAAU,QAAI,0DAAqB;AAAA,IACjD,MAAM;AAAA,IACN,UAAU;AAAA,IACV,aAAa,kBAAkB;AAAA,IAC/B,QAAQ;AAAA,EACV,CAAC;AAED,SACE;AAAA,IAAC,iCAAU;AAAA,IAAV;AAAA,MACC,MAAK;AAAA,MACL,gBAAc;AAAA,MACd,cAAY,UAAU,OAAO;AAAA,MAC7B,iBAAe,MAAM,WAAW,KAAK;AAAA,MACpC,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,aAAS,uCAAqB,MAAM,SAAS,MAAM;AACjD,YAAI,CAAC,MAAM,UAAU;AACnB,qBAAW,CAAC,OAAO;AAAA,QACrB;AAAA,MACF,CAAC;AAAA;AAAA,EACH;AAEJ,CAAC;AAED,OAAO,cAAc;AAIrB,IAAM,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// src/toggle.tsx
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
6
6
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
@@ -8,11 +8,12 @@ import { Primitive } from "@radix-ui/react-primitive";
|
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
var NAME = "Toggle";
|
|
10
10
|
var Toggle = React.forwardRef((props, forwardedRef) => {
|
|
11
|
-
const { pressed: pressedProp, defaultPressed
|
|
12
|
-
const [pressed
|
|
11
|
+
const { pressed: pressedProp, defaultPressed, onPressedChange, ...buttonProps } = props;
|
|
12
|
+
const [pressed, setPressed] = useControllableState({
|
|
13
13
|
prop: pressedProp,
|
|
14
14
|
onChange: onPressedChange,
|
|
15
|
-
defaultProp: defaultPressed
|
|
15
|
+
defaultProp: defaultPressed ?? false,
|
|
16
|
+
caller: NAME
|
|
16
17
|
});
|
|
17
18
|
return /* @__PURE__ */ jsx(
|
|
18
19
|
Primitive.button,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/toggle.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Toggle\n * -----------------------------------------------------------------------------------------------*/\n\nconst NAME = 'Toggle';\n\ntype ToggleElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface ToggleProps extends PrimitiveButtonProps {\n /**\n * The controlled state of the toggle.\n */\n pressed?: boolean;\n /**\n * The state of the toggle when initially rendered. Use `defaultPressed`\n * if you do not need to control the state of the toggle.\n * @defaultValue false\n */\n defaultPressed?: boolean;\n /**\n * The callback that fires when the state of the toggle changes.\n */\n onPressedChange?(pressed: boolean): void;\n}\n\nconst Toggle = React.forwardRef<ToggleElement, ToggleProps>((props, forwardedRef) => {\n const { pressed: pressedProp, defaultPressed
|
|
5
|
-
"mappings": ";;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Toggle\n * -----------------------------------------------------------------------------------------------*/\n\nconst NAME = 'Toggle';\n\ntype ToggleElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface ToggleProps extends PrimitiveButtonProps {\n /**\n * The controlled state of the toggle.\n */\n pressed?: boolean;\n /**\n * The state of the toggle when initially rendered. Use `defaultPressed`\n * if you do not need to control the state of the toggle.\n * @defaultValue false\n */\n defaultPressed?: boolean;\n /**\n * The callback that fires when the state of the toggle changes.\n */\n onPressedChange?(pressed: boolean): void;\n}\n\nconst Toggle = React.forwardRef<ToggleElement, ToggleProps>((props, forwardedRef) => {\n const { pressed: pressedProp, defaultPressed, onPressedChange, ...buttonProps } = props;\n\n const [pressed, setPressed] = useControllableState({\n prop: pressedProp,\n onChange: onPressedChange,\n defaultProp: defaultPressed ?? false,\n caller: NAME,\n });\n\n return (\n <Primitive.button\n type=\"button\"\n aria-pressed={pressed}\n data-state={pressed ? 'on' : 'off'}\n data-disabled={props.disabled ? '' : undefined}\n {...buttonProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => {\n if (!props.disabled) {\n setPressed(!pressed);\n }\n })}\n />\n );\n});\n\nToggle.displayName = NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst Root = Toggle;\n\nexport {\n Toggle,\n //\n Root,\n};\nexport type { ToggleProps };\n"],
|
|
5
|
+
"mappings": ";;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;AAsCtB;AAhCJ,IAAM,OAAO;AAqBb,IAAM,SAAe,iBAAuC,CAAC,OAAO,iBAAiB;AACnF,QAAM,EAAE,SAAS,aAAa,gBAAgB,iBAAiB,GAAG,YAAY,IAAI;AAElF,QAAM,CAAC,SAAS,UAAU,IAAI,qBAAqB;AAAA,IACjD,MAAM;AAAA,IACN,UAAU;AAAA,IACV,aAAa,kBAAkB;AAAA,IAC/B,QAAQ;AAAA,EACV,CAAC;AAED,SACE;AAAA,IAAC,UAAU;AAAA,IAAV;AAAA,MACC,MAAK;AAAA,MACL,gBAAc;AAAA,MACd,cAAY,UAAU,OAAO;AAAA,MAC7B,iBAAe,MAAM,WAAW,KAAK;AAAA,MACpC,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,SAAS,qBAAqB,MAAM,SAAS,MAAM;AACjD,YAAI,CAAC,MAAM,UAAU;AACnB,qBAAW,CAAC,OAAO;AAAA,QACrB;AAAA,MACF,CAAC;AAAA;AAAA,EACH;AAEJ,CAAC;AAED,OAAO,cAAc;AAIrB,IAAM,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,51 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-toggle",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4-rc.1744259191780",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
8
|
-
"publishConfig": {
|
|
9
|
-
"main": "./dist/index.js",
|
|
10
|
-
"module": "./dist/index.mjs",
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"import": {
|
|
15
|
-
"types": "./dist/index.d.mts",
|
|
16
|
-
"default": "./dist/index.mjs"
|
|
17
|
-
},
|
|
18
|
-
"require": {
|
|
19
|
-
"types": "./dist/index.d.ts",
|
|
20
|
-
"default": "./dist/index.js"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
8
|
"files": [
|
|
26
9
|
"dist",
|
|
27
10
|
"README.md"
|
|
28
11
|
],
|
|
29
12
|
"sideEffects": false,
|
|
30
|
-
"scripts": {
|
|
31
|
-
"lint": "eslint --max-warnings 0 src",
|
|
32
|
-
"clean": "rm -rf dist",
|
|
33
|
-
"version": "yarn version"
|
|
34
|
-
},
|
|
35
13
|
"dependencies": {
|
|
36
14
|
"@radix-ui/primitive": "1.1.2",
|
|
37
15
|
"@radix-ui/react-primitive": "2.0.3",
|
|
38
|
-
"@radix-ui/react-use-controllable-state": "1.
|
|
16
|
+
"@radix-ui/react-use-controllable-state": "1.2.0-rc.1744259191780"
|
|
39
17
|
},
|
|
40
18
|
"devDependencies": {
|
|
41
|
-
"@repo/eslint-config": "0.0.0",
|
|
42
|
-
"@repo/typescript-config": "0.0.0",
|
|
43
19
|
"@types/react": "^19.0.7",
|
|
44
20
|
"@types/react-dom": "^19.0.3",
|
|
45
21
|
"eslint": "^9.18.0",
|
|
46
22
|
"react": "^19.0.0",
|
|
47
23
|
"react-dom": "^19.0.0",
|
|
48
|
-
"typescript": "^5.7.3"
|
|
24
|
+
"typescript": "^5.7.3",
|
|
25
|
+
"@repo/eslint-config": "0.0.0",
|
|
26
|
+
"@repo/typescript-config": "0.0.0",
|
|
27
|
+
"@repo/builder": "0.0.0"
|
|
49
28
|
},
|
|
50
29
|
"peerDependencies": {
|
|
51
30
|
"@types/react": "*",
|
|
@@ -69,6 +48,13 @@
|
|
|
69
48
|
"bugs": {
|
|
70
49
|
"url": "https://github.com/radix-ui/primitives/issues"
|
|
71
50
|
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"lint": "eslint --max-warnings 0 src",
|
|
53
|
+
"clean": "rm -rf dist",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"build": "radix-build"
|
|
56
|
+
},
|
|
57
|
+
"types": "./dist/index.d.ts",
|
|
72
58
|
"exports": {
|
|
73
59
|
".": {
|
|
74
60
|
"import": {
|
|
@@ -80,6 +66,5 @@
|
|
|
80
66
|
"default": "./dist/index.js"
|
|
81
67
|
}
|
|
82
68
|
}
|
|
83
|
-
}
|
|
84
|
-
"types": "./dist/index.d.ts"
|
|
69
|
+
}
|
|
85
70
|
}
|