DIR : /home/kozerus/public_html/cropex/node/node_modules/@radix-ui/react-checkbox/dist/index.mjs
/home/kozerus/public_html/cropex/node/node_modules/@radix-ui/react-checkbox/dist
"use client";
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// 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 { 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 [userInteractionCount, onUserInteraction] = React.useReducer(
(count) => count + 1,
0
);
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,
userInteractionCount,
onUserInteraction,
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
}
);
}
__name(CheckboxProvider, "CheckboxProvider");
var TRIGGER_NAME = "CheckboxTrigger";
var CheckboxTrigger = /* @__PURE__ */ React.forwardRef(
/* @__PURE__ */ __name(function CheckboxTrigger2({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) {
const {
control,
value,
disabled,
checked,
required,
setControl,
setChecked,
hasConsumerStoppedPropagationRef,
onUserInteraction,
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 = /* @__PURE__ */ __name(() => setChecked(initialCheckedStateRef.current), "reset");
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) => {
onUserInteraction();
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
if (bubbleInput && isFormControl) {
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
}
})
}
);
}, "CheckboxTrigger")
);
var Checkbox = /* @__PURE__ */ React.forwardRef(
// blank line to reduce diff noise
/* @__PURE__ */ __name(function Checkbox2(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")
);
var INDICATOR_NAME = "CheckboxIndicator";
var CheckboxIndicator = /* @__PURE__ */ React.forwardRef(
// blank line to reduce diff noise
/* @__PURE__ */ __name(function CheckboxIndicator2(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")
);
var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
var CheckboxBubbleInput = /* @__PURE__ */ React.forwardRef(
// blank line to reduce diff noise
/* @__PURE__ */ __name(function CheckboxBubbleInput2({ __scopeCheckbox, onClick, ...props }, forwardedRef) {
const {
control,
hasConsumerStoppedPropagationRef,
userInteractionCount,
checked,
defaultChecked,
required,
disabled,
name,
value,
form,
bubbleInput,
setBubbleInput
} = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
const controlSize = useSize(control);
const shouldStopClickPropagationRef = React.useRef(false);
const prevCheckedRef = React.useRef(checked);
const prevUserInteractionCountRef = React.useRef(userInteractionCount);
React.useEffect(() => {
const input = bubbleInput;
if (!input) return;
const inputProto = window.HTMLInputElement.prototype;
const descriptor = Object.getOwnPropertyDescriptor(
inputProto,
"checked"
);
const setChecked = descriptor.set;
const isUserInteraction = userInteractionCount !== prevUserInteractionCountRef.current;
prevUserInteractionCountRef.current = userInteractionCount;
const checkedChanged = prevCheckedRef.current !== checked;
prevCheckedRef.current = checked;
const bubbles = !(isUserInteraction && hasConsumerStoppedPropagationRef.current);
if (checkedChanged && setChecked) {
shouldStopClickPropagationRef.current = !isUserInteraction;
const event = new Event("click", { bubbles });
input.indeterminate = isIndeterminate(checked);
setChecked.call(input, isIndeterminate(checked) ? false : checked);
input.dispatchEvent(event);
shouldStopClickPropagationRef.current = false;
}
}, [bubbleInput, checked, hasConsumerStoppedPropagationRef, userInteractionCount]);
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,
onClick: composeEventHandlers(onClick, (event) => {
if (shouldStopClickPropagationRef.current) {
event.stopPropagation();
}
}),
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")
);
function isFunction(value) {
return typeof value === "function";
}
__name(isFunction, "isFunction");
function isIndeterminate(checked) {
return checked === "indeterminate";
}
__name(isIndeterminate, "isIndeterminate");
function getState(checked) {
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
}
__name(getState, "getState");
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
//
koh5_pano
Drag mouse to navigate.
Navigation
- Left/Right Mouse drag: Changes camera heading.
- Up/Sown Mouse drag: Changes camera pitch.
- Scroll wheel: Changes camera field of view.
- I-Key: Displays Info panel with canvas size, image size and FPS.
17.Aug.2010, Martin Wengenmayer