main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

13
node_modules/@radix-ui/react-toggle-group/README.md generated vendored Normal file
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,86 @@
import * as React from 'react';
import React__default from 'react';
import { Primitive } from '@radix-ui/react-primitive';
import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
import { Toggle } from '@radix-ui/react-toggle';
type Scope<C = any> = {
[scopeName: string]: React.Context<C>[];
} | undefined;
type ScopeHook = (scope: Scope) => {
[__scopeProp: string]: Scope;
};
interface CreateScope {
scopeName: string;
(): ScopeHook;
}
declare const createToggleGroupScope: CreateScope;
interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
type: 'single';
}
interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
type: 'multiple';
}
declare const ToggleGroup: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.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 = React__default.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
type PrimitiveDivProps = React__default.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'];
}
interface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {
}
declare const ToggleGroupItem: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>;
type ToggleProps = React__default.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;
}
declare const Root: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.RefAttributes<HTMLDivElement>>;
declare const Item: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>;
export { Item, Root, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupMultipleProps, type ToggleGroupSingleProps, createToggleGroupScope };

View File

@@ -0,0 +1,86 @@
import * as React from 'react';
import React__default from 'react';
import { Primitive } from '@radix-ui/react-primitive';
import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
import { Toggle } from '@radix-ui/react-toggle';
type Scope<C = any> = {
[scopeName: string]: React.Context<C>[];
} | undefined;
type ScopeHook = (scope: Scope) => {
[__scopeProp: string]: Scope;
};
interface CreateScope {
scopeName: string;
(): ScopeHook;
}
declare const createToggleGroupScope: CreateScope;
interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
type: 'single';
}
interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
type: 'multiple';
}
declare const ToggleGroup: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.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 = React__default.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
type PrimitiveDivProps = React__default.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'];
}
interface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {
}
declare const ToggleGroupItem: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>;
type ToggleProps = React__default.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;
}
declare const Root: React__default.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React__default.RefAttributes<HTMLDivElement>>;
declare const Item: React__default.ForwardRefExoticComponent<ToggleGroupItemProps & React__default.RefAttributes<HTMLButtonElement>>;
export { Item, Root, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupMultipleProps, type ToggleGroupSingleProps, createToggleGroupScope };

207
node_modules/@radix-ui/react-toggle-group/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,207 @@
"use strict";
"use client";
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 __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
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
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// packages/react/toggle-group/src/index.ts
var src_exports = {};
__export(src_exports, {
Item: () => Item2,
Root: () => Root2,
ToggleGroup: () => ToggleGroup,
ToggleGroupItem: () => ToggleGroupItem,
createToggleGroupScope: () => createToggleGroupScope
});
module.exports = __toCommonJS(src_exports);
// 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__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplMultiple, { ...multipleProps, ref: forwardedRef });
}
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__ */ (0, import_jsx_runtime.jsx)(
ToggleGroupValueProvider,
{
scope: props.__scopeToggleGroup,
type: "single",
value: value ? [value] : [],
onItemActivate: setValue,
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 = 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,
onItemActivate: handleButtonActivate,
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
} = 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 })
}
) : /* @__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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,175 @@
"use client";
// packages/react/toggle-group/src/ToggleGroup.tsx
import React from "react";
import { createContextScope } from "@radix-ui/react-context";
import { Primitive } from "@radix-ui/react-primitive";
import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
import { createRovingFocusGroupScope } from "@radix-ui/react-roving-focus";
import { Toggle } from "@radix-ui/react-toggle";
import { useControllableState } from "@radix-ui/react-use-controllable-state";
import { useDirection } from "@radix-ui/react-direction";
import { jsx } from "react/jsx-runtime";
var TOGGLE_GROUP_NAME = "ToggleGroup";
var [createToggleGroupContext, createToggleGroupScope] = createContextScope(TOGGLE_GROUP_NAME, [
createRovingFocusGroupScope
]);
var useRovingFocusGroupScope = createRovingFocusGroupScope();
var ToggleGroup = React.forwardRef((props, forwardedRef) => {
const { type, ...toggleGroupProps } = props;
if (type === "single") {
const singleProps = toggleGroupProps;
return /* @__PURE__ */ jsx(ToggleGroupImplSingle, { ...singleProps, ref: forwardedRef });
}
if (type === "multiple") {
const multipleProps = toggleGroupProps;
return /* @__PURE__ */ jsx(ToggleGroupImplMultiple, { ...multipleProps, ref: forwardedRef });
}
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 = React.forwardRef((props, forwardedRef) => {
const {
value: valueProp,
defaultValue,
onValueChange = () => {
},
...toggleGroupSingleProps
} = props;
const [value, setValue] = useControllableState({
prop: valueProp,
defaultProp: defaultValue,
onChange: onValueChange
});
return /* @__PURE__ */ jsx(
ToggleGroupValueProvider,
{
scope: props.__scopeToggleGroup,
type: "single",
value: value ? [value] : [],
onItemActivate: setValue,
onItemDeactivate: React.useCallback(() => setValue(""), [setValue]),
children: /* @__PURE__ */ jsx(ToggleGroupImpl, { ...toggleGroupSingleProps, ref: forwardedRef })
}
);
});
var ToggleGroupImplMultiple = React.forwardRef((props, forwardedRef) => {
const {
value: valueProp,
defaultValue,
onValueChange = () => {
},
...toggleGroupMultipleProps
} = props;
const [value = [], setValue] = useControllableState({
prop: valueProp,
defaultProp: defaultValue,
onChange: onValueChange
});
const handleButtonActivate = React.useCallback(
(itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
[setValue]
);
const handleButtonDeactivate = React.useCallback(
(itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
[setValue]
);
return /* @__PURE__ */ jsx(
ToggleGroupValueProvider,
{
scope: props.__scopeToggleGroup,
type: "multiple",
value,
onItemActivate: handleButtonActivate,
onItemDeactivate: handleButtonDeactivate,
children: /* @__PURE__ */ jsx(ToggleGroupImpl, { ...toggleGroupMultipleProps, ref: forwardedRef })
}
);
});
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
var [ToggleGroupContext, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
var ToggleGroupImpl = React.forwardRef(
(props, forwardedRef) => {
const {
__scopeToggleGroup,
disabled = false,
rovingFocus = true,
orientation,
dir,
loop = true,
...toggleGroupProps
} = props;
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup);
const direction = useDirection(dir);
const commonProps = { role: "group", dir: direction, ...toggleGroupProps };
return /* @__PURE__ */ jsx(ToggleGroupContext, { scope: __scopeToggleGroup, rovingFocus, disabled, children: rovingFocus ? /* @__PURE__ */ jsx(
RovingFocusGroup.Root,
{
asChild: true,
...rovingFocusGroupScope,
orientation,
dir: direction,
loop,
children: /* @__PURE__ */ jsx(Primitive.div, { ...commonProps, ref: forwardedRef })
}
) : /* @__PURE__ */ jsx(Primitive.div, { ...commonProps, ref: forwardedRef }) });
}
);
var ITEM_NAME = "ToggleGroupItem";
var ToggleGroupItem = React.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 = React.useRef(null);
return context.rovingFocus ? /* @__PURE__ */ jsx(
RovingFocusGroup.Item,
{
asChild: true,
...rovingFocusGroupScope,
focusable: !disabled,
active: pressed,
ref,
children: /* @__PURE__ */ jsx(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef })
}
) : /* @__PURE__ */ jsx(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef });
}
);
ToggleGroupItem.displayName = ITEM_NAME;
var ToggleGroupItemImpl = React.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__ */ jsx(
Toggle,
{
...typeProps,
...itemProps,
ref: forwardedRef,
onPressedChange: (pressed) => {
if (pressed) {
valueContext.onItemActivate(value);
} else {
valueContext.onItemDeactivate(value);
}
}
}
);
}
);
var Root2 = ToggleGroup;
var Item2 = ToggleGroupItem;
export {
Item2 as Item,
Root2 as Root,
ToggleGroup,
ToggleGroupItem,
createToggleGroupScope
};
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
# `react-context`
## Installation
```sh
$ yarn add @radix-ui/react-context
# or
$ npm install @radix-ui/react-context
```
## Usage
This is an internal utility, not intended for public usage.

View File

@@ -0,0 +1,28 @@
import * as react_jsx_runtime from 'react/jsx-runtime';
import * as React from 'react';
declare function createContext<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType): readonly [{
(props: ContextValueType & {
children: React.ReactNode;
}): react_jsx_runtime.JSX.Element;
displayName: string;
}, (consumerName: string) => ContextValueType];
type Scope<C = any> = {
[scopeName: string]: React.Context<C>[];
} | undefined;
type ScopeHook = (scope: Scope) => {
[__scopeProp: string]: Scope;
};
interface CreateScope {
scopeName: string;
(): ScopeHook;
}
declare function createContextScope(scopeName: string, createContextScopeDeps?: CreateScope[]): readonly [<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [{
(props: ContextValueType & {
scope: Scope<ContextValueType>;
children: React.ReactNode;
}): react_jsx_runtime.JSX.Element;
displayName: string;
}, (consumerName: string, scope: Scope<ContextValueType | undefined>) => ContextValueType], CreateScope];
export { type CreateScope, type Scope, createContext, createContextScope };

View File

@@ -0,0 +1,28 @@
import * as react_jsx_runtime from 'react/jsx-runtime';
import * as React from 'react';
declare function createContext<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType): readonly [{
(props: ContextValueType & {
children: React.ReactNode;
}): react_jsx_runtime.JSX.Element;
displayName: string;
}, (consumerName: string) => ContextValueType];
type Scope<C = any> = {
[scopeName: string]: React.Context<C>[];
} | undefined;
type ScopeHook = (scope: Scope) => {
[__scopeProp: string]: Scope;
};
interface CreateScope {
scopeName: string;
(): ScopeHook;
}
declare function createContextScope(scopeName: string, createContextScopeDeps?: CreateScope[]): readonly [<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [{
(props: ContextValueType & {
scope: Scope<ContextValueType>;
children: React.ReactNode;
}): react_jsx_runtime.JSX.Element;
displayName: string;
}, (consumerName: string, scope: Scope<ContextValueType | undefined>) => ContextValueType], CreateScope];
export { type CreateScope, type Scope, createContext, createContextScope };

View File

@@ -0,0 +1,114 @@
"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 __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
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
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// packages/react/context/src/index.ts
var src_exports = {};
__export(src_exports, {
createContext: () => createContext2,
createContextScope: () => createContextScope
});
module.exports = __toCommonJS(src_exports);
// packages/react/context/src/createContext.tsx
var React = __toESM(require("react"));
var import_jsx_runtime = require("react/jsx-runtime");
function createContext2(rootComponentName, defaultContext) {
const Context = React.createContext(defaultContext);
function Provider(props) {
const { children, ...context } = props;
const value = React.useMemo(() => context, Object.values(context));
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, { value, children });
}
function useContext2(consumerName) {
const context = React.useContext(Context);
if (context) return context;
if (defaultContext !== void 0) return defaultContext;
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
}
Provider.displayName = rootComponentName + "Provider";
return [Provider, useContext2];
}
function createContextScope(scopeName, createContextScopeDeps = []) {
let defaultContexts = [];
function createContext3(rootComponentName, defaultContext) {
const BaseContext = React.createContext(defaultContext);
const index = defaultContexts.length;
defaultContexts = [...defaultContexts, defaultContext];
function Provider(props) {
const { scope, children, ...context } = props;
const Context = scope?.[scopeName][index] || BaseContext;
const value = React.useMemo(() => context, Object.values(context));
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, { value, children });
}
function useContext2(consumerName, scope) {
const Context = scope?.[scopeName][index] || BaseContext;
const context = React.useContext(Context);
if (context) return context;
if (defaultContext !== void 0) return defaultContext;
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
}
Provider.displayName = rootComponentName + "Provider";
return [Provider, useContext2];
}
const createScope = () => {
const scopeContexts = defaultContexts.map((defaultContext) => {
return React.createContext(defaultContext);
});
return function useScope(scope) {
const contexts = scope?.[scopeName] || scopeContexts;
return React.useMemo(
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
[scope, contexts]
);
};
};
createScope.scopeName = scopeName;
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
}
function composeContextScopes(...scopes) {
const baseScope = scopes[0];
if (scopes.length === 1) return baseScope;
const createScope = () => {
const scopeHooks = scopes.map((createScope2) => ({
useScope: createScope2(),
scopeName: createScope2.scopeName
}));
return function useComposedScopes(overrideScopes) {
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
const scopeProps = useScope(overrideScopes);
const currentScope = scopeProps[`__scope${scopeName}`];
return { ...nextScopes2, ...currentScope };
}, {});
return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
};
};
createScope.scopeName = baseScope.scopeName;
return createScope;
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,81 @@
// packages/react/context/src/createContext.tsx
import * as React from "react";
import { jsx } from "react/jsx-runtime";
function createContext2(rootComponentName, defaultContext) {
const Context = React.createContext(defaultContext);
function Provider(props) {
const { children, ...context } = props;
const value = React.useMemo(() => context, Object.values(context));
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
}
function useContext2(consumerName) {
const context = React.useContext(Context);
if (context) return context;
if (defaultContext !== void 0) return defaultContext;
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
}
Provider.displayName = rootComponentName + "Provider";
return [Provider, useContext2];
}
function createContextScope(scopeName, createContextScopeDeps = []) {
let defaultContexts = [];
function createContext3(rootComponentName, defaultContext) {
const BaseContext = React.createContext(defaultContext);
const index = defaultContexts.length;
defaultContexts = [...defaultContexts, defaultContext];
function Provider(props) {
const { scope, children, ...context } = props;
const Context = scope?.[scopeName][index] || BaseContext;
const value = React.useMemo(() => context, Object.values(context));
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
}
function useContext2(consumerName, scope) {
const Context = scope?.[scopeName][index] || BaseContext;
const context = React.useContext(Context);
if (context) return context;
if (defaultContext !== void 0) return defaultContext;
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
}
Provider.displayName = rootComponentName + "Provider";
return [Provider, useContext2];
}
const createScope = () => {
const scopeContexts = defaultContexts.map((defaultContext) => {
return React.createContext(defaultContext);
});
return function useScope(scope) {
const contexts = scope?.[scopeName] || scopeContexts;
return React.useMemo(
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
[scope, contexts]
);
};
};
createScope.scopeName = scopeName;
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
}
function composeContextScopes(...scopes) {
const baseScope = scopes[0];
if (scopes.length === 1) return baseScope;
const createScope = () => {
const scopeHooks = scopes.map((createScope2) => ({
useScope: createScope2(),
scopeName: createScope2.scopeName
}));
return function useComposedScopes(overrideScopes) {
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
const scopeProps = useScope(overrideScopes);
const currentScope = scopeProps[`__scope${scopeName}`];
return { ...nextScopes2, ...currentScope };
}, {});
return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
};
};
createScope.scopeName = baseScope.scopeName;
return createScope;
}
export {
createContext2 as createContext,
createContextScope
};
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,47 @@
{
"name": "@radix-ui/react-context",
"version": "1.1.0",
"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"
},
"peerDependencies": {
"@types/react": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"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"
}
}

61
node_modules/@radix-ui/react-toggle-group/package.json generated vendored Normal file
View File

@@ -0,0 +1,61 @@
{
"name": "@radix-ui/react-toggle-group",
"version": "1.1.0",
"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": {
"@radix-ui/primitive": "1.1.0",
"@radix-ui/react-context": "1.1.0",
"@radix-ui/react-direction": "1.1.0",
"@radix-ui/react-primitive": "2.0.0",
"@radix-ui/react-roving-focus": "1.1.0",
"@radix-ui/react-toggle": "1.1.0",
"@radix-ui/react-use-controllable-state": "1.1.0"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"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"
}
}