Files
NapCatQQ/.pnpm-store/v3/files/57/9c517701934afeea796ec947ae11e842503f59708fd66eff116305bf84efcff2912eba8a7208b44da91adfc57361ca984ddb3a789d278db74ec9f1d13f1e4b
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

234 lines
8.0 KiB
Plaintext

"use client";
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/checkbox-group.tsx
var checkbox_group_exports = {};
__export(checkbox_group_exports, {
default: () => checkbox_group_default
});
module.exports = __toCommonJS(checkbox_group_exports);
var import_system2 = require("@heroui/system");
// src/checkbox-group-context.ts
var import_react_utils = require("@heroui/react-utils");
var [CheckboxGroupProvider, useCheckboxGroupContext] = (0, import_react_utils.createContext)({
name: "CheckboxGroupContext",
strict: false
});
// src/use-checkbox-group.ts
var import_system = require("@heroui/system");
var import_react = require("react");
var import_theme = require("@heroui/theme");
var import_checkbox = require("@react-aria/checkbox");
var import_checkbox2 = require("@react-stately/checkbox");
var import_react_utils2 = require("@heroui/react-utils");
var import_shared_utils = require("@heroui/shared-utils");
var import_form = require("@heroui/form");
function useCheckboxGroup(props) {
var _a, _b;
const globalContext = (0, import_system.useProviderContext)();
const { validationBehavior: formValidationBehavior } = (0, import_form.useSlottedContext)(import_form.FormContext) || {};
const {
as,
ref,
classNames,
children,
label,
radius,
value,
name,
defaultValue,
isInvalid: isInvalidProp,
validationState,
size = "md",
color = "primary",
orientation = "vertical",
lineThrough = false,
isDisabled = false,
validationBehavior = (_a = formValidationBehavior != null ? formValidationBehavior : globalContext == null ? void 0 : globalContext.validationBehavior) != null ? _a : "native",
disableAnimation = (_b = globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false,
isReadOnly,
isRequired,
onValueChange,
description,
errorMessage,
className,
...otherProps
} = props;
const Component = as || "div";
const shouldFilterDOMProps = typeof Component === "string";
const domRef = (0, import_react_utils2.useDOMRef)(ref);
const checkboxGroupProps = (0, import_react.useMemo)(() => {
return {
...otherProps,
value,
name,
"aria-label": (0, import_shared_utils.safeAriaLabel)(otherProps["aria-label"], label),
defaultValue,
isRequired,
isReadOnly,
orientation,
validationBehavior,
isInvalid: validationState === "invalid" || isInvalidProp,
onChange: (0, import_shared_utils.chain)(props.onChange, onValueChange)
};
}, [
value,
name,
label,
defaultValue,
isRequired,
isReadOnly,
orientation,
onValueChange,
isInvalidProp,
validationState,
validationBehavior,
otherProps["aria-label"],
otherProps
]);
const groupState = (0, import_checkbox2.useCheckboxGroupState)(checkboxGroupProps);
const {
labelProps,
groupProps,
descriptionProps,
errorMessageProps,
validationErrors,
validationDetails
} = (0, import_checkbox.useCheckboxGroup)(checkboxGroupProps, groupState);
const context = (0, import_react.useMemo)(
() => ({
size,
color,
radius,
lineThrough,
isInvalid: groupState.isInvalid,
isDisabled,
disableAnimation,
validationBehavior,
groupState
}),
[
size,
color,
radius,
lineThrough,
isDisabled,
disableAnimation,
validationBehavior,
groupState.value,
groupState.isDisabled,
groupState.isReadOnly,
groupState.isInvalid,
groupState.isSelected
]
);
const slots = (0, import_react.useMemo)(
() => (0, import_theme.checkboxGroup)({ isRequired, isInvalid: groupState.isInvalid, disableAnimation }),
[isRequired, groupState.isInvalid, , disableAnimation]
);
const baseStyles = (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className);
const getGroupProps = (0, import_react.useCallback)(() => {
return {
ref: domRef,
className: slots.base({ class: baseStyles }),
...(0, import_shared_utils.mergeProps)(
groupProps,
(0, import_react_utils2.filterDOMProps)(otherProps, {
enabled: shouldFilterDOMProps
})
)
};
}, [slots, domRef, baseStyles, groupProps, otherProps]);
const getLabelProps = (0, import_react.useCallback)(() => {
return {
className: slots.label({ class: classNames == null ? void 0 : classNames.label }),
...labelProps
};
}, [slots, labelProps, classNames == null ? void 0 : classNames.label]);
const getWrapperProps = (0, import_react.useCallback)(() => {
return {
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
role: "presentation",
"data-orientation": orientation
};
}, [slots, orientation, classNames == null ? void 0 : classNames.wrapper]);
const getDescriptionProps = (0, import_react.useCallback)(
(props2 = {}) => {
return {
...props2,
...descriptionProps,
className: slots.description({ class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.description, props2 == null ? void 0 : props2.className) })
};
},
[slots, descriptionProps, classNames == null ? void 0 : classNames.description]
);
const getErrorMessageProps = (0, import_react.useCallback)(
(props2 = {}) => {
return {
...props2,
...errorMessageProps,
className: slots.errorMessage({ class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.errorMessage, props2 == null ? void 0 : props2.className) })
};
},
[slots, errorMessageProps, classNames == null ? void 0 : classNames.errorMessage]
);
return {
Component,
children,
label,
context,
description,
isInvalid: groupState.isInvalid,
errorMessage: typeof errorMessage === "function" ? errorMessage({ isInvalid: groupState.isInvalid, validationErrors, validationDetails }) : errorMessage || (validationErrors == null ? void 0 : validationErrors.join(" ")),
getGroupProps,
getLabelProps,
getWrapperProps,
getDescriptionProps,
getErrorMessageProps
};
}
// src/checkbox-group.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var CheckboxGroup = (0, import_system2.forwardRef)((props, ref) => {
const {
children,
context,
label,
description,
isInvalid,
errorMessage,
getGroupProps,
getLabelProps,
getWrapperProps,
getDescriptionProps,
getErrorMessageProps
} = useCheckboxGroup({ ...props, ref });
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...getGroupProps(), children: [
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ...getLabelProps(), children: label }),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...getWrapperProps(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxGroupProvider, { value: context, children }) }),
isInvalid && errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...getErrorMessageProps(), children: errorMessage }) : description ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...getDescriptionProps(), children: description }) : null
] });
});
CheckboxGroup.displayName = "HeroUI.CheckboxGroup";
var checkbox_group_default = CheckboxGroup;