@purpurds/checkbox 7.5.1 → 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/dist/LICENSE.txt +11 -4
- package/dist/checkbox.cjs.js +11 -7
- package/dist/checkbox.cjs.js.map +1 -1
- package/dist/checkbox.d.ts +8 -0
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.es.js +518 -444
- package/dist/checkbox.es.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +7 -6
- package/src/checkbox.module.scss +6 -2
- package/src/checkbox.stories.tsx +3 -0
- package/src/checkbox.test.tsx +10 -0
- package/src/checkbox.tsx +30 -13
package/src/checkbox.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
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
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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`}>
|