node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
# `react-toggle-group`
## Installation
```sh
$ yarn add @radix-ui/react-toggle-group
# or
$ npm install @radix-ui/react-toggle-group
```
## Usage
View docs [here](https://radix-ui.com/primitives/docs/components/toggle-group).

View File

@@ -0,0 +1,74 @@
import React from "react";
import * as Radix from "@radix-ui/react-primitive";
import { Primitive } from "@radix-ui/react-primitive";
import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
import { Toggle } from "@radix-ui/react-toggle";
export const createToggleGroupScope: import("@radix-ui/react-context").CreateScope;
export interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
type: 'single';
}
export interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
type: 'multiple';
}
export const ToggleGroup: React.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React.RefAttributes<HTMLDivElement>>;
interface ToggleGroupImplSingleProps extends ToggleGroupImplProps {
/**
* The controlled stateful value of the item that is pressed.
*/
value?: string;
/**
* The value of the item that is pressed when initially rendered. Use
* `defaultValue` if you do not need to control the state of a toggle group.
*/
defaultValue?: string;
/**
* The callback that fires when the value of the toggle group changes.
*/
onValueChange?(value: string): void;
}
interface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {
/**
* The controlled stateful value of the items that are pressed.
*/
value?: string[];
/**
* The value of the items that are pressed when initially rendered. Use
* `defaultValue` if you do not need to control the state of a toggle group.
*/
defaultValue?: string[];
/**
* The callback that fires when the state of the toggle group changes.
*/
onValueChange?(value: string[]): void;
}
type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
interface ToggleGroupImplProps extends PrimitiveDivProps {
/**
* Whether the group is disabled from user interaction.
* @defaultValue false
*/
disabled?: boolean;
/**
* Whether the group should maintain roving focus of its buttons.
* @defaultValue true
*/
rovingFocus?: boolean;
loop?: RovingFocusGroupProps['loop'];
orientation?: RovingFocusGroupProps['orientation'];
dir?: RovingFocusGroupProps['dir'];
}
export interface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {
}
export const ToggleGroupItem: React.ForwardRefExoticComponent<ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
type ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;
interface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> {
/**
* A string value for the toggle group item. All items within a toggle group should use a unique value.
*/
value: string;
}
export const Root: React.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React.RefAttributes<HTMLDivElement>>;
export const Item: React.ForwardRefExoticComponent<ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,74 @@
import React from "react";
import * as Radix from "@radix-ui/react-primitive";
import { Primitive } from "@radix-ui/react-primitive";
import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
import { Toggle } from "@radix-ui/react-toggle";
export const createToggleGroupScope: import("@radix-ui/react-context").CreateScope;
export interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
type: 'single';
}
export interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
type: 'multiple';
}
export const ToggleGroup: React.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React.RefAttributes<HTMLDivElement>>;
interface ToggleGroupImplSingleProps extends ToggleGroupImplProps {
/**
* The controlled stateful value of the item that is pressed.
*/
value?: string;
/**
* The value of the item that is pressed when initially rendered. Use
* `defaultValue` if you do not need to control the state of a toggle group.
*/
defaultValue?: string;
/**
* The callback that fires when the value of the toggle group changes.
*/
onValueChange?(value: string): void;
}
interface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {
/**
* The controlled stateful value of the items that are pressed.
*/
value?: string[];
/**
* The value of the items that are pressed when initially rendered. Use
* `defaultValue` if you do not need to control the state of a toggle group.
*/
defaultValue?: string[];
/**
* The callback that fires when the state of the toggle group changes.
*/
onValueChange?(value: string[]): void;
}
type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
interface ToggleGroupImplProps extends PrimitiveDivProps {
/**
* Whether the group is disabled from user interaction.
* @defaultValue false
*/
disabled?: boolean;
/**
* Whether the group should maintain roving focus of its buttons.
* @defaultValue true
*/
rovingFocus?: boolean;
loop?: RovingFocusGroupProps['loop'];
orientation?: RovingFocusGroupProps['orientation'];
dir?: RovingFocusGroupProps['dir'];
}
export interface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {
}
export const ToggleGroupItem: React.ForwardRefExoticComponent<ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
type ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;
interface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> {
/**
* A string value for the toggle group item. All items within a toggle group should use a unique value.
*/
value: string;
}
export const Root: React.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React.RefAttributes<HTMLDivElement>>;
export const Item: React.ForwardRefExoticComponent<ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;;AAmBA,OAAA,6FAEE,CAAC;AAIH,uCAAiC,SAAQ,0BAA0B;IACjE,IAAI,EAAE,QAAQ,CAAC;CAChB;AACD,yCAAmC,SAAQ,4BAA4B;IACrE,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,OAAA,MAAM,uIAiBJ,CAAC;AAiBH,oCAAqC,SAAQ,oBAAoB;IAC/D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAiCD,sCAAuC,SAAQ,oBAAoB;IACjE;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;OAEG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CACvC;AAoDD,6BAA6B,MAAM,wBAAwB,CAAC,OAAO,iBAAiB,IAAI,CAAC,CAAC;AAE1F,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,8BAA+B,SAAQ,iBAAiB;IACtD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACnD,GAAG,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC;CACpC;AA2CD,qCAA+B,SAAQ,IAAI,CAAC,wBAAwB,EAAE,SAAS,CAAC;CAAG;AAEnF,OAAA,MAAM,+GAuBL,CAAC;AAOF,mBAAmB,MAAM,wBAAwB,CAAC,aAAa,CAAC,CAAC;AACjE,kCAAmC,SAAQ,IAAI,CAAC,WAAW,EAAE,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"}

View File

@@ -0,0 +1,193 @@
var $1z6X1$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
var $1z6X1$react = require("react");
var $1z6X1$radixuireactcontext = require("@radix-ui/react-context");
var $1z6X1$radixuireactprimitive = require("@radix-ui/react-primitive");
var $1z6X1$radixuireactrovingfocus = require("@radix-ui/react-roving-focus");
var $1z6X1$radixuireacttoggle = require("@radix-ui/react-toggle");
var $1z6X1$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
var $1z6X1$radixuireactdirection = require("@radix-ui/react-direction");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
$parcel$export(module.exports, "createToggleGroupScope", () => $14b404ddd46c8376$export$d1c7c4bcd9f26dd4);
$parcel$export(module.exports, "ToggleGroup", () => $14b404ddd46c8376$export$af3ec21f6cfb5e30);
$parcel$export(module.exports, "ToggleGroupItem", () => $14b404ddd46c8376$export$b453109e13abe10b);
$parcel$export(module.exports, "Root", () => $14b404ddd46c8376$export$be92b6f5f03c0fe9);
$parcel$export(module.exports, "Item", () => $14b404ddd46c8376$export$6d08773d2e66f8f2);
/* -------------------------------------------------------------------------------------------------
* ToggleGroup
* -----------------------------------------------------------------------------------------------*/ const $14b404ddd46c8376$var$TOGGLE_GROUP_NAME = 'ToggleGroup';
const [$14b404ddd46c8376$var$createToggleGroupContext, $14b404ddd46c8376$export$d1c7c4bcd9f26dd4] = $1z6X1$radixuireactcontext.createContextScope($14b404ddd46c8376$var$TOGGLE_GROUP_NAME, [
$1z6X1$radixuireactrovingfocus.createRovingFocusGroupScope
]);
const $14b404ddd46c8376$var$useRovingFocusGroupScope = $1z6X1$radixuireactrovingfocus.createRovingFocusGroupScope();
const $14b404ddd46c8376$export$af3ec21f6cfb5e30 = /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).forwardRef((props, forwardedRef)=>{
const { type: type , ...toggleGroupProps } = props;
if (type === 'single') {
const singleProps = toggleGroupProps;
return /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupImplSingle, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, singleProps, {
ref: forwardedRef
}));
}
if (type === 'multiple') {
const multipleProps = toggleGroupProps;
return /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupImplMultiple, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, multipleProps, {
ref: forwardedRef
}));
}
throw new Error(`Missing prop \`type\` expected on \`${$14b404ddd46c8376$var$TOGGLE_GROUP_NAME}\``);
});
/*#__PURE__*/ Object.assign($14b404ddd46c8376$export$af3ec21f6cfb5e30, {
displayName: $14b404ddd46c8376$var$TOGGLE_GROUP_NAME
});
/* -----------------------------------------------------------------------------------------------*/ const [$14b404ddd46c8376$var$ToggleGroupValueProvider, $14b404ddd46c8376$var$useToggleGroupValueContext] = $14b404ddd46c8376$var$createToggleGroupContext($14b404ddd46c8376$var$TOGGLE_GROUP_NAME);
const $14b404ddd46c8376$var$ToggleGroupImplSingle = /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).forwardRef((props, forwardedRef)=>{
const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , ...toggleGroupSingleProps } = props;
const [value, setValue] = $1z6X1$radixuireactusecontrollablestate.useControllableState({
prop: valueProp,
defaultProp: defaultValue,
onChange: onValueChange
});
return /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupValueProvider, {
scope: props.__scopeToggleGroup,
type: "single",
value: value ? [
value
] : [],
onItemActivate: setValue,
onItemDeactivate: ($parcel$interopDefault($1z6X1$react)).useCallback(()=>setValue('')
, [
setValue
])
}, /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupImpl, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, toggleGroupSingleProps, {
ref: forwardedRef
})));
});
const $14b404ddd46c8376$var$ToggleGroupImplMultiple = /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).forwardRef((props, forwardedRef)=>{
const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , ...toggleGroupMultipleProps } = props;
const [value1 = [], setValue] = $1z6X1$radixuireactusecontrollablestate.useControllableState({
prop: valueProp,
defaultProp: defaultValue,
onChange: onValueChange
});
const handleButtonActivate = ($parcel$interopDefault($1z6X1$react)).useCallback((itemValue)=>setValue((prevValue = [])=>[
...prevValue,
itemValue
]
)
, [
setValue
]);
const handleButtonDeactivate = ($parcel$interopDefault($1z6X1$react)).useCallback((itemValue)=>setValue((prevValue = [])=>prevValue.filter((value)=>value !== itemValue
)
)
, [
setValue
]);
return /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupValueProvider, {
scope: props.__scopeToggleGroup,
type: "multiple",
value: value1,
onItemActivate: handleButtonActivate,
onItemDeactivate: handleButtonDeactivate
}, /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupImpl, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, toggleGroupMultipleProps, {
ref: forwardedRef
})));
});
/*#__PURE__*/ Object.assign($14b404ddd46c8376$export$af3ec21f6cfb5e30, {
displayName: $14b404ddd46c8376$var$TOGGLE_GROUP_NAME
});
/* -----------------------------------------------------------------------------------------------*/ const [$14b404ddd46c8376$var$ToggleGroupContext, $14b404ddd46c8376$var$useToggleGroupContext] = $14b404ddd46c8376$var$createToggleGroupContext($14b404ddd46c8376$var$TOGGLE_GROUP_NAME);
const $14b404ddd46c8376$var$ToggleGroupImpl = /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).forwardRef((props, forwardedRef)=>{
const { __scopeToggleGroup: __scopeToggleGroup , disabled: disabled = false , rovingFocus: rovingFocus = true , orientation: orientation , dir: dir , loop: loop = true , ...toggleGroupProps } = props;
const rovingFocusGroupScope = $14b404ddd46c8376$var$useRovingFocusGroupScope(__scopeToggleGroup);
const direction = $1z6X1$radixuireactdirection.useDirection(dir);
const commonProps = {
role: 'group',
dir: direction,
...toggleGroupProps
};
return /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupContext, {
scope: __scopeToggleGroup,
rovingFocus: rovingFocus,
disabled: disabled
}, rovingFocus ? /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($1z6X1$radixuireactrovingfocus.Root, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({
asChild: true
}, rovingFocusGroupScope, {
orientation: orientation,
dir: direction,
loop: loop
}), /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($1z6X1$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, commonProps, {
ref: forwardedRef
}))) : /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($1z6X1$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, commonProps, {
ref: forwardedRef
})));
});
/* -------------------------------------------------------------------------------------------------
* ToggleGroupItem
* -----------------------------------------------------------------------------------------------*/ const $14b404ddd46c8376$var$ITEM_NAME = 'ToggleGroupItem';
const $14b404ddd46c8376$export$b453109e13abe10b = /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).forwardRef((props, forwardedRef)=>{
const valueContext = $14b404ddd46c8376$var$useToggleGroupValueContext($14b404ddd46c8376$var$ITEM_NAME, props.__scopeToggleGroup);
const context = $14b404ddd46c8376$var$useToggleGroupContext($14b404ddd46c8376$var$ITEM_NAME, props.__scopeToggleGroup);
const rovingFocusGroupScope = $14b404ddd46c8376$var$useRovingFocusGroupScope(props.__scopeToggleGroup);
const pressed = valueContext.value.includes(props.value);
const disabled = context.disabled || props.disabled;
const commonProps = {
...props,
pressed: pressed,
disabled: disabled
};
const ref = ($parcel$interopDefault($1z6X1$react)).useRef(null);
return context.rovingFocus ? /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($1z6X1$radixuireactrovingfocus.Item, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({
asChild: true
}, rovingFocusGroupScope, {
focusable: !disabled,
active: pressed,
ref: ref
}), /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupItemImpl, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, commonProps, {
ref: forwardedRef
}))) : /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupItemImpl, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, commonProps, {
ref: forwardedRef
}));
});
/*#__PURE__*/ Object.assign($14b404ddd46c8376$export$b453109e13abe10b, {
displayName: $14b404ddd46c8376$var$ITEM_NAME
});
/* -----------------------------------------------------------------------------------------------*/ const $14b404ddd46c8376$var$ToggleGroupItemImpl = /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).forwardRef((props, forwardedRef)=>{
const { __scopeToggleGroup: __scopeToggleGroup , value: value , ...itemProps } = props;
const valueContext = $14b404ddd46c8376$var$useToggleGroupValueContext($14b404ddd46c8376$var$ITEM_NAME, __scopeToggleGroup);
const singleProps = {
role: 'radio',
'aria-checked': props.pressed,
'aria-pressed': undefined
};
const typeProps = valueContext.type === 'single' ? singleProps : undefined;
return /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($1z6X1$radixuireacttoggle.Toggle, ($parcel$interopDefault($1z6X1$babelruntimehelpersextends))({}, typeProps, itemProps, {
ref: forwardedRef,
onPressedChange: (pressed)=>{
if (pressed) valueContext.onItemActivate(value);
else valueContext.onItemDeactivate(value);
}
}));
});
/* -----------------------------------------------------------------------------------------------*/ const $14b404ddd46c8376$export$be92b6f5f03c0fe9 = $14b404ddd46c8376$export$af3ec21f6cfb5e30;
const $14b404ddd46c8376$export$6d08773d2e66f8f2 = $14b404ddd46c8376$export$b453109e13abe10b;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,182 @@
import $jFibJ$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
import $jFibJ$react from "react";
import {createContextScope as $jFibJ$createContextScope} from "@radix-ui/react-context";
import {Primitive as $jFibJ$Primitive} from "@radix-ui/react-primitive";
import {createRovingFocusGroupScope as $jFibJ$createRovingFocusGroupScope, Root as $jFibJ$Root, Item as $jFibJ$Item} from "@radix-ui/react-roving-focus";
import {Toggle as $jFibJ$Toggle} from "@radix-ui/react-toggle";
import {useControllableState as $jFibJ$useControllableState} from "@radix-ui/react-use-controllable-state";
import {useDirection as $jFibJ$useDirection} from "@radix-ui/react-direction";
/* -------------------------------------------------------------------------------------------------
* ToggleGroup
* -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME = 'ToggleGroup';
const [$6c1fd9e6a8969628$var$createToggleGroupContext, $6c1fd9e6a8969628$export$d1c7c4bcd9f26dd4] = $jFibJ$createContextScope($6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME, [
$jFibJ$createRovingFocusGroupScope
]);
const $6c1fd9e6a8969628$var$useRovingFocusGroupScope = $jFibJ$createRovingFocusGroupScope();
const $6c1fd9e6a8969628$export$af3ec21f6cfb5e30 = /*#__PURE__*/ $jFibJ$react.forwardRef((props, forwardedRef)=>{
const { type: type , ...toggleGroupProps } = props;
if (type === 'single') {
const singleProps = toggleGroupProps;
return /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupImplSingle, $jFibJ$babelruntimehelpersesmextends({}, singleProps, {
ref: forwardedRef
}));
}
if (type === 'multiple') {
const multipleProps = toggleGroupProps;
return /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupImplMultiple, $jFibJ$babelruntimehelpersesmextends({}, multipleProps, {
ref: forwardedRef
}));
}
throw new Error(`Missing prop \`type\` expected on \`${$6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME}\``);
});
/*#__PURE__*/ Object.assign($6c1fd9e6a8969628$export$af3ec21f6cfb5e30, {
displayName: $6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME
});
/* -----------------------------------------------------------------------------------------------*/ const [$6c1fd9e6a8969628$var$ToggleGroupValueProvider, $6c1fd9e6a8969628$var$useToggleGroupValueContext] = $6c1fd9e6a8969628$var$createToggleGroupContext($6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME);
const $6c1fd9e6a8969628$var$ToggleGroupImplSingle = /*#__PURE__*/ $jFibJ$react.forwardRef((props, forwardedRef)=>{
const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , ...toggleGroupSingleProps } = props;
const [value, setValue] = $jFibJ$useControllableState({
prop: valueProp,
defaultProp: defaultValue,
onChange: onValueChange
});
return /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupValueProvider, {
scope: props.__scopeToggleGroup,
type: "single",
value: value ? [
value
] : [],
onItemActivate: setValue,
onItemDeactivate: $jFibJ$react.useCallback(()=>setValue('')
, [
setValue
])
}, /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupImpl, $jFibJ$babelruntimehelpersesmextends({}, toggleGroupSingleProps, {
ref: forwardedRef
})));
});
const $6c1fd9e6a8969628$var$ToggleGroupImplMultiple = /*#__PURE__*/ $jFibJ$react.forwardRef((props, forwardedRef)=>{
const { value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange = ()=>{} , ...toggleGroupMultipleProps } = props;
const [value1 = [], setValue] = $jFibJ$useControllableState({
prop: valueProp,
defaultProp: defaultValue,
onChange: onValueChange
});
const handleButtonActivate = $jFibJ$react.useCallback((itemValue)=>setValue((prevValue = [])=>[
...prevValue,
itemValue
]
)
, [
setValue
]);
const handleButtonDeactivate = $jFibJ$react.useCallback((itemValue)=>setValue((prevValue = [])=>prevValue.filter((value)=>value !== itemValue
)
)
, [
setValue
]);
return /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupValueProvider, {
scope: props.__scopeToggleGroup,
type: "multiple",
value: value1,
onItemActivate: handleButtonActivate,
onItemDeactivate: handleButtonDeactivate
}, /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupImpl, $jFibJ$babelruntimehelpersesmextends({}, toggleGroupMultipleProps, {
ref: forwardedRef
})));
});
/*#__PURE__*/ Object.assign($6c1fd9e6a8969628$export$af3ec21f6cfb5e30, {
displayName: $6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME
});
/* -----------------------------------------------------------------------------------------------*/ const [$6c1fd9e6a8969628$var$ToggleGroupContext, $6c1fd9e6a8969628$var$useToggleGroupContext] = $6c1fd9e6a8969628$var$createToggleGroupContext($6c1fd9e6a8969628$var$TOGGLE_GROUP_NAME);
const $6c1fd9e6a8969628$var$ToggleGroupImpl = /*#__PURE__*/ $jFibJ$react.forwardRef((props, forwardedRef)=>{
const { __scopeToggleGroup: __scopeToggleGroup , disabled: disabled = false , rovingFocus: rovingFocus = true , orientation: orientation , dir: dir , loop: loop = true , ...toggleGroupProps } = props;
const rovingFocusGroupScope = $6c1fd9e6a8969628$var$useRovingFocusGroupScope(__scopeToggleGroup);
const direction = $jFibJ$useDirection(dir);
const commonProps = {
role: 'group',
dir: direction,
...toggleGroupProps
};
return /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupContext, {
scope: __scopeToggleGroup,
rovingFocus: rovingFocus,
disabled: disabled
}, rovingFocus ? /*#__PURE__*/ $jFibJ$react.createElement($jFibJ$Root, $jFibJ$babelruntimehelpersesmextends({
asChild: true
}, rovingFocusGroupScope, {
orientation: orientation,
dir: direction,
loop: loop
}), /*#__PURE__*/ $jFibJ$react.createElement($jFibJ$Primitive.div, $jFibJ$babelruntimehelpersesmextends({}, commonProps, {
ref: forwardedRef
}))) : /*#__PURE__*/ $jFibJ$react.createElement($jFibJ$Primitive.div, $jFibJ$babelruntimehelpersesmextends({}, commonProps, {
ref: forwardedRef
})));
});
/* -------------------------------------------------------------------------------------------------
* ToggleGroupItem
* -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$var$ITEM_NAME = 'ToggleGroupItem';
const $6c1fd9e6a8969628$export$b453109e13abe10b = /*#__PURE__*/ $jFibJ$react.forwardRef((props, forwardedRef)=>{
const valueContext = $6c1fd9e6a8969628$var$useToggleGroupValueContext($6c1fd9e6a8969628$var$ITEM_NAME, props.__scopeToggleGroup);
const context = $6c1fd9e6a8969628$var$useToggleGroupContext($6c1fd9e6a8969628$var$ITEM_NAME, props.__scopeToggleGroup);
const rovingFocusGroupScope = $6c1fd9e6a8969628$var$useRovingFocusGroupScope(props.__scopeToggleGroup);
const pressed = valueContext.value.includes(props.value);
const disabled = context.disabled || props.disabled;
const commonProps = {
...props,
pressed: pressed,
disabled: disabled
};
const ref = $jFibJ$react.useRef(null);
return context.rovingFocus ? /*#__PURE__*/ $jFibJ$react.createElement($jFibJ$Item, $jFibJ$babelruntimehelpersesmextends({
asChild: true
}, rovingFocusGroupScope, {
focusable: !disabled,
active: pressed,
ref: ref
}), /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupItemImpl, $jFibJ$babelruntimehelpersesmextends({}, commonProps, {
ref: forwardedRef
}))) : /*#__PURE__*/ $jFibJ$react.createElement($6c1fd9e6a8969628$var$ToggleGroupItemImpl, $jFibJ$babelruntimehelpersesmextends({}, commonProps, {
ref: forwardedRef
}));
});
/*#__PURE__*/ Object.assign($6c1fd9e6a8969628$export$b453109e13abe10b, {
displayName: $6c1fd9e6a8969628$var$ITEM_NAME
});
/* -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$var$ToggleGroupItemImpl = /*#__PURE__*/ $jFibJ$react.forwardRef((props, forwardedRef)=>{
const { __scopeToggleGroup: __scopeToggleGroup , value: value , ...itemProps } = props;
const valueContext = $6c1fd9e6a8969628$var$useToggleGroupValueContext($6c1fd9e6a8969628$var$ITEM_NAME, __scopeToggleGroup);
const singleProps = {
role: 'radio',
'aria-checked': props.pressed,
'aria-pressed': undefined
};
const typeProps = valueContext.type === 'single' ? singleProps : undefined;
return /*#__PURE__*/ $jFibJ$react.createElement($jFibJ$Toggle, $jFibJ$babelruntimehelpersesmextends({}, typeProps, itemProps, {
ref: forwardedRef,
onPressedChange: (pressed)=>{
if (pressed) valueContext.onItemActivate(value);
else valueContext.onItemDeactivate(value);
}
}));
});
/* -----------------------------------------------------------------------------------------------*/ const $6c1fd9e6a8969628$export$be92b6f5f03c0fe9 = $6c1fd9e6a8969628$export$af3ec21f6cfb5e30;
const $6c1fd9e6a8969628$export$6d08773d2e66f8f2 = $6c1fd9e6a8969628$export$b453109e13abe10b;
export {$6c1fd9e6a8969628$export$d1c7c4bcd9f26dd4 as createToggleGroupScope, $6c1fd9e6a8969628$export$af3ec21f6cfb5e30 as ToggleGroup, $6c1fd9e6a8969628$export$b453109e13abe10b as ToggleGroupItem, $6c1fd9e6a8969628$export$be92b6f5f03c0fe9 as Root, $6c1fd9e6a8969628$export$6d08773d2e66f8f2 as Item};
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,62 @@
{
"name": "@radix-ui/react-toggle-group",
"version": "1.0.4",
"license": "MIT",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"source": "./src/index.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist",
"README.md"
],
"sideEffects": false,
"scripts": {
"clean": "rm -rf dist",
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "1.0.1",
"@radix-ui/react-context": "1.0.1",
"@radix-ui/react-direction": "1.0.1",
"@radix-ui/react-primitive": "1.0.3",
"@radix-ui/react-roving-focus": "1.0.4",
"@radix-ui/react-toggle": "1.0.3",
"@radix-ui/react-use-controllable-state": "1.0.1"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
},
"homepage": "https://radix-ui.com/primitives",
"repository": {
"type": "git",
"url": "git+https://github.com/radix-ui/primitives.git"
},
"bugs": {
"url": "https://github.com/radix-ui/primitives/issues"
}
}