@donotdev/components 0.0.23 → 0.0.24
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/atomic/ButtonGroup/index.d.ts +93 -0
- package/dist/atomic/ButtonGroup/index.d.ts.map +1 -0
- package/dist/atomic/ButtonGroup/index.js +57 -0
- package/dist/atomic/ColorPicker/index.d.ts +100 -0
- package/dist/atomic/ColorPicker/index.d.ts.map +1 -0
- package/dist/atomic/ColorPicker/index.js +195 -0
- package/dist/atomic/Combobox/index.d.ts.map +1 -1
- package/dist/atomic/Combobox/index.js +27 -3
- package/dist/atomic/SkipLink/index.d.ts +38 -0
- package/dist/atomic/SkipLink/index.d.ts.map +1 -0
- package/dist/atomic/SkipLink/index.js +56 -0
- package/dist/atomic/TreeView/index.d.ts +116 -0
- package/dist/atomic/TreeView/index.d.ts.map +1 -0
- package/dist/atomic/TreeView/index.js +316 -0
- package/dist/atomic/index.d.ts +8 -0
- package/dist/atomic/index.d.ts.map +1 -1
- package/dist/atomic/index.js +4 -0
- package/dist/hooks/useSwipeToClose.d.ts.map +1 -1
- package/dist/hooks/useSwipeToClose.js +2 -1
- package/dist/index.js +6 -6
- package/dist/styles/index.css +454 -3
- package/package.json +2 -2
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import Button from '../Button';
|
|
2
|
+
import type { ButtonVariant } from '../Button';
|
|
3
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
4
|
+
import './ButtonGroup.css';
|
|
5
|
+
export interface ButtonGroupItem {
|
|
6
|
+
/** Unique key for the item */
|
|
7
|
+
key: string;
|
|
8
|
+
/** Button label text */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** Icon — Lucide component, string name, or ReactNode */
|
|
11
|
+
icon?: ButtonProps['icon'];
|
|
12
|
+
/** Override variant for this specific item */
|
|
13
|
+
variant?: ButtonVariant;
|
|
14
|
+
/** Click handler */
|
|
15
|
+
onClick?: () => void;
|
|
16
|
+
/** Disabled state for this item */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** aria-label for icon-only buttons */
|
|
19
|
+
'aria-label'?: string;
|
|
20
|
+
}
|
|
21
|
+
type ButtonProps = React.ComponentProps<typeof Button>;
|
|
22
|
+
export interface ButtonGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role'> {
|
|
23
|
+
/**
|
|
24
|
+
* Items API — array of button definitions.
|
|
25
|
+
* For 90% use cases. Each item renders as a Button.
|
|
26
|
+
*/
|
|
27
|
+
items?: ButtonGroupItem[];
|
|
28
|
+
/**
|
|
29
|
+
* Children API — render raw Button/ActionButton elements.
|
|
30
|
+
* Power-user escape hatch when items API is insufficient.
|
|
31
|
+
*/
|
|
32
|
+
children?: ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Visual variant propagated to all items.
|
|
35
|
+
* Individual items can override via their own variant prop.
|
|
36
|
+
* @default 'primary'
|
|
37
|
+
*/
|
|
38
|
+
variant?: ButtonVariant;
|
|
39
|
+
/**
|
|
40
|
+
* Orientation of the group.
|
|
41
|
+
* @default 'horizontal'
|
|
42
|
+
*/
|
|
43
|
+
orientation?: 'horizontal' | 'vertical';
|
|
44
|
+
/**
|
|
45
|
+
* Whether all buttons in the group are disabled.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Accessible label for the group.
|
|
51
|
+
* Required — describes the purpose of the button group.
|
|
52
|
+
*/
|
|
53
|
+
'aria-label': string;
|
|
54
|
+
/** Additional CSS classes */
|
|
55
|
+
className?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Visual grouping of buttons with joined borders and shared radius.
|
|
59
|
+
* NOT a toggle group — provides no selection state.
|
|
60
|
+
*
|
|
61
|
+
* Uses `role="group"` with `aria-label` for accessibility.
|
|
62
|
+
* Each button remains an independent tab stop.
|
|
63
|
+
*
|
|
64
|
+
* @component
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* // Items API (recommended)
|
|
68
|
+
* <ButtonGroup
|
|
69
|
+
* aria-label="Text formatting"
|
|
70
|
+
* variant="outline"
|
|
71
|
+
* items={[
|
|
72
|
+
* { key: 'bold', label: 'Bold', icon: Bold },
|
|
73
|
+
* { key: 'italic', label: 'Italic', icon: Italic },
|
|
74
|
+
* { key: 'underline', label: 'Underline', icon: Underline },
|
|
75
|
+
* ]}
|
|
76
|
+
* />
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```tsx
|
|
81
|
+
* // Children API
|
|
82
|
+
* <ButtonGroup aria-label="Actions" orientation="vertical">
|
|
83
|
+
* <Button variant="primary" onClick={handleSave}>Save</Button>
|
|
84
|
+
* <Button variant="outline" onClick={handleCancel}>Cancel</Button>
|
|
85
|
+
* </ButtonGroup>
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @param {ButtonGroupProps} props - The props for the button group
|
|
89
|
+
* @returns {JSX.Element} The rendered button group
|
|
90
|
+
*/
|
|
91
|
+
declare const ButtonGroup: import("react").ForwardRefExoticComponent<ButtonGroupProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
92
|
+
export default ButtonGroup;
|
|
93
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/ButtonGroup/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,mBAAmB,CAAC;AAE3B,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,KAAK,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC;AAEvD,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,cAAc,CAAC,cAAc,CAAC,EAC9B,MAAM,CACP;IACC;;;OAGG;IACH,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,QAAA,MAAM,WAAW,6GA6ChB,CAAC;AAIF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// packages/components/src/atomic/ButtonGroup/index.tsx
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview ButtonGroup component
|
|
5
|
+
* @description Visual grouping of buttons with joined borders. Supports horizontal and vertical
|
|
6
|
+
* orientation, variant/size propagation, and both items-based and children-based APIs.
|
|
7
|
+
* NOT a toggle group — no state management.
|
|
8
|
+
*
|
|
9
|
+
* @version 0.0.1
|
|
10
|
+
* @since 0.0.1
|
|
11
|
+
* @author AMBROISE PARK Consulting
|
|
12
|
+
*/
|
|
13
|
+
import { forwardRef } from 'react';
|
|
14
|
+
import { cn, getVariantDataAttrs } from '../../utils/helpers';
|
|
15
|
+
import Button from '../Button';
|
|
16
|
+
import './ButtonGroup.css';
|
|
17
|
+
/**
|
|
18
|
+
* Visual grouping of buttons with joined borders and shared radius.
|
|
19
|
+
* NOT a toggle group — provides no selection state.
|
|
20
|
+
*
|
|
21
|
+
* Uses `role="group"` with `aria-label` for accessibility.
|
|
22
|
+
* Each button remains an independent tab stop.
|
|
23
|
+
*
|
|
24
|
+
* @component
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* // Items API (recommended)
|
|
28
|
+
* <ButtonGroup
|
|
29
|
+
* aria-label="Text formatting"
|
|
30
|
+
* variant="outline"
|
|
31
|
+
* items={[
|
|
32
|
+
* { key: 'bold', label: 'Bold', icon: Bold },
|
|
33
|
+
* { key: 'italic', label: 'Italic', icon: Italic },
|
|
34
|
+
* { key: 'underline', label: 'Underline', icon: Underline },
|
|
35
|
+
* ]}
|
|
36
|
+
* />
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // Children API
|
|
42
|
+
* <ButtonGroup aria-label="Actions" orientation="vertical">
|
|
43
|
+
* <Button variant="primary" onClick={handleSave}>Save</Button>
|
|
44
|
+
* <Button variant="outline" onClick={handleCancel}>Cancel</Button>
|
|
45
|
+
* </ButtonGroup>
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param {ButtonGroupProps} props - The props for the button group
|
|
49
|
+
* @returns {JSX.Element} The rendered button group
|
|
50
|
+
*/
|
|
51
|
+
const ButtonGroup = forwardRef(function ButtonGroup({ className, variant = 'primary', orientation = 'horizontal', disabled = false, items, children, 'aria-label': ariaLabel, ...props }, ref) {
|
|
52
|
+
const variantAttrs = getVariantDataAttrs({ variant });
|
|
53
|
+
return (_jsxs("div", { ref: ref, role: "group", "aria-label": ariaLabel, "aria-orientation": orientation, "aria-disabled": disabled || undefined, "data-orientation": orientation, className: cn('dndev-button-group', className), ...variantAttrs, ...props, children: [children, items &&
|
|
54
|
+
items.map((item) => (_jsx(Button, { variant: item.variant ?? variant, icon: item.icon, onClick: item.onClick, disabled: item.disabled ?? disabled, "aria-label": item['aria-label'], children: item.label }, item.key)))] }));
|
|
55
|
+
});
|
|
56
|
+
ButtonGroup.displayName = 'ButtonGroup';
|
|
57
|
+
export default ButtonGroup;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import './ColorPicker.css';
|
|
3
|
+
/** A preset color swatch */
|
|
4
|
+
export interface ColorSwatch {
|
|
5
|
+
/** Hex color value (e.g., '#ff0000') */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Human-readable name — used as aria-label for accessibility */
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const COLOR_PRESETS: {
|
|
11
|
+
readonly BASIC: "basic";
|
|
12
|
+
readonly MATERIAL: "material";
|
|
13
|
+
readonly PASTEL: "pastel";
|
|
14
|
+
};
|
|
15
|
+
export type ColorPreset = (typeof COLOR_PRESETS)[keyof typeof COLOR_PRESETS];
|
|
16
|
+
export interface ColorPickerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
17
|
+
/** Controlled hex color value (e.g., '#00bcd4') */
|
|
18
|
+
value?: string;
|
|
19
|
+
/** Default hex color value (uncontrolled) */
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
/** Callback when color changes. Returns hex string. */
|
|
22
|
+
onChange?: (color: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Preset swatch palette name, or custom array.
|
|
25
|
+
* @default 'basic'
|
|
26
|
+
*/
|
|
27
|
+
swatches?: ColorPreset | ColorSwatch[];
|
|
28
|
+
/**
|
|
29
|
+
* Number of columns in swatch grid.
|
|
30
|
+
* @default 8
|
|
31
|
+
*/
|
|
32
|
+
columns?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Show native color input for custom color selection.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
showCustom?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Show hex value display below swatches.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
showHexValue?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the picker is disabled.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
/** Accessible label for the color picker */
|
|
49
|
+
'aria-label'?: string;
|
|
50
|
+
/** Additional CSS classes */
|
|
51
|
+
className?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Color selection component with preset swatch grid and native color input.
|
|
55
|
+
* Full ARIA radiogroup pattern with roving tabindex for keyboard navigation.
|
|
56
|
+
*
|
|
57
|
+
* @component
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* // Basic usage with preset palette
|
|
61
|
+
* <ColorPicker
|
|
62
|
+
* value={color}
|
|
63
|
+
* onChange={setColor}
|
|
64
|
+
* aria-label="Choose accent color"
|
|
65
|
+
* />
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* // Material palette with hex display
|
|
71
|
+
* <ColorPicker
|
|
72
|
+
* swatches="material"
|
|
73
|
+
* showHexValue
|
|
74
|
+
* defaultValue="#2196f3"
|
|
75
|
+
* onChange={(hex) => console.log(hex)}
|
|
76
|
+
* aria-label="Theme color"
|
|
77
|
+
* />
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```tsx
|
|
82
|
+
* // Custom swatches, no native picker
|
|
83
|
+
* <ColorPicker
|
|
84
|
+
* swatches={[
|
|
85
|
+
* { value: '#ff0000', label: 'Red' },
|
|
86
|
+
* { value: '#00ff00', label: 'Green' },
|
|
87
|
+
* { value: '#0000ff', label: 'Blue' },
|
|
88
|
+
* ]}
|
|
89
|
+
* showCustom={false}
|
|
90
|
+
* columns={3}
|
|
91
|
+
* aria-label="Primary color"
|
|
92
|
+
* />
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @param {ColorPickerProps} props - The props for the color picker
|
|
96
|
+
* @returns {JSX.Element} The rendered color picker
|
|
97
|
+
*/
|
|
98
|
+
declare const ColorPicker: import("react").ForwardRefExoticComponent<ColorPickerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
99
|
+
export default ColorPicker;
|
|
100
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/ColorPicker/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,OAAO,CAAC;AAE3D,OAAO,mBAAmB,CAAC;AAE3B,4BAA4B;AAC5B,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAyE7E,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,cAAc,CAAC,cAAc,CAAC,EAC9B,UAAU,GAAG,cAAc,CAC5B;IACC,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;IACvC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,QAAA,MAAM,WAAW,6GAkKhB,CAAC;AAIF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// packages/components/src/atomic/ColorPicker/index.tsx
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview ColorPicker component
|
|
5
|
+
* @description Color selection component with preset swatch grid, native color input fallback,
|
|
6
|
+
* and full ARIA radiogroup pattern with roving tabindex. SSR-safe, no external dependencies.
|
|
7
|
+
*
|
|
8
|
+
* @version 0.0.1
|
|
9
|
+
* @since 0.0.1
|
|
10
|
+
* @author AMBROISE PARK Consulting
|
|
11
|
+
*/
|
|
12
|
+
import { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
|
|
13
|
+
import { cn } from '../../utils/helpers';
|
|
14
|
+
import './ColorPicker.css';
|
|
15
|
+
export const COLOR_PRESETS = {
|
|
16
|
+
BASIC: 'basic',
|
|
17
|
+
MATERIAL: 'material',
|
|
18
|
+
PASTEL: 'pastel',
|
|
19
|
+
};
|
|
20
|
+
const BASIC_SWATCHES = [
|
|
21
|
+
{ value: '#000000', label: 'Black' },
|
|
22
|
+
{ value: '#ffffff', label: 'White' },
|
|
23
|
+
{ value: '#6b7280', label: 'Gray' },
|
|
24
|
+
{ value: '#9ca3af', label: 'Light gray' },
|
|
25
|
+
{ value: '#dc2626', label: 'Red' },
|
|
26
|
+
{ value: '#ea580c', label: 'Orange' },
|
|
27
|
+
{ value: '#d97706', label: 'Amber' },
|
|
28
|
+
{ value: '#eab308', label: 'Yellow' },
|
|
29
|
+
{ value: '#84cc16', label: 'Lime' },
|
|
30
|
+
{ value: '#16a34a', label: 'Green' },
|
|
31
|
+
{ value: '#14b8a6', label: 'Teal' },
|
|
32
|
+
{ value: '#06b6d4', label: 'Cyan' },
|
|
33
|
+
{ value: '#2563eb', label: 'Blue' },
|
|
34
|
+
{ value: '#7c3aed', label: 'Purple' },
|
|
35
|
+
{ value: '#db2777', label: 'Pink' },
|
|
36
|
+
{ value: '#e11d48', label: 'Rose' },
|
|
37
|
+
];
|
|
38
|
+
const MATERIAL_SWATCHES = [
|
|
39
|
+
{ value: '#f44336', label: 'Red' },
|
|
40
|
+
{ value: '#e91e63', label: 'Pink' },
|
|
41
|
+
{ value: '#9c27b0', label: 'Purple' },
|
|
42
|
+
{ value: '#673ab7', label: 'Deep purple' },
|
|
43
|
+
{ value: '#3f51b5', label: 'Indigo' },
|
|
44
|
+
{ value: '#2196f3', label: 'Blue' },
|
|
45
|
+
{ value: '#03a9f4', label: 'Light blue' },
|
|
46
|
+
{ value: '#00bcd4', label: 'Cyan' },
|
|
47
|
+
{ value: '#009688', label: 'Teal' },
|
|
48
|
+
{ value: '#4caf50', label: 'Green' },
|
|
49
|
+
{ value: '#8bc34a', label: 'Light green' },
|
|
50
|
+
{ value: '#cddc39', label: 'Lime' },
|
|
51
|
+
{ value: '#ffeb3b', label: 'Yellow' },
|
|
52
|
+
{ value: '#ffc107', label: 'Amber' },
|
|
53
|
+
{ value: '#ff9800', label: 'Orange' },
|
|
54
|
+
{ value: '#ff5722', label: 'Deep orange' },
|
|
55
|
+
];
|
|
56
|
+
const PASTEL_SWATCHES = [
|
|
57
|
+
{ value: '#fecdd3', label: 'Pastel rose' },
|
|
58
|
+
{ value: '#fbcfe8', label: 'Pastel pink' },
|
|
59
|
+
{ value: '#e9d5ff', label: 'Pastel purple' },
|
|
60
|
+
{ value: '#c7d2fe', label: 'Pastel indigo' },
|
|
61
|
+
{ value: '#bfdbfe', label: 'Pastel blue' },
|
|
62
|
+
{ value: '#a5f3fc', label: 'Pastel cyan' },
|
|
63
|
+
{ value: '#99f6e4', label: 'Pastel teal' },
|
|
64
|
+
{ value: '#bbf7d0', label: 'Pastel green' },
|
|
65
|
+
{ value: '#d9f99d', label: 'Pastel lime' },
|
|
66
|
+
{ value: '#fef08a', label: 'Pastel yellow' },
|
|
67
|
+
{ value: '#fed7aa', label: 'Pastel orange' },
|
|
68
|
+
{ value: '#fecaca', label: 'Pastel red' },
|
|
69
|
+
{ value: '#e5e7eb', label: 'Pastel gray' },
|
|
70
|
+
{ value: '#f5f5f4', label: 'Pastel stone' },
|
|
71
|
+
{ value: '#fce7f3', label: 'Pastel fuchsia' },
|
|
72
|
+
{ value: '#dbeafe', label: 'Pastel sky' },
|
|
73
|
+
];
|
|
74
|
+
const PRESET_MAP = {
|
|
75
|
+
[COLOR_PRESETS.BASIC]: BASIC_SWATCHES,
|
|
76
|
+
[COLOR_PRESETS.MATERIAL]: MATERIAL_SWATCHES,
|
|
77
|
+
[COLOR_PRESETS.PASTEL]: PASTEL_SWATCHES,
|
|
78
|
+
};
|
|
79
|
+
/** Determine if a hex color is light (for checkmark contrast) */
|
|
80
|
+
function isLightColor(hex) {
|
|
81
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
82
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
83
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
84
|
+
return (r * 299 + g * 587 + b * 114) / 1000 > 128;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Color selection component with preset swatch grid and native color input.
|
|
88
|
+
* Full ARIA radiogroup pattern with roving tabindex for keyboard navigation.
|
|
89
|
+
*
|
|
90
|
+
* @component
|
|
91
|
+
* @example
|
|
92
|
+
* ```tsx
|
|
93
|
+
* // Basic usage with preset palette
|
|
94
|
+
* <ColorPicker
|
|
95
|
+
* value={color}
|
|
96
|
+
* onChange={setColor}
|
|
97
|
+
* aria-label="Choose accent color"
|
|
98
|
+
* />
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* // Material palette with hex display
|
|
104
|
+
* <ColorPicker
|
|
105
|
+
* swatches="material"
|
|
106
|
+
* showHexValue
|
|
107
|
+
* defaultValue="#2196f3"
|
|
108
|
+
* onChange={(hex) => console.log(hex)}
|
|
109
|
+
* aria-label="Theme color"
|
|
110
|
+
* />
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```tsx
|
|
115
|
+
* // Custom swatches, no native picker
|
|
116
|
+
* <ColorPicker
|
|
117
|
+
* swatches={[
|
|
118
|
+
* { value: '#ff0000', label: 'Red' },
|
|
119
|
+
* { value: '#00ff00', label: 'Green' },
|
|
120
|
+
* { value: '#0000ff', label: 'Blue' },
|
|
121
|
+
* ]}
|
|
122
|
+
* showCustom={false}
|
|
123
|
+
* columns={3}
|
|
124
|
+
* aria-label="Primary color"
|
|
125
|
+
* />
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @param {ColorPickerProps} props - The props for the color picker
|
|
129
|
+
* @returns {JSX.Element} The rendered color picker
|
|
130
|
+
*/
|
|
131
|
+
const ColorPicker = forwardRef(function ColorPicker({ value, defaultValue = '#000000', onChange, swatches = COLOR_PRESETS.BASIC, columns = 8, showCustom = true, showHexValue = false, disabled = false, 'aria-label': ariaLabel = 'Color picker', className, ...props }, ref) {
|
|
132
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
133
|
+
const isControlled = value !== undefined;
|
|
134
|
+
const currentValue = isControlled ? value : internalValue;
|
|
135
|
+
const swatchesRef = useRef(null);
|
|
136
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
137
|
+
const resolvedSwatches = useMemo(() => typeof swatches === 'string'
|
|
138
|
+
? (PRESET_MAP[swatches] ?? BASIC_SWATCHES)
|
|
139
|
+
: swatches, [swatches]);
|
|
140
|
+
const selectColor = useCallback((hex) => {
|
|
141
|
+
if (!isControlled)
|
|
142
|
+
setInternalValue(hex);
|
|
143
|
+
onChange?.(hex);
|
|
144
|
+
}, [isControlled, onChange]);
|
|
145
|
+
const handleSwatchKeyDown = useCallback((e) => {
|
|
146
|
+
const total = resolvedSwatches.length;
|
|
147
|
+
if (total === 0)
|
|
148
|
+
return;
|
|
149
|
+
let nextIndex = focusedIndex;
|
|
150
|
+
switch (e.key) {
|
|
151
|
+
case 'ArrowRight':
|
|
152
|
+
case 'ArrowDown':
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
nextIndex = (focusedIndex + 1) % total;
|
|
155
|
+
break;
|
|
156
|
+
case 'ArrowLeft':
|
|
157
|
+
case 'ArrowUp':
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
nextIndex = (focusedIndex - 1 + total) % total;
|
|
160
|
+
break;
|
|
161
|
+
case 'Home':
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
nextIndex = 0;
|
|
164
|
+
break;
|
|
165
|
+
case 'End':
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
nextIndex = total - 1;
|
|
168
|
+
break;
|
|
169
|
+
case 'Enter':
|
|
170
|
+
case ' ':
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
if (focusedIndex >= 0 && focusedIndex < total) {
|
|
173
|
+
const swatch = resolvedSwatches[focusedIndex];
|
|
174
|
+
if (swatch)
|
|
175
|
+
selectColor(swatch.value);
|
|
176
|
+
}
|
|
177
|
+
return;
|
|
178
|
+
default:
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
setFocusedIndex(nextIndex);
|
|
182
|
+
// Focus the swatch button
|
|
183
|
+
const buttons = swatchesRef.current?.querySelectorAll('[role="radio"]');
|
|
184
|
+
buttons?.[nextIndex]?.focus();
|
|
185
|
+
}, [focusedIndex, resolvedSwatches, selectColor]);
|
|
186
|
+
// Determine which swatch is "active" for roving tabindex
|
|
187
|
+
const activeIndex = resolvedSwatches.findIndex((s) => s.value.toLowerCase() === currentValue?.toLowerCase());
|
|
188
|
+
const tabbableIndex = focusedIndex >= 0 ? focusedIndex : Math.max(activeIndex, 0);
|
|
189
|
+
return (_jsxs("div", { ref: ref, className: cn('dndev-color-picker', className), "aria-disabled": disabled || undefined, ...props, children: [_jsx("div", { ref: swatchesRef, role: "radiogroup", "aria-label": ariaLabel, className: "dndev-color-swatches", style: { '--color-picker-columns': columns }, onKeyDown: handleSwatchKeyDown, children: resolvedSwatches.map((swatch, index) => {
|
|
190
|
+
const isSelected = swatch.value.toLowerCase() === currentValue?.toLowerCase();
|
|
191
|
+
return (_jsx("button", { type: "button", role: "radio", "aria-checked": isSelected, "aria-label": `${swatch.label} (${swatch.value})`, tabIndex: index === tabbableIndex ? 0 : -1, disabled: disabled, className: "dndev-color-swatch", "data-light": isLightColor(swatch.value), style: { '--swatch-color': swatch.value }, onClick: () => selectColor(swatch.value), onFocus: () => setFocusedIndex(index) }, swatch.value));
|
|
192
|
+
}) }), showCustom && (_jsx("div", { className: "dndev-color-custom", children: _jsxs("label", { className: "dndev-color-custom-label", children: [_jsx("span", { children: "Custom" }), _jsx("input", { type: "color", value: currentValue, disabled: disabled, "aria-label": "Custom color", onChange: (e) => selectColor(e.target.value) })] }) })), showHexValue && (_jsx("output", { className: "dndev-color-hex", "aria-live": "polite", children: currentValue }))] }));
|
|
193
|
+
});
|
|
194
|
+
ColorPicker.displayName = 'ColorPicker';
|
|
195
|
+
export default ColorPicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Combobox/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM7E,OAAO,gBAAgB,CAAC;AAExB,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iFAAiF;IACjF,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB;AAkBD,QAAA,MAAM,QAAQ,GAAI,kOAoBf,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/Combobox/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM7E,OAAO,gBAAgB,CAAC;AAExB,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iFAAiF;IACjF,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB;AAkBD,QAAA,MAAM,QAAQ,GAAI,kOAoBf,aAAa,4CAkYf,CAAC;AAEF,eAAe,QAAQ,CAAC;AACxB,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,CAAC;AAC/C,YAAY,EAAE,cAAc,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -27,6 +27,8 @@ const Combobox = ({ value, onValueChange, placeholder = 'Select...', emptyMessag
|
|
|
27
27
|
const id = useId();
|
|
28
28
|
const [open, setOpen] = useState(false);
|
|
29
29
|
const [search, setSearch] = useState('');
|
|
30
|
+
/** Tracks whether the user has typed in the input during this open session */
|
|
31
|
+
const isSearchingRef = useRef(false);
|
|
30
32
|
const [highlightedIndex, setHighlightedIndex] = useState(0);
|
|
31
33
|
const containerRef = useRef(null);
|
|
32
34
|
const inputRef = useRef(null);
|
|
@@ -74,10 +76,18 @@ const Combobox = ({ value, onValueChange, placeholder = 'Select...', emptyMessag
|
|
|
74
76
|
if (open) {
|
|
75
77
|
setHighlightedIndex(0);
|
|
76
78
|
}
|
|
77
|
-
else
|
|
78
|
-
|
|
79
|
+
else {
|
|
80
|
+
isSearchingRef.current = false;
|
|
81
|
+
if (!multiple) {
|
|
82
|
+
setSearch('');
|
|
83
|
+
}
|
|
79
84
|
}
|
|
80
85
|
}, [open, multiple]);
|
|
86
|
+
// Cleanup debounce timer on unmount
|
|
87
|
+
useEffect(() => () => {
|
|
88
|
+
if (searchTimerRef.current)
|
|
89
|
+
clearTimeout(searchTimerRef.current);
|
|
90
|
+
}, []);
|
|
81
91
|
useEffect(() => {
|
|
82
92
|
if (open && listRef.current) {
|
|
83
93
|
const highlightedElement = listRef.current.children[highlightedIndex];
|
|
@@ -157,6 +167,9 @@ const Combobox = ({ value, onValueChange, placeholder = 'Select...', emptyMessag
|
|
|
157
167
|
onValueChange?.(multiple ? [] : '');
|
|
158
168
|
};
|
|
159
169
|
const getDisplayValue = () => {
|
|
170
|
+
// User is actively typing/backspacing — always show the search text (even if empty)
|
|
171
|
+
if (open && isSearchingRef.current)
|
|
172
|
+
return search;
|
|
160
173
|
if (open && search)
|
|
161
174
|
return search;
|
|
162
175
|
if (selectedValues.length === 0)
|
|
@@ -168,12 +181,23 @@ const Combobox = ({ value, onValueChange, placeholder = 'Select...', emptyMessag
|
|
|
168
181
|
};
|
|
169
182
|
const displayValue = getDisplayValue();
|
|
170
183
|
const hasSelection = selectedValues.length > 0;
|
|
184
|
+
const searchTimerRef = useRef(null);
|
|
171
185
|
const handleInputChange = (e) => {
|
|
172
186
|
const newValue = e.target.value;
|
|
187
|
+
isSearchingRef.current = true;
|
|
173
188
|
setSearch(newValue);
|
|
174
|
-
onSearchChange?.(newValue);
|
|
175
189
|
if (!open)
|
|
176
190
|
handleOpenChange(true);
|
|
191
|
+
// Backspaced to empty while having a selection → clear the value
|
|
192
|
+
if (newValue === '' && hasSelection && !multiple) {
|
|
193
|
+
onValueChange?.('');
|
|
194
|
+
}
|
|
195
|
+
// Debounce onSearchChange (300ms) — callers may trigger API calls
|
|
196
|
+
if (onSearchChange) {
|
|
197
|
+
if (searchTimerRef.current)
|
|
198
|
+
clearTimeout(searchTimerRef.current);
|
|
199
|
+
searchTimerRef.current = setTimeout(() => onSearchChange(newValue), 300);
|
|
200
|
+
}
|
|
177
201
|
};
|
|
178
202
|
const handleInputFocus = () => {
|
|
179
203
|
if (!disabled) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import './SkipLink.css';
|
|
3
|
+
export interface SkipLinkItem {
|
|
4
|
+
/** Target element ID (without #). The href will be `#${targetId}` */
|
|
5
|
+
targetId: string;
|
|
6
|
+
/** Visible label when focused (e.g., "Skip to main content") */
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SkipLinkProps extends Omit<HTMLAttributes<HTMLElement>, 'role'> {
|
|
10
|
+
/**
|
|
11
|
+
* Array of skip link targets.
|
|
12
|
+
* Each renders as a focusable anchor that scrolls to and focuses the target.
|
|
13
|
+
*/
|
|
14
|
+
items: SkipLinkItem[];
|
|
15
|
+
/** Additional CSS classes */
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Accessibility skip links — invisible until focused via keyboard.
|
|
20
|
+
* Place as the first element in the page body.
|
|
21
|
+
*
|
|
22
|
+
* @component
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <SkipLink
|
|
26
|
+
* items={[
|
|
27
|
+
* { targetId: 'main-content', label: 'Skip to main content' },
|
|
28
|
+
* { targetId: 'navigation', label: 'Skip to navigation' },
|
|
29
|
+
* ]}
|
|
30
|
+
* />
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param {SkipLinkProps} props - The props for the skip links
|
|
34
|
+
* @returns {JSX.Element} The rendered skip link navigation
|
|
35
|
+
*/
|
|
36
|
+
declare function SkipLink({ items, className, ...props }: SkipLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export default SkipLink;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/SkipLink/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,OAAO,CAAC;AAExD,OAAO,gBAAgB,CAAC;AAExB,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CACzC,cAAc,CAAC,WAAW,CAAC,EAC3B,MAAM,CACP;IACC;;;OAGG;IACH,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA0BD;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,2CAmB9D;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// packages/components/src/atomic/SkipLink/index.tsx
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview SkipLink component
|
|
5
|
+
* @description Accessibility skip-to-content links that become visible only on keyboard focus.
|
|
6
|
+
* Should be placed as the first focusable element in the DOM. Supports multiple targets.
|
|
7
|
+
* Gracefully degrades without JS via native anchor behavior.
|
|
8
|
+
*
|
|
9
|
+
* @version 0.0.1
|
|
10
|
+
* @since 0.0.1
|
|
11
|
+
* @author AMBROISE PARK Consulting
|
|
12
|
+
*/
|
|
13
|
+
import { cn } from '../../utils/helpers';
|
|
14
|
+
import './SkipLink.css';
|
|
15
|
+
/**
|
|
16
|
+
* Handle skip link click: scroll to target and focus it.
|
|
17
|
+
* Makes non-focusable targets temporarily focusable via tabindex="-1".
|
|
18
|
+
*/
|
|
19
|
+
function handleSkipClick(e, targetId) {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
const target = document.getElementById(targetId);
|
|
22
|
+
if (!target)
|
|
23
|
+
return;
|
|
24
|
+
// Make target focusable if it isn't already
|
|
25
|
+
const isFocusable = target.matches('a, button, input, select, textarea, [tabindex]');
|
|
26
|
+
if (!isFocusable) {
|
|
27
|
+
target.setAttribute('tabindex', '-1');
|
|
28
|
+
target.addEventListener('blur', () => target.removeAttribute('tabindex'), {
|
|
29
|
+
once: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
target.scrollIntoView({ behavior: 'smooth' });
|
|
33
|
+
target.focus({ preventScroll: true });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Accessibility skip links — invisible until focused via keyboard.
|
|
37
|
+
* Place as the first element in the page body.
|
|
38
|
+
*
|
|
39
|
+
* @component
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <SkipLink
|
|
43
|
+
* items={[
|
|
44
|
+
* { targetId: 'main-content', label: 'Skip to main content' },
|
|
45
|
+
* { targetId: 'navigation', label: 'Skip to navigation' },
|
|
46
|
+
* ]}
|
|
47
|
+
* />
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param {SkipLinkProps} props - The props for the skip links
|
|
51
|
+
* @returns {JSX.Element} The rendered skip link navigation
|
|
52
|
+
*/
|
|
53
|
+
function SkipLink({ items, className, ...props }) {
|
|
54
|
+
return (_jsx("nav", { "aria-label": "Skip links", className: cn('dndev-skip-links', className), ...props, children: items.map((item) => (_jsx("a", { href: `#${item.targetId}`, className: "dndev-skip-link", onClick: (e) => handleSkipClick(e, item.targetId), children: item.label }, item.targetId))) }));
|
|
55
|
+
}
|
|
56
|
+
export default SkipLink;
|