@juspay/blend-design-system 0.0.32-beta → 0.0.33-beta
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/components/Accordion/index.d.ts +1 -0
- package/dist/components/Alert/alert.tokens.d.ts +2 -0
- package/dist/components/Alert/index.d.ts +1 -0
- package/dist/components/Alert/types.d.ts +3 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/AvatarGroup/index.d.ts +1 -0
- package/dist/components/Breadcrumb/index.d.ts +1 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/ButtonV2/ButtonGroupV2/ButtonGroupV2.d.ts +4 -0
- package/dist/components/ButtonV2/ButtonGroupV2/buttonGroupV2.types.d.ts +10 -0
- package/dist/components/ButtonV2/ButtonGroupV2/index.d.ts +3 -0
- package/dist/components/ButtonV2/ButtonGroupV2/utils.d.ts +3 -0
- package/dist/components/ButtonV2/ButtonV2.d.ts +24 -0
- package/dist/components/ButtonV2/IconButton.d.ts +7 -0
- package/dist/components/ButtonV2/LinkButton.d.ts +7 -0
- package/dist/components/ButtonV2/VisuallyHidden.d.ts +1 -0
- package/dist/components/ButtonV2/buttonV2.dark.tokens.d.ts +3 -0
- package/dist/components/ButtonV2/buttonV2.light.tokens.d.ts +3 -0
- package/dist/components/ButtonV2/buttonV2.tokens.d.ts +67 -0
- package/dist/components/ButtonV2/buttonV2.types.d.ts +64 -0
- package/dist/components/ButtonV2/index.d.ts +8 -0
- package/dist/components/Card/index.d.ts +1 -0
- package/dist/components/Charts/CustomTooltip.d.ts +3 -1
- package/dist/components/Charts/index.d.ts +1 -0
- package/dist/components/Charts/utils.d.ts +12 -0
- package/dist/components/ChatInput/index.d.ts +1 -0
- package/dist/components/DataTable/index.d.ts +1 -1
- package/dist/components/DateRangePicker/index.d.ts +1 -0
- package/dist/components/Directory/index.d.ts +1 -0
- package/dist/components/Inputs/AutofillStyles/AutofillStyles.d.ts +1 -0
- package/dist/components/Inputs/DropdownInput/index.d.ts +1 -0
- package/dist/components/Inputs/MultiValueInput/MultiValueInput.d.ts +1 -1
- package/dist/components/Inputs/MultiValueInput/index.d.ts +1 -0
- package/dist/components/Inputs/MultiValueInput/types.d.ts +2 -0
- package/dist/components/Inputs/NumberInput/index.d.ts +1 -0
- package/dist/components/Inputs/OTPInput/index.d.ts +1 -0
- package/dist/components/Inputs/SearchInput/index.d.ts +1 -0
- package/dist/components/Inputs/TextInput/index.d.ts +1 -0
- package/dist/components/Inputs/UnitInput/index.d.ts +1 -0
- package/dist/components/KeyValuePair/index.d.ts +1 -0
- package/dist/components/Menu/index.d.ts +1 -0
- package/dist/components/Menu/types.d.ts +10 -0
- package/dist/components/Modal/index.d.ts +1 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/dist/components/MultiSelect/index.d.ts +1 -0
- package/dist/components/MultiSelect/types.d.ts +1 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Primitives/Block/Block.d.ts +2 -0
- package/dist/components/Primitives/Group/Group.d.ts +4 -0
- package/dist/components/Primitives/Group/index.d.ts +3 -0
- package/dist/components/Primitives/Group/types.d.ts +81 -0
- package/dist/components/Primitives/Group/utils.d.ts +35 -0
- package/dist/components/Primitives/PrimitiveButton/PrimitiveButton.d.ts +4 -0
- package/dist/components/ProgressBar/index.d.ts +1 -0
- package/dist/components/Sidebar/index.d.ts +1 -0
- package/dist/components/SingleSelect/index.d.ts +1 -0
- package/dist/components/Snackbar/index.d.ts +1 -0
- package/dist/components/StatCard/StatCard.d.ts +1 -1
- package/dist/components/StatCard/index.d.ts +1 -0
- package/dist/components/StatCard/types.d.ts +3 -2
- package/dist/components/StatCard/utils.d.ts +1 -1
- package/dist/components/Stepper/index.d.ts +1 -0
- package/dist/components/Tabs/Tabs.d.ts +1 -0
- package/dist/components/Tabs/TabsList.d.ts +1 -0
- package/dist/components/Tabs/index.d.ts +1 -0
- package/dist/components/Tabs/types.d.ts +2 -2
- package/dist/components/TagGroupV2/TagGroupV2.d.ts +4 -0
- package/dist/components/TagGroupV2/TagGroupV2.types.d.ts +8 -0
- package/dist/components/TagGroupV2/index.d.ts +2 -0
- package/dist/components/TagV2/TagSkeleton.d.ts +15 -0
- package/dist/components/TagV2/TagV2.d.ts +22 -0
- package/dist/components/TagV2/TagV2.types.d.ts +46 -0
- package/dist/components/TagV2/index.d.ts +2 -0
- package/dist/components/TagV2/tagV2.dark.tokens.d.ts +3 -0
- package/dist/components/TagV2/tagV2.light.tokens.d.ts +3 -0
- package/dist/components/TagV2/tagV2.tokens.d.ts +62 -0
- package/dist/components/TagV2/utils.d.ts +6 -0
- package/dist/components/Tags/index.d.ts +1 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/Topbar/index.d.ts +1 -0
- package/dist/components/Upload/index.d.ts +2 -0
- package/dist/components/Upload/types.d.ts +14 -0
- package/dist/components/Upload/utils.d.ts +1 -1
- package/dist/components/common/TruncatedTextWithTooltip.d.ts +1 -2
- package/dist/context/ThemeContext.d.ts +4 -0
- package/dist/context/useComponentToken.d.ts +3 -1
- package/dist/global-utils/GlobalUtils.d.ts +1 -0
- package/dist/main.js +38131 -33933
- package/dist/pollyfills/resizeObserverPollyfill.d.ts +1 -0
- package/dist/tokens/font.tokens.d.ts +55 -0
- package/dist/utils/accessibility/aria-helpers.d.ts +202 -0
- package/dist/utils/accessibility/focus-helpers.d.ts +115 -0
- package/dist/utils/accessibility/icon-helpers.d.ts +3 -0
- package/dist/utils/accessibility/index.d.ts +21 -0
- package/dist/utils/accessibility/keyboard-helpers.d.ts +117 -0
- package/dist/utils/prop-helpers.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function patchResizeObserver(): void;
|
|
@@ -55,10 +55,65 @@ type FontSizeType = Readonly<{
|
|
|
55
55
|
lg: FontGroupType;
|
|
56
56
|
};
|
|
57
57
|
}>;
|
|
58
|
+
type FontSizesType = Readonly<{
|
|
59
|
+
10: CSSObject['fontSize'];
|
|
60
|
+
12: CSSObject['fontSize'];
|
|
61
|
+
14: CSSObject['fontSize'];
|
|
62
|
+
16: CSSObject['fontSize'];
|
|
63
|
+
18: CSSObject['fontSize'];
|
|
64
|
+
20: CSSObject['fontSize'];
|
|
65
|
+
24: CSSObject['fontSize'];
|
|
66
|
+
28: CSSObject['fontSize'];
|
|
67
|
+
32: CSSObject['fontSize'];
|
|
68
|
+
36: CSSObject['fontSize'];
|
|
69
|
+
40: CSSObject['fontSize'];
|
|
70
|
+
44: CSSObject['fontSize'];
|
|
71
|
+
48: CSSObject['fontSize'];
|
|
72
|
+
52: CSSObject['fontSize'];
|
|
73
|
+
56: CSSObject['fontSize'];
|
|
74
|
+
60: CSSObject['fontSize'];
|
|
75
|
+
64: CSSObject['fontSize'];
|
|
76
|
+
68: CSSObject['fontSize'];
|
|
77
|
+
72: CSSObject['fontSize'];
|
|
78
|
+
76: CSSObject['fontSize'];
|
|
79
|
+
80: CSSObject['fontSize'];
|
|
80
|
+
84: CSSObject['fontSize'];
|
|
81
|
+
88: CSSObject['fontSize'];
|
|
82
|
+
92: CSSObject['fontSize'];
|
|
83
|
+
96: CSSObject['fontSize'];
|
|
84
|
+
100: CSSObject['fontSize'];
|
|
85
|
+
}>;
|
|
86
|
+
type LineHeightType = Readonly<{
|
|
87
|
+
14: CSSObject['lineHeight'];
|
|
88
|
+
18: CSSObject['lineHeight'];
|
|
89
|
+
20: CSSObject['lineHeight'];
|
|
90
|
+
24: CSSObject['lineHeight'];
|
|
91
|
+
28: CSSObject['lineHeight'];
|
|
92
|
+
32: CSSObject['lineHeight'];
|
|
93
|
+
36: CSSObject['lineHeight'];
|
|
94
|
+
40: CSSObject['lineHeight'];
|
|
95
|
+
44: CSSObject['lineHeight'];
|
|
96
|
+
48: CSSObject['lineHeight'];
|
|
97
|
+
52: CSSObject['lineHeight'];
|
|
98
|
+
56: CSSObject['lineHeight'];
|
|
99
|
+
60: CSSObject['lineHeight'];
|
|
100
|
+
64: CSSObject['lineHeight'];
|
|
101
|
+
68: CSSObject['lineHeight'];
|
|
102
|
+
72: CSSObject['lineHeight'];
|
|
103
|
+
76: CSSObject['lineHeight'];
|
|
104
|
+
80: CSSObject['lineHeight'];
|
|
105
|
+
84: CSSObject['lineHeight'];
|
|
106
|
+
88: CSSObject['lineHeight'];
|
|
107
|
+
92: CSSObject['lineHeight'];
|
|
108
|
+
96: CSSObject['lineHeight'];
|
|
109
|
+
100: CSSObject['lineHeight'];
|
|
110
|
+
}>;
|
|
58
111
|
export type FontTokensType = Readonly<{
|
|
59
112
|
family: FontFamilyType;
|
|
60
113
|
weight: FontWeightType;
|
|
61
114
|
letterSpacing: LetterSpacingType;
|
|
115
|
+
fontSize: FontSizesType;
|
|
116
|
+
lineHeight: LineHeightType;
|
|
62
117
|
size: FontSizeType;
|
|
63
118
|
}>;
|
|
64
119
|
/**
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ARIA attribute helpers for consistent accessibility across all components
|
|
3
|
+
*
|
|
4
|
+
* These utilities ensure consistent ARIA implementation following WCAG 2.2 Level AA standards
|
|
5
|
+
* and reduce code duplication across components.
|
|
6
|
+
*/
|
|
7
|
+
export type AriaAttributes = {
|
|
8
|
+
'aria-label'?: string;
|
|
9
|
+
'aria-labelledby'?: string;
|
|
10
|
+
'aria-describedby'?: string;
|
|
11
|
+
'aria-expanded'?: boolean;
|
|
12
|
+
'aria-selected'?: boolean;
|
|
13
|
+
'aria-disabled'?: boolean;
|
|
14
|
+
'aria-busy'?: boolean;
|
|
15
|
+
'aria-invalid'?: boolean;
|
|
16
|
+
'aria-required'?: boolean;
|
|
17
|
+
'aria-controls'?: string;
|
|
18
|
+
'aria-live'?: 'polite' | 'assertive' | 'off';
|
|
19
|
+
'aria-atomic'?: boolean;
|
|
20
|
+
'aria-haspopup'?: 'true' | 'false' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
21
|
+
'aria-modal'?: boolean;
|
|
22
|
+
'aria-orientation'?: 'horizontal' | 'vertical';
|
|
23
|
+
role?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Generate ARIA attributes for button components
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const ariaAttrs = getButtonAriaAttributes({
|
|
31
|
+
* disabled: true,
|
|
32
|
+
* loading: false,
|
|
33
|
+
* ariaLabel: 'Close dialog'
|
|
34
|
+
* })
|
|
35
|
+
* <button {...ariaAttrs}>Close</button>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function getButtonAriaAttributes(props: {
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
loading?: boolean;
|
|
41
|
+
ariaLabel?: string;
|
|
42
|
+
ariaLabelledBy?: string;
|
|
43
|
+
}): AriaAttributes;
|
|
44
|
+
/**
|
|
45
|
+
* Generate ARIA attributes for input components
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* const ariaAttrs = getInputAriaAttributes({
|
|
50
|
+
* id: 'email-input',
|
|
51
|
+
* labelId: 'email-label',
|
|
52
|
+
* errorId: 'email-error',
|
|
53
|
+
* hintId: 'email-hint',
|
|
54
|
+
* required: true,
|
|
55
|
+
* invalid: true
|
|
56
|
+
* })
|
|
57
|
+
* <input {...ariaAttrs} />
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function getInputAriaAttributes(props: {
|
|
61
|
+
id: string;
|
|
62
|
+
labelId?: string;
|
|
63
|
+
errorId?: string;
|
|
64
|
+
hintId?: string;
|
|
65
|
+
required?: boolean;
|
|
66
|
+
invalid?: boolean;
|
|
67
|
+
describedBy?: string[];
|
|
68
|
+
}): AriaAttributes;
|
|
69
|
+
/**
|
|
70
|
+
* Generate ARIA attributes for modal/dialog components
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* const ariaAttrs = getModalAriaAttributes({
|
|
75
|
+
* id: 'dialog-1',
|
|
76
|
+
* titleId: 'dialog-title',
|
|
77
|
+
* descriptionId: 'dialog-description',
|
|
78
|
+
* isAlert: false
|
|
79
|
+
* })
|
|
80
|
+
* <div role="dialog" {...ariaAttrs}>...</div>
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function getModalAriaAttributes(props: {
|
|
84
|
+
id: string;
|
|
85
|
+
titleId: string;
|
|
86
|
+
descriptionId?: string;
|
|
87
|
+
isAlert?: boolean;
|
|
88
|
+
}): AriaAttributes;
|
|
89
|
+
/**
|
|
90
|
+
* Generate ARIA attributes for dropdown/select components
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```tsx
|
|
94
|
+
* const ariaAttrs = getDropdownAriaAttributes({
|
|
95
|
+
* id: 'select-1',
|
|
96
|
+
* isOpen: true,
|
|
97
|
+
* triggerId: 'select-trigger',
|
|
98
|
+
* menuId: 'select-menu'
|
|
99
|
+
* })
|
|
100
|
+
* <button {...ariaAttrs}>Select</button>
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function getDropdownAriaAttributes(props: {
|
|
104
|
+
id: string;
|
|
105
|
+
isOpen: boolean;
|
|
106
|
+
triggerId: string;
|
|
107
|
+
menuId: string;
|
|
108
|
+
hasPopup?: 'listbox' | 'menu';
|
|
109
|
+
}): AriaAttributes;
|
|
110
|
+
/**
|
|
111
|
+
* Generate ARIA attributes for tab components
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```tsx
|
|
115
|
+
* const ariaAttrs = getTabAriaAttributes({
|
|
116
|
+
* id: 'tab-1',
|
|
117
|
+
* panelId: 'panel-1',
|
|
118
|
+
* selected: true
|
|
119
|
+
* })
|
|
120
|
+
* <button role="tab" {...ariaAttrs}>Tab 1</button>
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare function getTabAriaAttributes(props: {
|
|
124
|
+
id: string;
|
|
125
|
+
panelId: string;
|
|
126
|
+
selected: boolean;
|
|
127
|
+
controls?: string;
|
|
128
|
+
}): AriaAttributes;
|
|
129
|
+
/**
|
|
130
|
+
* Generate ARIA attributes for tab panel components
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```tsx
|
|
134
|
+
* const ariaAttrs = getTabPanelAriaAttributes({
|
|
135
|
+
* id: 'panel-1',
|
|
136
|
+
* tabId: 'tab-1',
|
|
137
|
+
* labelledBy: 'tab-1-label'
|
|
138
|
+
* })
|
|
139
|
+
* <div role="tabpanel" {...ariaAttrs}>Panel content</div>
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export declare function getTabPanelAriaAttributes(props: {
|
|
143
|
+
id: string;
|
|
144
|
+
tabId: string;
|
|
145
|
+
labelledBy?: string;
|
|
146
|
+
}): AriaAttributes;
|
|
147
|
+
/**
|
|
148
|
+
* Generate ARIA attributes for accordion components
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```tsx
|
|
152
|
+
* const ariaAttrs = getAccordionAriaAttributes({
|
|
153
|
+
* headerId: 'accordion-header-1',
|
|
154
|
+
* contentId: 'accordion-content-1',
|
|
155
|
+
* expanded: false
|
|
156
|
+
* })
|
|
157
|
+
* <button {...ariaAttrs}>Accordion Header</button>
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare function getAccordionAriaAttributes(props: {
|
|
161
|
+
headerId: string;
|
|
162
|
+
contentId: string;
|
|
163
|
+
expanded: boolean;
|
|
164
|
+
}): AriaAttributes;
|
|
165
|
+
/**
|
|
166
|
+
* Generate ARIA live region attributes for dynamic content
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* const ariaAttrs = getLiveRegionAriaAttributes({
|
|
171
|
+
* live: 'assertive',
|
|
172
|
+
* atomic: true
|
|
173
|
+
* })
|
|
174
|
+
* <div {...ariaAttrs}>Error message</div>
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export declare function getLiveRegionAriaAttributes(props: {
|
|
178
|
+
live?: 'polite' | 'assertive' | 'off';
|
|
179
|
+
atomic?: boolean;
|
|
180
|
+
}): AriaAttributes;
|
|
181
|
+
/**
|
|
182
|
+
* Generate unique IDs for ARIA relationships
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```tsx
|
|
186
|
+
* const labelId = generateAriaId('label')
|
|
187
|
+
* const inputId = generateAriaId('input')
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export declare function generateAriaId(prefix: string): string;
|
|
191
|
+
/**
|
|
192
|
+
* Combine multiple ARIA attribute objects
|
|
193
|
+
* Later objects override earlier ones for conflicting keys
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```tsx
|
|
197
|
+
* const baseAttrs = getButtonAriaAttributes({ disabled: true })
|
|
198
|
+
* const additionalAttrs = { 'aria-label': 'Custom label' }
|
|
199
|
+
* const merged = mergeAriaAttributes(baseAttrs, additionalAttrs)
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export declare function mergeAriaAttributes(...attrs: Array<AriaAttributes | undefined>): AriaAttributes;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus management helpers for accessibility
|
|
3
|
+
*
|
|
4
|
+
* These utilities ensure consistent focus management across all components,
|
|
5
|
+
* following WCAG 2.2 Level AA standards for keyboard navigation and focus visibility.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Focus an element safely (handles cases where element might not exist)
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const inputRef = useRef<HTMLInputElement>(null)
|
|
13
|
+
* safeFocus(inputRef.current)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function safeFocus(element: HTMLElement | null): void;
|
|
17
|
+
/**
|
|
18
|
+
* Focus first focusable element in container
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const containerRef = useRef<HTMLDivElement>(null)
|
|
23
|
+
* focusFirstFocusable(containerRef.current!)
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function focusFirstFocusable(container: HTMLElement): void;
|
|
27
|
+
/**
|
|
28
|
+
* Focus last focusable element in container
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* const containerRef = useRef<HTMLDivElement>(null)
|
|
33
|
+
* focusLastFocusable(containerRef.current!)
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function focusLastFocusable(container: HTMLElement): void;
|
|
37
|
+
/**
|
|
38
|
+
* Store and restore focus (for modals, dropdowns, etc.)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const focusManager = createFocusManager()
|
|
43
|
+
*
|
|
44
|
+
* // When opening modal
|
|
45
|
+
* focusManager.store()
|
|
46
|
+
* focusFirstFocusable(modalRef.current!)
|
|
47
|
+
*
|
|
48
|
+
* // When closing modal
|
|
49
|
+
* focusManager.restore()
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function createFocusManager(): {
|
|
53
|
+
store: () => void;
|
|
54
|
+
restore: () => void;
|
|
55
|
+
getStored: () => HTMLElement | null;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Check if element is focusable
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* if (isFocusable(element)) {
|
|
63
|
+
* element.focus()
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function isFocusable(element: HTMLElement): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Get all focusable elements within a container
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* const focusables = getFocusableElements(containerRef.current!)
|
|
74
|
+
* focusables.forEach(el => console.log(el))
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function getFocusableElements(container: HTMLElement): HTMLElement[];
|
|
78
|
+
/**
|
|
79
|
+
* Check if focus is within a container
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* if (isFocusWithin(modalRef.current!)) {
|
|
84
|
+
* // Focus is inside modal
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function isFocusWithin(container: HTMLElement): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Focus next focusable element in document order
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```tsx
|
|
94
|
+
* focusNextFocusable(currentElement)
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function focusNextFocusable(currentElement: HTMLElement): void;
|
|
98
|
+
/**
|
|
99
|
+
* Focus previous focusable element in document order
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* focusPreviousFocusable(currentElement)
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function focusPreviousFocusable(currentElement: HTMLElement): void;
|
|
107
|
+
/**
|
|
108
|
+
* Remove focus from element
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```tsx
|
|
112
|
+
* removeFocus(element)
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function removeFocus(element: HTMLElement): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized accessibility utilities export
|
|
3
|
+
*
|
|
4
|
+
* This module provides shared accessibility utilities for consistent
|
|
5
|
+
* ARIA implementation, keyboard navigation, and focus management across
|
|
6
|
+
* all components in the Blend Design System.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import {
|
|
11
|
+
* getButtonAriaAttributes,
|
|
12
|
+
* createButtonKeyboardHandler,
|
|
13
|
+
* focusFirstFocusable
|
|
14
|
+
* } from '@juspay/blend-design-system/utils/accessibility'
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export * from './aria-helpers';
|
|
18
|
+
export * from './keyboard-helpers';
|
|
19
|
+
export * from './focus-helpers';
|
|
20
|
+
export type { AriaAttributes } from './aria-helpers';
|
|
21
|
+
export type { KeyboardHandler } from './keyboard-helpers';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Keyboard navigation helpers for consistent keyboard support across all components
|
|
4
|
+
*
|
|
5
|
+
* These utilities ensure consistent keyboard interaction patterns following
|
|
6
|
+
* WCAG 2.2 Level AA standards and ARIA Authoring Practices Guide.
|
|
7
|
+
*/
|
|
8
|
+
export type KeyboardHandler = {
|
|
9
|
+
onKeyDown: (e: KeyboardEvent<HTMLElement>) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Create keyboard handler for button-like elements
|
|
13
|
+
* Supports Enter and Space keys for activation
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const keyboardHandler = createButtonKeyboardHandler(
|
|
18
|
+
* () => handleClick(),
|
|
19
|
+
* false // disabled
|
|
20
|
+
* )
|
|
21
|
+
* <button {...keyboardHandler}>Click me</button>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createButtonKeyboardHandler(onClick: () => void, disabled?: boolean): KeyboardHandler;
|
|
25
|
+
/**
|
|
26
|
+
* Create keyboard handler for arrow key navigation
|
|
27
|
+
* Supports ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Home, and End keys
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const keyboardHandler = createArrowKeyHandler({
|
|
32
|
+
* onArrowDown: () => moveToNext(),
|
|
33
|
+
* onArrowUp: () => moveToPrevious(),
|
|
34
|
+
* onHome: () => moveToFirst(),
|
|
35
|
+
* onEnd: () => moveToLast()
|
|
36
|
+
* })
|
|
37
|
+
* <div {...keyboardHandler}>...</div>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createArrowKeyHandler(options: {
|
|
41
|
+
onArrowUp?: () => void;
|
|
42
|
+
onArrowDown?: () => void;
|
|
43
|
+
onArrowLeft?: () => void;
|
|
44
|
+
onArrowRight?: () => void;
|
|
45
|
+
onHome?: () => void;
|
|
46
|
+
onEnd?: () => void;
|
|
47
|
+
}): KeyboardHandler;
|
|
48
|
+
/**
|
|
49
|
+
* Create keyboard handler for escape key
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* const keyboardHandler = createEscapeHandler(() => closeModal())
|
|
54
|
+
* <div {...keyboardHandler}>Modal content</div>
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function createEscapeHandler(onEscape: () => void): KeyboardHandler;
|
|
58
|
+
/**
|
|
59
|
+
* Create keyboard handler for tab trapping (modals, dropdowns)
|
|
60
|
+
* Traps focus within a container by cycling between first and last elements
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```tsx
|
|
64
|
+
* const firstElement = containerRef.current?.querySelector('[tabindex="0"]')
|
|
65
|
+
* const lastElement = containerRef.current?.querySelector('[tabindex="0"]:last-child')
|
|
66
|
+
* const keyboardHandler = createTabTrapHandler(firstElement, lastElement)
|
|
67
|
+
* <div {...keyboardHandler}>Modal content</div>
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function createTabTrapHandler(firstElement: HTMLElement | null, lastElement: HTMLElement | null): KeyboardHandler;
|
|
71
|
+
/**
|
|
72
|
+
* Create keyboard handler for list navigation
|
|
73
|
+
* Combines arrow keys with Enter/Space for selection
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* const keyboardHandler = createListNavigationHandler({
|
|
78
|
+
* onArrowDown: () => moveToNext(),
|
|
79
|
+
* onArrowUp: () => moveToPrevious(),
|
|
80
|
+
* onSelect: () => selectCurrent()
|
|
81
|
+
* })
|
|
82
|
+
* <ul {...keyboardHandler}>...</ul>
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function createListNavigationHandler(options: {
|
|
86
|
+
onArrowDown?: () => void;
|
|
87
|
+
onArrowUp?: () => void;
|
|
88
|
+
onArrowLeft?: () => void;
|
|
89
|
+
onArrowRight?: () => void;
|
|
90
|
+
onHome?: () => void;
|
|
91
|
+
onEnd?: () => void;
|
|
92
|
+
onSelect?: () => void;
|
|
93
|
+
}): KeyboardHandler;
|
|
94
|
+
/**
|
|
95
|
+
* Create keyboard handler for grid navigation
|
|
96
|
+
* Supports arrow keys for 2D navigation
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* const keyboardHandler = createGridNavigationHandler({
|
|
101
|
+
* onArrowUp: () => moveUp(),
|
|
102
|
+
* onArrowDown: () => moveDown(),
|
|
103
|
+
* onArrowLeft: () => moveLeft(),
|
|
104
|
+
* onArrowRight: () => moveRight()
|
|
105
|
+
* })
|
|
106
|
+
* <div role="grid" {...keyboardHandler}>...</div>
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function createGridNavigationHandler(options: {
|
|
110
|
+
onArrowUp?: () => void;
|
|
111
|
+
onArrowDown?: () => void;
|
|
112
|
+
onArrowLeft?: () => void;
|
|
113
|
+
onArrowRight?: () => void;
|
|
114
|
+
onHome?: () => void;
|
|
115
|
+
onEnd?: () => void;
|
|
116
|
+
orientation?: 'horizontal' | 'vertical';
|
|
117
|
+
}): KeyboardHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function filterBlockedProps<T extends Record<string, unknown>>(props: T): Omit<T, 'className' | 'style'>;
|
package/package.json
CHANGED