@purpurds/checkbox 7.5.0 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/checkbox.tsx CHANGED
@@ -1,5 +1,6 @@
1
- import React, { ForwardedRef, forwardRef } from "react";
1
+ import React, { type ForwardedRef, forwardRef } from "react";
2
2
  import { FieldErrorText } from "@purpurds/field-error-text";
3
+ import { FieldHelperText } from "@purpurds/field-helper-text";
3
4
  import { Icon } from "@purpurds/icon";
4
5
  import { checkmarkBold } from "@purpurds/icon/assets/checkmark-bold";
5
6
  import { minusBold } from "@purpurds/icon/assets/minus-bold";
@@ -54,6 +55,10 @@ export type CheckboxProps = Omit<React.HTMLAttributes<HTMLButtonElement>, "onCha
54
55
  * The name of the checkbox. Submitted with its owning form as part of a name/value pair.
55
56
  * */
56
57
  name?: string;
58
+ /**
59
+ * The helper text displayed below the checkbox.
60
+ */
61
+ helperText?: string;
57
62
  /**
58
63
  * Event handler called when the checked state of the checkbox changes.
59
64
  * */
@@ -78,6 +83,7 @@ const CheckboxComponent = (
78
83
  error = false,
79
84
  errorText,
80
85
  label,
86
+ helperText,
81
87
  onChange,
82
88
  ...props
83
89
  }: CheckboxProps,
@@ -121,19 +127,30 @@ const CheckboxComponent = (
121
127
  </RadixCheckbox.Indicator>
122
128
  </span>
123
129
  </RadixCheckbox.Root>
124
- {label && (
125
- <Label
126
- htmlFor={props.id}
127
- data-testid={dataTestId && `${dataTestId}-label`}
128
- disabled={props.disabled}
129
- className={cx(`${rootClassName}__label`)}
130
- >
131
- <Paragraph variant="paragraph-100" disabled={props.disabled}>
132
- {props.required && <span aria-hidden>{"* "}</span>}
133
- {label}
134
- </Paragraph>
135
- </Label>
136
- )}
130
+ <span className={cx(`${rootClassName}__label-container`)}>
131
+ {label && (
132
+ <Label
133
+ htmlFor={props.id}
134
+ data-testid={dataTestId && `${dataTestId}-label`}
135
+ disabled={props.disabled}
136
+ >
137
+ <Paragraph variant="paragraph-100" disabled={props.disabled}>
138
+ {props.required && <span aria-hidden>{"* "}</span>}
139
+ {label}
140
+ </Paragraph>
141
+ </Label>
142
+ )}
143
+ {helperText && (
144
+ <FieldHelperText
145
+ className={cx(`${rootClassName}__helper`)}
146
+ data-testid={dataTestId && `${dataTestId}-helper-text`}
147
+ disabled={props.disabled}
148
+ id={`${props.id}-helper-text`}
149
+ >
150
+ {helperText}
151
+ </FieldHelperText>
152
+ )}
153
+ </span>
137
154
  </div>
138
155
  {isError && (
139
156
  <FieldErrorText data-testid={dataTestId && `${dataTestId}-error-text`}>