@fpkit/acss 3.6.0 → 3.8.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/libs/{chunk-URBGDUFN.cjs → chunk-75YQDONV.cjs} +3 -3
- package/libs/chunk-AOFQDQVS.cjs +17 -0
- package/libs/chunk-AOFQDQVS.cjs.map +1 -0
- package/libs/{chunk-ZF6Y7W57.js → chunk-G3TFKMWB.js} +2 -2
- package/libs/chunk-Q7OAQLUT.js +10 -0
- package/libs/chunk-Q7OAQLUT.js.map +1 -0
- package/libs/components/checkbox/checkbox.css +1 -0
- package/libs/components/checkbox/checkbox.css.map +1 -0
- package/libs/components/checkbox/checkbox.min.css +3 -0
- package/libs/components/dialog/dialog.cjs +4 -4
- package/libs/components/dialog/dialog.js +2 -2
- package/libs/components/heading/heading.cjs +2 -2
- package/libs/components/heading/heading.d.cts +1 -1
- package/libs/components/heading/heading.d.ts +1 -1
- package/libs/components/heading/heading.js +1 -1
- package/libs/components/title/title.css +1 -0
- package/libs/components/title/title.css.map +1 -0
- package/libs/components/title/title.min.css +3 -0
- package/libs/{heading-7446cb46.d.ts → heading-81eef89a.d.ts} +42 -0
- package/libs/index.cjs +32 -31
- package/libs/index.cjs.map +1 -1
- package/libs/index.css +1 -1
- package/libs/index.css.map +1 -1
- package/libs/index.d.cts +357 -2
- package/libs/index.d.ts +357 -2
- package/libs/index.js +7 -7
- package/libs/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/box/box.stories.tsx +1 -1
- package/src/components/checkbox/README.mdx +263 -0
- package/src/components/checkbox/STYLES.mdx +434 -0
- package/src/components/checkbox/checkbox.scss +432 -0
- package/src/components/checkbox/checkbox.stories.tsx +607 -0
- package/src/components/checkbox/checkbox.test.tsx +535 -0
- package/src/components/checkbox/checkbox.tsx +575 -0
- package/src/components/cluster/cluster.stories.tsx +1 -1
- package/src/components/col/README.mdx +233 -9
- package/src/components/col/STYLES.mdx +1380 -0
- package/src/components/col/col.stories.tsx +1 -1
- package/src/components/form/README.mdx +173 -146
- package/src/components/grid/grid.stories.tsx +130 -35
- package/src/components/row/row.stories.tsx +1 -1
- package/src/components/stack/stack.stories.tsx +219 -60
- package/src/components/title/README.mdx +87 -1
- package/src/components/title/STYLES.mdx +501 -0
- package/src/components/title/title.scss +51 -0
- package/src/components/title/title.stories.tsx +158 -0
- package/src/components/title/title.test.tsx +113 -0
- package/src/components/title/title.tsx +53 -1
- package/src/index.scss +2 -0
- package/src/index.ts +7 -0
- package/src/sass/_columns.scss +13 -9
- package/src/sass/columns.stories.tsx +434 -10
- package/src/styles/checkbox/checkbox.css +372 -0
- package/src/styles/checkbox/checkbox.css.map +1 -0
- package/src/styles/index.css +445 -0
- package/src/styles/index.css.map +1 -1
- package/src/styles/title/title.css +75 -0
- package/src/styles/title/title.css.map +1 -0
- package/libs/chunk-2C3YLBWP.cjs +0 -17
- package/libs/chunk-2C3YLBWP.cjs.map +0 -1
- package/libs/chunk-KDMX3FAW.js +0 -10
- package/libs/chunk-KDMX3FAW.js.map +0 -1
- /package/libs/{chunk-URBGDUFN.cjs.map → chunk-75YQDONV.cjs.map} +0 -0
- /package/libs/{chunk-ZF6Y7W57.js.map → chunk-G3TFKMWB.js.map} +0 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@fpkit/acss",
|
|
3
3
|
"description": "A lightweight React UI library for building modern and accessible components that leverage CSS custom properties for reactive Styles.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.8.0",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=22.12.0",
|
|
8
8
|
"npm": ">=8.0.0"
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"publishConfig": {
|
|
127
127
|
"access": "public"
|
|
128
128
|
},
|
|
129
|
-
"gitHead": "
|
|
129
|
+
"gitHead": "28c554debc03c30107f61b62fd70961861b322ea"
|
|
130
130
|
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
import * as CheckboxStories from "./checkbox.stories";
|
|
3
|
+
|
|
4
|
+
<Meta of={CheckboxStories} />
|
|
5
|
+
|
|
6
|
+
# Checkbox
|
|
7
|
+
|
|
8
|
+
Accessible checkbox component with size and color variants, validation support,
|
|
9
|
+
and comprehensive ARIA attributes.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- ✅ **WCAG 2.1 AA Compliant** - Meets accessibility standards
|
|
14
|
+
- ✅ **Controlled & Uncontrolled** - Flexible state management
|
|
15
|
+
- ✅ **Indeterminate State** - Three-state checkbox support
|
|
16
|
+
- ✅ **Validation** - Built-in error messaging
|
|
17
|
+
- ✅ **Size Variants** - sm, md, lg
|
|
18
|
+
- ✅ **Color Variants** - primary, secondary, error, success
|
|
19
|
+
- ✅ **Keyboard Navigation** - Full keyboard support
|
|
20
|
+
- ✅ **Custom Styling** - CSS custom properties
|
|
21
|
+
|
|
22
|
+
## Basic Usage
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { Checkbox } from "@fpkit/acss";
|
|
26
|
+
|
|
27
|
+
function MyForm() {
|
|
28
|
+
return <Checkbox id="terms" label="I accept the terms and conditions" />;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Controlled Mode
|
|
33
|
+
|
|
34
|
+
Use controlled mode when you need to manage checkbox state in your component:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { useState } from "react";
|
|
38
|
+
import { Checkbox } from "@fpkit/acss";
|
|
39
|
+
|
|
40
|
+
function ControlledExample() {
|
|
41
|
+
const [checked, setChecked] = useState(false);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Checkbox
|
|
45
|
+
id="newsletter"
|
|
46
|
+
label="Subscribe to newsletter"
|
|
47
|
+
checked={checked}
|
|
48
|
+
onChange={(e) => setChecked(e.target.checked)}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Uncontrolled Mode
|
|
55
|
+
|
|
56
|
+
Use uncontrolled mode for simple forms where you read the value on submission:
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { Checkbox } from "@fpkit/acss";
|
|
60
|
+
|
|
61
|
+
function UncontrolledExample() {
|
|
62
|
+
const handleSubmit = (e) => {
|
|
63
|
+
const formData = new FormData(e.target);
|
|
64
|
+
console.log(formData.get("agree")); // "on" if checked
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<form onSubmit={handleSubmit}>
|
|
69
|
+
<Checkbox id="agree" name="agree" label="I agree" defaultChecked={true} />
|
|
70
|
+
<button type="submit">Submit</button>
|
|
71
|
+
</form>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## With Validation
|
|
77
|
+
|
|
78
|
+
Display validation errors and helper text:
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<Checkbox
|
|
82
|
+
id="required"
|
|
83
|
+
label="Required checkbox"
|
|
84
|
+
required
|
|
85
|
+
validationState="invalid"
|
|
86
|
+
errorMessage="This field is required"
|
|
87
|
+
description="You must check this box to continue"
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Indeterminate State
|
|
92
|
+
|
|
93
|
+
Use for "select all" patterns where some but not all items are selected:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import { useState } from "react";
|
|
97
|
+
import { Checkbox } from "@fpkit/acss";
|
|
98
|
+
|
|
99
|
+
function SelectAllExample() {
|
|
100
|
+
const [selectedItems, setSelectedItems] = useState([]);
|
|
101
|
+
const totalItems = 4;
|
|
102
|
+
|
|
103
|
+
const allSelected = selectedItems.length === totalItems;
|
|
104
|
+
const someSelected = selectedItems.length > 0 && !allSelected;
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<Checkbox
|
|
108
|
+
id="select-all"
|
|
109
|
+
label="Select all"
|
|
110
|
+
checked={allSelected}
|
|
111
|
+
indeterminate={someSelected}
|
|
112
|
+
onChange={(e) => {
|
|
113
|
+
if (e.target.checked) {
|
|
114
|
+
setSelectedItems([1, 2, 3, 4]);
|
|
115
|
+
} else {
|
|
116
|
+
setSelectedItems([]);
|
|
117
|
+
}
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Size Variants
|
|
125
|
+
|
|
126
|
+
Choose from three sizes:
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
<Checkbox id="sm" label="Small" size="sm" />
|
|
130
|
+
<Checkbox id="md" label="Medium (default)" size="md" />
|
|
131
|
+
<Checkbox id="lg" label="Large" size="lg" />
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Color Variants
|
|
135
|
+
|
|
136
|
+
All colors meet WCAG 2.1 AA contrast requirements:
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
<Checkbox id="primary" label="Primary (Blue)" color="primary" />
|
|
140
|
+
<Checkbox id="secondary" label="Secondary (Gray)" color="secondary" />
|
|
141
|
+
<Checkbox id="error" label="Error (Red)" color="error" />
|
|
142
|
+
<Checkbox id="success" label="Success (Green)" color="success" />
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Label Positioning
|
|
146
|
+
|
|
147
|
+
Position labels before or after the checkbox:
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
<Checkbox id="left" label="Label on left" labelPosition="left" />
|
|
151
|
+
<Checkbox id="right" label="Label on right" labelPosition="right" />
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Custom Styling
|
|
155
|
+
|
|
156
|
+
Customize appearance using CSS custom properties:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<Checkbox
|
|
160
|
+
id="custom"
|
|
161
|
+
label="Custom styled"
|
|
162
|
+
styles={{
|
|
163
|
+
"--checkbox-size": "2rem",
|
|
164
|
+
"--checkbox-checked-bg": "#7c3aed",
|
|
165
|
+
"--checkbox-radius": "0.5rem",
|
|
166
|
+
}}
|
|
167
|
+
/>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
See [STYLES.mdx](./STYLES.mdx) for complete CSS variable reference.
|
|
171
|
+
|
|
172
|
+
## Accessibility
|
|
173
|
+
|
|
174
|
+
### WCAG 2.1 AA Compliance
|
|
175
|
+
|
|
176
|
+
The Checkbox component implements multiple WCAG success criteria:
|
|
177
|
+
|
|
178
|
+
- **3.2.2 On Input (Level A)** - Checking the box doesn't cause unexpected
|
|
179
|
+
context changes
|
|
180
|
+
- **4.1.2 Name, Role, Value (Level A)** - Proper ARIA attributes communicate
|
|
181
|
+
state
|
|
182
|
+
- **1.4.3 Contrast (Minimum) (Level AA)** - All color variants meet 4.5:1
|
|
183
|
+
contrast ratio
|
|
184
|
+
- **2.4.7 Focus Visible (Level AA)** - Clear focus indicators on keyboard
|
|
185
|
+
navigation
|
|
186
|
+
|
|
187
|
+
### Keyboard Support
|
|
188
|
+
|
|
189
|
+
- **Tab** - Move focus to/from checkbox
|
|
190
|
+
- **Space** - Toggle checkbox state
|
|
191
|
+
- **Shift+Tab** - Move focus backward
|
|
192
|
+
|
|
193
|
+
### Screen Reader Support
|
|
194
|
+
|
|
195
|
+
- Checkbox state announced (checked/unchecked/indeterminate)
|
|
196
|
+
- Label text announced
|
|
197
|
+
- Description text announced via `aria-describedby`
|
|
198
|
+
- Error messages announced via `aria-errormessage`
|
|
199
|
+
- Required state announced via `aria-required`
|
|
200
|
+
- Disabled state announced via `aria-disabled`
|
|
201
|
+
|
|
202
|
+
### Best Practices
|
|
203
|
+
|
|
204
|
+
1. **Always provide labels** - Use `label` or `children` prop for accessible
|
|
205
|
+
name
|
|
206
|
+
2. **Use semantic colors** - Use `error` variant for validation failures
|
|
207
|
+
3. **Provide descriptions** - Use `description` prop for additional context
|
|
208
|
+
4. **Group related checkboxes** - Use `<fieldset>` and `<legend>` for checkbox
|
|
209
|
+
groups
|
|
210
|
+
5. **Don't mix modes** - Use either controlled or uncontrolled, not both
|
|
211
|
+
|
|
212
|
+
## Props
|
|
213
|
+
|
|
214
|
+
See TypeScript types for complete prop reference with JSDoc documentation.
|
|
215
|
+
|
|
216
|
+
### Key Props
|
|
217
|
+
|
|
218
|
+
| Prop | Type | Default | Description |
|
|
219
|
+
| ----------------- | -------------------------------------------------- | ------------ | -------------------- |
|
|
220
|
+
| `id` | `string` | **required** | Unique identifier |
|
|
221
|
+
| `label` | `ReactNode` | - | Label text |
|
|
222
|
+
| `children` | `ReactNode` | - | Alternative to label |
|
|
223
|
+
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | Size variant |
|
|
224
|
+
| `color` | `"primary" \| "secondary" \| "error" \| "success"` | `"primary"` | Color variant |
|
|
225
|
+
| `checked` | `boolean` | - | Controlled mode |
|
|
226
|
+
| `defaultChecked` | `boolean` | - | Uncontrolled mode |
|
|
227
|
+
| `indeterminate` | `boolean` | `false` | Indeterminate state |
|
|
228
|
+
| `disabled` | `boolean` | - | Disabled state |
|
|
229
|
+
| `required` | `boolean` | `false` | Required field |
|
|
230
|
+
| `validationState` | `"valid" \| "invalid" \| "none"` | `"none"` | Validation state |
|
|
231
|
+
| `errorMessage` | `string` | - | Error message |
|
|
232
|
+
| `description` | `string` | - | Helper text |
|
|
233
|
+
|
|
234
|
+
## Examples
|
|
235
|
+
|
|
236
|
+
See Storybook stories for interactive examples:
|
|
237
|
+
|
|
238
|
+
- **Basic** - Simple checkbox with label
|
|
239
|
+
- **Sizes** - All size variants
|
|
240
|
+
- **Colors** - All color variants
|
|
241
|
+
- **States** - Checked, unchecked, indeterminate, disabled
|
|
242
|
+
- **WithDescription** - Checkbox with helper text
|
|
243
|
+
- **WithError** - Checkbox with validation error
|
|
244
|
+
- **LabelPositions** - Left and right label positioning
|
|
245
|
+
- **Controlled** - Controlled mode example
|
|
246
|
+
- **Uncontrolled** - Uncontrolled mode example
|
|
247
|
+
- **Required** - Required field indicator
|
|
248
|
+
- **ComplexForm** - Complete form example
|
|
249
|
+
- **SelectAll** - Indeterminate "select all" pattern
|
|
250
|
+
- **CustomStyling** - CSS custom property examples
|
|
251
|
+
|
|
252
|
+
## Related Components
|
|
253
|
+
|
|
254
|
+
- **Form** - Form wrapper component
|
|
255
|
+
- **Field** - Form field with label and error handling
|
|
256
|
+
- **Input** - Text input component
|
|
257
|
+
- **Select** - Dropdown select component
|
|
258
|
+
|
|
259
|
+
## Resources
|
|
260
|
+
|
|
261
|
+
- [ARIA Checkbox Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/)
|
|
262
|
+
- [WCAG 2.1 Guidelines](https://www.w3.org/WAI/WCAG21/quickref/)
|
|
263
|
+
- [CSS Variables Reference](./STYLES.mdx)
|