@radix-ui/react-toggle-group 1.0.5-rc.8 → 1.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +30 -17
- package/dist/index.d.ts +30 -17
- package/dist/index.js +184 -179
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +161 -170
- package/dist/index.mjs.map +7 -1
- package/package.json +8 -9
- package/dist/index.d.ts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import * as Radix from '@radix-ui/react-primitive';
|
|
4
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
5
|
+
import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
|
|
6
|
+
import { Toggle } from '@radix-ui/react-toggle';
|
|
7
|
+
|
|
8
|
+
declare type Scope<C = any> = {
|
|
9
|
+
[scopeName: string]: React.Context<C>[];
|
|
10
|
+
} | undefined;
|
|
11
|
+
declare type ScopeHook = (scope: Scope) => {
|
|
12
|
+
[__scopeProp: string]: Scope;
|
|
13
|
+
};
|
|
14
|
+
interface CreateScope {
|
|
15
|
+
scopeName: string;
|
|
16
|
+
(): ScopeHook;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const createToggleGroupScope: CreateScope;
|
|
20
|
+
interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
|
|
8
21
|
type: 'single';
|
|
9
22
|
}
|
|
10
|
-
|
|
23
|
+
interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
|
|
11
24
|
type: 'multiple';
|
|
12
25
|
}
|
|
13
|
-
|
|
26
|
+
declare const ToggleGroup: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.RefAttributes<HTMLDivElement>>;
|
|
14
27
|
interface ToggleGroupImplSingleProps extends ToggleGroupImplProps {
|
|
15
28
|
/**
|
|
16
29
|
* The controlled stateful value of the item that is pressed.
|
|
@@ -41,8 +54,8 @@ interface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {
|
|
|
41
54
|
*/
|
|
42
55
|
onValueChange?(value: string[]): void;
|
|
43
56
|
}
|
|
44
|
-
type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
|
|
45
|
-
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
57
|
+
declare type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
|
|
58
|
+
declare type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
46
59
|
interface ToggleGroupImplProps extends PrimitiveDivProps {
|
|
47
60
|
/**
|
|
48
61
|
* Whether the group is disabled from user interaction.
|
|
@@ -58,17 +71,17 @@ interface ToggleGroupImplProps extends PrimitiveDivProps {
|
|
|
58
71
|
orientation?: RovingFocusGroupProps['orientation'];
|
|
59
72
|
dir?: RovingFocusGroupProps['dir'];
|
|
60
73
|
}
|
|
61
|
-
|
|
74
|
+
interface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {
|
|
62
75
|
}
|
|
63
|
-
|
|
64
|
-
type ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;
|
|
76
|
+
declare const ToggleGroupItem: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
77
|
+
declare type ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;
|
|
65
78
|
interface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> {
|
|
66
79
|
/**
|
|
67
80
|
* A string value for the toggle group item. All items within a toggle group should use a unique value.
|
|
68
81
|
*/
|
|
69
82
|
value: string;
|
|
70
83
|
}
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
declare const Root: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.RefAttributes<HTMLDivElement>>;
|
|
85
|
+
declare const Item: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
73
86
|
|
|
74
|
-
|
|
87
|
+
export { Item, Root, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupMultipleProps, type ToggleGroupSingleProps, createToggleGroupScope };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import * as Radix from '@radix-ui/react-primitive';
|
|
4
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
5
|
+
import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
|
|
6
|
+
import { Toggle } from '@radix-ui/react-toggle';
|
|
7
|
+
|
|
8
|
+
declare type Scope<C = any> = {
|
|
9
|
+
[scopeName: string]: React.Context<C>[];
|
|
10
|
+
} | undefined;
|
|
11
|
+
declare type ScopeHook = (scope: Scope) => {
|
|
12
|
+
[__scopeProp: string]: Scope;
|
|
13
|
+
};
|
|
14
|
+
interface CreateScope {
|
|
15
|
+
scopeName: string;
|
|
16
|
+
(): ScopeHook;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const createToggleGroupScope: CreateScope;
|
|
20
|
+
interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
|
|
8
21
|
type: 'single';
|
|
9
22
|
}
|
|
10
|
-
|
|
23
|
+
interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
|
|
11
24
|
type: 'multiple';
|
|
12
25
|
}
|
|
13
|
-
|
|
26
|
+
declare const ToggleGroup: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.RefAttributes<HTMLDivElement>>;
|
|
14
27
|
interface ToggleGroupImplSingleProps extends ToggleGroupImplProps {
|
|
15
28
|
/**
|
|
16
29
|
* The controlled stateful value of the item that is pressed.
|
|
@@ -41,8 +54,8 @@ interface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {
|
|
|
41
54
|
*/
|
|
42
55
|
onValueChange?(value: string[]): void;
|
|
43
56
|
}
|
|
44
|
-
type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
|
|
45
|
-
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
57
|
+
declare type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
|
|
58
|
+
declare type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
46
59
|
interface ToggleGroupImplProps extends PrimitiveDivProps {
|
|
47
60
|
/**
|
|
48
61
|
* Whether the group is disabled from user interaction.
|
|
@@ -58,17 +71,17 @@ interface ToggleGroupImplProps extends PrimitiveDivProps {
|
|
|
58
71
|
orientation?: RovingFocusGroupProps['orientation'];
|
|
59
72
|
dir?: RovingFocusGroupProps['dir'];
|
|
60
73
|
}
|
|
61
|
-
|
|
74
|
+
interface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {
|
|
62
75
|
}
|
|
63
|
-
|
|
64
|
-
type ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;
|
|
76
|
+
declare const ToggleGroupItem: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
77
|
+
declare type ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;
|
|
65
78
|
interface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> {
|
|
66
79
|
/**
|
|
67
80
|
* A string value for the toggle group item. All items within a toggle group should use a unique value.
|
|
68
81
|
*/
|
|
69
82
|
value: string;
|
|
70
83
|
}
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
declare const Root: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.RefAttributes<HTMLDivElement>>;
|
|
85
|
+
declare const Item: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
73
86
|
|
|
74
|
-
|
|
87
|
+
export { Item, Root, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupMultipleProps, type ToggleGroupSingleProps, createToggleGroupScope };
|
package/dist/index.js
CHANGED
|
@@ -1,193 +1,198 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
// packages/react/toggle-group/src/ToggleGroup.tsx
|
|
33
|
+
var import_react = __toESM(__require("react"));
|
|
34
|
+
var import_react_context = __require("@radix-ui/react-context");
|
|
35
|
+
var import_react_primitive = __require("@radix-ui/react-primitive");
|
|
36
|
+
var RovingFocusGroup = __toESM(__require("@radix-ui/react-roving-focus"));
|
|
37
|
+
var import_react_roving_focus = __require("@radix-ui/react-roving-focus");
|
|
38
|
+
var import_react_toggle = __require("@radix-ui/react-toggle");
|
|
39
|
+
var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
|
|
40
|
+
var import_react_direction = __require("@radix-ui/react-direction");
|
|
41
|
+
var import_jsx_runtime = __require("react/jsx-runtime");
|
|
42
|
+
var TOGGLE_GROUP_NAME = "ToggleGroup";
|
|
43
|
+
var [createToggleGroupContext, createToggleGroupScope] = (0, import_react_context.createContextScope)(TOGGLE_GROUP_NAME, [
|
|
44
|
+
import_react_roving_focus.createRovingFocusGroupScope
|
|
45
|
+
]);
|
|
46
|
+
var useRovingFocusGroupScope = (0, import_react_roving_focus.createRovingFocusGroupScope)();
|
|
47
|
+
var ToggleGroup = import_react.default.forwardRef((props, forwardedRef) => {
|
|
48
|
+
const { type, ...toggleGroupProps } = props;
|
|
49
|
+
if (type === "single") {
|
|
50
|
+
const singleProps = toggleGroupProps;
|
|
51
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplSingle, { ...singleProps, ref: forwardedRef });
|
|
45
52
|
}
|
|
46
|
-
if (type ===
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
ref: forwardedRef
|
|
50
|
-
}));
|
|
53
|
+
if (type === "multiple") {
|
|
54
|
+
const multipleProps = toggleGroupProps;
|
|
55
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplMultiple, { ...multipleProps, ref: forwardedRef });
|
|
51
56
|
}
|
|
52
|
-
throw new Error(`Missing prop \`type\` expected on \`${
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``);
|
|
58
|
+
});
|
|
59
|
+
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
60
|
+
var [ToggleGroupValueProvider, useToggleGroupValueContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
|
|
61
|
+
var ToggleGroupImplSingle = import_react.default.forwardRef((props, forwardedRef) => {
|
|
62
|
+
const {
|
|
63
|
+
value: valueProp,
|
|
64
|
+
defaultValue,
|
|
65
|
+
onValueChange = () => {
|
|
66
|
+
},
|
|
67
|
+
...toggleGroupSingleProps
|
|
68
|
+
} = props;
|
|
69
|
+
const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({
|
|
70
|
+
prop: valueProp,
|
|
71
|
+
defaultProp: defaultValue,
|
|
72
|
+
onChange: onValueChange
|
|
64
73
|
});
|
|
65
|
-
return
|
|
74
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
75
|
+
ToggleGroupValueProvider,
|
|
76
|
+
{
|
|
66
77
|
scope: props.__scopeToggleGroup,
|
|
67
78
|
type: "single",
|
|
68
|
-
value: value ? [
|
|
69
|
-
value
|
|
70
|
-
] : [],
|
|
79
|
+
value: value ? [value] : [],
|
|
71
80
|
onItemActivate: setValue,
|
|
72
|
-
onItemDeactivate:
|
|
73
|
-
,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
onItemDeactivate: import_react.default.useCallback(() => setValue(""), [setValue]),
|
|
82
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupSingleProps, ref: forwardedRef })
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
var ToggleGroupImplMultiple = import_react.default.forwardRef((props, forwardedRef) => {
|
|
87
|
+
const {
|
|
88
|
+
value: valueProp,
|
|
89
|
+
defaultValue,
|
|
90
|
+
onValueChange = () => {
|
|
91
|
+
},
|
|
92
|
+
...toggleGroupMultipleProps
|
|
93
|
+
} = props;
|
|
94
|
+
const [value = [], setValue] = (0, import_react_use_controllable_state.useControllableState)({
|
|
95
|
+
prop: valueProp,
|
|
96
|
+
defaultProp: defaultValue,
|
|
97
|
+
onChange: onValueChange
|
|
86
98
|
});
|
|
87
|
-
const handleButtonActivate =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
, [
|
|
99
|
-
setValue
|
|
100
|
-
]);
|
|
101
|
-
return /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupValueProvider, {
|
|
99
|
+
const handleButtonActivate = import_react.default.useCallback(
|
|
100
|
+
(itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
|
|
101
|
+
[setValue]
|
|
102
|
+
);
|
|
103
|
+
const handleButtonDeactivate = import_react.default.useCallback(
|
|
104
|
+
(itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
|
|
105
|
+
[setValue]
|
|
106
|
+
);
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
|
+
ToggleGroupValueProvider,
|
|
109
|
+
{
|
|
102
110
|
scope: props.__scopeToggleGroup,
|
|
103
111
|
type: "multiple",
|
|
104
|
-
value
|
|
112
|
+
value,
|
|
105
113
|
onItemActivate: handleButtonActivate,
|
|
106
|
-
onItemDeactivate: handleButtonDeactivate
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
onItemDeactivate: handleButtonDeactivate,
|
|
115
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupMultipleProps, ref: forwardedRef })
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
120
|
+
var [ToggleGroupContext, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
|
|
121
|
+
var ToggleGroupImpl = import_react.default.forwardRef(
|
|
122
|
+
(props, forwardedRef) => {
|
|
123
|
+
const {
|
|
124
|
+
__scopeToggleGroup,
|
|
125
|
+
disabled = false,
|
|
126
|
+
rovingFocus = true,
|
|
127
|
+
orientation,
|
|
128
|
+
dir,
|
|
129
|
+
loop = true,
|
|
122
130
|
...toggleGroupProps
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}))) : /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($1z6X1$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, commonProps, {
|
|
137
|
-
ref: forwardedRef
|
|
138
|
-
})));
|
|
139
|
-
});
|
|
140
|
-
/* -------------------------------------------------------------------------------------------------
|
|
141
|
-
* ToggleGroupItem
|
|
142
|
-
* -----------------------------------------------------------------------------------------------*/ const $14b404ddd46c8376$var$ITEM_NAME = 'ToggleGroupItem';
|
|
143
|
-
const $14b404ddd46c8376$export$b453109e13abe10b = /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).forwardRef((props, forwardedRef)=>{
|
|
144
|
-
const valueContext = $14b404ddd46c8376$var$useToggleGroupValueContext($14b404ddd46c8376$var$ITEM_NAME, props.__scopeToggleGroup);
|
|
145
|
-
const context = $14b404ddd46c8376$var$useToggleGroupContext($14b404ddd46c8376$var$ITEM_NAME, props.__scopeToggleGroup);
|
|
146
|
-
const rovingFocusGroupScope = $14b404ddd46c8376$var$useRovingFocusGroupScope(props.__scopeToggleGroup);
|
|
147
|
-
const pressed = valueContext.value.includes(props.value);
|
|
148
|
-
const disabled = context.disabled || props.disabled;
|
|
149
|
-
const commonProps = {
|
|
150
|
-
...props,
|
|
151
|
-
pressed: pressed,
|
|
152
|
-
disabled: disabled
|
|
153
|
-
};
|
|
154
|
-
const ref = ($parcel$interopDefault($1z6X1$react)).useRef(null);
|
|
155
|
-
return context.rovingFocus ? /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($1z6X1$radixuireactrovingfocus.Item, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({
|
|
156
|
-
asChild: true
|
|
157
|
-
}, rovingFocusGroupScope, {
|
|
158
|
-
focusable: !disabled,
|
|
159
|
-
active: pressed,
|
|
160
|
-
ref: ref
|
|
161
|
-
}), /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupItemImpl, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, commonProps, {
|
|
162
|
-
ref: forwardedRef
|
|
163
|
-
}))) : /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupItemImpl, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, commonProps, {
|
|
164
|
-
ref: forwardedRef
|
|
165
|
-
}));
|
|
166
|
-
});
|
|
167
|
-
/*#__PURE__*/ Object.assign($14b404ddd46c8376$export$b453109e13abe10b, {
|
|
168
|
-
displayName: $14b404ddd46c8376$var$ITEM_NAME
|
|
169
|
-
});
|
|
170
|
-
/* -----------------------------------------------------------------------------------------------*/ const $14b404ddd46c8376$var$ToggleGroupItemImpl = /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).forwardRef((props, forwardedRef)=>{
|
|
171
|
-
const { __scopeToggleGroup: __scopeToggleGroup , value: value , ...itemProps } = props;
|
|
172
|
-
const valueContext = $14b404ddd46c8376$var$useToggleGroupValueContext($14b404ddd46c8376$var$ITEM_NAME, __scopeToggleGroup);
|
|
173
|
-
const singleProps = {
|
|
174
|
-
role: 'radio',
|
|
175
|
-
'aria-checked': props.pressed,
|
|
176
|
-
'aria-pressed': undefined
|
|
177
|
-
};
|
|
178
|
-
const typeProps = valueContext.type === 'single' ? singleProps : undefined;
|
|
179
|
-
return /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($1z6X1$radixuireacttoggle.Toggle, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, typeProps, itemProps, {
|
|
180
|
-
ref: forwardedRef,
|
|
181
|
-
onPressedChange: (pressed)=>{
|
|
182
|
-
if (pressed) valueContext.onItemActivate(value);
|
|
183
|
-
else valueContext.onItemDeactivate(value);
|
|
131
|
+
} = props;
|
|
132
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup);
|
|
133
|
+
const direction = (0, import_react_direction.useDirection)(dir);
|
|
134
|
+
const commonProps = { role: "group", dir: direction, ...toggleGroupProps };
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupContext, { scope: __scopeToggleGroup, rovingFocus, disabled, children: rovingFocus ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
136
|
+
RovingFocusGroup.Root,
|
|
137
|
+
{
|
|
138
|
+
asChild: true,
|
|
139
|
+
...rovingFocusGroupScope,
|
|
140
|
+
orientation,
|
|
141
|
+
dir: direction,
|
|
142
|
+
loop,
|
|
143
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...commonProps, ref: forwardedRef })
|
|
184
144
|
}
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
145
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...commonProps, ref: forwardedRef }) });
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
var ITEM_NAME = "ToggleGroupItem";
|
|
149
|
+
var ToggleGroupItem = import_react.default.forwardRef(
|
|
150
|
+
(props, forwardedRef) => {
|
|
151
|
+
const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup);
|
|
152
|
+
const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup);
|
|
153
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup);
|
|
154
|
+
const pressed = valueContext.value.includes(props.value);
|
|
155
|
+
const disabled = context.disabled || props.disabled;
|
|
156
|
+
const commonProps = { ...props, pressed, disabled };
|
|
157
|
+
const ref = import_react.default.useRef(null);
|
|
158
|
+
return context.rovingFocus ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
159
|
+
RovingFocusGroup.Item,
|
|
160
|
+
{
|
|
161
|
+
asChild: true,
|
|
162
|
+
...rovingFocusGroupScope,
|
|
163
|
+
focusable: !disabled,
|
|
164
|
+
active: pressed,
|
|
165
|
+
ref,
|
|
166
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef })
|
|
167
|
+
}
|
|
168
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef });
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
ToggleGroupItem.displayName = ITEM_NAME;
|
|
172
|
+
var ToggleGroupItemImpl = import_react.default.forwardRef(
|
|
173
|
+
(props, forwardedRef) => {
|
|
174
|
+
const { __scopeToggleGroup, value, ...itemProps } = props;
|
|
175
|
+
const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup);
|
|
176
|
+
const singleProps = { role: "radio", "aria-checked": props.pressed, "aria-pressed": void 0 };
|
|
177
|
+
const typeProps = valueContext.type === "single" ? singleProps : void 0;
|
|
178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
179
|
+
import_react_toggle.Toggle,
|
|
180
|
+
{
|
|
181
|
+
...typeProps,
|
|
182
|
+
...itemProps,
|
|
183
|
+
ref: forwardedRef,
|
|
184
|
+
onPressedChange: (pressed) => {
|
|
185
|
+
if (pressed) {
|
|
186
|
+
valueContext.onItemActivate(value);
|
|
187
|
+
} else {
|
|
188
|
+
valueContext.onItemDeactivate(value);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
var Root2 = ToggleGroup;
|
|
196
|
+
var Item2 = ToggleGroupItem;
|
|
197
|
+
})();
|
|
193
198
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;ACYA;;oGAEA,CAEA,MAAMa,uCAAiB,GAAG,aAA1B,AAAA;AAGA,MAAM,CAACC,8CAAD,EAA2Bd,yCAA3B,CAAA,GAAqDM,6CAAkB,CAACO,uCAAD,EAAoB;IAC/FJ,0DAD+F;CAApB,CAA7E,AAAA;AAGA,MAAMM,8CAAwB,GAAGN,0DAA2B,EAA5D,AAAA;AAUA,MAAMR,yCAAW,GAAA,aAAGI,CAAAA,sCAAK,CAACW,UAAN,CAGlB,CAACC,KAAD,EAAQC,YAAR,GAAyB;IACzB,MAAM,E,MAAEC,IAAF,CAAA,EAAQ,GAAGC,gBAAH,EAAR,GAAgCH,KAAtC,AAAM;IAEN,IAAIE,IAAI,KAAK,QAAb,EAAuB;QACrB,MAAME,WAAW,GAAGD,gBAApB,AAAA;QACA,OAAA,aAAO,CAAA,sCAAA,CAAA,aAAA,CAAC,2CAAD,EAAA,2DAAA,CAAA,EAAA,EAA2BC,WAA3B,EAAP;YAA+C,GAAG,EAAEH,YAAL;SAAxC,CAAA,CAAP,CAAO;KACR;IAED,IAAIC,IAAI,KAAK,UAAb,EAAyB;QACvB,MAAMG,aAAa,GAA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,KAAsB,QAAtB,GAAiCE,WAAjC,GAA+C6C,SAAjE,AAAA;IACA,OAAA,aACE,CAAA,sCAAA,CAAA,aAAA,CAAC,gCAAD,EAAA,2DAAA,CAAA,EAAA,EACMC,SADN,EAEMF,SAFN,EADF;QAII,GAAG,EAAE/C,YAHP;QAIE,eAAe,EAAG0C,CAAAA,OAAD,GAAa;YAC5B,IAAIA,OAAJ,EACEF,YAAY,CAACU,cAAb,CAA4BzC,KAA5B,CAAA+B,CAAAA;iBAEAA,YAAY,CAACW,gBAAb,CAA8B1C,KAA9B,CAAA+B,CAAAA;SAEH;KAVH,CAAA,CADF,CACE;CAPsB,CAA5B,AAoBG;AAGH,oGAAA,CAEA,MAAMvD,yCAAI,GAAGF,yCAAb,AAAA;AACA,MAAMG,yCAAI,GAAGF,yCAAb,AAAA;;ADjTA","sources":["packages/react/toggle-group/src/index.ts","packages/react/toggle-group/src/ToggleGroup.tsx"],"sourcesContent":["export {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n Root,\n Item,\n} from './ToggleGroup';\nexport type {\n ToggleGroupSingleProps,\n ToggleGroupMultipleProps,\n ToggleGroupItemProps,\n} from './ToggleGroup';\n","import React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { Toggle } from '@radix-ui/react-toggle';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * ToggleGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOGGLE_GROUP_NAME = 'ToggleGroup';\n\ntype ScopedProps<P> = P & { __scopeToggleGroup?: Scope };\nconst [createToggleGroupContext, createToggleGroupScope] = createContextScope(TOGGLE_GROUP_NAME, [\n createRovingFocusGroupScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\n\ntype ToggleGroupElement = ToggleGroupImplSingleElement | ToggleGroupImplMultipleElement;\ninterface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {\n type: 'single';\n}\ninterface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {\n type: 'multiple';\n}\n\nconst ToggleGroup = React.forwardRef<\n ToggleGroupElement,\n ToggleGroupSingleProps | ToggleGroupMultipleProps\n>((props, forwardedRef) => {\n const { type, ...toggleGroupProps } = props;\n\n if (type === 'single') {\n const singleProps = toggleGroupProps as ToggleGroupImplSingleProps;\n return <ToggleGroupImplSingle {...singleProps} ref={forwardedRef} />;\n }\n\n if (type === 'multiple') {\n const multipleProps = toggleGroupProps as ToggleGroupImplMultipleProps;\n return <ToggleGroupImplMultiple {...multipleProps} ref={forwardedRef} />;\n }\n\n throw new Error(`Missing prop \\`type\\` expected on \\`${TOGGLE_GROUP_NAME}\\``);\n});\n\nToggleGroup.displayName = TOGGLE_GROUP_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupValueContextValue = {\n type: 'single' | 'multiple';\n value: string[];\n onItemActivate(value: string): void;\n onItemDeactivate(value: string): void;\n};\n\nconst [ToggleGroupValueProvider, useToggleGroupValueContext] =\n createToggleGroupContext<ToggleGroupValueContextValue>(TOGGLE_GROUP_NAME);\n\ntype ToggleGroupImplSingleElement = ToggleGroupImplElement;\ninterface ToggleGroupImplSingleProps extends ToggleGroupImplProps {\n /**\n * The controlled stateful value of the item that is pressed.\n */\n value?: string;\n /**\n * The value of the item that is pressed when initially rendered. Use\n * `defaultValue` if you do not need to control the state of a toggle group.\n */\n defaultValue?: string;\n /**\n * The callback that fires when the value of the toggle group changes.\n */\n onValueChange?(value: string): void;\n}\n\nconst ToggleGroupImplSingle = React.forwardRef<\n ToggleGroupImplSingleElement,\n ToggleGroupImplSingleProps\n>((props: ScopedProps<ToggleGroupImplSingleProps>, forwardedRef) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...toggleGroupSingleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"single\"\n value={value ? [value] : []}\n onItemActivate={setValue}\n onItemDeactivate={React.useCallback(() => setValue(''), [setValue])}\n >\n <ToggleGroupImpl {...toggleGroupSingleProps} ref={forwardedRef} />\n </ToggleGroupValueProvider>\n );\n});\n\ntype ToggleGroupImplMultipleElement = ToggleGroupImplElement;\ninterface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {\n /**\n * The controlled stateful value of the items that are pressed.\n */\n value?: string[];\n /**\n * The value of the items that are pressed when initially rendered. Use\n * `defaultValue` if you do not need to control the state of a toggle group.\n */\n defaultValue?: string[];\n /**\n * The callback that fires when the state of the toggle group changes.\n */\n onValueChange?(value: string[]): void;\n}\n\nconst ToggleGroupImplMultiple = React.forwardRef<\n ToggleGroupImplMultipleElement,\n ToggleGroupImplMultipleProps\n>((props: ScopedProps<ToggleGroupImplMultipleProps>, forwardedRef) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...toggleGroupMultipleProps\n } = props;\n\n const [value = [], setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n const handleButtonActivate = React.useCallback(\n (itemValue: string) => setValue((prevValue = []) => [...prevValue, itemValue]),\n [setValue]\n );\n\n const handleButtonDeactivate = React.useCallback(\n (itemValue: string) =>\n setValue((prevValue = []) => prevValue.filter((value) => value !== itemValue)),\n [setValue]\n );\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"multiple\"\n value={value}\n onItemActivate={handleButtonActivate}\n onItemDeactivate={handleButtonDeactivate}\n >\n <ToggleGroupImpl {...toggleGroupMultipleProps} ref={forwardedRef} />\n </ToggleGroupValueProvider>\n );\n});\n\nToggleGroup.displayName = TOGGLE_GROUP_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupContextValue = { rovingFocus: boolean; disabled: boolean };\n\nconst [ToggleGroupContext, useToggleGroupContext] =\n createToggleGroupContext<ToggleGroupContextValue>(TOGGLE_GROUP_NAME);\n\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype ToggleGroupImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ToggleGroupImplProps extends PrimitiveDivProps {\n /**\n * Whether the group is disabled from user interaction.\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * Whether the group should maintain roving focus of its buttons.\n * @defaultValue true\n */\n rovingFocus?: boolean;\n loop?: RovingFocusGroupProps['loop'];\n orientation?: RovingFocusGroupProps['orientation'];\n dir?: RovingFocusGroupProps['dir'];\n}\n\nconst ToggleGroupImpl = React.forwardRef<ToggleGroupImplElement, ToggleGroupImplProps>(\n (props: ScopedProps<ToggleGroupImplProps>, forwardedRef) => {\n const {\n __scopeToggleGroup,\n disabled = false,\n rovingFocus = true,\n orientation,\n dir,\n loop = true,\n ...toggleGroupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup);\n const direction = useDirection(dir);\n const commonProps = { role: 'group', dir: direction, ...toggleGroupProps };\n return (\n <ToggleGroupContext scope={__scopeToggleGroup} rovingFocus={rovingFocus} disabled={disabled}>\n {rovingFocus ? (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div {...commonProps} ref={forwardedRef} />\n </RovingFocusGroup.Root>\n ) : (\n <Primitive.div {...commonProps} ref={forwardedRef} />\n )}\n </ToggleGroupContext>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToggleGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'ToggleGroupItem';\n\ntype ToggleGroupItemElement = ToggleGroupItemImplElement;\ninterface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {}\n\nconst ToggleGroupItem = React.forwardRef<ToggleGroupItemElement, ToggleGroupItemProps>(\n (props: ScopedProps<ToggleGroupItemProps>, forwardedRef) => {\n const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup);\n const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup);\n const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup);\n const pressed = valueContext.value.includes(props.value);\n const disabled = context.disabled || props.disabled;\n const commonProps = { ...props, pressed, disabled };\n const ref = React.useRef<HTMLDivElement>(null);\n return context.rovingFocus ? (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={pressed}\n ref={ref}\n >\n <ToggleGroupItemImpl {...commonProps} ref={forwardedRef} />\n </RovingFocusGroup.Item>\n ) : (\n <ToggleGroupItemImpl {...commonProps} ref={forwardedRef} />\n );\n }\n);\n\nToggleGroupItem.displayName = ITEM_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupItemImplElement = React.ElementRef<typeof Toggle>;\ntype ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;\ninterface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> {\n /**\n * A string value for the toggle group item. All items within a toggle group should use a unique value.\n */\n value: string;\n}\n\nconst ToggleGroupItemImpl = React.forwardRef<ToggleGroupItemImplElement, ToggleGroupItemImplProps>(\n (props: ScopedProps<ToggleGroupItemImplProps>, forwardedRef) => {\n const { __scopeToggleGroup, value, ...itemProps } = props;\n const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup);\n const singleProps = { role: 'radio', 'aria-checked': props.pressed, 'aria-pressed': undefined };\n const typeProps = valueContext.type === 'single' ? singleProps : undefined;\n return (\n <Toggle\n {...typeProps}\n {...itemProps}\n ref={forwardedRef}\n onPressedChange={(pressed) => {\n if (pressed) {\n valueContext.onItemActivate(value);\n } else {\n valueContext.onItemDeactivate(value);\n }\n }}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = ToggleGroup;\nconst Item = ToggleGroupItem;\n\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n Root,\n Item,\n};\nexport type { ToggleGroupSingleProps, ToggleGroupMultipleProps, ToggleGroupItemProps };\n"],"names":["createToggleGroupScope","ToggleGroup","ToggleGroupItem","Root","Item","React","createContextScope","Primitive","RovingFocusGroup","createRovingFocusGroupScope","Toggle","useControllableState","useDirection","TOGGLE_GROUP_NAME","createToggleGroupContext","useRovingFocusGroupScope","forwardRef","props","forwardedRef","type","toggleGroupProps","singleProps","multipleProps","Error","ToggleGroupValueProvider","useToggleGroupValueContext","ToggleGroupImplSingle","value","valueProp","defaultValue","onValueChange","toggleGroupSingleProps","setValue","prop","defaultProp","onChange","__scopeToggleGroup","useCallback","ToggleGroupImplMultiple","toggleGroupMultipleProps","handleButtonActivate","itemValue","prevValue","handleButtonDeactivate","filter","ToggleGroupContext","useToggleGroupContext","ToggleGroupImpl","disabled","rovingFocus","orientation","dir","loop","rovingFocusGroupScope","direction","commonProps","role","ITEM_NAME","valueContext","context","pressed","includes","ref","useRef","ToggleGroupItemImpl","itemProps","undefined","typeProps","onItemActivate","onItemDeactivate"],"version":3,"file":"index.js.map"}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/ToggleGroup.tsx"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { Toggle } from '@radix-ui/react-toggle';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * ToggleGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOGGLE_GROUP_NAME = 'ToggleGroup';\n\ntype ScopedProps<P> = P & { __scopeToggleGroup?: Scope };\nconst [createToggleGroupContext, createToggleGroupScope] = createContextScope(TOGGLE_GROUP_NAME, [\n createRovingFocusGroupScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\n\ntype ToggleGroupElement = ToggleGroupImplSingleElement | ToggleGroupImplMultipleElement;\ninterface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {\n type: 'single';\n}\ninterface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {\n type: 'multiple';\n}\n\nconst ToggleGroup = React.forwardRef<\n ToggleGroupElement,\n ToggleGroupSingleProps | ToggleGroupMultipleProps\n>((props, forwardedRef) => {\n const { type, ...toggleGroupProps } = props;\n\n if (type === 'single') {\n const singleProps = toggleGroupProps as ToggleGroupImplSingleProps;\n return <ToggleGroupImplSingle {...singleProps} ref={forwardedRef} />;\n }\n\n if (type === 'multiple') {\n const multipleProps = toggleGroupProps as ToggleGroupImplMultipleProps;\n return <ToggleGroupImplMultiple {...multipleProps} ref={forwardedRef} />;\n }\n\n throw new Error(`Missing prop \\`type\\` expected on \\`${TOGGLE_GROUP_NAME}\\``);\n});\n\nToggleGroup.displayName = TOGGLE_GROUP_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupValueContextValue = {\n type: 'single' | 'multiple';\n value: string[];\n onItemActivate(value: string): void;\n onItemDeactivate(value: string): void;\n};\n\nconst [ToggleGroupValueProvider, useToggleGroupValueContext] =\n createToggleGroupContext<ToggleGroupValueContextValue>(TOGGLE_GROUP_NAME);\n\ntype ToggleGroupImplSingleElement = ToggleGroupImplElement;\ninterface ToggleGroupImplSingleProps extends ToggleGroupImplProps {\n /**\n * The controlled stateful value of the item that is pressed.\n */\n value?: string;\n /**\n * The value of the item that is pressed when initially rendered. Use\n * `defaultValue` if you do not need to control the state of a toggle group.\n */\n defaultValue?: string;\n /**\n * The callback that fires when the value of the toggle group changes.\n */\n onValueChange?(value: string): void;\n}\n\nconst ToggleGroupImplSingle = React.forwardRef<\n ToggleGroupImplSingleElement,\n ToggleGroupImplSingleProps\n>((props: ScopedProps<ToggleGroupImplSingleProps>, forwardedRef) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...toggleGroupSingleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"single\"\n value={value ? [value] : []}\n onItemActivate={setValue}\n onItemDeactivate={React.useCallback(() => setValue(''), [setValue])}\n >\n <ToggleGroupImpl {...toggleGroupSingleProps} ref={forwardedRef} />\n </ToggleGroupValueProvider>\n );\n});\n\ntype ToggleGroupImplMultipleElement = ToggleGroupImplElement;\ninterface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {\n /**\n * The controlled stateful value of the items that are pressed.\n */\n value?: string[];\n /**\n * The value of the items that are pressed when initially rendered. Use\n * `defaultValue` if you do not need to control the state of a toggle group.\n */\n defaultValue?: string[];\n /**\n * The callback that fires when the state of the toggle group changes.\n */\n onValueChange?(value: string[]): void;\n}\n\nconst ToggleGroupImplMultiple = React.forwardRef<\n ToggleGroupImplMultipleElement,\n ToggleGroupImplMultipleProps\n>((props: ScopedProps<ToggleGroupImplMultipleProps>, forwardedRef) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...toggleGroupMultipleProps\n } = props;\n\n const [value = [], setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n const handleButtonActivate = React.useCallback(\n (itemValue: string) => setValue((prevValue = []) => [...prevValue, itemValue]),\n [setValue]\n );\n\n const handleButtonDeactivate = React.useCallback(\n (itemValue: string) =>\n setValue((prevValue = []) => prevValue.filter((value) => value !== itemValue)),\n [setValue]\n );\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"multiple\"\n value={value}\n onItemActivate={handleButtonActivate}\n onItemDeactivate={handleButtonDeactivate}\n >\n <ToggleGroupImpl {...toggleGroupMultipleProps} ref={forwardedRef} />\n </ToggleGroupValueProvider>\n );\n});\n\nToggleGroup.displayName = TOGGLE_GROUP_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupContextValue = { rovingFocus: boolean; disabled: boolean };\n\nconst [ToggleGroupContext, useToggleGroupContext] =\n createToggleGroupContext<ToggleGroupContextValue>(TOGGLE_GROUP_NAME);\n\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype ToggleGroupImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ToggleGroupImplProps extends PrimitiveDivProps {\n /**\n * Whether the group is disabled from user interaction.\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * Whether the group should maintain roving focus of its buttons.\n * @defaultValue true\n */\n rovingFocus?: boolean;\n loop?: RovingFocusGroupProps['loop'];\n orientation?: RovingFocusGroupProps['orientation'];\n dir?: RovingFocusGroupProps['dir'];\n}\n\nconst ToggleGroupImpl = React.forwardRef<ToggleGroupImplElement, ToggleGroupImplProps>(\n (props: ScopedProps<ToggleGroupImplProps>, forwardedRef) => {\n const {\n __scopeToggleGroup,\n disabled = false,\n rovingFocus = true,\n orientation,\n dir,\n loop = true,\n ...toggleGroupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup);\n const direction = useDirection(dir);\n const commonProps = { role: 'group', dir: direction, ...toggleGroupProps };\n return (\n <ToggleGroupContext scope={__scopeToggleGroup} rovingFocus={rovingFocus} disabled={disabled}>\n {rovingFocus ? (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div {...commonProps} ref={forwardedRef} />\n </RovingFocusGroup.Root>\n ) : (\n <Primitive.div {...commonProps} ref={forwardedRef} />\n )}\n </ToggleGroupContext>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToggleGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'ToggleGroupItem';\n\ntype ToggleGroupItemElement = ToggleGroupItemImplElement;\ninterface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {}\n\nconst ToggleGroupItem = React.forwardRef<ToggleGroupItemElement, ToggleGroupItemProps>(\n (props: ScopedProps<ToggleGroupItemProps>, forwardedRef) => {\n const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup);\n const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup);\n const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup);\n const pressed = valueContext.value.includes(props.value);\n const disabled = context.disabled || props.disabled;\n const commonProps = { ...props, pressed, disabled };\n const ref = React.useRef<HTMLDivElement>(null);\n return context.rovingFocus ? (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={pressed}\n ref={ref}\n >\n <ToggleGroupItemImpl {...commonProps} ref={forwardedRef} />\n </RovingFocusGroup.Item>\n ) : (\n <ToggleGroupItemImpl {...commonProps} ref={forwardedRef} />\n );\n }\n);\n\nToggleGroupItem.displayName = ITEM_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupItemImplElement = React.ElementRef<typeof Toggle>;\ntype ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;\ninterface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> {\n /**\n * A string value for the toggle group item. All items within a toggle group should use a unique value.\n */\n value: string;\n}\n\nconst ToggleGroupItemImpl = React.forwardRef<ToggleGroupItemImplElement, ToggleGroupItemImplProps>(\n (props: ScopedProps<ToggleGroupItemImplProps>, forwardedRef) => {\n const { __scopeToggleGroup, value, ...itemProps } = props;\n const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup);\n const singleProps = { role: 'radio', 'aria-checked': props.pressed, 'aria-pressed': undefined };\n const typeProps = valueContext.type === 'single' ? singleProps : undefined;\n return (\n <Toggle\n {...typeProps}\n {...itemProps}\n ref={forwardedRef}\n onPressedChange={(pressed) => {\n if (pressed) {\n valueContext.onItemActivate(value);\n } else {\n valueContext.onItemDeactivate(value);\n }\n }}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = ToggleGroup;\nconst Item = ToggleGroupItem;\n\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n Root,\n Item,\n};\nexport type { ToggleGroupSingleProps, ToggleGroupMultipleProps, ToggleGroupItemProps };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAkB;AAClB,6BAAmC;AACnC,+BAA0B;AAC1B,yBAAkC;AAClC,kCAA4C;AAC5C,4BAAuB;AACvB,4CAAqC;AACrC,+BAA6B;AAiClB;AAxBX,MAAM,oBAAoB;AAG1B,MAAM,CAAC,0BAA0B,sBAAsB,QAAI,yCAAmB,mBAAmB;AAAA,IAC/F;AAAA,EACF,CAAC;AACD,MAAM,+BAA2B,uDAA4B;AAU7D,MAAM,cAAc,aAAAA,QAAM,WAGxB,CAAC,OAAO,iBAAiB;AACzB,UAAM,EAAE,MAAM,GAAG,iBAAiB,IAAI;AAEtC,QAAI,SAAS,UAAU;AACrB,YAAM,cAAc;AACpB,aAAO,4CAAC,yBAAuB,GAAG,aAAa,KAAK,cAA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EACF;AAIA,MAAME,QAAO;AACb,MAAMC,QAAO;",
|
|
6
|
+
"names": ["React", "value", "Root", "Item"]
|
|
7
|
+
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,182 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {createContextScope
|
|
4
|
-
import {Primitive
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/* -------------------------------------------------------------------------------------------------
|
|
20
|
-
* ToggleGroup
|
|
21
|
-
* -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME = 'ToggleGroup';
|
|
22
|
-
const [$6c1fd9e6a8969628$var$createToggleGroupContext, $6c1fd9e6a8969628$export$d1c7c4bcd9f26dd4] = $jFibJ$createContextScope($6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME, [
|
|
23
|
-
$jFibJ$createRovingFocusGroupScope
|
|
1
|
+
// packages/react/toggle-group/src/ToggleGroup.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
4
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
5
|
+
import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
|
|
6
|
+
import { createRovingFocusGroupScope } from "@radix-ui/react-roving-focus";
|
|
7
|
+
import { Toggle } from "@radix-ui/react-toggle";
|
|
8
|
+
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
9
|
+
import { useDirection } from "@radix-ui/react-direction";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
var TOGGLE_GROUP_NAME = "ToggleGroup";
|
|
12
|
+
var [createToggleGroupContext, createToggleGroupScope] = createContextScope(TOGGLE_GROUP_NAME, [
|
|
13
|
+
createRovingFocusGroupScope
|
|
24
14
|
]);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ref: forwardedRef
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
throw new Error(`Missing prop \`type\` expected on \`${$6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME}\``);
|
|
41
|
-
});
|
|
42
|
-
/*#__PURE__*/ Object.assign($6c1fd9e6a8969628$export$af3ec21f6cfb5e30, {
|
|
43
|
-
displayName: $6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME
|
|
15
|
+
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
16
|
+
var ToggleGroup = React.forwardRef((props, forwardedRef) => {
|
|
17
|
+
const { type, ...toggleGroupProps } = props;
|
|
18
|
+
if (type === "single") {
|
|
19
|
+
const singleProps = toggleGroupProps;
|
|
20
|
+
return /* @__PURE__ */ jsx(ToggleGroupImplSingle, { ...singleProps, ref: forwardedRef });
|
|
21
|
+
}
|
|
22
|
+
if (type === "multiple") {
|
|
23
|
+
const multipleProps = toggleGroupProps;
|
|
24
|
+
return /* @__PURE__ */ jsx(ToggleGroupImplMultiple, { ...multipleProps, ref: forwardedRef });
|
|
25
|
+
}
|
|
26
|
+
throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``);
|
|
44
27
|
});
|
|
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
|
-
prop: valueProp,
|
|
72
|
-
defaultProp: defaultValue,
|
|
73
|
-
onChange: onValueChange
|
|
74
|
-
});
|
|
75
|
-
const handleButtonActivate = $jFibJ$react.useCallback((itemValue)=>setValue((prevValue = [])=>[
|
|
76
|
-
...prevValue,
|
|
77
|
-
itemValue
|
|
78
|
-
]
|
|
79
|
-
)
|
|
80
|
-
, [
|
|
81
|
-
setValue
|
|
82
|
-
]);
|
|
83
|
-
const handleButtonDeactivate = $jFibJ$react.useCallback((itemValue)=>setValue((prevValue = [])=>prevValue.filter((value)=>value !== itemValue
|
|
84
|
-
)
|
|
85
|
-
)
|
|
86
|
-
, [
|
|
87
|
-
setValue
|
|
88
|
-
]);
|
|
89
|
-
return /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupValueProvider, {
|
|
90
|
-
scope: props.__scopeToggleGroup,
|
|
91
|
-
type: "multiple",
|
|
92
|
-
value: value1,
|
|
93
|
-
onItemActivate: handleButtonActivate,
|
|
94
|
-
onItemDeactivate: handleButtonDeactivate
|
|
95
|
-
}, /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupImpl, $jFibJ$babelruntimehelpersesmextends({}, toggleGroupMultipleProps, {
|
|
96
|
-
ref: forwardedRef
|
|
97
|
-
})));
|
|
28
|
+
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
29
|
+
var [ToggleGroupValueProvider, useToggleGroupValueContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
|
|
30
|
+
var ToggleGroupImplSingle = React.forwardRef((props, forwardedRef) => {
|
|
31
|
+
const {
|
|
32
|
+
value: valueProp,
|
|
33
|
+
defaultValue,
|
|
34
|
+
onValueChange = () => {
|
|
35
|
+
},
|
|
36
|
+
...toggleGroupSingleProps
|
|
37
|
+
} = props;
|
|
38
|
+
const [value, setValue] = useControllableState({
|
|
39
|
+
prop: valueProp,
|
|
40
|
+
defaultProp: defaultValue,
|
|
41
|
+
onChange: onValueChange
|
|
42
|
+
});
|
|
43
|
+
return /* @__PURE__ */ jsx(
|
|
44
|
+
ToggleGroupValueProvider,
|
|
45
|
+
{
|
|
46
|
+
scope: props.__scopeToggleGroup,
|
|
47
|
+
type: "single",
|
|
48
|
+
value: value ? [value] : [],
|
|
49
|
+
onItemActivate: setValue,
|
|
50
|
+
onItemDeactivate: React.useCallback(() => setValue(""), [setValue]),
|
|
51
|
+
children: /* @__PURE__ */ jsx(ToggleGroupImpl, { ...toggleGroupSingleProps, ref: forwardedRef })
|
|
52
|
+
}
|
|
53
|
+
);
|
|
98
54
|
});
|
|
99
|
-
|
|
100
|
-
|
|
55
|
+
var ToggleGroupImplMultiple = React.forwardRef((props, forwardedRef) => {
|
|
56
|
+
const {
|
|
57
|
+
value: valueProp,
|
|
58
|
+
defaultValue,
|
|
59
|
+
onValueChange = () => {
|
|
60
|
+
},
|
|
61
|
+
...toggleGroupMultipleProps
|
|
62
|
+
} = props;
|
|
63
|
+
const [value = [], setValue] = useControllableState({
|
|
64
|
+
prop: valueProp,
|
|
65
|
+
defaultProp: defaultValue,
|
|
66
|
+
onChange: onValueChange
|
|
67
|
+
});
|
|
68
|
+
const handleButtonActivate = React.useCallback(
|
|
69
|
+
(itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
|
|
70
|
+
[setValue]
|
|
71
|
+
);
|
|
72
|
+
const handleButtonDeactivate = React.useCallback(
|
|
73
|
+
(itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
|
|
74
|
+
[setValue]
|
|
75
|
+
);
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
ToggleGroupValueProvider,
|
|
78
|
+
{
|
|
79
|
+
scope: props.__scopeToggleGroup,
|
|
80
|
+
type: "multiple",
|
|
81
|
+
value,
|
|
82
|
+
onItemActivate: handleButtonActivate,
|
|
83
|
+
onItemDeactivate: handleButtonDeactivate,
|
|
84
|
+
children: /* @__PURE__ */ jsx(ToggleGroupImpl, { ...toggleGroupMultipleProps, ref: forwardedRef })
|
|
85
|
+
}
|
|
86
|
+
);
|
|
101
87
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
88
|
+
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
89
|
+
var [ToggleGroupContext, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
|
|
90
|
+
var ToggleGroupImpl = React.forwardRef(
|
|
91
|
+
(props, forwardedRef) => {
|
|
92
|
+
const {
|
|
93
|
+
__scopeToggleGroup,
|
|
94
|
+
disabled = false,
|
|
95
|
+
rovingFocus = true,
|
|
96
|
+
orientation,
|
|
97
|
+
dir,
|
|
98
|
+
loop = true,
|
|
99
|
+
...toggleGroupProps
|
|
100
|
+
} = props;
|
|
101
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup);
|
|
102
|
+
const direction = useDirection(dir);
|
|
103
|
+
const commonProps = { role: "group", dir: direction, ...toggleGroupProps };
|
|
104
|
+
return /* @__PURE__ */ jsx(ToggleGroupContext, { scope: __scopeToggleGroup, rovingFocus, disabled, children: rovingFocus ? /* @__PURE__ */ jsx(
|
|
105
|
+
RovingFocusGroup.Root,
|
|
106
|
+
{
|
|
107
|
+
asChild: true,
|
|
108
|
+
...rovingFocusGroupScope,
|
|
109
|
+
orientation,
|
|
109
110
|
dir: direction,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}), /*#__PURE__*/ $jFibJ$react.createElement($jFibJ$Primitive.div, $jFibJ$babelruntimehelpersesmextends({}, commonProps, {
|
|
123
|
-
ref: forwardedRef
|
|
124
|
-
}))) : /*#__PURE__*/ $jFibJ$react.createElement($jFibJ$Primitive.div, $jFibJ$babelruntimehelpersesmextends({}, commonProps, {
|
|
125
|
-
ref: forwardedRef
|
|
126
|
-
})));
|
|
127
|
-
});
|
|
128
|
-
/* -------------------------------------------------------------------------------------------------
|
|
129
|
-
* ToggleGroupItem
|
|
130
|
-
* -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$var$ITEM_NAME = 'ToggleGroupItem';
|
|
131
|
-
const $6c1fd9e6a8969628$export$b453109e13abe10b = /*#__PURE__*/ $jFibJ$react.forwardRef((props, forwardedRef)=>{
|
|
132
|
-
const valueContext = $6c1fd9e6a8969628$var$useToggleGroupValueContext($6c1fd9e6a8969628$var$ITEM_NAME, props.__scopeToggleGroup);
|
|
133
|
-
const context = $6c1fd9e6a8969628$var$useToggleGroupContext($6c1fd9e6a8969628$var$ITEM_NAME, props.__scopeToggleGroup);
|
|
134
|
-
const rovingFocusGroupScope = $6c1fd9e6a8969628$var$useRovingFocusGroupScope(props.__scopeToggleGroup);
|
|
111
|
+
loop,
|
|
112
|
+
children: /* @__PURE__ */ jsx(Primitive.div, { ...commonProps, ref: forwardedRef })
|
|
113
|
+
}
|
|
114
|
+
) : /* @__PURE__ */ jsx(Primitive.div, { ...commonProps, ref: forwardedRef }) });
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
var ITEM_NAME = "ToggleGroupItem";
|
|
118
|
+
var ToggleGroupItem = React.forwardRef(
|
|
119
|
+
(props, forwardedRef) => {
|
|
120
|
+
const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup);
|
|
121
|
+
const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup);
|
|
122
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup);
|
|
135
123
|
const pressed = valueContext.value.includes(props.value);
|
|
136
124
|
const disabled = context.disabled || props.disabled;
|
|
137
|
-
const commonProps = {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
asChild: true
|
|
145
|
-
}, rovingFocusGroupScope, {
|
|
125
|
+
const commonProps = { ...props, pressed, disabled };
|
|
126
|
+
const ref = React.useRef(null);
|
|
127
|
+
return context.rovingFocus ? /* @__PURE__ */ jsx(
|
|
128
|
+
RovingFocusGroup.Item,
|
|
129
|
+
{
|
|
130
|
+
asChild: true,
|
|
131
|
+
...rovingFocusGroupScope,
|
|
146
132
|
focusable: !disabled,
|
|
147
133
|
active: pressed,
|
|
148
|
-
ref
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const typeProps = valueContext.type === 'single' ? singleProps : undefined;
|
|
167
|
-
return /*#__PURE__*/ $jFibJ$react.createElement($jFibJ$Toggle, $jFibJ$babelruntimehelpersesmextends({}, typeProps, itemProps, {
|
|
134
|
+
ref,
|
|
135
|
+
children: /* @__PURE__ */ jsx(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef })
|
|
136
|
+
}
|
|
137
|
+
) : /* @__PURE__ */ jsx(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef });
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
ToggleGroupItem.displayName = ITEM_NAME;
|
|
141
|
+
var ToggleGroupItemImpl = React.forwardRef(
|
|
142
|
+
(props, forwardedRef) => {
|
|
143
|
+
const { __scopeToggleGroup, value, ...itemProps } = props;
|
|
144
|
+
const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup);
|
|
145
|
+
const singleProps = { role: "radio", "aria-checked": props.pressed, "aria-pressed": void 0 };
|
|
146
|
+
const typeProps = valueContext.type === "single" ? singleProps : void 0;
|
|
147
|
+
return /* @__PURE__ */ jsx(
|
|
148
|
+
Toggle,
|
|
149
|
+
{
|
|
150
|
+
...typeProps,
|
|
151
|
+
...itemProps,
|
|
168
152
|
ref: forwardedRef,
|
|
169
|
-
onPressedChange: (pressed)=>{
|
|
170
|
-
|
|
171
|
-
|
|
153
|
+
onPressedChange: (pressed) => {
|
|
154
|
+
if (pressed) {
|
|
155
|
+
valueContext.onItemActivate(value);
|
|
156
|
+
} else {
|
|
157
|
+
valueContext.onItemDeactivate(value);
|
|
158
|
+
}
|
|
172
159
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
var Root2 = ToggleGroup;
|
|
165
|
+
var Item2 = ToggleGroupItem;
|
|
166
|
+
export {
|
|
167
|
+
Item2 as Item,
|
|
168
|
+
Root2 as Root,
|
|
169
|
+
ToggleGroup,
|
|
170
|
+
ToggleGroupItem,
|
|
171
|
+
createToggleGroupScope
|
|
172
|
+
};
|
|
182
173
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;A;;;;;;;;;ACYA;;oGAEA,CAEA,MAAMa,uCAAiB,GAAG,aAA1B,AAAA;AAGA,MAAM,CAACC,8CAAD,EAA2Bd,yCAA3B,CAAA,GAAqDM,yBAAkB,CAACO,uCAAD,EAAoB;IAC/FJ,kCAD+F;CAApB,CAA7E,AAAA;AAGA,MAAMM,8CAAwB,GAAGN,kCAA2B,EAA5D,AAAA;AAUA,MAAMR,yCAAW,GAAA,aAAGI,CAAAA,YAAK,CAACW,UAAN,CAGlB,CAACC,KAAD,EAAQC,YAAR,GAAyB;IACzB,MAAM,E,MAAEC,IAAF,CAAA,EAAQ,GAAGC,gBAAH,EAAR,GAAgCH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A8ChD,KAApD,AAAM;IACN,MAAMyC,YAAY,GAAGjC,gDAA0B,CAACgC,+BAAD,EAAYrB,kBAAZ,CAA/C,AAAA;IACA,MAAMf,WAAW,GAAG;QAAEmC,IAAI,EAAE,OAAR;QAAiB,cAAA,EAAgBvC,KAAK,CAAC2C,OAAvC;QAAgD,cAAA,EAAgBM,SAAhB;KAApE,AAAoB;IACpB,MAAMC,SAAS,GAAGT,YAAY,CAACvC,IAAb,KAAsB,QAAtB,GAAiCE,WAAjC,GAA+C6C,SAAjE,AAAA;IACA,OAAA,aACE,CAAA,YAAA,CAAA,aAAA,CAAC,aAAD,EAAA,oCAAA,CAAA,EAAA,EACMC,SADN,EAEMF,SAFN,EADF;QAII,GAAG,EAAE/C,YAHP;QAIE,eAAe,EAAG0C,CAAAA,OAAD,GAAa;YAC5B,IAAIA,OAAJ,EACEF,YAAY,CAACU,cAAb,CAA4BzC,KAA5B,CAAA+B,CAAAA;iBAEAA,YAAY,CAACW,gBAAb,CAA8B1C,KAA9B,CAAA+B,CAAAA;SAEH;KAVH,CAAA,CADF,CACE;CAPsB,CAA5B,AAoBG;AAGH,oGAAA,CAEA,MAAMvD,yCAAI,GAAGF,yCAAb,AAAA;AACA,MAAMG,yCAAI,GAAGF,yCAAb,AAAA;;ADjTA","sources":["packages/react/toggle-group/src/index.ts","packages/react/toggle-group/src/ToggleGroup.tsx"],"sourcesContent":["export {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n Root,\n Item,\n} from './ToggleGroup';\nexport type {\n ToggleGroupSingleProps,\n ToggleGroupMultipleProps,\n ToggleGroupItemProps,\n} from './ToggleGroup';\n","import React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { Toggle } from '@radix-ui/react-toggle';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * ToggleGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOGGLE_GROUP_NAME = 'ToggleGroup';\n\ntype ScopedProps<P> = P & { __scopeToggleGroup?: Scope };\nconst [createToggleGroupContext, createToggleGroupScope] = createContextScope(TOGGLE_GROUP_NAME, [\n createRovingFocusGroupScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\n\ntype ToggleGroupElement = ToggleGroupImplSingleElement | ToggleGroupImplMultipleElement;\ninterface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {\n type: 'single';\n}\ninterface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {\n type: 'multiple';\n}\n\nconst ToggleGroup = React.forwardRef<\n ToggleGroupElement,\n ToggleGroupSingleProps | ToggleGroupMultipleProps\n>((props, forwardedRef) => {\n const { type, ...toggleGroupProps } = props;\n\n if (type === 'single') {\n const singleProps = toggleGroupProps as ToggleGroupImplSingleProps;\n return <ToggleGroupImplSingle {...singleProps} ref={forwardedRef} />;\n }\n\n if (type === 'multiple') {\n const multipleProps = toggleGroupProps as ToggleGroupImplMultipleProps;\n return <ToggleGroupImplMultiple {...multipleProps} ref={forwardedRef} />;\n }\n\n throw new Error(`Missing prop \\`type\\` expected on \\`${TOGGLE_GROUP_NAME}\\``);\n});\n\nToggleGroup.displayName = TOGGLE_GROUP_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupValueContextValue = {\n type: 'single' | 'multiple';\n value: string[];\n onItemActivate(value: string): void;\n onItemDeactivate(value: string): void;\n};\n\nconst [ToggleGroupValueProvider, useToggleGroupValueContext] =\n createToggleGroupContext<ToggleGroupValueContextValue>(TOGGLE_GROUP_NAME);\n\ntype ToggleGroupImplSingleElement = ToggleGroupImplElement;\ninterface ToggleGroupImplSingleProps extends ToggleGroupImplProps {\n /**\n * The controlled stateful value of the item that is pressed.\n */\n value?: string;\n /**\n * The value of the item that is pressed when initially rendered. Use\n * `defaultValue` if you do not need to control the state of a toggle group.\n */\n defaultValue?: string;\n /**\n * The callback that fires when the value of the toggle group changes.\n */\n onValueChange?(value: string): void;\n}\n\nconst ToggleGroupImplSingle = React.forwardRef<\n ToggleGroupImplSingleElement,\n ToggleGroupImplSingleProps\n>((props: ScopedProps<ToggleGroupImplSingleProps>, forwardedRef) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...toggleGroupSingleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"single\"\n value={value ? [value] : []}\n onItemActivate={setValue}\n onItemDeactivate={React.useCallback(() => setValue(''), [setValue])}\n >\n <ToggleGroupImpl {...toggleGroupSingleProps} ref={forwardedRef} />\n </ToggleGroupValueProvider>\n );\n});\n\ntype ToggleGroupImplMultipleElement = ToggleGroupImplElement;\ninterface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {\n /**\n * The controlled stateful value of the items that are pressed.\n */\n value?: string[];\n /**\n * The value of the items that are pressed when initially rendered. Use\n * `defaultValue` if you do not need to control the state of a toggle group.\n */\n defaultValue?: string[];\n /**\n * The callback that fires when the state of the toggle group changes.\n */\n onValueChange?(value: string[]): void;\n}\n\nconst ToggleGroupImplMultiple = React.forwardRef<\n ToggleGroupImplMultipleElement,\n ToggleGroupImplMultipleProps\n>((props: ScopedProps<ToggleGroupImplMultipleProps>, forwardedRef) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...toggleGroupMultipleProps\n } = props;\n\n const [value = [], setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n const handleButtonActivate = React.useCallback(\n (itemValue: string) => setValue((prevValue = []) => [...prevValue, itemValue]),\n [setValue]\n );\n\n const handleButtonDeactivate = React.useCallback(\n (itemValue: string) =>\n setValue((prevValue = []) => prevValue.filter((value) => value !== itemValue)),\n [setValue]\n );\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"multiple\"\n value={value}\n onItemActivate={handleButtonActivate}\n onItemDeactivate={handleButtonDeactivate}\n >\n <ToggleGroupImpl {...toggleGroupMultipleProps} ref={forwardedRef} />\n </ToggleGroupValueProvider>\n );\n});\n\nToggleGroup.displayName = TOGGLE_GROUP_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupContextValue = { rovingFocus: boolean; disabled: boolean };\n\nconst [ToggleGroupContext, useToggleGroupContext] =\n createToggleGroupContext<ToggleGroupContextValue>(TOGGLE_GROUP_NAME);\n\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype ToggleGroupImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ToggleGroupImplProps extends PrimitiveDivProps {\n /**\n * Whether the group is disabled from user interaction.\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * Whether the group should maintain roving focus of its buttons.\n * @defaultValue true\n */\n rovingFocus?: boolean;\n loop?: RovingFocusGroupProps['loop'];\n orientation?: RovingFocusGroupProps['orientation'];\n dir?: RovingFocusGroupProps['dir'];\n}\n\nconst ToggleGroupImpl = React.forwardRef<ToggleGroupImplElement, ToggleGroupImplProps>(\n (props: ScopedProps<ToggleGroupImplProps>, forwardedRef) => {\n const {\n __scopeToggleGroup,\n disabled = false,\n rovingFocus = true,\n orientation,\n dir,\n loop = true,\n ...toggleGroupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup);\n const direction = useDirection(dir);\n const commonProps = { role: 'group', dir: direction, ...toggleGroupProps };\n return (\n <ToggleGroupContext scope={__scopeToggleGroup} rovingFocus={rovingFocus} disabled={disabled}>\n {rovingFocus ? (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div {...commonProps} ref={forwardedRef} />\n </RovingFocusGroup.Root>\n ) : (\n <Primitive.div {...commonProps} ref={forwardedRef} />\n )}\n </ToggleGroupContext>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToggleGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'ToggleGroupItem';\n\ntype ToggleGroupItemElement = ToggleGroupItemImplElement;\ninterface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {}\n\nconst ToggleGroupItem = React.forwardRef<ToggleGroupItemElement, ToggleGroupItemProps>(\n (props: ScopedProps<ToggleGroupItemProps>, forwardedRef) => {\n const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup);\n const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup);\n const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup);\n const pressed = valueContext.value.includes(props.value);\n const disabled = context.disabled || props.disabled;\n const commonProps = { ...props, pressed, disabled };\n const ref = React.useRef<HTMLDivElement>(null);\n return context.rovingFocus ? (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={pressed}\n ref={ref}\n >\n <ToggleGroupItemImpl {...commonProps} ref={forwardedRef} />\n </RovingFocusGroup.Item>\n ) : (\n <ToggleGroupItemImpl {...commonProps} ref={forwardedRef} />\n );\n }\n);\n\nToggleGroupItem.displayName = ITEM_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupItemImplElement = React.ElementRef<typeof Toggle>;\ntype ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;\ninterface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> {\n /**\n * A string value for the toggle group item. All items within a toggle group should use a unique value.\n */\n value: string;\n}\n\nconst ToggleGroupItemImpl = React.forwardRef<ToggleGroupItemImplElement, ToggleGroupItemImplProps>(\n (props: ScopedProps<ToggleGroupItemImplProps>, forwardedRef) => {\n const { __scopeToggleGroup, value, ...itemProps } = props;\n const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup);\n const singleProps = { role: 'radio', 'aria-checked': props.pressed, 'aria-pressed': undefined };\n const typeProps = valueContext.type === 'single' ? singleProps : undefined;\n return (\n <Toggle\n {...typeProps}\n {...itemProps}\n ref={forwardedRef}\n onPressedChange={(pressed) => {\n if (pressed) {\n valueContext.onItemActivate(value);\n } else {\n valueContext.onItemDeactivate(value);\n }\n }}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = ToggleGroup;\nconst Item = ToggleGroupItem;\n\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n Root,\n Item,\n};\nexport type { ToggleGroupSingleProps, ToggleGroupMultipleProps, ToggleGroupItemProps };\n"],"names":["createToggleGroupScope","ToggleGroup","ToggleGroupItem","Root","Item","React","createContextScope","Primitive","RovingFocusGroup","createRovingFocusGroupScope","Toggle","useControllableState","useDirection","TOGGLE_GROUP_NAME","createToggleGroupContext","useRovingFocusGroupScope","forwardRef","props","forwardedRef","type","toggleGroupProps","singleProps","multipleProps","Error","ToggleGroupValueProvider","useToggleGroupValueContext","ToggleGroupImplSingle","value","valueProp","defaultValue","onValueChange","toggleGroupSingleProps","setValue","prop","defaultProp","onChange","__scopeToggleGroup","useCallback","ToggleGroupImplMultiple","toggleGroupMultipleProps","handleButtonActivate","itemValue","prevValue","handleButtonDeactivate","filter","ToggleGroupContext","useToggleGroupContext","ToggleGroupImpl","disabled","rovingFocus","orientation","dir","loop","rovingFocusGroupScope","direction","commonProps","role","ITEM_NAME","valueContext","context","pressed","includes","ref","useRef","ToggleGroupItemImpl","itemProps","undefined","typeProps","onItemActivate","onItemDeactivate"],"version":3,"file":"index.mjs.map"}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/ToggleGroup.tsx"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { Toggle } from '@radix-ui/react-toggle';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * ToggleGroup\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOGGLE_GROUP_NAME = 'ToggleGroup';\n\ntype ScopedProps<P> = P & { __scopeToggleGroup?: Scope };\nconst [createToggleGroupContext, createToggleGroupScope] = createContextScope(TOGGLE_GROUP_NAME, [\n createRovingFocusGroupScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\n\ntype ToggleGroupElement = ToggleGroupImplSingleElement | ToggleGroupImplMultipleElement;\ninterface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {\n type: 'single';\n}\ninterface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {\n type: 'multiple';\n}\n\nconst ToggleGroup = React.forwardRef<\n ToggleGroupElement,\n ToggleGroupSingleProps | ToggleGroupMultipleProps\n>((props, forwardedRef) => {\n const { type, ...toggleGroupProps } = props;\n\n if (type === 'single') {\n const singleProps = toggleGroupProps as ToggleGroupImplSingleProps;\n return <ToggleGroupImplSingle {...singleProps} ref={forwardedRef} />;\n }\n\n if (type === 'multiple') {\n const multipleProps = toggleGroupProps as ToggleGroupImplMultipleProps;\n return <ToggleGroupImplMultiple {...multipleProps} ref={forwardedRef} />;\n }\n\n throw new Error(`Missing prop \\`type\\` expected on \\`${TOGGLE_GROUP_NAME}\\``);\n});\n\nToggleGroup.displayName = TOGGLE_GROUP_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupValueContextValue = {\n type: 'single' | 'multiple';\n value: string[];\n onItemActivate(value: string): void;\n onItemDeactivate(value: string): void;\n};\n\nconst [ToggleGroupValueProvider, useToggleGroupValueContext] =\n createToggleGroupContext<ToggleGroupValueContextValue>(TOGGLE_GROUP_NAME);\n\ntype ToggleGroupImplSingleElement = ToggleGroupImplElement;\ninterface ToggleGroupImplSingleProps extends ToggleGroupImplProps {\n /**\n * The controlled stateful value of the item that is pressed.\n */\n value?: string;\n /**\n * The value of the item that is pressed when initially rendered. Use\n * `defaultValue` if you do not need to control the state of a toggle group.\n */\n defaultValue?: string;\n /**\n * The callback that fires when the value of the toggle group changes.\n */\n onValueChange?(value: string): void;\n}\n\nconst ToggleGroupImplSingle = React.forwardRef<\n ToggleGroupImplSingleElement,\n ToggleGroupImplSingleProps\n>((props: ScopedProps<ToggleGroupImplSingleProps>, forwardedRef) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...toggleGroupSingleProps\n } = props;\n\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"single\"\n value={value ? [value] : []}\n onItemActivate={setValue}\n onItemDeactivate={React.useCallback(() => setValue(''), [setValue])}\n >\n <ToggleGroupImpl {...toggleGroupSingleProps} ref={forwardedRef} />\n </ToggleGroupValueProvider>\n );\n});\n\ntype ToggleGroupImplMultipleElement = ToggleGroupImplElement;\ninterface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {\n /**\n * The controlled stateful value of the items that are pressed.\n */\n value?: string[];\n /**\n * The value of the items that are pressed when initially rendered. Use\n * `defaultValue` if you do not need to control the state of a toggle group.\n */\n defaultValue?: string[];\n /**\n * The callback that fires when the state of the toggle group changes.\n */\n onValueChange?(value: string[]): void;\n}\n\nconst ToggleGroupImplMultiple = React.forwardRef<\n ToggleGroupImplMultipleElement,\n ToggleGroupImplMultipleProps\n>((props: ScopedProps<ToggleGroupImplMultipleProps>, forwardedRef) => {\n const {\n value: valueProp,\n defaultValue,\n onValueChange = () => {},\n ...toggleGroupMultipleProps\n } = props;\n\n const [value = [], setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n const handleButtonActivate = React.useCallback(\n (itemValue: string) => setValue((prevValue = []) => [...prevValue, itemValue]),\n [setValue]\n );\n\n const handleButtonDeactivate = React.useCallback(\n (itemValue: string) =>\n setValue((prevValue = []) => prevValue.filter((value) => value !== itemValue)),\n [setValue]\n );\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"multiple\"\n value={value}\n onItemActivate={handleButtonActivate}\n onItemDeactivate={handleButtonDeactivate}\n >\n <ToggleGroupImpl {...toggleGroupMultipleProps} ref={forwardedRef} />\n </ToggleGroupValueProvider>\n );\n});\n\nToggleGroup.displayName = TOGGLE_GROUP_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupContextValue = { rovingFocus: boolean; disabled: boolean };\n\nconst [ToggleGroupContext, useToggleGroupContext] =\n createToggleGroupContext<ToggleGroupContextValue>(TOGGLE_GROUP_NAME);\n\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype ToggleGroupImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ToggleGroupImplProps extends PrimitiveDivProps {\n /**\n * Whether the group is disabled from user interaction.\n * @defaultValue false\n */\n disabled?: boolean;\n /**\n * Whether the group should maintain roving focus of its buttons.\n * @defaultValue true\n */\n rovingFocus?: boolean;\n loop?: RovingFocusGroupProps['loop'];\n orientation?: RovingFocusGroupProps['orientation'];\n dir?: RovingFocusGroupProps['dir'];\n}\n\nconst ToggleGroupImpl = React.forwardRef<ToggleGroupImplElement, ToggleGroupImplProps>(\n (props: ScopedProps<ToggleGroupImplProps>, forwardedRef) => {\n const {\n __scopeToggleGroup,\n disabled = false,\n rovingFocus = true,\n orientation,\n dir,\n loop = true,\n ...toggleGroupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup);\n const direction = useDirection(dir);\n const commonProps = { role: 'group', dir: direction, ...toggleGroupProps };\n return (\n <ToggleGroupContext scope={__scopeToggleGroup} rovingFocus={rovingFocus} disabled={disabled}>\n {rovingFocus ? (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div {...commonProps} ref={forwardedRef} />\n </RovingFocusGroup.Root>\n ) : (\n <Primitive.div {...commonProps} ref={forwardedRef} />\n )}\n </ToggleGroupContext>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ToggleGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'ToggleGroupItem';\n\ntype ToggleGroupItemElement = ToggleGroupItemImplElement;\ninterface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {}\n\nconst ToggleGroupItem = React.forwardRef<ToggleGroupItemElement, ToggleGroupItemProps>(\n (props: ScopedProps<ToggleGroupItemProps>, forwardedRef) => {\n const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup);\n const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup);\n const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup);\n const pressed = valueContext.value.includes(props.value);\n const disabled = context.disabled || props.disabled;\n const commonProps = { ...props, pressed, disabled };\n const ref = React.useRef<HTMLDivElement>(null);\n return context.rovingFocus ? (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={pressed}\n ref={ref}\n >\n <ToggleGroupItemImpl {...commonProps} ref={forwardedRef} />\n </RovingFocusGroup.Item>\n ) : (\n <ToggleGroupItemImpl {...commonProps} ref={forwardedRef} />\n );\n }\n);\n\nToggleGroupItem.displayName = ITEM_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupItemImplElement = React.ElementRef<typeof Toggle>;\ntype ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;\ninterface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> {\n /**\n * A string value for the toggle group item. All items within a toggle group should use a unique value.\n */\n value: string;\n}\n\nconst ToggleGroupItemImpl = React.forwardRef<ToggleGroupItemImplElement, ToggleGroupItemImplProps>(\n (props: ScopedProps<ToggleGroupItemImplProps>, forwardedRef) => {\n const { __scopeToggleGroup, value, ...itemProps } = props;\n const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup);\n const singleProps = { role: 'radio', 'aria-checked': props.pressed, 'aria-pressed': undefined };\n const typeProps = valueContext.type === 'single' ? singleProps : undefined;\n return (\n <Toggle\n {...typeProps}\n {...itemProps}\n ref={forwardedRef}\n onPressedChange={(pressed) => {\n if (pressed) {\n valueContext.onItemActivate(value);\n } else {\n valueContext.onItemDeactivate(value);\n }\n }}\n />\n );\n }\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = ToggleGroup;\nconst Item = ToggleGroupItem;\n\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n Root,\n Item,\n};\nexport type { ToggleGroupSingleProps, ToggleGroupMultipleProps, ToggleGroupItemProps };\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,WAAW;AAClB,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAC1B,YAAY,sBAAsB;AAClC,SAAS,mCAAmC;AAC5C,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAiClB;AAxBX,IAAM,oBAAoB;AAG1B,IAAM,CAAC,0BAA0B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,QACL,iBAAiB,CAAC,YAAY;AAC5B,cAAI,SAAS;AACX,yBAAa,eAAe,KAAK;AAAA,UACnC,OAAO;AACL,yBAAa,iBAAiB,KAAK;AAAA,UACrC;AAAA,QACF;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAIA,IAAMC,QAAO;AACb,IAAMC,QAAO;",
|
|
6
|
+
"names": ["value", "Root", "Item"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-toggle-group",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-rc.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -28,14 +28,13 @@
|
|
|
28
28
|
"version": "yarn version"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@radix-ui/
|
|
33
|
-
"@radix-ui/react-
|
|
34
|
-
"@radix-ui/react-
|
|
35
|
-
"@radix-ui/react-
|
|
36
|
-
"@radix-ui/react-
|
|
37
|
-
"@radix-ui/react-
|
|
38
|
-
"@radix-ui/react-use-controllable-state": "1.0.1"
|
|
31
|
+
"@radix-ui/primitive": "1.1.0-rc.1",
|
|
32
|
+
"@radix-ui/react-context": "1.1.0-rc.1",
|
|
33
|
+
"@radix-ui/react-direction": "1.1.0-rc.1",
|
|
34
|
+
"@radix-ui/react-primitive": "1.1.0-rc.1",
|
|
35
|
+
"@radix-ui/react-roving-focus": "1.1.0-rc.1",
|
|
36
|
+
"@radix-ui/react-toggle": "1.1.0-rc.1",
|
|
37
|
+
"@radix-ui/react-use-controllable-state": "1.1.0-rc.1"
|
|
39
38
|
},
|
|
40
39
|
"peerDependencies": {
|
|
41
40
|
"@types/react": "*",
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;AAmBA,OAAA,6FAEE,CAAC;A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AAE,gBAAgB,GAAG,iBAAiB,CAAC;IAChG;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AA2BD,OAAA,MAAM,gIAAkB,CAAC;AACzB,OAAA,MAAM,oGAAsB,CAAC","sources":["packages/react/toggle-group/src/packages/react/toggle-group/src/ToggleGroup.tsx","packages/react/toggle-group/src/packages/react/toggle-group/src/index.ts","packages/react/toggle-group/src/index.ts"],"sourcesContent":[null,null,"export {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n Root,\n Item,\n} from './ToggleGroup';\nexport type {\n ToggleGroupSingleProps,\n ToggleGroupMultipleProps,\n ToggleGroupItemProps,\n} from './ToggleGroup';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|