@radix-ui/react-toggle-group 1.1.15 → 1.1.16-rc.1784074599772
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.js +23 -22
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +24 -22
- package/dist/index.mjs.map +3 -3
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
10
|
var __export = (target, all) => {
|
|
10
11
|
for (var name in all)
|
|
11
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -54,7 +55,7 @@ var [createToggleGroupContext, createToggleGroupScope] = (0, import_react_contex
|
|
|
54
55
|
import_react_roving_focus.createRovingFocusGroupScope
|
|
55
56
|
]);
|
|
56
57
|
var useRovingFocusGroupScope = (0, import_react_roving_focus.createRovingFocusGroupScope)();
|
|
57
|
-
var ToggleGroup = React.forwardRef((props, forwardedRef)
|
|
58
|
+
var ToggleGroup = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function ToggleGroup2(props, forwardedRef) {
|
|
58
59
|
const { type, ...toggleGroupProps } = props;
|
|
59
60
|
if (type === "single") {
|
|
60
61
|
const singleProps = toggleGroupProps;
|
|
@@ -65,15 +66,14 @@ var ToggleGroup = React.forwardRef((props, forwardedRef) => {
|
|
|
65
66
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplMultiple, { role: "toolbar", ...multipleProps, ref: forwardedRef });
|
|
66
67
|
}
|
|
67
68
|
throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``);
|
|
68
|
-
});
|
|
69
|
-
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
69
|
+
}, "ToggleGroup"));
|
|
70
70
|
var [ToggleGroupValueProvider, useToggleGroupValueContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
|
|
71
|
-
var ToggleGroupImplSingle = React.forwardRef((props, forwardedRef)
|
|
71
|
+
var ToggleGroupImplSingle = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function ToggleGroupImplSingle2(props, forwardedRef) {
|
|
72
72
|
const {
|
|
73
73
|
value: valueProp,
|
|
74
74
|
defaultValue,
|
|
75
|
-
onValueChange = () => {
|
|
76
|
-
},
|
|
75
|
+
onValueChange = /* @__PURE__ */ __name(() => {
|
|
76
|
+
}, "onValueChange"),
|
|
77
77
|
...toggleGroupSingleProps
|
|
78
78
|
} = props;
|
|
79
79
|
const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({
|
|
@@ -93,13 +93,13 @@ var ToggleGroupImplSingle = React.forwardRef((props, forwardedRef) => {
|
|
|
93
93
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupSingleProps, ref: forwardedRef })
|
|
94
94
|
}
|
|
95
95
|
);
|
|
96
|
-
});
|
|
97
|
-
var ToggleGroupImplMultiple = React.forwardRef((props, forwardedRef)
|
|
96
|
+
}, "ToggleGroupImplSingle"));
|
|
97
|
+
var ToggleGroupImplMultiple = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function ToggleGroupImplMultiple2(props, forwardedRef) {
|
|
98
98
|
const {
|
|
99
99
|
value: valueProp,
|
|
100
100
|
defaultValue,
|
|
101
|
-
onValueChange = () => {
|
|
102
|
-
},
|
|
101
|
+
onValueChange = /* @__PURE__ */ __name(() => {
|
|
102
|
+
}, "onValueChange"),
|
|
103
103
|
...toggleGroupMultipleProps
|
|
104
104
|
} = props;
|
|
105
105
|
const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({
|
|
@@ -127,11 +127,11 @@ var ToggleGroupImplMultiple = React.forwardRef((props, forwardedRef) => {
|
|
|
127
127
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupMultipleProps, ref: forwardedRef })
|
|
128
128
|
}
|
|
129
129
|
);
|
|
130
|
-
});
|
|
131
|
-
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
130
|
+
}, "ToggleGroupImplMultiple"));
|
|
132
131
|
var [ToggleGroupContext, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
|
|
133
|
-
var ToggleGroupImpl = React.forwardRef(
|
|
134
|
-
|
|
132
|
+
var ToggleGroupImpl = /* @__PURE__ */ React.forwardRef(
|
|
133
|
+
// blank line to reduce diff noise
|
|
134
|
+
/* @__PURE__ */ __name(function ToggleGroupImpl2(props, forwardedRef) {
|
|
135
135
|
const {
|
|
136
136
|
__scopeToggleGroup,
|
|
137
137
|
disabled = false,
|
|
@@ -155,11 +155,12 @@ var ToggleGroupImpl = React.forwardRef(
|
|
|
155
155
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...commonProps, ref: forwardedRef })
|
|
156
156
|
}
|
|
157
157
|
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...commonProps, ref: forwardedRef }) });
|
|
158
|
-
}
|
|
158
|
+
}, "ToggleGroupImpl")
|
|
159
159
|
);
|
|
160
160
|
var ITEM_NAME = "ToggleGroupItem";
|
|
161
|
-
var ToggleGroupItem = React.forwardRef(
|
|
162
|
-
|
|
161
|
+
var ToggleGroupItem = /* @__PURE__ */ React.forwardRef(
|
|
162
|
+
// blank line to reduce diff noise
|
|
163
|
+
/* @__PURE__ */ __name(function ToggleGroupItem2(props, forwardedRef) {
|
|
163
164
|
const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup);
|
|
164
165
|
const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup);
|
|
165
166
|
const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup);
|
|
@@ -178,11 +179,11 @@ var ToggleGroupItem = React.forwardRef(
|
|
|
178
179
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef })
|
|
179
180
|
}
|
|
180
181
|
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef });
|
|
181
|
-
}
|
|
182
|
+
}, "ToggleGroupItem")
|
|
182
183
|
);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
(props, forwardedRef)
|
|
184
|
+
var ToggleGroupItemImpl = /* @__PURE__ */ React.forwardRef(
|
|
185
|
+
// blank line to reduce diff noise
|
|
186
|
+
/* @__PURE__ */ __name(function ToggleGroupItemImpl2(props, forwardedRef) {
|
|
186
187
|
const { __scopeToggleGroup, value, ...itemProps } = props;
|
|
187
188
|
const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup);
|
|
188
189
|
const singleProps = { role: "radio", "aria-checked": props.pressed, "aria-pressed": void 0 };
|
|
@@ -202,6 +203,6 @@ var ToggleGroupItemImpl = React.forwardRef(
|
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
205
|
);
|
|
205
|
-
}
|
|
206
|
+
}, "ToggleGroupItemImpl")
|
|
206
207
|
);
|
|
207
208
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/toggle-group.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n Root,\n Item,\n} from './toggle-group';\nexport type {\n ToggleGroupSingleProps,\n ToggleGroupMultipleProps,\n ToggleGroupItemProps,\n} from './toggle-group';\n", "import * as 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 { 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 role=\"radiogroup\" {...singleProps} ref={forwardedRef} />;\n }\n\n if (type === 'multiple') {\n const multipleProps = toggleGroupProps as ToggleGroupImplMultipleProps;\n return <ToggleGroupImplMultiple role=\"toolbar\" {...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 caller: TOGGLE_GROUP_NAME,\n });\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"single\"\n value={React.useMemo(() => (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 caller: TOGGLE_GROUP_NAME,\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 = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype ToggleGroupImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.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 = { 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.ComponentRef<typeof Toggle>;\ntype ToggleProps = React.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\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n ToggleGroup as Root,\n ToggleGroupItem as Item,\n};\nexport type { ToggleGroupSingleProps, ToggleGroupMultipleProps, ToggleGroupItemProps };\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["value"]
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n Root,\n Item,\n} from './toggle-group';\nexport type {\n ToggleGroupSingleProps,\n ToggleGroupMultipleProps,\n ToggleGroupItemProps,\n} from './toggle-group';\n", "import * as 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 { 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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupElement,\n ToggleGroupSingleProps | ToggleGroupMultipleProps\n>(function ToggleGroup(props, forwardedRef) {\n const { type, ...toggleGroupProps } = props;\n\n if (type === 'single') {\n const singleProps = toggleGroupProps as ToggleGroupImplSingleProps;\n return <ToggleGroupImplSingle role=\"radiogroup\" {...singleProps} ref={forwardedRef} />;\n }\n\n if (type === 'multiple') {\n const multipleProps = toggleGroupProps as ToggleGroupImplMultipleProps;\n return <ToggleGroupImplMultiple role=\"toolbar\" {...multipleProps} ref={forwardedRef} />;\n }\n\n throw new Error(`Missing prop \\`type\\` expected on \\`${TOGGLE_GROUP_NAME}\\``);\n});\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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupImplSingleElement,\n ToggleGroupImplSingleProps\n>(function ToggleGroupImplSingle(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 caller: TOGGLE_GROUP_NAME,\n });\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"single\"\n value={React.useMemo(() => (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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupImplMultipleElement,\n ToggleGroupImplMultipleProps\n>(function ToggleGroupImplMultiple(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 caller: TOGGLE_GROUP_NAME,\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\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupContextValue = { rovingFocus: boolean; disabled: boolean };\n\nconst [ToggleGroupContext, useToggleGroupContext] =\n createToggleGroupContext<ToggleGroupContextValue>(TOGGLE_GROUP_NAME);\n\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype ToggleGroupImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupImplElement,\n ToggleGroupImplProps\n>(\n // blank line to reduce diff noise\n function ToggleGroupImpl(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 = { 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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupItemElement,\n ToggleGroupItemProps\n>(\n // blank line to reduce diff noise\n function ToggleGroupItem(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\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupItemImplElement = React.ComponentRef<typeof Toggle>;\ntype ToggleProps = React.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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupItemImplElement,\n ToggleGroupItemImplProps\n>(\n // blank line to reduce diff noise\n function ToggleGroupItemImpl(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\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n ToggleGroup as Root,\n ToggleGroupItem as Item,\n};\nexport type { ToggleGroupSingleProps, ToggleGroupMultipleProps, ToggleGroupItemProps };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,2BAAmC;AACnC,6BAA0B;AAC1B,uBAAkC;AAClC,gCAA4C;AAC5C,0BAAuB;AACvB,0CAAqC;AACrC,6BAA6B;AAgClB;AAxBX,IAAM,oBAAoB;AAG1B,IAAM,CAAC,0BAA0B,sBAAsB,QAAI,yC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,OAAU;AAC9F,UAAM,YAAY,aAAa,SAAS,WAAW,cAAc;AACjE,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACJ,KAAK;AAAA,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,GAnBA;AAoBF;",
|
|
6
|
+
"names": ["ToggleGroup", "ToggleGroupImplSingle", "ToggleGroupImplMultiple", "value", "ToggleGroupImpl", "ToggleGroupItem", "ToggleGroupItemImpl"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
4
|
|
|
3
5
|
// src/toggle-group.tsx
|
|
4
6
|
import * as React from "react";
|
|
@@ -15,7 +17,7 @@ var [createToggleGroupContext, createToggleGroupScope] = createContextScope(TOGG
|
|
|
15
17
|
createRovingFocusGroupScope
|
|
16
18
|
]);
|
|
17
19
|
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
18
|
-
var ToggleGroup = React.forwardRef((props, forwardedRef)
|
|
20
|
+
var ToggleGroup = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function ToggleGroup2(props, forwardedRef) {
|
|
19
21
|
const { type, ...toggleGroupProps } = props;
|
|
20
22
|
if (type === "single") {
|
|
21
23
|
const singleProps = toggleGroupProps;
|
|
@@ -26,15 +28,14 @@ var ToggleGroup = React.forwardRef((props, forwardedRef) => {
|
|
|
26
28
|
return /* @__PURE__ */ jsx(ToggleGroupImplMultiple, { role: "toolbar", ...multipleProps, ref: forwardedRef });
|
|
27
29
|
}
|
|
28
30
|
throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``);
|
|
29
|
-
});
|
|
30
|
-
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
31
|
+
}, "ToggleGroup"));
|
|
31
32
|
var [ToggleGroupValueProvider, useToggleGroupValueContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
|
|
32
|
-
var ToggleGroupImplSingle = React.forwardRef((props, forwardedRef)
|
|
33
|
+
var ToggleGroupImplSingle = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function ToggleGroupImplSingle2(props, forwardedRef) {
|
|
33
34
|
const {
|
|
34
35
|
value: valueProp,
|
|
35
36
|
defaultValue,
|
|
36
|
-
onValueChange = () => {
|
|
37
|
-
},
|
|
37
|
+
onValueChange = /* @__PURE__ */ __name(() => {
|
|
38
|
+
}, "onValueChange"),
|
|
38
39
|
...toggleGroupSingleProps
|
|
39
40
|
} = props;
|
|
40
41
|
const [value, setValue] = useControllableState({
|
|
@@ -54,13 +55,13 @@ var ToggleGroupImplSingle = React.forwardRef((props, forwardedRef) => {
|
|
|
54
55
|
children: /* @__PURE__ */ jsx(ToggleGroupImpl, { ...toggleGroupSingleProps, ref: forwardedRef })
|
|
55
56
|
}
|
|
56
57
|
);
|
|
57
|
-
});
|
|
58
|
-
var ToggleGroupImplMultiple = React.forwardRef((props, forwardedRef)
|
|
58
|
+
}, "ToggleGroupImplSingle"));
|
|
59
|
+
var ToggleGroupImplMultiple = /* @__PURE__ */ React.forwardRef(/* @__PURE__ */ __name(function ToggleGroupImplMultiple2(props, forwardedRef) {
|
|
59
60
|
const {
|
|
60
61
|
value: valueProp,
|
|
61
62
|
defaultValue,
|
|
62
|
-
onValueChange = () => {
|
|
63
|
-
},
|
|
63
|
+
onValueChange = /* @__PURE__ */ __name(() => {
|
|
64
|
+
}, "onValueChange"),
|
|
64
65
|
...toggleGroupMultipleProps
|
|
65
66
|
} = props;
|
|
66
67
|
const [value, setValue] = useControllableState({
|
|
@@ -88,11 +89,11 @@ var ToggleGroupImplMultiple = React.forwardRef((props, forwardedRef) => {
|
|
|
88
89
|
children: /* @__PURE__ */ jsx(ToggleGroupImpl, { ...toggleGroupMultipleProps, ref: forwardedRef })
|
|
89
90
|
}
|
|
90
91
|
);
|
|
91
|
-
});
|
|
92
|
-
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
92
|
+
}, "ToggleGroupImplMultiple"));
|
|
93
93
|
var [ToggleGroupContext, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
|
|
94
|
-
var ToggleGroupImpl = React.forwardRef(
|
|
95
|
-
|
|
94
|
+
var ToggleGroupImpl = /* @__PURE__ */ React.forwardRef(
|
|
95
|
+
// blank line to reduce diff noise
|
|
96
|
+
/* @__PURE__ */ __name(function ToggleGroupImpl2(props, forwardedRef) {
|
|
96
97
|
const {
|
|
97
98
|
__scopeToggleGroup,
|
|
98
99
|
disabled = false,
|
|
@@ -116,11 +117,12 @@ var ToggleGroupImpl = React.forwardRef(
|
|
|
116
117
|
children: /* @__PURE__ */ jsx(Primitive.div, { ...commonProps, ref: forwardedRef })
|
|
117
118
|
}
|
|
118
119
|
) : /* @__PURE__ */ jsx(Primitive.div, { ...commonProps, ref: forwardedRef }) });
|
|
119
|
-
}
|
|
120
|
+
}, "ToggleGroupImpl")
|
|
120
121
|
);
|
|
121
122
|
var ITEM_NAME = "ToggleGroupItem";
|
|
122
|
-
var ToggleGroupItem = React.forwardRef(
|
|
123
|
-
|
|
123
|
+
var ToggleGroupItem = /* @__PURE__ */ React.forwardRef(
|
|
124
|
+
// blank line to reduce diff noise
|
|
125
|
+
/* @__PURE__ */ __name(function ToggleGroupItem2(props, forwardedRef) {
|
|
124
126
|
const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup);
|
|
125
127
|
const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup);
|
|
126
128
|
const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup);
|
|
@@ -139,11 +141,11 @@ var ToggleGroupItem = React.forwardRef(
|
|
|
139
141
|
children: /* @__PURE__ */ jsx(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef })
|
|
140
142
|
}
|
|
141
143
|
) : /* @__PURE__ */ jsx(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef });
|
|
142
|
-
}
|
|
144
|
+
}, "ToggleGroupItem")
|
|
143
145
|
);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
(props, forwardedRef)
|
|
146
|
+
var ToggleGroupItemImpl = /* @__PURE__ */ React.forwardRef(
|
|
147
|
+
// blank line to reduce diff noise
|
|
148
|
+
/* @__PURE__ */ __name(function ToggleGroupItemImpl2(props, forwardedRef) {
|
|
147
149
|
const { __scopeToggleGroup, value, ...itemProps } = props;
|
|
148
150
|
const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup);
|
|
149
151
|
const singleProps = { role: "radio", "aria-checked": props.pressed, "aria-pressed": void 0 };
|
|
@@ -163,7 +165,7 @@ var ToggleGroupItemImpl = React.forwardRef(
|
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
);
|
|
166
|
-
}
|
|
168
|
+
}, "ToggleGroupItemImpl")
|
|
167
169
|
);
|
|
168
170
|
export {
|
|
169
171
|
ToggleGroupItem as Item,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/toggle-group.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as 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 { 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 role=\"radiogroup\" {...singleProps} ref={forwardedRef} />;\n }\n\n if (type === 'multiple') {\n const multipleProps = toggleGroupProps as ToggleGroupImplMultipleProps;\n return <ToggleGroupImplMultiple role=\"toolbar\" {...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 caller: TOGGLE_GROUP_NAME,\n });\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"single\"\n value={React.useMemo(() => (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 caller: TOGGLE_GROUP_NAME,\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 = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype ToggleGroupImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.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 = { 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.ComponentRef<typeof Toggle>;\ntype ToggleProps = React.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\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n ToggleGroup as Root,\n ToggleGroupItem as Item,\n};\nexport type { ToggleGroupSingleProps, ToggleGroupMultipleProps, ToggleGroupItemProps };\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["value"]
|
|
4
|
+
"sourcesContent": ["import * as 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 { 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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupElement,\n ToggleGroupSingleProps | ToggleGroupMultipleProps\n>(function ToggleGroup(props, forwardedRef) {\n const { type, ...toggleGroupProps } = props;\n\n if (type === 'single') {\n const singleProps = toggleGroupProps as ToggleGroupImplSingleProps;\n return <ToggleGroupImplSingle role=\"radiogroup\" {...singleProps} ref={forwardedRef} />;\n }\n\n if (type === 'multiple') {\n const multipleProps = toggleGroupProps as ToggleGroupImplMultipleProps;\n return <ToggleGroupImplMultiple role=\"toolbar\" {...multipleProps} ref={forwardedRef} />;\n }\n\n throw new Error(`Missing prop \\`type\\` expected on \\`${TOGGLE_GROUP_NAME}\\``);\n});\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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupImplSingleElement,\n ToggleGroupImplSingleProps\n>(function ToggleGroupImplSingle(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 caller: TOGGLE_GROUP_NAME,\n });\n\n return (\n <ToggleGroupValueProvider\n scope={props.__scopeToggleGroup}\n type=\"single\"\n value={React.useMemo(() => (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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupImplMultipleElement,\n ToggleGroupImplMultipleProps\n>(function ToggleGroupImplMultiple(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 caller: TOGGLE_GROUP_NAME,\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\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupContextValue = { rovingFocus: boolean; disabled: boolean };\n\nconst [ToggleGroupContext, useToggleGroupContext] =\n createToggleGroupContext<ToggleGroupContextValue>(TOGGLE_GROUP_NAME);\n\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype ToggleGroupImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupImplElement,\n ToggleGroupImplProps\n>(\n // blank line to reduce diff noise\n function ToggleGroupImpl(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 = { 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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupItemElement,\n ToggleGroupItemProps\n>(\n // blank line to reduce diff noise\n function ToggleGroupItem(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\n/* -----------------------------------------------------------------------------------------------*/\n\ntype ToggleGroupItemImplElement = React.ComponentRef<typeof Toggle>;\ntype ToggleProps = React.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 = /* @__PURE__ */ React.forwardRef<\n ToggleGroupItemImplElement,\n ToggleGroupItemImplProps\n>(\n // blank line to reduce diff noise\n function ToggleGroupItemImpl(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\nexport {\n createToggleGroupScope,\n //\n ToggleGroup,\n ToggleGroupItem,\n //\n ToggleGroup as Root,\n ToggleGroupItem as Item,\n};\nexport type { ToggleGroupSingleProps, ToggleGroupMultipleProps, ToggleGroupItemProps };\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAC1B,YAAY,sBAAsB;AAClC,SAAS,mCAAmC;AAC5C,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAgClB;AAxBX,IAAM,oBAAoB;AAG1B,IAAM,CAAC,0BAA0B,sBAAsB,IAAI,mBAAmB,mBAAmB;AAAA,EAC/F;AACF,CAAC;AACD,IAAM,2BAA2B,4BAA4B;AAU7D,IAAM,cAA8B,gBAAM,iBAGxC,gCAASA,aAAY,OAAO,cAAc;AAC1C,QAAM,EAAE,MAAM,GAAG,iBAAiB,IAAI;AAEtC,MAAI,SAAS,UAAU;AACrB,UAAM,cAAc;AACpB,WAAO,oBAAC,yBAAsB,MAAK,cAAc,GAAG,aAAa,KAAK,cAAc;AAAA,EACtF;AAEA,MAAI,SAAS,YAAY;AACvB,UAAM,gBAAgB;AACtB,WAAO,oBAAC,2BAAwB,MAAK,WAAW,GAAG,eAAe,KAAK,cAAc;AAAA,EACvF;AAEA,QAAM,IAAI,MAAM,uCAAuC,iBAAiB,IAAI;AAC9E,GAdE,cAcD;AAWD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|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-toggle-group",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16-rc.1784074599772",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
],
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@radix-ui/primitive": "1.1.5",
|
|
15
14
|
"@radix-ui/react-context": "1.2.0",
|
|
16
15
|
"@radix-ui/react-direction": "1.1.2",
|
|
17
16
|
"@radix-ui/react-primitive": "2.1.7",
|
|
18
|
-
"@radix-ui/react-roving-focus": "1.1.
|
|
19
|
-
"@radix-ui/react-toggle": "1.1.
|
|
20
|
-
"@radix-ui/
|
|
17
|
+
"@radix-ui/react-roving-focus": "1.1.16-rc.1784074599772",
|
|
18
|
+
"@radix-ui/react-toggle": "1.1.15-rc.1784074599772",
|
|
19
|
+
"@radix-ui/primitive": "1.1.6-rc.1784074599772",
|
|
20
|
+
"@radix-ui/react-use-controllable-state": "1.2.4-rc.1784074599772"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/react": "^19.2.2",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react": "^19.2.0",
|
|
26
26
|
"react-dom": "^19.2.0",
|
|
27
27
|
"typescript": "^5.9.3",
|
|
28
|
-
"@repo/builder": "0.0.
|
|
28
|
+
"@repo/builder": "0.0.1-rc.1784074599772",
|
|
29
29
|
"@repo/typescript-config": "0.0.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|