@radix-ui/react-checkbox 1.1.0-rc.2 → 1.1.0-rc.4
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/index.d.mts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +183 -175
- package/dist/index.js.map +3 -3
- package/dist/index.mjs.map +2 -2
- package/package.json +11 -11
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as Radix from '@radix-ui/react-primitive';
|
|
3
2
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
type Scope<C = any> = {
|
|
6
5
|
[scopeName: string]: React.Context<C>[];
|
|
7
6
|
} | undefined;
|
|
8
|
-
|
|
7
|
+
type ScopeHook = (scope: Scope) => {
|
|
9
8
|
[__scopeProp: string]: Scope;
|
|
10
9
|
};
|
|
11
10
|
interface CreateScope {
|
|
@@ -14,8 +13,8 @@ interface CreateScope {
|
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
declare const createCheckboxScope: CreateScope;
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
type CheckedState = boolean | 'indeterminate';
|
|
17
|
+
type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
|
|
19
18
|
interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {
|
|
20
19
|
checked?: CheckedState;
|
|
21
20
|
defaultChecked?: CheckedState;
|
|
@@ -23,7 +22,7 @@ interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultC
|
|
|
23
22
|
onCheckedChange?(checked: CheckedState): void;
|
|
24
23
|
}
|
|
25
24
|
declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
|
|
26
|
-
|
|
25
|
+
type PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;
|
|
27
26
|
interface CheckboxIndicatorProps extends PrimitiveSpanProps {
|
|
28
27
|
/**
|
|
29
28
|
* Used to force mounting when more control is needed. Useful when
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as Radix from '@radix-ui/react-primitive';
|
|
3
2
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
type Scope<C = any> = {
|
|
6
5
|
[scopeName: string]: React.Context<C>[];
|
|
7
6
|
} | undefined;
|
|
8
|
-
|
|
7
|
+
type ScopeHook = (scope: Scope) => {
|
|
9
8
|
[__scopeProp: string]: Scope;
|
|
10
9
|
};
|
|
11
10
|
interface CreateScope {
|
|
@@ -14,8 +13,8 @@ interface CreateScope {
|
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
declare const createCheckboxScope: CreateScope;
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
type CheckedState = boolean | 'indeterminate';
|
|
17
|
+
type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
|
|
19
18
|
interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {
|
|
20
19
|
checked?: CheckedState;
|
|
21
20
|
defaultChecked?: CheckedState;
|
|
@@ -23,7 +22,7 @@ interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultC
|
|
|
23
22
|
onCheckedChange?(checked: CheckedState): void;
|
|
24
23
|
}
|
|
25
24
|
declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
|
|
26
|
-
|
|
25
|
+
type PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;
|
|
27
26
|
interface CheckboxIndicatorProps extends PrimitiveSpanProps {
|
|
28
27
|
/**
|
|
29
28
|
* Used to force mounting when more control is needed. Useful when
|
package/dist/index.js
CHANGED
|
@@ -1,185 +1,193 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// packages/react/checkbox/src/index.ts
|
|
32
|
+
var src_exports = {};
|
|
33
|
+
__export(src_exports, {
|
|
34
|
+
Checkbox: () => Checkbox,
|
|
35
|
+
CheckboxIndicator: () => CheckboxIndicator,
|
|
36
|
+
Indicator: () => Indicator,
|
|
37
|
+
Root: () => Root,
|
|
38
|
+
createCheckboxScope: () => createCheckboxScope
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
42
|
+
// packages/react/checkbox/src/Checkbox.tsx
|
|
43
|
+
var React = __toESM(require("react"));
|
|
44
|
+
var import_react_compose_refs = require("@radix-ui/react-compose-refs");
|
|
45
|
+
var import_react_context = require("@radix-ui/react-context");
|
|
46
|
+
var import_primitive = require("@radix-ui/primitive");
|
|
47
|
+
var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
|
|
48
|
+
var import_react_use_previous = require("@radix-ui/react-use-previous");
|
|
49
|
+
var import_react_use_size = require("@radix-ui/react-use-size");
|
|
50
|
+
var import_react_presence = require("@radix-ui/react-presence");
|
|
51
|
+
var import_react_primitive = require("@radix-ui/react-primitive");
|
|
52
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
53
|
+
var CHECKBOX_NAME = "Checkbox";
|
|
54
|
+
var [createCheckboxContext, createCheckboxScope] = (0, import_react_context.createContextScope)(CHECKBOX_NAME);
|
|
55
|
+
var [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
|
|
56
|
+
var Checkbox = React.forwardRef(
|
|
57
|
+
(props, forwardedRef) => {
|
|
58
|
+
const {
|
|
59
|
+
__scopeCheckbox,
|
|
60
|
+
name,
|
|
61
|
+
checked: checkedProp,
|
|
62
|
+
defaultChecked,
|
|
63
|
+
required,
|
|
64
|
+
disabled,
|
|
65
|
+
value = "on",
|
|
66
|
+
onCheckedChange,
|
|
67
|
+
...checkboxProps
|
|
68
|
+
} = props;
|
|
69
|
+
const [button, setButton] = React.useState(null);
|
|
70
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, (node) => setButton(node));
|
|
71
|
+
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
72
|
+
const isFormControl = button ? Boolean(button.closest("form")) : true;
|
|
73
|
+
const [checked = false, setChecked] = (0, import_react_use_controllable_state.useControllableState)({
|
|
74
|
+
prop: checkedProp,
|
|
75
|
+
defaultProp: defaultChecked,
|
|
76
|
+
onChange: onCheckedChange
|
|
77
|
+
});
|
|
78
|
+
const initialCheckedStateRef = React.useRef(checked);
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
const form = button?.form;
|
|
81
|
+
if (form) {
|
|
82
|
+
const reset = () => setChecked(initialCheckedStateRef.current);
|
|
83
|
+
form.addEventListener("reset", reset);
|
|
84
|
+
return () => form.removeEventListener("reset", reset);
|
|
85
|
+
}
|
|
86
|
+
}, [button, setChecked]);
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CheckboxProvider, { scope: __scopeCheckbox, state: checked, disabled, children: [
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
import_react_primitive.Primitive.button,
|
|
90
|
+
{
|
|
91
|
+
type: "button",
|
|
92
|
+
role: "checkbox",
|
|
93
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
94
|
+
"aria-required": required,
|
|
95
|
+
"data-state": getState(checked),
|
|
96
|
+
"data-disabled": disabled ? "" : void 0,
|
|
97
|
+
disabled,
|
|
98
|
+
value,
|
|
99
|
+
...checkboxProps,
|
|
100
|
+
ref: composedRefs,
|
|
101
|
+
onKeyDown: (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
102
|
+
if (event.key === "Enter") event.preventDefault();
|
|
103
|
+
}),
|
|
104
|
+
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, (event) => {
|
|
105
|
+
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
|
|
106
|
+
if (isFormControl) {
|
|
107
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
108
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
109
|
+
}
|
|
110
|
+
})
|
|
76
111
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
import_react_primitive.Primitive.button,
|
|
81
|
-
{
|
|
82
|
-
type: "button",
|
|
83
|
-
role: "checkbox",
|
|
84
|
-
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
85
|
-
"aria-required": required,
|
|
86
|
-
"data-state": getState(checked),
|
|
87
|
-
"data-disabled": disabled ? "" : void 0,
|
|
88
|
-
disabled,
|
|
89
|
-
value,
|
|
90
|
-
...checkboxProps,
|
|
91
|
-
ref: composedRefs,
|
|
92
|
-
onKeyDown: (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
|
|
93
|
-
if (event.key === "Enter") event.preventDefault();
|
|
94
|
-
}),
|
|
95
|
-
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, (event) => {
|
|
96
|
-
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
|
|
97
|
-
if (isFormControl) {
|
|
98
|
-
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
99
|
-
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
),
|
|
104
|
-
isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
-
BubbleInput,
|
|
106
|
-
{
|
|
107
|
-
control: button,
|
|
108
|
-
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
109
|
-
name,
|
|
110
|
-
value,
|
|
111
|
-
checked,
|
|
112
|
-
required,
|
|
113
|
-
disabled,
|
|
114
|
-
style: { transform: "translateX(-100%)" }
|
|
115
|
-
}
|
|
116
|
-
)
|
|
117
|
-
] });
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
Checkbox.displayName = CHECKBOX_NAME;
|
|
121
|
-
var INDICATOR_NAME = "CheckboxIndicator";
|
|
122
|
-
var CheckboxIndicator = React.forwardRef(
|
|
123
|
-
(props, forwardedRef) => {
|
|
124
|
-
const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
|
|
125
|
-
const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
|
|
126
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || isIndeterminate(context.state) || context.state === true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
-
import_react_primitive.Primitive.span,
|
|
112
|
+
),
|
|
113
|
+
isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
114
|
+
BubbleInput,
|
|
128
115
|
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
116
|
+
control: button,
|
|
117
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
118
|
+
name,
|
|
119
|
+
value,
|
|
120
|
+
checked,
|
|
121
|
+
required,
|
|
122
|
+
disabled,
|
|
123
|
+
style: { transform: "translateX(-100%)" }
|
|
134
124
|
}
|
|
135
|
-
)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
|
|
148
|
-
const setChecked = descriptor.set;
|
|
149
|
-
if (prevChecked !== checked && setChecked) {
|
|
150
|
-
const event = new Event("click", { bubbles });
|
|
151
|
-
input.indeterminate = isIndeterminate(checked);
|
|
152
|
-
setChecked.call(input, isIndeterminate(checked) ? false : checked);
|
|
153
|
-
input.dispatchEvent(event);
|
|
154
|
-
}
|
|
155
|
-
}, [prevChecked, checked, bubbles]);
|
|
156
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
157
|
-
"input",
|
|
125
|
+
)
|
|
126
|
+
] });
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
Checkbox.displayName = CHECKBOX_NAME;
|
|
130
|
+
var INDICATOR_NAME = "CheckboxIndicator";
|
|
131
|
+
var CheckboxIndicator = React.forwardRef(
|
|
132
|
+
(props, forwardedRef) => {
|
|
133
|
+
const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
|
|
134
|
+
const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || isIndeterminate(context.state) || context.state === true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
136
|
+
import_react_primitive.Primitive.span,
|
|
158
137
|
{
|
|
159
|
-
|
|
160
|
-
"
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
ref,
|
|
165
|
-
style: {
|
|
166
|
-
...props.style,
|
|
167
|
-
...controlSize,
|
|
168
|
-
position: "absolute",
|
|
169
|
-
pointerEvents: "none",
|
|
170
|
-
opacity: 0,
|
|
171
|
-
margin: 0
|
|
172
|
-
}
|
|
138
|
+
"data-state": getState(context.state),
|
|
139
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
140
|
+
...indicatorProps,
|
|
141
|
+
ref: forwardedRef,
|
|
142
|
+
style: { pointerEvents: "none", ...props.style }
|
|
173
143
|
}
|
|
174
|
-
);
|
|
175
|
-
};
|
|
176
|
-
function isIndeterminate(checked) {
|
|
177
|
-
return checked === "indeterminate";
|
|
178
|
-
}
|
|
179
|
-
function getState(checked) {
|
|
180
|
-
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
144
|
+
) });
|
|
181
145
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
146
|
+
);
|
|
147
|
+
CheckboxIndicator.displayName = INDICATOR_NAME;
|
|
148
|
+
var BubbleInput = (props) => {
|
|
149
|
+
const { control, checked, bubbles = true, ...inputProps } = props;
|
|
150
|
+
const ref = React.useRef(null);
|
|
151
|
+
const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
|
|
152
|
+
const controlSize = (0, import_react_use_size.useSize)(control);
|
|
153
|
+
React.useEffect(() => {
|
|
154
|
+
const input = ref.current;
|
|
155
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
156
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
|
|
157
|
+
const setChecked = descriptor.set;
|
|
158
|
+
if (prevChecked !== checked && setChecked) {
|
|
159
|
+
const event = new Event("click", { bubbles });
|
|
160
|
+
input.indeterminate = isIndeterminate(checked);
|
|
161
|
+
setChecked.call(input, isIndeterminate(checked) ? false : checked);
|
|
162
|
+
input.dispatchEvent(event);
|
|
163
|
+
}
|
|
164
|
+
}, [prevChecked, checked, bubbles]);
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
166
|
+
"input",
|
|
167
|
+
{
|
|
168
|
+
type: "checkbox",
|
|
169
|
+
"aria-hidden": true,
|
|
170
|
+
defaultChecked: isIndeterminate(checked) ? false : checked,
|
|
171
|
+
...inputProps,
|
|
172
|
+
tabIndex: -1,
|
|
173
|
+
ref,
|
|
174
|
+
style: {
|
|
175
|
+
...props.style,
|
|
176
|
+
...controlSize,
|
|
177
|
+
position: "absolute",
|
|
178
|
+
pointerEvents: "none",
|
|
179
|
+
opacity: 0,
|
|
180
|
+
margin: 0
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
function isIndeterminate(checked) {
|
|
186
|
+
return checked === "indeterminate";
|
|
187
|
+
}
|
|
188
|
+
function getState(checked) {
|
|
189
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
190
|
+
}
|
|
191
|
+
var Root = Checkbox;
|
|
192
|
+
var Indicator = CheckboxIndicator;
|
|
185
193
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/Checkbox.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": ["../src/index.ts", "../src/Checkbox.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createCheckboxScope,\n //\n Checkbox,\n CheckboxIndicator,\n //\n Root,\n Indicator,\n} from './Checkbox';\nexport type { CheckboxProps, CheckboxIndicatorProps } from './Checkbox';\n", "import * as React from 'react';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Checkbox\n * -----------------------------------------------------------------------------------------------*/\n\nconst CHECKBOX_NAME = 'Checkbox';\n\ntype ScopedProps<P> = P & { __scopeCheckbox?: Scope };\nconst [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);\n\ntype CheckedState = boolean | 'indeterminate';\n\ntype CheckboxContextValue = {\n state: CheckedState;\n disabled?: boolean;\n};\n\nconst [CheckboxProvider, useCheckboxContext] =\n createCheckboxContext<CheckboxContextValue>(CHECKBOX_NAME);\n\ntype CheckboxElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {\n checked?: CheckedState;\n defaultChecked?: CheckedState;\n required?: boolean;\n onCheckedChange?(checked: CheckedState): void;\n}\n\nconst Checkbox = React.forwardRef<CheckboxElement, CheckboxProps>(\n (props: ScopedProps<CheckboxProps>, forwardedRef) => {\n const {\n __scopeCheckbox,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n ...checkboxProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange,\n });\n const initialCheckedStateRef = React.useRef(checked);\n React.useEffect(() => {\n const form = button?.form;\n if (form) {\n const reset = () => setChecked(initialCheckedStateRef.current);\n form.addEventListener('reset', reset);\n return () => form.removeEventListener('reset', reset);\n }\n }, [button, setChecked]);\n\n return (\n <CheckboxProvider scope={__scopeCheckbox} state={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"checkbox\"\n aria-checked={isIndeterminate(checked) ? 'mixed' : checked}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...checkboxProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n // According to WAI ARIA, Checkboxes don't activate on enter keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onClick={composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => (isIndeterminate(prevChecked) ? true : !prevChecked));\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if checkbox is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect checkbox updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </CheckboxProvider>\n );\n }\n);\n\nCheckbox.displayName = CHECKBOX_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * CheckboxIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'CheckboxIndicator';\n\ntype CheckboxIndicatorElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface CheckboxIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst CheckboxIndicator = React.forwardRef<CheckboxIndicatorElement, CheckboxIndicatorProps>(\n (props: ScopedProps<CheckboxIndicatorProps>, forwardedRef) => {\n const { __scopeCheckbox, forceMount, ...indicatorProps } = props;\n const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);\n return (\n <Presence present={forceMount || isIndeterminate(context.state) || context.state === true}>\n <Primitive.span\n data-state={getState(context.state)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n style={{ pointerEvents: 'none', ...props.style }}\n />\n </Presence>\n );\n }\n);\n\nCheckboxIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = React.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: CheckedState;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n input.indeterminate = isIndeterminate(checked);\n setChecked.call(input, isIndeterminate(checked) ? false : checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={isIndeterminate(checked) ? false : checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction isIndeterminate(checked?: CheckedState): checked is 'indeterminate' {\n return checked === 'indeterminate';\n}\n\nfunction getState(checked: CheckedState) {\n return isIndeterminate(checked) ? 'indeterminate' : checked ? 'checked' : 'unchecked';\n}\n\nconst Root = Checkbox;\nconst Indicator = CheckboxIndicator;\n\nexport {\n createCheckboxScope,\n //\n Checkbox,\n CheckboxIndicator,\n //\n Root,\n Indicator,\n};\nexport type { CheckboxProps, CheckboxIndicatorProps };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,gCAAgC;AAChC,2BAAmC;AACnC,uBAAqC;AACrC,0CAAqC;AACrC,gCAA4B;AAC5B,4BAAwB;AACxB,4BAAyB;AACzB,6BAA0B;AAkEpB;AA1DN,IAAM,gBAAgB;AAGtB,IAAM,CAAC,uBAAuB,mBAAmB,QAAI,yCAAmB,aAAa;AASrF,IAAM,CAAC,kBAAkB,kBAAkB,IACzC,sBAA4C,aAAa;AAW3D,IAAM,WAAiB;AAAA,EACrB,CAAC,OAAmC,iBAAiB;AACnD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,UAAM,CAAC,QAAQ,SAAS,IAAU,eAAmC,IAAI;AACzE,UAAM,mBAAe,2CAAgB,cA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iBAAW,KAAK,OAAO,gBAAgB,OAAO,IAAI,QAAQ,OAAO;AACjE,YAAM,cAAc,KAAK;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,aAAa,SAAS,OAAO,CAAC;AAElC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,eAAW;AAAA,MACX,gBAAgB,gBAAgB,OAAO,IAAI,QAAQ;AAAA,MAClD,GAAG;AAAA,MACJ,UAAU;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,GAAG,MAAM;AAAA,QACT,GAAG;AAAA,QACH,UAAU;AAAA,QACV,eAAe;AAAA,QACf,SAAS;AAAA,QACT,QAAQ;AAAA,MACV;AAAA;AAAA,EACF;AAEJ;AAEA,SAAS,gBAAgB,SAAoD;AAC3E,SAAO,YAAY;AACrB;AAEA,SAAS,SAAS,SAAuB;AACvC,SAAO,gBAAgB,OAAO,IAAI,kBAAkB,UAAU,YAAY;AAC5E;AAEA,IAAM,OAAO;AACb,IAAM,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/Checkbox.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type
|
|
5
|
-
"mappings": ";;;AAAA,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Checkbox\n * -----------------------------------------------------------------------------------------------*/\n\nconst CHECKBOX_NAME = 'Checkbox';\n\ntype ScopedProps<P> = P & { __scopeCheckbox?: Scope };\nconst [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);\n\ntype CheckedState = boolean | 'indeterminate';\n\ntype CheckboxContextValue = {\n state: CheckedState;\n disabled?: boolean;\n};\n\nconst [CheckboxProvider, useCheckboxContext] =\n createCheckboxContext<CheckboxContextValue>(CHECKBOX_NAME);\n\ntype CheckboxElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {\n checked?: CheckedState;\n defaultChecked?: CheckedState;\n required?: boolean;\n onCheckedChange?(checked: CheckedState): void;\n}\n\nconst Checkbox = React.forwardRef<CheckboxElement, CheckboxProps>(\n (props: ScopedProps<CheckboxProps>, forwardedRef) => {\n const {\n __scopeCheckbox,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n ...checkboxProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange,\n });\n const initialCheckedStateRef = React.useRef(checked);\n React.useEffect(() => {\n const form = button?.form;\n if (form) {\n const reset = () => setChecked(initialCheckedStateRef.current);\n form.addEventListener('reset', reset);\n return () => form.removeEventListener('reset', reset);\n }\n }, [button, setChecked]);\n\n return (\n <CheckboxProvider scope={__scopeCheckbox} state={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"checkbox\"\n aria-checked={isIndeterminate(checked) ? 'mixed' : checked}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...checkboxProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n // According to WAI ARIA, Checkboxes don't activate on enter keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onClick={composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => (isIndeterminate(prevChecked) ? true : !prevChecked));\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if checkbox is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect checkbox updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </CheckboxProvider>\n );\n }\n);\n\nCheckbox.displayName = CHECKBOX_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * CheckboxIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'CheckboxIndicator';\n\ntype CheckboxIndicatorElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface CheckboxIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst CheckboxIndicator = React.forwardRef<CheckboxIndicatorElement, CheckboxIndicatorProps>(\n (props: ScopedProps<CheckboxIndicatorProps>, forwardedRef) => {\n const { __scopeCheckbox, forceMount, ...indicatorProps } = props;\n const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);\n return (\n <Presence present={forceMount || isIndeterminate(context.state) || context.state === true}>\n <Primitive.span\n data-state={getState(context.state)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n style={{ pointerEvents: 'none', ...props.style }}\n />\n </Presence>\n );\n }\n);\n\nCheckboxIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = React.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: CheckedState;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n input.indeterminate = isIndeterminate(checked);\n setChecked.call(input, isIndeterminate(checked) ? false : checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={isIndeterminate(checked) ? false : checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction isIndeterminate(checked?: CheckedState): checked is 'indeterminate' {\n return checked === 'indeterminate';\n}\n\nfunction getState(checked: CheckedState) {\n return isIndeterminate(checked) ? 'indeterminate' : checked ? 'checked' : 'unchecked';\n}\n\nconst Root = Checkbox;\nconst Indicator = CheckboxIndicator;\n\nexport {\n createCheckboxScope,\n //\n Checkbox,\n CheckboxIndicator,\n //\n Root,\n Indicator,\n};\nexport type { CheckboxProps, CheckboxIndicatorProps };\n"],
|
|
5
|
+
"mappings": ";;;AAAA,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAkEpB,SACE,KADF;AA1DN,IAAM,gBAAgB;AAGtB,IAAM,CAAC,uBAAuB,mBAAmB,IAAI,mBAAmB,aAAa;AASrF,IAAM,CAAC,kBAAkB,kBAAkB,IACzC,sBAA4C,aAAa;AAW3D,IAAM,WAAiB;AAAA,EACrB,CAAC,OAAmC,iBAAiB;AACnD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,UAAM,CAAC,QAAQ,SAAS,IAAU,eAAmC,IAAI;AACzE,UAAM,eAAe,gBAAgB,cAAc,CAAC,SAAS,UAAU,IAAI,CAAC;AAC5E,UAAM,mCAAyC,aAAO,KAAK;AAE3D,UAAM,gBAAgB,SAAS,QAAQ,OAAO,QAAQ,MAAM,CAAC,IAAI;AAC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ACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,eAAW;AAAA,MACX,gBAAgB,gBAAgB,OAAO,IAAI,QAAQ;AAAA,MAClD,GAAG;AAAA,MACJ,UAAU;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,GAAG,MAAM;AAAA,QACT,GAAG;AAAA,QACH,UAAU;AAAA,QACV,eAAe;AAAA,QACf,SAAS;AAAA,QACT,QAAQ;AAAA,MACV;AAAA;AAAA,EACF;AAEJ;AAEA,SAAS,gBAAgB,SAAoD;AAC3E,SAAO,YAAY;AACrB;AAEA,SAAS,SAAS,SAAuB;AACvC,SAAO,gBAAgB,OAAO,IAAI,kBAAkB,UAAU,YAAY;AAC5E;AAEA,IAAM,OAAO;AACb,IAAM,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-checkbox",
|
|
3
|
-
"version": "1.1.0-rc.
|
|
3
|
+
"version": "1.1.0-rc.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"version": "yarn version"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@radix-ui/primitive": "1.1.0-rc.
|
|
32
|
-
"@radix-ui/react-compose-refs": "1.1.0-rc.
|
|
33
|
-
"@radix-ui/react-context": "1.1.0-rc.
|
|
34
|
-
"@radix-ui/react-presence": "1.1.0-rc.
|
|
35
|
-
"@radix-ui/react-primitive": "
|
|
36
|
-
"@radix-ui/react-use-controllable-state": "1.1.0-rc.
|
|
37
|
-
"@radix-ui/react-use-previous": "1.1.0-rc.
|
|
38
|
-
"@radix-ui/react-use-size": "1.1.0-rc.
|
|
31
|
+
"@radix-ui/primitive": "1.1.0-rc.4",
|
|
32
|
+
"@radix-ui/react-compose-refs": "1.1.0-rc.4",
|
|
33
|
+
"@radix-ui/react-context": "1.1.0-rc.4",
|
|
34
|
+
"@radix-ui/react-presence": "1.1.0-rc.4",
|
|
35
|
+
"@radix-ui/react-primitive": "2.0.0-rc.1",
|
|
36
|
+
"@radix-ui/react-use-controllable-state": "1.1.0-rc.4",
|
|
37
|
+
"@radix-ui/react-use-previous": "1.1.0-rc.4",
|
|
38
|
+
"@radix-ui/react-use-size": "1.1.0-rc.4"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@types/react": "*",
|
|
42
42
|
"@types/react-dom": "*",
|
|
43
|
-
"react": "^16.8 || ^17.0 || ^18.0",
|
|
44
|
-
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
|
43
|
+
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0",
|
|
44
|
+
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
47
|
"@types/react": {
|