Files
NapCatQQ/.pnpm-store/v3/files/98/537e8e3eef9841e07a187a631fae1197f1a035baef518fe68ea5157322e2a82cc3d1354790d94e915f082b32861b05b4d16283d844832190ee784f6d40d232
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

82 lines
3.8 KiB
Plaintext

var $ar5WQ$react = require("react");
var $ar5WQ$reactariautils = require("@react-aria/utils");
var $ar5WQ$reactstatelyform = require("@react-stately/form");
var $ar5WQ$reactariaform = require("@react-aria/form");
var $ar5WQ$reactariainteractions = require("@react-aria/interactions");
var $ar5WQ$reactariatoggle = require("@react-aria/toggle");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "useCheckbox", () => $468c774d7db917b7$export$e375f10ce42261c5);
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $468c774d7db917b7$export$e375f10ce42261c5(props, state, inputRef) {
// Create validation state here because it doesn't make sense to add to general useToggleState.
let validationState = (0, $ar5WQ$reactstatelyform.useFormValidationState)({
...props,
value: state.isSelected
});
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = validationState.displayValidation;
let { labelProps: labelProps, inputProps: inputProps, isSelected: isSelected, isPressed: isPressed, isDisabled: isDisabled, isReadOnly: isReadOnly } = (0, $ar5WQ$reactariatoggle.useToggle)({
...props,
isInvalid: isInvalid
}, state, inputRef);
(0, $ar5WQ$reactariaform.useFormValidation)(props, validationState, inputRef);
let { isIndeterminate: isIndeterminate, isRequired: isRequired, validationBehavior: validationBehavior = 'aria' } = props;
(0, $ar5WQ$react.useEffect)(()=>{
// indeterminate is a property, but it can only be set via javascript
// https://css-tricks.com/indeterminate-checkboxes/
if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
});
// Reset validation state on label press for checkbox with a hidden input.
let { pressProps: pressProps } = (0, $ar5WQ$reactariainteractions.usePress)({
isDisabled: isDisabled || isReadOnly,
onPress () {
// @ts-expect-error
let { [(0, $ar5WQ$reactstatelyform.privateValidationStateProp)]: groupValidationState } = props;
let { commitValidation: commitValidation } = groupValidationState ? groupValidationState : validationState;
commitValidation();
}
});
return {
labelProps: (0, $ar5WQ$reactariautils.mergeProps)(labelProps, pressProps, (0, $ar5WQ$react.useMemo)(()=>({
// Prevent label from being focused when mouse down on it.
// Note, this does not prevent the input from being focused in the `click` event.
onMouseDown: (e)=>e.preventDefault()
}), [])),
inputProps: {
...inputProps,
checked: isSelected,
'aria-required': isRequired && validationBehavior === 'aria' || undefined,
required: isRequired && validationBehavior === 'native'
},
isSelected: isSelected,
isPressed: isPressed,
isDisabled: isDisabled,
isReadOnly: isReadOnly,
isInvalid: isInvalid,
validationErrors: validationErrors,
validationDetails: validationDetails
};
}
//# sourceMappingURL=useCheckbox.main.js.map