Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F118968579
FormCheck.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jun 23, 09:34
Size
2 KB
Mime Type
text/x-java
Expires
Wed, Jun 25, 09:34 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
26951038
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
FormCheck.js
View Options
import classNames from 'classnames';
import * as React from 'react';
import { useContext, useMemo } from 'react';
import Feedback from './Feedback';
import FormCheckInput from './FormCheckInput';
import FormCheckLabel from './FormCheckLabel';
import FormContext from './FormContext';
import { useBootstrapPrefix } from './ThemeProvider';
import { hasChildOfType } from './ElementChildren';
import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const FormCheck = /*#__PURE__*/React.forwardRef(({
id,
bsPrefix,
bsSwitchPrefix,
inline = false,
reverse = false,
disabled = false,
isValid = false,
isInvalid = false,
feedbackTooltip = false,
feedback,
feedbackType,
className,
style,
title = '',
type = 'checkbox',
label,
children,
// Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
as = 'input',
...props
}, ref) => {
bsPrefix = useBootstrapPrefix(bsPrefix, 'form-check');
bsSwitchPrefix = useBootstrapPrefix(bsSwitchPrefix, 'form-switch');
const {
controlId
} = useContext(FormContext);
const innerFormContext = useMemo(() => ({
controlId: id || controlId
}), [controlId, id]);
const hasLabel = !children && label != null && label !== false || hasChildOfType(children, FormCheckLabel);
const input = /*#__PURE__*/_jsx(FormCheckInput, {
...props,
type: type === 'switch' ? 'checkbox' : type,
ref: ref,
isValid: isValid,
isInvalid: isInvalid,
disabled: disabled,
as: as
});
return /*#__PURE__*/_jsx(FormContext.Provider, {
value: innerFormContext,
children: /*#__PURE__*/_jsx("div", {
style: style,
className: classNames(className, hasLabel && bsPrefix, inline && `${bsPrefix}-inline`, reverse && `${bsPrefix}-reverse`, type === 'switch' && bsSwitchPrefix),
children: children || /*#__PURE__*/_jsxs(_Fragment, {
children: [input, hasLabel && /*#__PURE__*/_jsx(FormCheckLabel, {
title: title,
children: label
}), feedback && /*#__PURE__*/_jsx(Feedback, {
type: feedbackType,
tooltip: feedbackTooltip,
children: feedback
})]
})
})
});
});
FormCheck.displayName = 'FormCheck';
export default Object.assign(FormCheck, {
Input: FormCheckInput,
Label: FormCheckLabel
});
Event Timeline
Log In to Comment