@radix-ui/react-toggle-group
Advanced tools
Comparing version 1.0.5-rc.11 to 1.1.0-rc.1
@@ -1,14 +0,27 @@ | ||
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 { | ||
import * as React from 'react'; | ||
import React__default 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'; | ||
declare type Scope<C = any> = { | ||
[scopeName: string]: React.Context<C>[]; | ||
} | undefined; | ||
declare type ScopeHook = (scope: Scope) => { | ||
[__scopeProp: string]: Scope; | ||
}; | ||
interface CreateScope { | ||
scopeName: string; | ||
(): ScopeHook; | ||
} | ||
declare const createToggleGroupScope: CreateScope; | ||
interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps { | ||
type: 'single'; | ||
} | ||
export interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps { | ||
interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps { | ||
type: 'multiple'; | ||
} | ||
export const ToggleGroup: React.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React.RefAttributes<HTMLDivElement>>; | ||
declare const ToggleGroup: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.RefAttributes<HTMLDivElement>>; | ||
interface ToggleGroupImplSingleProps extends ToggleGroupImplProps { | ||
@@ -44,4 +57,4 @@ /** | ||
} | ||
type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>; | ||
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>; | ||
declare type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>; | ||
declare type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>; | ||
interface ToggleGroupImplProps extends PrimitiveDivProps { | ||
@@ -62,6 +75,6 @@ /** | ||
} | ||
export interface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> { | ||
interface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> { | ||
} | ||
export const ToggleGroupItem: React.ForwardRefExoticComponent<ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>>; | ||
type ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>; | ||
declare const ToggleGroupItem: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>; | ||
declare type ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>; | ||
interface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> { | ||
@@ -73,5 +86,5 @@ /** | ||
} | ||
export const Root: React.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React.RefAttributes<HTMLDivElement>>; | ||
export const Item: React.ForwardRefExoticComponent<ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>>; | ||
declare const Root: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.RefAttributes<HTMLDivElement>>; | ||
declare const Item: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>; | ||
//# sourceMappingURL=index.d.ts.map | ||
export { Item, Root, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupMultipleProps, type ToggleGroupSingleProps, createToggleGroupScope }; |
@@ -1,193 +0,198 @@ | ||
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"); | ||
"use strict"; | ||
(() => { | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { | ||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b] | ||
}) : x)(function(x) { | ||
if (typeof require !== "undefined") return require.apply(this, arguments); | ||
throw Error('Dynamic require of "' + x + '" is not supported'); | ||
}); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
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 | ||
})); | ||
// packages/react/toggle-group/src/ToggleGroup.tsx | ||
var import_react = __toESM(__require("react")); | ||
var import_react_context = __require("@radix-ui/react-context"); | ||
var import_react_primitive = __require("@radix-ui/react-primitive"); | ||
var RovingFocusGroup = __toESM(__require("@radix-ui/react-roving-focus")); | ||
var import_react_roving_focus = __require("@radix-ui/react-roving-focus"); | ||
var import_react_toggle = __require("@radix-ui/react-toggle"); | ||
var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state"); | ||
var import_react_direction = __require("@radix-ui/react-direction"); | ||
var import_jsx_runtime = __require("react/jsx-runtime"); | ||
var TOGGLE_GROUP_NAME = "ToggleGroup"; | ||
var [createToggleGroupContext, createToggleGroupScope] = (0, import_react_context.createContextScope)(TOGGLE_GROUP_NAME, [ | ||
import_react_roving_focus.createRovingFocusGroupScope | ||
]); | ||
var useRovingFocusGroupScope = (0, import_react_roving_focus.createRovingFocusGroupScope)(); | ||
var ToggleGroup = import_react.default.forwardRef((props, forwardedRef) => { | ||
const { type, ...toggleGroupProps } = props; | ||
if (type === "single") { | ||
const singleProps = toggleGroupProps; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplSingle, { ...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 | ||
})); | ||
if (type === "multiple") { | ||
const multipleProps = toggleGroupProps; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplMultiple, { ...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 | ||
throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``); | ||
}); | ||
ToggleGroup.displayName = TOGGLE_GROUP_NAME; | ||
var [ToggleGroupValueProvider, useToggleGroupValueContext] = createToggleGroupContext(TOGGLE_GROUP_NAME); | ||
var ToggleGroupImplSingle = import_react.default.forwardRef((props, forwardedRef) => { | ||
const { | ||
value: valueProp, | ||
defaultValue, | ||
onValueChange = () => { | ||
}, | ||
...toggleGroupSingleProps | ||
} = props; | ||
const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({ | ||
prop: valueProp, | ||
defaultProp: defaultValue, | ||
onChange: onValueChange | ||
}); | ||
return /*#__PURE__*/ ($parcel$interopDefault($1z6X1$react)).createElement($14b404ddd46c8376$var$ToggleGroupValueProvider, { | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
ToggleGroupValueProvider, | ||
{ | ||
scope: props.__scopeToggleGroup, | ||
type: "single", | ||
value: value ? [ | ||
value | ||
] : [], | ||
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 | ||
onItemDeactivate: import_react.default.useCallback(() => setValue(""), [setValue]), | ||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupSingleProps, ref: forwardedRef }) | ||
} | ||
); | ||
}); | ||
var ToggleGroupImplMultiple = import_react.default.forwardRef((props, forwardedRef) => { | ||
const { | ||
value: valueProp, | ||
defaultValue, | ||
onValueChange = () => { | ||
}, | ||
...toggleGroupMultipleProps | ||
} = props; | ||
const [value = [], setValue] = (0, import_react_use_controllable_state.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, { | ||
const handleButtonActivate = import_react.default.useCallback( | ||
(itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]), | ||
[setValue] | ||
); | ||
const handleButtonDeactivate = import_react.default.useCallback( | ||
(itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)), | ||
[setValue] | ||
); | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
ToggleGroupValueProvider, | ||
{ | ||
scope: props.__scopeToggleGroup, | ||
type: "multiple", | ||
value: value1, | ||
value, | ||
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, | ||
onItemDeactivate: handleButtonDeactivate, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupMultipleProps, ref: forwardedRef }) | ||
} | ||
); | ||
}); | ||
ToggleGroup.displayName = TOGGLE_GROUP_NAME; | ||
var [ToggleGroupContext, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME); | ||
var ToggleGroupImpl = import_react.default.forwardRef( | ||
(props, forwardedRef) => { | ||
const { | ||
__scopeToggleGroup, | ||
disabled = false, | ||
rovingFocus = true, | ||
orientation, | ||
dir, | ||
loop = true, | ||
...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); | ||
} = props; | ||
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup); | ||
const direction = (0, import_react_direction.useDirection)(dir); | ||
const commonProps = { role: "group", dir: direction, ...toggleGroupProps }; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupContext, { scope: __scopeToggleGroup, rovingFocus, disabled, children: rovingFocus ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
RovingFocusGroup.Root, | ||
{ | ||
asChild: true, | ||
...rovingFocusGroupScope, | ||
orientation, | ||
dir: direction, | ||
loop, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...commonProps, ref: forwardedRef }) | ||
} | ||
})); | ||
}); | ||
/* -----------------------------------------------------------------------------------------------*/ const $14b404ddd46c8376$export$be92b6f5f03c0fe9 = $14b404ddd46c8376$export$af3ec21f6cfb5e30; | ||
const $14b404ddd46c8376$export$6d08773d2e66f8f2 = $14b404ddd46c8376$export$b453109e13abe10b; | ||
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...commonProps, ref: forwardedRef }) }); | ||
} | ||
); | ||
var ITEM_NAME = "ToggleGroupItem"; | ||
var ToggleGroupItem = import_react.default.forwardRef( | ||
(props, forwardedRef) => { | ||
const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup); | ||
const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup); | ||
const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup); | ||
const pressed = valueContext.value.includes(props.value); | ||
const disabled = context.disabled || props.disabled; | ||
const commonProps = { ...props, pressed, disabled }; | ||
const ref = import_react.default.useRef(null); | ||
return context.rovingFocus ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
RovingFocusGroup.Item, | ||
{ | ||
asChild: true, | ||
...rovingFocusGroupScope, | ||
focusable: !disabled, | ||
active: pressed, | ||
ref, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef }) | ||
} | ||
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef }); | ||
} | ||
); | ||
ToggleGroupItem.displayName = ITEM_NAME; | ||
var ToggleGroupItemImpl = import_react.default.forwardRef( | ||
(props, forwardedRef) => { | ||
const { __scopeToggleGroup, value, ...itemProps } = props; | ||
const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup); | ||
const singleProps = { role: "radio", "aria-checked": props.pressed, "aria-pressed": void 0 }; | ||
const typeProps = valueContext.type === "single" ? singleProps : void 0; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
import_react_toggle.Toggle, | ||
{ | ||
...typeProps, | ||
...itemProps, | ||
ref: forwardedRef, | ||
onPressedChange: (pressed) => { | ||
if (pressed) { | ||
valueContext.onItemActivate(value); | ||
} else { | ||
valueContext.onItemDeactivate(value); | ||
} | ||
} | ||
} | ||
); | ||
} | ||
); | ||
var Root2 = ToggleGroup; | ||
var Item2 = ToggleGroupItem; | ||
})(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@radix-ui/react-toggle-group", | ||
"version": "1.0.5-rc.11", | ||
"version": "1.1.0-rc.1", | ||
"license": "MIT", | ||
@@ -31,10 +31,9 @@ "exports": { | ||
"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.5-rc.11", | ||
"@radix-ui/react-toggle": "1.0.3", | ||
"@radix-ui/react-use-controllable-state": "1.0.1" | ||
"@radix-ui/primitive": "1.1.0-rc.1", | ||
"@radix-ui/react-context": "1.1.0-rc.1", | ||
"@radix-ui/react-direction": "1.1.0-rc.1", | ||
"@radix-ui/react-primitive": "1.1.0-rc.1", | ||
"@radix-ui/react-roving-focus": "1.1.0-rc.1", | ||
"@radix-ui/react-toggle": "1.1.0-rc.1", | ||
"@radix-ui/react-use-controllable-state": "1.1.0-rc.1" | ||
}, | ||
@@ -41,0 +40,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
454
53789
8
3
+ Added@radix-ui/primitive@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-collection@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-compose-refs@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-context@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-direction@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-id@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-primitive@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-roving-focus@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-slot@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-toggle@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-use-callback-ref@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-use-controllable-state@1.1.0-rc.1(transitive)
+ Added@radix-ui/react-use-layout-effect@1.1.0-rc.1(transitive)
- Removed@babel/runtime@^7.13.10
- Removed@babel/runtime@7.26.0(transitive)
- Removed@radix-ui/primitive@1.0.1(transitive)
- Removed@radix-ui/react-collection@1.0.3(transitive)
- Removed@radix-ui/react-compose-refs@1.0.1(transitive)
- Removed@radix-ui/react-context@1.0.1(transitive)
- Removed@radix-ui/react-direction@1.0.1(transitive)
- Removed@radix-ui/react-id@1.0.1(transitive)
- Removed@radix-ui/react-primitive@1.0.3(transitive)
- Removed@radix-ui/react-roving-focus@1.0.5-rc.11(transitive)
- Removed@radix-ui/react-slot@1.0.2(transitive)
- Removed@radix-ui/react-toggle@1.0.3(transitive)
- Removed@radix-ui/react-use-callback-ref@1.0.1(transitive)
- Removed@radix-ui/react-use-controllable-state@1.0.1(transitive)
- Removed@radix-ui/react-use-layout-effect@1.0.1(transitive)
- Removedregenerator-runtime@0.14.1(transitive)