@fpkit/acss 3.7.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/index.d.cts CHANGED
@@ -176,6 +176,361 @@ type AlertProps = {
176
176
  } & Omit<React$1.HTMLAttributes<HTMLDivElement>, "title" | "children">;
177
177
  declare const Alert: React$1.FC<AlertProps>;
178
178
 
179
+ /**
180
+ * Size variants for checkbox component using t-shirt sizing.
181
+ *
182
+ * @remarks
183
+ * Size affects both the checkbox visual size and label font size:
184
+ * - sm: 1rem checkbox, 0.875rem label (16px / 14px)
185
+ * - md: 1.25rem checkbox, 1rem label (20px / 16px)
186
+ * - lg: 1.5rem checkbox, 1.125rem label (24px / 18px)
187
+ */
188
+ type CheckboxSize = "sm" | "md" | "lg";
189
+ /**
190
+ * Color variants for checkbox component.
191
+ * All variants meet WCAG 2.1 AA contrast requirements (4.5:1 minimum).
192
+ *
193
+ * @remarks
194
+ * Color variants:
195
+ * - primary: Blue (#2563eb) - 4.68:1 contrast
196
+ * - secondary: Gray (#4b5563) - 7.56:1 contrast
197
+ * - error: Red (#dc2626) - 5.14:1 contrast
198
+ * - success: Green (#16a34a) - 4.54:1 contrast
199
+ */
200
+ type CheckboxColor = "primary" | "secondary" | "error" | "success";
201
+ /**
202
+ * Label positioning relative to the checkbox.
203
+ *
204
+ * @remarks
205
+ * - left: Label appears before the checkbox
206
+ * - right: Label appears after the checkbox (default)
207
+ */
208
+ type CheckboxLabelPosition = "left" | "right";
209
+ /**
210
+ * Props for the Checkbox component.
211
+ *
212
+ * @remarks
213
+ * Checkbox supports both controlled and uncontrolled modes:
214
+ * - Controlled: Pass `checked` prop and `onChange` handler
215
+ * - Uncontrolled: Pass `defaultChecked` prop only
216
+ *
217
+ * For AI assistants: This component implements WCAG 2.1 AA accessibility
218
+ * with proper ARIA attributes, keyboard navigation, and focus management.
219
+ */
220
+ interface CheckboxProps extends Omit<React$1.ComponentPropsWithoutRef<"input">, "type" | "size" | "className"> {
221
+ /**
222
+ * Unique identifier for the checkbox input.
223
+ *
224
+ * @remarks
225
+ * Required for proper label association and ARIA attribute linking.
226
+ * Used to generate IDs for description and error messages.
227
+ */
228
+ id: string;
229
+ /**
230
+ * Label text content displayed next to the checkbox.
231
+ *
232
+ * @remarks
233
+ * Alternative to `children` prop. Rendered as text content.
234
+ * Automatically associates with input via htmlFor.
235
+ */
236
+ label?: React$1.ReactNode;
237
+ /**
238
+ * Child content displayed as the label.
239
+ *
240
+ * @remarks
241
+ * Alternative to `label` prop. Allows for more complex label content.
242
+ * Takes precedence over `label` prop if both are provided.
243
+ */
244
+ children?: React$1.ReactNode;
245
+ /**
246
+ * Size variant of the checkbox.
247
+ *
248
+ * @default "md"
249
+ *
250
+ * @remarks
251
+ * Affects both checkbox size and label font size.
252
+ * All sizes maintain proper touch target size (44x44px minimum).
253
+ */
254
+ size?: CheckboxSize;
255
+ /**
256
+ * Color variant of the checkbox when checked.
257
+ *
258
+ * @default "primary"
259
+ *
260
+ * @remarks
261
+ * All color variants meet WCAG 2.1 AA contrast requirements.
262
+ * Use semantic colors (error, success) for validation states.
263
+ */
264
+ color?: CheckboxColor;
265
+ /**
266
+ * Position of the label relative to the checkbox.
267
+ *
268
+ * @default "right"
269
+ *
270
+ * @remarks
271
+ * - "left": Label before checkbox (useful for RTL layouts)
272
+ * - "right": Label after checkbox (standard pattern)
273
+ */
274
+ labelPosition?: CheckboxLabelPosition;
275
+ /**
276
+ * Helper text displayed below the checkbox.
277
+ *
278
+ * @remarks
279
+ * Provides additional context or instructions.
280
+ * Linked to input via aria-describedby for screen readers.
281
+ * Automatically generates ID: `${id}-description`.
282
+ */
283
+ description?: string;
284
+ /**
285
+ * Error message displayed when validation fails.
286
+ *
287
+ * @remarks
288
+ * Displayed below the checkbox in error color.
289
+ * Linked to input via aria-errormessage when validationState="invalid".
290
+ * Automatically generates ID: `${id}-error`.
291
+ */
292
+ errorMessage?: string;
293
+ /**
294
+ * Validation state of the checkbox.
295
+ *
296
+ * @default "none"
297
+ *
298
+ * @remarks
299
+ * - "valid": Checkbox passes validation
300
+ * - "invalid": Checkbox fails validation (sets aria-invalid)
301
+ * - "none": No validation applied
302
+ */
303
+ validationState?: "valid" | "invalid" | "none";
304
+ /**
305
+ * Checked state for controlled mode.
306
+ *
307
+ * @remarks
308
+ * When provided, component operates in controlled mode.
309
+ * Must be used with onChange handler to update state.
310
+ * Do not combine with defaultChecked.
311
+ */
312
+ checked?: boolean;
313
+ /**
314
+ * Default checked state for uncontrolled mode.
315
+ *
316
+ * @remarks
317
+ * When provided without `checked` prop, component operates in uncontrolled mode.
318
+ * Browser manages state internally.
319
+ * Do not combine with checked.
320
+ */
321
+ defaultChecked?: boolean;
322
+ /**
323
+ * Indeterminate state for partially selected groups.
324
+ *
325
+ * @default false
326
+ *
327
+ * @remarks
328
+ * Common for "select all" checkboxes where some but not all items are selected.
329
+ * Cannot be set via HTML - requires JavaScript.
330
+ * Visually displays a dash instead of a checkmark.
331
+ */
332
+ indeterminate?: boolean;
333
+ /**
334
+ * Whether the checkbox is disabled.
335
+ *
336
+ * @remarks
337
+ * Uses aria-disabled pattern to maintain keyboard focusability.
338
+ * Prevents all interactions while keeping element in tab order.
339
+ * Essential for screen reader users to discover disabled controls.
340
+ */
341
+ disabled?: boolean;
342
+ /**
343
+ * Whether the checkbox is required for form submission.
344
+ *
345
+ * @default false
346
+ *
347
+ * @remarks
348
+ * Sets aria-required attribute for screen readers.
349
+ * Displays visual required indicator (asterisk).
350
+ * Does NOT prevent form submission - use validation instead.
351
+ */
352
+ required?: boolean;
353
+ /**
354
+ * Name attribute for form submission.
355
+ *
356
+ * @remarks
357
+ * Used when checkbox is part of a form.
358
+ * Multiple checkboxes can share the same name for checkbox groups.
359
+ */
360
+ name?: string;
361
+ /**
362
+ * Value attribute for form submission.
363
+ *
364
+ * @remarks
365
+ * Submitted with form when checkbox is checked.
366
+ * Defaults to "on" if not specified.
367
+ */
368
+ value?: string;
369
+ /**
370
+ * CSS class names to apply to the wrapper element.
371
+ *
372
+ * @remarks
373
+ * Applied to the outermost div wrapper.
374
+ * Merged with disabled class from useDisabledState hook.
375
+ */
376
+ classes?: string;
377
+ /**
378
+ * Inline styles to apply to the wrapper element.
379
+ *
380
+ * @remarks
381
+ * Use CSS custom properties for theming:
382
+ * - --checkbox-size: Custom checkbox size
383
+ * - --checkbox-checked-bg: Checked background color
384
+ * - --checkbox-border: Border style
385
+ * See STYLES.mdx for complete variable reference.
386
+ */
387
+ styles?: React$1.CSSProperties;
388
+ /**
389
+ * Event handler fired when checkbox state changes.
390
+ *
391
+ * @param event - Change event from the input element
392
+ *
393
+ * @remarks
394
+ * Required when using controlled mode (with `checked` prop).
395
+ * Prevented when checkbox is disabled (via useDisabledState hook).
396
+ */
397
+ onChange?: React$1.ChangeEventHandler<HTMLInputElement>;
398
+ /**
399
+ * Event handler fired when checkbox loses focus.
400
+ *
401
+ * @param event - Focus event from the input element
402
+ */
403
+ onBlur?: React$1.FocusEventHandler<HTMLInputElement>;
404
+ /**
405
+ * Event handler fired when checkbox gains focus.
406
+ *
407
+ * @param event - Focus event from the input element
408
+ *
409
+ * @remarks
410
+ * Still fires when checkbox is disabled (for accessibility).
411
+ * useDisabledState hook allows focus events on disabled elements.
412
+ */
413
+ onFocus?: React$1.FocusEventHandler<HTMLInputElement>;
414
+ }
415
+ /**
416
+ * Checkbox - Accessible checkbox input with size and color variants.
417
+ *
418
+ * A fully accessible checkbox component that supports controlled and uncontrolled modes,
419
+ * indeterminate state, validation, and comprehensive ARIA attributes for screen readers.
420
+ *
421
+ * ## Key Features
422
+ *
423
+ * - **Accessible**: WCAG 2.1 AA compliant with proper ARIA attributes
424
+ * - **Flexible**: Controlled and uncontrolled modes
425
+ * - **Indeterminate**: Supports three-state checkboxes
426
+ * - **Validation**: Built-in error message and validation state support
427
+ * - **Customizable**: Size and color variants, plus CSS custom properties
428
+ * - **Keyboard**: Full keyboard navigation (Tab, Space)
429
+ * - **Type-Safe**: Full TypeScript support with comprehensive JSDoc
430
+ *
431
+ * ## Accessibility Considerations
432
+ *
433
+ * ### WCAG 2.1 AA Compliance
434
+ *
435
+ * - **3.2.2 On Input (Level A)**: onChange events don't cause unexpected context changes
436
+ * - **4.1.2 Name, Role, Value (Level A)**: Proper ARIA attributes communicate state
437
+ * - **1.4.3 Contrast (Minimum) (Level AA)**: All color variants meet 4.5:1 contrast
438
+ * - **2.4.7 Focus Visible (Level AA)**: Clear focus indicators on keyboard navigation
439
+ *
440
+ * ### Best Practices
441
+ *
442
+ * 1. **Always provide labels**: Use `label` or `children` prop for accessible name
443
+ * 2. **Use semantic colors**: error variant for validation failures
444
+ * 3. **Provide descriptions**: Use `description` prop for additional context
445
+ * 4. **Group related checkboxes**: Use fieldset/legend for checkbox groups
446
+ * 5. **Don't mix modes**: Use either controlled or uncontrolled, not both
447
+ *
448
+ * ## Usage Examples
449
+ *
450
+ * @example
451
+ * // Basic checkbox
452
+ * <Checkbox id="terms" label="I accept the terms and conditions" />
453
+ *
454
+ * @example
455
+ * // Controlled checkbox
456
+ * const [checked, setChecked] = useState(false);
457
+ * <Checkbox
458
+ * id="newsletter"
459
+ * label="Subscribe to newsletter"
460
+ * checked={checked}
461
+ * onChange={(e) => setChecked(e.target.checked)}
462
+ * />
463
+ *
464
+ * @example
465
+ * // Checkbox with validation error
466
+ * <Checkbox
467
+ * id="agree"
468
+ * label="You must agree to continue"
469
+ * required
470
+ * validationState="invalid"
471
+ * errorMessage="Please accept the terms to continue"
472
+ * />
473
+ *
474
+ * @example
475
+ * // Checkbox with description
476
+ * <Checkbox
477
+ * id="notifications"
478
+ * label="Enable notifications"
479
+ * description="Receive email notifications about important updates"
480
+ * />
481
+ *
482
+ * @example
483
+ * // Indeterminate checkbox (select all pattern)
484
+ * const [selectedItems, setSelectedItems] = useState([]);
485
+ * const allSelected = selectedItems.length === totalItems;
486
+ * const someSelected = selectedItems.length > 0 && !allSelected;
487
+ *
488
+ * <Checkbox
489
+ * id="select-all"
490
+ * label="Select all"
491
+ * checked={allSelected}
492
+ * indeterminate={someSelected}
493
+ * onChange={(e) => {
494
+ * if (e.target.checked) {
495
+ * setSelectedItems(allItemIds);
496
+ * } else {
497
+ * setSelectedItems([]);
498
+ * }
499
+ * }}
500
+ * />
501
+ *
502
+ * @example
503
+ * // Size and color variants
504
+ * <Checkbox id="sm" label="Small primary" size="sm" color="primary" />
505
+ * <Checkbox id="md" label="Medium secondary" size="md" color="secondary" />
506
+ * <Checkbox id="lg" label="Large success" size="lg" color="success" />
507
+ *
508
+ * @example
509
+ * // Label positioning
510
+ * <Checkbox id="left" label="Label on left" labelPosition="left" />
511
+ * <Checkbox id="right" label="Label on right" labelPosition="right" />
512
+ *
513
+ * @example
514
+ * // Custom styling with CSS variables
515
+ * <Checkbox
516
+ * id="custom"
517
+ * label="Custom styled"
518
+ * styles={{
519
+ * "--checkbox-size": "2rem",
520
+ * "--checkbox-checked-bg": "#7c3aed",
521
+ * "--checkbox-radius": "0.5rem",
522
+ * }}
523
+ * />
524
+ *
525
+ * @param {CheckboxProps} props - Component props
526
+ * @returns {React.ReactElement} Checkbox component
527
+ *
528
+ * @see {@link https://www.w3.org/WAI/WCAG21/Understanding/on-input.html WCAG 3.2.2 On Input}
529
+ * @see {@link https://www.w3.org/WAI/WCAG21/Understanding/name-role-value.html WCAG 4.1.2 Name, Role, Value}
530
+ * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/ ARIA Checkbox Pattern}
531
+ */
532
+ declare const Checkbox: React$1.ForwardRefExoticComponent<CheckboxProps & React$1.RefAttributes<HTMLInputElement>>;
533
+
179
534
  /**
180
535
  * Props for the Img component.
181
536
  *
@@ -2546,4 +2901,4 @@ type FPComponent = {
2546
2901
  */
2547
2902
  declare const FP: FPComponent;
2548
2903
 
2549
- export { Alert, AlertProps, Article, Aside, Badge, BadgeProps, Box, BoxProps, Caption, Cluster, ClusterProps, Col, ColProps, ComponentProps$1 as ComponentProps, Details, FP, Flex, FlexAlign, FlexAlignContent, FlexAlignSelf, FlexContainerElement, FlexDirection, FlexGap, FlexItemElement, FlexItemProps, FlexJustify, FlexProps, FlexSpacerProps, FlexVariant, FlexWrap, Footer, GridWithItem as Grid, GridItem, GridItemProps, GridProps, Header, Img, ImgProps, Landmarks, Main, ResponsiveFlexProps, Row, RowProps, Section, Stack, StackProps, Table, Tag, TagProps, TagVariant, Tbody, Td, TextToSpeech, Thead, Tr, UI };
2904
+ export { Alert, AlertProps, Article, Aside, Badge, BadgeProps, Box, BoxProps, Caption, Checkbox, CheckboxColor, CheckboxLabelPosition, CheckboxProps, CheckboxSize, Cluster, ClusterProps, Col, ColProps, ComponentProps$1 as ComponentProps, Details, FP, Flex, FlexAlign, FlexAlignContent, FlexAlignSelf, FlexContainerElement, FlexDirection, FlexGap, FlexItemElement, FlexItemProps, FlexJustify, FlexProps, FlexSpacerProps, FlexVariant, FlexWrap, Footer, GridWithItem as Grid, GridItem, GridItemProps, GridProps, Header, Img, ImgProps, Landmarks, Main, ResponsiveFlexProps, Row, RowProps, Section, Stack, StackProps, Table, Tag, TagProps, TagVariant, Tbody, Td, TextToSpeech, Thead, Tr, UI };