v1.0 with SW PWA enabled
This commit is contained in:
50
frontend/node_modules/@radix-ui/react-checkbox/dist/index.d.mts
generated
vendored
Normal file
50
frontend/node_modules/@radix-ui/react-checkbox/dist/index.d.mts
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
import * as react_jsx_runtime from 'react/jsx-runtime';
|
||||
import * as _radix_ui_react_context from '@radix-ui/react-context';
|
||||
import { Scope } from '@radix-ui/react-context';
|
||||
import * as React from 'react';
|
||||
import { Primitive } from '@radix-ui/react-primitive';
|
||||
|
||||
type ScopedProps<P> = P & {
|
||||
__scopeCheckbox?: Scope;
|
||||
};
|
||||
declare const createCheckboxScope: _radix_ui_react_context.CreateScope;
|
||||
type CheckedState = boolean | 'indeterminate';
|
||||
interface CheckboxProviderProps<State extends CheckedState = CheckedState> {
|
||||
checked?: State | boolean;
|
||||
defaultChecked?: State | boolean;
|
||||
required?: boolean;
|
||||
onCheckedChange?(checked: State | boolean): void;
|
||||
name?: string;
|
||||
form?: string;
|
||||
disabled?: boolean;
|
||||
value?: string | number | readonly string[];
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
declare function CheckboxProvider<State extends CheckedState = CheckedState>(props: ScopedProps<CheckboxProviderProps<State>>): react_jsx_runtime.JSX.Element;
|
||||
interface CheckboxTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof Primitive.button>, keyof CheckboxProviderProps> {
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
declare const CheckboxTrigger: React.ForwardRefExoticComponent<CheckboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
||||
type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
|
||||
interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {
|
||||
checked?: CheckedState;
|
||||
defaultChecked?: CheckedState;
|
||||
required?: boolean;
|
||||
onCheckedChange?(checked: CheckedState): void;
|
||||
}
|
||||
declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
|
||||
type PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;
|
||||
interface CheckboxIndicatorProps extends PrimitiveSpanProps {
|
||||
/**
|
||||
* Used to force mounting when more control is needed. Useful when
|
||||
* controlling animation with React animation libraries.
|
||||
*/
|
||||
forceMount?: true;
|
||||
}
|
||||
declare const CheckboxIndicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
type InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;
|
||||
interface CheckboxBubbleInputProps extends Omit<InputProps, 'checked'> {
|
||||
}
|
||||
declare const CheckboxBubbleInput: React.ForwardRefExoticComponent<CheckboxBubbleInputProps & React.RefAttributes<HTMLInputElement>>;
|
||||
|
||||
export { Checkbox, CheckboxIndicator, type CheckboxIndicatorProps, type CheckboxProps, type CheckedState, CheckboxIndicator as Indicator, Checkbox as Root, createCheckboxScope, CheckboxBubbleInput as unstable_BubbleInput, CheckboxBubbleInput as unstable_CheckboxBubbleInput, type CheckboxBubbleInputProps as unstable_CheckboxBubbleInputProps, CheckboxProvider as unstable_CheckboxProvider, type CheckboxProviderProps as unstable_CheckboxProviderProps, CheckboxTrigger as unstable_CheckboxTrigger, type CheckboxTriggerProps as unstable_CheckboxTriggerProps, CheckboxProvider as unstable_Provider, CheckboxTrigger as unstable_Trigger };
|
||||
50
frontend/node_modules/@radix-ui/react-checkbox/dist/index.d.ts
generated
vendored
Normal file
50
frontend/node_modules/@radix-ui/react-checkbox/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
import * as react_jsx_runtime from 'react/jsx-runtime';
|
||||
import * as _radix_ui_react_context from '@radix-ui/react-context';
|
||||
import { Scope } from '@radix-ui/react-context';
|
||||
import * as React from 'react';
|
||||
import { Primitive } from '@radix-ui/react-primitive';
|
||||
|
||||
type ScopedProps<P> = P & {
|
||||
__scopeCheckbox?: Scope;
|
||||
};
|
||||
declare const createCheckboxScope: _radix_ui_react_context.CreateScope;
|
||||
type CheckedState = boolean | 'indeterminate';
|
||||
interface CheckboxProviderProps<State extends CheckedState = CheckedState> {
|
||||
checked?: State | boolean;
|
||||
defaultChecked?: State | boolean;
|
||||
required?: boolean;
|
||||
onCheckedChange?(checked: State | boolean): void;
|
||||
name?: string;
|
||||
form?: string;
|
||||
disabled?: boolean;
|
||||
value?: string | number | readonly string[];
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
declare function CheckboxProvider<State extends CheckedState = CheckedState>(props: ScopedProps<CheckboxProviderProps<State>>): react_jsx_runtime.JSX.Element;
|
||||
interface CheckboxTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof Primitive.button>, keyof CheckboxProviderProps> {
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
declare const CheckboxTrigger: React.ForwardRefExoticComponent<CheckboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
||||
type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
|
||||
interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {
|
||||
checked?: CheckedState;
|
||||
defaultChecked?: CheckedState;
|
||||
required?: boolean;
|
||||
onCheckedChange?(checked: CheckedState): void;
|
||||
}
|
||||
declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
|
||||
type PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;
|
||||
interface CheckboxIndicatorProps extends PrimitiveSpanProps {
|
||||
/**
|
||||
* Used to force mounting when more control is needed. Useful when
|
||||
* controlling animation with React animation libraries.
|
||||
*/
|
||||
forceMount?: true;
|
||||
}
|
||||
declare const CheckboxIndicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
type InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;
|
||||
interface CheckboxBubbleInputProps extends Omit<InputProps, 'checked'> {
|
||||
}
|
||||
declare const CheckboxBubbleInput: React.ForwardRefExoticComponent<CheckboxBubbleInputProps & React.RefAttributes<HTMLInputElement>>;
|
||||
|
||||
export { Checkbox, CheckboxIndicator, type CheckboxIndicatorProps, type CheckboxProps, type CheckedState, CheckboxIndicator as Indicator, Checkbox as Root, createCheckboxScope, CheckboxBubbleInput as unstable_BubbleInput, CheckboxBubbleInput as unstable_CheckboxBubbleInput, type CheckboxBubbleInputProps as unstable_CheckboxBubbleInputProps, CheckboxProvider as unstable_CheckboxProvider, type CheckboxProviderProps as unstable_CheckboxProviderProps, CheckboxTrigger as unstable_CheckboxTrigger, type CheckboxTriggerProps as unstable_CheckboxTriggerProps, CheckboxProvider as unstable_Provider, CheckboxTrigger as unstable_Trigger };
|
||||
316
frontend/node_modules/@radix-ui/react-checkbox/dist/index.js
generated
vendored
Normal file
316
frontend/node_modules/@radix-ui/react-checkbox/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,316 @@
|
||||
"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);
|
||||
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
Checkbox: () => Checkbox,
|
||||
CheckboxIndicator: () => CheckboxIndicator,
|
||||
Indicator: () => CheckboxIndicator,
|
||||
Root: () => Checkbox,
|
||||
createCheckboxScope: () => createCheckboxScope,
|
||||
unstable_BubbleInput: () => CheckboxBubbleInput,
|
||||
unstable_CheckboxBubbleInput: () => CheckboxBubbleInput,
|
||||
unstable_CheckboxProvider: () => CheckboxProvider,
|
||||
unstable_CheckboxTrigger: () => CheckboxTrigger,
|
||||
unstable_Provider: () => CheckboxProvider,
|
||||
unstable_Trigger: () => CheckboxTrigger
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
// src/checkbox.tsx
|
||||
var React = __toESM(require("react"));
|
||||
var import_react_compose_refs = require("@radix-ui/react-compose-refs");
|
||||
var import_react_context = require("@radix-ui/react-context");
|
||||
var import_primitive = require("@radix-ui/primitive");
|
||||
var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
|
||||
var import_react_use_previous = require("@radix-ui/react-use-previous");
|
||||
var import_react_use_size = require("@radix-ui/react-use-size");
|
||||
var import_react_presence = require("@radix-ui/react-presence");
|
||||
var import_react_primitive = require("@radix-ui/react-primitive");
|
||||
var import_jsx_runtime = require("react/jsx-runtime");
|
||||
var CHECKBOX_NAME = "Checkbox";
|
||||
var [createCheckboxContext, createCheckboxScope] = (0, import_react_context.createContextScope)(CHECKBOX_NAME);
|
||||
var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
|
||||
function CheckboxProvider(props) {
|
||||
const {
|
||||
__scopeCheckbox,
|
||||
checked: checkedProp,
|
||||
children,
|
||||
defaultChecked,
|
||||
disabled,
|
||||
form,
|
||||
name,
|
||||
onCheckedChange,
|
||||
required,
|
||||
value = "on",
|
||||
// @ts-expect-error
|
||||
internal_do_not_use_render
|
||||
} = props;
|
||||
const [checked, setChecked] = (0, import_react_use_controllable_state.useControllableState)({
|
||||
prop: checkedProp,
|
||||
defaultProp: defaultChecked ?? false,
|
||||
onChange: onCheckedChange,
|
||||
caller: CHECKBOX_NAME
|
||||
});
|
||||
const [control, setControl] = React.useState(null);
|
||||
const [bubbleInput, setBubbleInput] = React.useState(null);
|
||||
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
||||
const isFormControl = control ? !!form || !!control.closest("form") : (
|
||||
// We set this to true by default so that events bubble to forms without JS (SSR)
|
||||
true
|
||||
);
|
||||
const context = {
|
||||
checked,
|
||||
disabled,
|
||||
setChecked,
|
||||
control,
|
||||
setControl,
|
||||
name,
|
||||
form,
|
||||
value,
|
||||
hasConsumerStoppedPropagationRef,
|
||||
required,
|
||||
defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
|
||||
isFormControl,
|
||||
bubbleInput,
|
||||
setBubbleInput
|
||||
};
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
||||
CheckboxProviderImpl,
|
||||
{
|
||||
scope: __scopeCheckbox,
|
||||
...context,
|
||||
children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
||||
}
|
||||
);
|
||||
}
|
||||
var TRIGGER_NAME = "CheckboxTrigger";
|
||||
var CheckboxTrigger = React.forwardRef(
|
||||
({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
|
||||
const {
|
||||
control,
|
||||
value,
|
||||
disabled,
|
||||
checked,
|
||||
required,
|
||||
setControl,
|
||||
setChecked,
|
||||
hasConsumerStoppedPropagationRef,
|
||||
isFormControl,
|
||||
bubbleInput
|
||||
} = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
|
||||
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, setControl);
|
||||
const initialCheckedStateRef = React.useRef(checked);
|
||||
React.useEffect(() => {
|
||||
const form = control?.form;
|
||||
if (form) {
|
||||
const reset = () => setChecked(initialCheckedStateRef.current);
|
||||
form.addEventListener("reset", reset);
|
||||
return () => form.removeEventListener("reset", reset);
|
||||
}
|
||||
}, [control, setChecked]);
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
||||
import_react_primitive.Primitive.button,
|
||||
{
|
||||
type: "button",
|
||||
role: "checkbox",
|
||||
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
||||
"aria-required": required,
|
||||
"data-state": getState(checked),
|
||||
"data-disabled": disabled ? "" : void 0,
|
||||
disabled,
|
||||
value,
|
||||
...checkboxProps,
|
||||
ref: composedRefs,
|
||||
onKeyDown: (0, import_primitive.composeEventHandlers)(onKeyDown, (event) => {
|
||||
if (event.key === "Enter") event.preventDefault();
|
||||
}),
|
||||
onClick: (0, import_primitive.composeEventHandlers)(onClick, (event) => {
|
||||
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
|
||||
if (bubbleInput && isFormControl) {
|
||||
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
||||
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
||||
}
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
CheckboxTrigger.displayName = TRIGGER_NAME;
|
||||
var Checkbox = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const {
|
||||
__scopeCheckbox,
|
||||
name,
|
||||
checked,
|
||||
defaultChecked,
|
||||
required,
|
||||
disabled,
|
||||
value,
|
||||
onCheckedChange,
|
||||
form,
|
||||
...checkboxProps
|
||||
} = props;
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
||||
CheckboxProvider,
|
||||
{
|
||||
__scopeCheckbox,
|
||||
checked,
|
||||
defaultChecked,
|
||||
disabled,
|
||||
required,
|
||||
onCheckedChange,
|
||||
name,
|
||||
form,
|
||||
value,
|
||||
internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
||||
CheckboxTrigger,
|
||||
{
|
||||
...checkboxProps,
|
||||
ref: forwardedRef,
|
||||
__scopeCheckbox
|
||||
}
|
||||
),
|
||||
isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
||||
CheckboxBubbleInput,
|
||||
{
|
||||
__scopeCheckbox
|
||||
}
|
||||
)
|
||||
] })
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
Checkbox.displayName = CHECKBOX_NAME;
|
||||
var INDICATOR_NAME = "CheckboxIndicator";
|
||||
var CheckboxIndicator = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
|
||||
const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
||||
import_react_presence.Presence,
|
||||
{
|
||||
present: forceMount || isIndeterminate(context.checked) || context.checked === true,
|
||||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
||||
import_react_primitive.Primitive.span,
|
||||
{
|
||||
"data-state": getState(context.checked),
|
||||
"data-disabled": context.disabled ? "" : void 0,
|
||||
...indicatorProps,
|
||||
ref: forwardedRef,
|
||||
style: { pointerEvents: "none", ...props.style }
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
CheckboxIndicator.displayName = INDICATOR_NAME;
|
||||
var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
|
||||
var CheckboxBubbleInput = React.forwardRef(
|
||||
({ __scopeCheckbox, ...props }, forwardedRef) => {
|
||||
const {
|
||||
control,
|
||||
hasConsumerStoppedPropagationRef,
|
||||
checked,
|
||||
defaultChecked,
|
||||
required,
|
||||
disabled,
|
||||
name,
|
||||
value,
|
||||
form,
|
||||
bubbleInput,
|
||||
setBubbleInput
|
||||
} = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
|
||||
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, setBubbleInput);
|
||||
const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
|
||||
const controlSize = (0, import_react_use_size.useSize)(control);
|
||||
React.useEffect(() => {
|
||||
const input = bubbleInput;
|
||||
if (!input) return;
|
||||
const inputProto = window.HTMLInputElement.prototype;
|
||||
const descriptor = Object.getOwnPropertyDescriptor(
|
||||
inputProto,
|
||||
"checked"
|
||||
);
|
||||
const setChecked = descriptor.set;
|
||||
const bubbles = !hasConsumerStoppedPropagationRef.current;
|
||||
if (prevChecked !== checked && setChecked) {
|
||||
const event = new Event("click", { bubbles });
|
||||
input.indeterminate = isIndeterminate(checked);
|
||||
setChecked.call(input, isIndeterminate(checked) ? false : checked);
|
||||
input.dispatchEvent(event);
|
||||
}
|
||||
}, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
|
||||
const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
||||
import_react_primitive.Primitive.input,
|
||||
{
|
||||
type: "checkbox",
|
||||
"aria-hidden": true,
|
||||
defaultChecked: defaultChecked ?? defaultCheckedRef.current,
|
||||
required,
|
||||
disabled,
|
||||
name,
|
||||
value,
|
||||
form,
|
||||
...props,
|
||||
tabIndex: -1,
|
||||
ref: composedRefs,
|
||||
style: {
|
||||
...props.style,
|
||||
...controlSize,
|
||||
position: "absolute",
|
||||
pointerEvents: "none",
|
||||
opacity: 0,
|
||||
margin: 0,
|
||||
// We transform because the input is absolutely positioned but we have
|
||||
// rendered it **after** the button. This pulls it back to sit on top
|
||||
// of the button.
|
||||
transform: "translateX(-100%)"
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
||||
function isFunction(value) {
|
||||
return typeof value === "function";
|
||||
}
|
||||
function isIndeterminate(checked) {
|
||||
return checked === "indeterminate";
|
||||
}
|
||||
function getState(checked) {
|
||||
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
7
frontend/node_modules/@radix-ui/react-checkbox/dist/index.js.map
generated
vendored
Normal file
7
frontend/node_modules/@radix-ui/react-checkbox/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
284
frontend/node_modules/@radix-ui/react-checkbox/dist/index.mjs
generated
vendored
Normal file
284
frontend/node_modules/@radix-ui/react-checkbox/dist/index.mjs
generated
vendored
Normal file
@ -0,0 +1,284 @@
|
||||
"use client";
|
||||
|
||||
// src/checkbox.tsx
|
||||
import * as React from "react";
|
||||
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
||||
import { createContextScope } from "@radix-ui/react-context";
|
||||
import { composeEventHandlers } from "@radix-ui/primitive";
|
||||
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
||||
import { usePrevious } from "@radix-ui/react-use-previous";
|
||||
import { useSize } from "@radix-ui/react-use-size";
|
||||
import { Presence } from "@radix-ui/react-presence";
|
||||
import { Primitive } from "@radix-ui/react-primitive";
|
||||
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
||||
var CHECKBOX_NAME = "Checkbox";
|
||||
var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
|
||||
var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
|
||||
function CheckboxProvider(props) {
|
||||
const {
|
||||
__scopeCheckbox,
|
||||
checked: checkedProp,
|
||||
children,
|
||||
defaultChecked,
|
||||
disabled,
|
||||
form,
|
||||
name,
|
||||
onCheckedChange,
|
||||
required,
|
||||
value = "on",
|
||||
// @ts-expect-error
|
||||
internal_do_not_use_render
|
||||
} = props;
|
||||
const [checked, setChecked] = useControllableState({
|
||||
prop: checkedProp,
|
||||
defaultProp: defaultChecked ?? false,
|
||||
onChange: onCheckedChange,
|
||||
caller: CHECKBOX_NAME
|
||||
});
|
||||
const [control, setControl] = React.useState(null);
|
||||
const [bubbleInput, setBubbleInput] = React.useState(null);
|
||||
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
||||
const isFormControl = control ? !!form || !!control.closest("form") : (
|
||||
// We set this to true by default so that events bubble to forms without JS (SSR)
|
||||
true
|
||||
);
|
||||
const context = {
|
||||
checked,
|
||||
disabled,
|
||||
setChecked,
|
||||
control,
|
||||
setControl,
|
||||
name,
|
||||
form,
|
||||
value,
|
||||
hasConsumerStoppedPropagationRef,
|
||||
required,
|
||||
defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
|
||||
isFormControl,
|
||||
bubbleInput,
|
||||
setBubbleInput
|
||||
};
|
||||
return /* @__PURE__ */ jsx(
|
||||
CheckboxProviderImpl,
|
||||
{
|
||||
scope: __scopeCheckbox,
|
||||
...context,
|
||||
children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
||||
}
|
||||
);
|
||||
}
|
||||
var TRIGGER_NAME = "CheckboxTrigger";
|
||||
var CheckboxTrigger = React.forwardRef(
|
||||
({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
|
||||
const {
|
||||
control,
|
||||
value,
|
||||
disabled,
|
||||
checked,
|
||||
required,
|
||||
setControl,
|
||||
setChecked,
|
||||
hasConsumerStoppedPropagationRef,
|
||||
isFormControl,
|
||||
bubbleInput
|
||||
} = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
|
||||
const composedRefs = useComposedRefs(forwardedRef, setControl);
|
||||
const initialCheckedStateRef = React.useRef(checked);
|
||||
React.useEffect(() => {
|
||||
const form = control?.form;
|
||||
if (form) {
|
||||
const reset = () => setChecked(initialCheckedStateRef.current);
|
||||
form.addEventListener("reset", reset);
|
||||
return () => form.removeEventListener("reset", reset);
|
||||
}
|
||||
}, [control, setChecked]);
|
||||
return /* @__PURE__ */ jsx(
|
||||
Primitive.button,
|
||||
{
|
||||
type: "button",
|
||||
role: "checkbox",
|
||||
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
||||
"aria-required": required,
|
||||
"data-state": getState(checked),
|
||||
"data-disabled": disabled ? "" : void 0,
|
||||
disabled,
|
||||
value,
|
||||
...checkboxProps,
|
||||
ref: composedRefs,
|
||||
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
||||
if (event.key === "Enter") event.preventDefault();
|
||||
}),
|
||||
onClick: composeEventHandlers(onClick, (event) => {
|
||||
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
|
||||
if (bubbleInput && isFormControl) {
|
||||
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
||||
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
||||
}
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
CheckboxTrigger.displayName = TRIGGER_NAME;
|
||||
var Checkbox = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const {
|
||||
__scopeCheckbox,
|
||||
name,
|
||||
checked,
|
||||
defaultChecked,
|
||||
required,
|
||||
disabled,
|
||||
value,
|
||||
onCheckedChange,
|
||||
form,
|
||||
...checkboxProps
|
||||
} = props;
|
||||
return /* @__PURE__ */ jsx(
|
||||
CheckboxProvider,
|
||||
{
|
||||
__scopeCheckbox,
|
||||
checked,
|
||||
defaultChecked,
|
||||
disabled,
|
||||
required,
|
||||
onCheckedChange,
|
||||
name,
|
||||
form,
|
||||
value,
|
||||
internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
||||
/* @__PURE__ */ jsx(
|
||||
CheckboxTrigger,
|
||||
{
|
||||
...checkboxProps,
|
||||
ref: forwardedRef,
|
||||
__scopeCheckbox
|
||||
}
|
||||
),
|
||||
isFormControl && /* @__PURE__ */ jsx(
|
||||
CheckboxBubbleInput,
|
||||
{
|
||||
__scopeCheckbox
|
||||
}
|
||||
)
|
||||
] })
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
Checkbox.displayName = CHECKBOX_NAME;
|
||||
var INDICATOR_NAME = "CheckboxIndicator";
|
||||
var CheckboxIndicator = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
|
||||
const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
|
||||
return /* @__PURE__ */ jsx(
|
||||
Presence,
|
||||
{
|
||||
present: forceMount || isIndeterminate(context.checked) || context.checked === true,
|
||||
children: /* @__PURE__ */ jsx(
|
||||
Primitive.span,
|
||||
{
|
||||
"data-state": getState(context.checked),
|
||||
"data-disabled": context.disabled ? "" : void 0,
|
||||
...indicatorProps,
|
||||
ref: forwardedRef,
|
||||
style: { pointerEvents: "none", ...props.style }
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
CheckboxIndicator.displayName = INDICATOR_NAME;
|
||||
var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
|
||||
var CheckboxBubbleInput = React.forwardRef(
|
||||
({ __scopeCheckbox, ...props }, forwardedRef) => {
|
||||
const {
|
||||
control,
|
||||
hasConsumerStoppedPropagationRef,
|
||||
checked,
|
||||
defaultChecked,
|
||||
required,
|
||||
disabled,
|
||||
name,
|
||||
value,
|
||||
form,
|
||||
bubbleInput,
|
||||
setBubbleInput
|
||||
} = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
|
||||
const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
|
||||
const prevChecked = usePrevious(checked);
|
||||
const controlSize = useSize(control);
|
||||
React.useEffect(() => {
|
||||
const input = bubbleInput;
|
||||
if (!input) return;
|
||||
const inputProto = window.HTMLInputElement.prototype;
|
||||
const descriptor = Object.getOwnPropertyDescriptor(
|
||||
inputProto,
|
||||
"checked"
|
||||
);
|
||||
const setChecked = descriptor.set;
|
||||
const bubbles = !hasConsumerStoppedPropagationRef.current;
|
||||
if (prevChecked !== checked && setChecked) {
|
||||
const event = new Event("click", { bubbles });
|
||||
input.indeterminate = isIndeterminate(checked);
|
||||
setChecked.call(input, isIndeterminate(checked) ? false : checked);
|
||||
input.dispatchEvent(event);
|
||||
}
|
||||
}, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
|
||||
const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
|
||||
return /* @__PURE__ */ jsx(
|
||||
Primitive.input,
|
||||
{
|
||||
type: "checkbox",
|
||||
"aria-hidden": true,
|
||||
defaultChecked: defaultChecked ?? defaultCheckedRef.current,
|
||||
required,
|
||||
disabled,
|
||||
name,
|
||||
value,
|
||||
form,
|
||||
...props,
|
||||
tabIndex: -1,
|
||||
ref: composedRefs,
|
||||
style: {
|
||||
...props.style,
|
||||
...controlSize,
|
||||
position: "absolute",
|
||||
pointerEvents: "none",
|
||||
opacity: 0,
|
||||
margin: 0,
|
||||
// We transform because the input is absolutely positioned but we have
|
||||
// rendered it **after** the button. This pulls it back to sit on top
|
||||
// of the button.
|
||||
transform: "translateX(-100%)"
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
||||
function isFunction(value) {
|
||||
return typeof value === "function";
|
||||
}
|
||||
function isIndeterminate(checked) {
|
||||
return checked === "indeterminate";
|
||||
}
|
||||
function getState(checked) {
|
||||
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
||||
}
|
||||
export {
|
||||
Checkbox,
|
||||
CheckboxIndicator,
|
||||
CheckboxIndicator as Indicator,
|
||||
Checkbox as Root,
|
||||
createCheckboxScope,
|
||||
CheckboxBubbleInput as unstable_BubbleInput,
|
||||
CheckboxBubbleInput as unstable_CheckboxBubbleInput,
|
||||
CheckboxProvider as unstable_CheckboxProvider,
|
||||
CheckboxTrigger as unstable_CheckboxTrigger,
|
||||
CheckboxProvider as unstable_Provider,
|
||||
CheckboxTrigger as unstable_Trigger
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
7
frontend/node_modules/@radix-ui/react-checkbox/dist/index.mjs.map
generated
vendored
Normal file
7
frontend/node_modules/@radix-ui/react-checkbox/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user