UNPKG

@rws-air/webcomponents

Version:
71 lines 7.89 kB
import { CheckboxProps as MUICheckboxProps } from '@mui/material/Checkbox'; import { FormControlLabelProps } from '@mui/material/FormControlLabel'; import React, { ChangeEvent } from 'react'; import { TooltipProps } from '../../Tooltip'; /** * Properties that can be passed to the Checkbox component * @extends [Checkbox API](https://material-ui.com/api/checkbox/#checkbox-api) */ export interface CheckboxProps extends MUICheckboxProps { /** * The name for this specific checkbox * * @remarks * It is recommend that this is different from the name given to the encapsulating FieldArray */ name: string; /** The label to display next to the checkbox */ label: string; /** A tracker for the current value of the checkbox */ value: string; /** The text to display inside the Tooltip that pops up when hovering over the checkbox or the label */ tooltipText: string; /** * Whether the checkbox should be in a checked state * @default false */ checked?: boolean; /** Data-QA to send to the checkbox for testing */ 'data-qa'?: string; /** Props applied to the [Tooltip](https://rws-nl.github.io/air-node-packages/modules/_rws_air_webcomponents.html#tooltip-1) component */ TooltipProps?: TooltipProps; /** Props applied to the [FormControlLabel](https://material-ui.com/api/form-control-label/#formcontrollabel-api) component */ FormControlLabelProps?: FormControlLabelProps; } export declare type CheckboxChangeEvent = ChangeEvent<{ checked: boolean; }>; /** * Constructs a Checkbox with formik validation * @param props Props to pass to the Checkbox component * @example * ```jsx * <FieldArray * name='fieldArrayName' * render={arrayHelpers => * arrayWithStrings((entry, index) => ( * <Grid item xs={4} key={index}> * <Checkbox * name={entry} * value={entry} * label={t(`form.fieldArrayName.labels.${entry}`)} * tooltipText={t(`form.fieldArrayName.tooltips.${entry}`)} * data-qa={`checkbox-${entry.toLowerCase()}`} * checked={values['fieldArrayName'].includes(entry)} * onChange={(e: CheckboxChangeEvent) => { * if (e.target.checked) { * arrayHelpers.push(entry); * } else { * const idx = values['fieldArrayName'].indexOf(entry); * arrayHelpers.remove(idx); * } * }} * /> * </Grid> * )) * } * /> * ``` */ export declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "classes" | "checkedIcon" | "color" | "icon" | "className" | "style" | "form" | "label" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "key" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "value" | "checked" | "disableFocusRipple" | "edge" | "inputProps" | "inputRef" | "readOnly" | "required" | "tooltipText" | "TooltipProps" | "FormControlLabelProps" | "data-qa" | "indeterminate" | "indeterminateIcon" | "size"> & React.RefAttributes<HTMLButtonElement>>; //# sourceMappingURL=index.d.ts.map