@nice2dev/ui-core 1.0.10
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/CHANGELOG.md +63 -0
- package/README.md +62 -0
- package/dist/core/NiceInlineHelp.d.ts +69 -0
- package/dist/core/NiceInlineHelp.d.ts.map +1 -0
- package/dist/core/NiceThemeProvider.d.ts +31 -0
- package/dist/core/NiceThemeProvider.d.ts.map +1 -0
- package/dist/core/NiceThemeVariants.d.ts +55 -0
- package/dist/core/NiceThemeVariants.d.ts.map +1 -0
- package/dist/core/NiceUserPreferences.d.ts +304 -0
- package/dist/core/NiceUserPreferences.d.ts.map +1 -0
- package/dist/core/a11y-advanced.d.ts +157 -0
- package/dist/core/a11y-advanced.d.ts.map +1 -0
- package/dist/core/a11y.d.ts +299 -0
- package/dist/core/a11y.d.ts.map +1 -0
- package/dist/core/access-control.d.ts +59 -0
- package/dist/core/access-control.d.ts.map +1 -0
- package/dist/core/adapters.d.ts +178 -0
- package/dist/core/adapters.d.ts.map +1 -0
- package/dist/core/ai.d.ts +191 -0
- package/dist/core/ai.d.ts.map +1 -0
- package/dist/core/animations.d.ts +48 -0
- package/dist/core/animations.d.ts.map +1 -0
- package/dist/core/colorBlind.d.ts +22 -0
- package/dist/core/colorBlind.d.ts.map +1 -0
- package/dist/core/datasource-advanced.d.ts +261 -0
- package/dist/core/datasource-advanced.d.ts.map +1 -0
- package/dist/core/datasource-aggregation.d.ts +221 -0
- package/dist/core/datasource-aggregation.d.ts.map +1 -0
- package/dist/core/datasource-hooks.d.ts +93 -0
- package/dist/core/datasource-hooks.d.ts.map +1 -0
- package/dist/core/datasource-offline.d.ts +201 -0
- package/dist/core/datasource-offline.d.ts.map +1 -0
- package/dist/core/datasource.d.ts +181 -0
- package/dist/core/datasource.d.ts.map +1 -0
- package/dist/core/displayMode.d.ts +46 -0
- package/dist/core/displayMode.d.ts.map +1 -0
- package/dist/core/displayStyle.d.ts +79 -0
- package/dist/core/displayStyle.d.ts.map +1 -0
- package/dist/core/helpContext.d.ts +97 -0
- package/dist/core/helpContext.d.ts.map +1 -0
- package/dist/core/hooks.d.ts +149 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +10 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/i18nDictionaries.d.ts +4 -0
- package/dist/core/i18nDictionaries.d.ts.map +1 -0
- package/dist/core/icons.d.ts +45 -0
- package/dist/core/icons.d.ts.map +1 -0
- package/dist/core/icuMessageFormat.d.ts +10 -0
- package/dist/core/icuMessageFormat.d.ts.map +1 -0
- package/dist/core/leak-detector.d.ts +263 -0
- package/dist/core/leak-detector.d.ts.map +1 -0
- package/dist/core/omniverkTypes.d.ts +164 -0
- package/dist/core/omniverkTypes.d.ts.map +1 -0
- package/dist/core/pluginSystem.d.ts +97 -0
- package/dist/core/pluginSystem.d.ts.map +1 -0
- package/dist/core/profiling.d.ts +276 -0
- package/dist/core/profiling.d.ts.map +1 -0
- package/dist/core/responsive.d.ts +107 -0
- package/dist/core/responsive.d.ts.map +1 -0
- package/dist/core/rtl.d.ts +47 -0
- package/dist/core/rtl.d.ts.map +1 -0
- package/dist/core/sanitizeHtml.d.ts +16 -0
- package/dist/core/sanitizeHtml.d.ts.map +1 -0
- package/dist/core/testing.d.ts +107 -0
- package/dist/core/testing.d.ts.map +1 -0
- package/dist/core/theme.d.ts +213 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/themeGallery.d.ts +104 -0
- package/dist/core/themeGallery.d.ts.map +1 -0
- package/dist/core/themePacks.d.ts +53 -0
- package/dist/core/themePacks.d.ts.map +1 -0
- package/dist/core/themePacksExtended.d.ts +59 -0
- package/dist/core/themePacksExtended.d.ts.map +1 -0
- package/dist/core/themePresets.d.ts +10 -0
- package/dist/core/themePresets.d.ts.map +1 -0
- package/dist/core/themeVariants.d.ts +204 -0
- package/dist/core/themeVariants.d.ts.map +1 -0
- package/dist/core/touch.d.ts +208 -0
- package/dist/core/touch.d.ts.map +1 -0
- package/dist/core/traceless.d.ts +461 -0
- package/dist/core/traceless.d.ts.map +1 -0
- package/dist/core/types.d.ts +105 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/useThemeIsDark.d.ts +15 -0
- package/dist/core/useThemeIsDark.d.ts.map +1 -0
- package/dist/index.cjs +128 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +16881 -0
- package/dist/index.mjs.map +1 -0
- package/dist/performance/concurrent.d.ts +190 -0
- package/dist/performance/concurrent.d.ts.map +1 -0
- package/dist/performance/images.d.ts +189 -0
- package/dist/performance/images.d.ts.map +1 -0
- package/dist/performance/index.d.ts +17 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/memory.d.ts +223 -0
- package/dist/performance/memory.d.ts.map +1 -0
- package/dist/performance/virtualization.d.ts +166 -0
- package/dist/performance/virtualization.d.ts.map +1 -0
- package/dist/performance/workers.d.ts +125 -0
- package/dist/performance/workers.d.ts.map +1 -0
- package/dist/viewSchema.d.ts +81 -0
- package/dist/viewSchema.d.ts.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* a11y-advanced.ts — Advanced accessibility features.
|
|
3
|
+
*
|
|
4
|
+
* Voice control, screen reader optimizations, cognitive accessibility,
|
|
5
|
+
* and WCAG 2.2 AAA compliance utilities.
|
|
6
|
+
*/
|
|
7
|
+
export interface VoiceCommand {
|
|
8
|
+
phrase: string | RegExp;
|
|
9
|
+
action: (matches: string[], transcript: string) => void;
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface VoiceControlOptions {
|
|
13
|
+
language?: string;
|
|
14
|
+
continuous?: boolean;
|
|
15
|
+
interimResults?: boolean;
|
|
16
|
+
commands?: VoiceCommand[];
|
|
17
|
+
onTranscript?: (text: string, isFinal: boolean) => void;
|
|
18
|
+
onError?: (error: string) => void;
|
|
19
|
+
}
|
|
20
|
+
export interface VoiceControlApi {
|
|
21
|
+
isListening: boolean;
|
|
22
|
+
isSupported: boolean;
|
|
23
|
+
start: () => void;
|
|
24
|
+
stop: () => void;
|
|
25
|
+
transcript: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook for voice-controlled UI interaction.
|
|
29
|
+
*
|
|
30
|
+
* Usage:
|
|
31
|
+
* const { isListening, start, stop } = useVoiceControl({
|
|
32
|
+
* commands: [
|
|
33
|
+
* { phrase: /open (.+)/i, action: ([, name]) => openPage(name) },
|
|
34
|
+
* { phrase: "scroll down", action: () => window.scrollBy(0, 300) },
|
|
35
|
+
* ],
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
38
|
+
export declare function useVoiceControl(options?: VoiceControlOptions): VoiceControlApi;
|
|
39
|
+
export interface LiveRegionOptions {
|
|
40
|
+
politeness?: 'polite' | 'assertive' | 'off';
|
|
41
|
+
atomic?: boolean;
|
|
42
|
+
relevant?: 'additions' | 'removals' | 'text' | 'all';
|
|
43
|
+
clearAfterMs?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Hook to announce dynamic content to screen readers via ARIA live regions.
|
|
47
|
+
*/
|
|
48
|
+
export declare function useLiveAnnouncement(options?: LiveRegionOptions): {
|
|
49
|
+
message: string;
|
|
50
|
+
announce: (text: string) => void;
|
|
51
|
+
regionProps: {
|
|
52
|
+
role: "status";
|
|
53
|
+
'aria-live': "off" | "polite" | "assertive";
|
|
54
|
+
'aria-atomic': boolean;
|
|
55
|
+
'aria-relevant': "text" | "all" | "additions" | "removals" | "additions text";
|
|
56
|
+
style: {
|
|
57
|
+
position: "absolute";
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
overflow: "hidden";
|
|
61
|
+
clip: string;
|
|
62
|
+
whiteSpace: "nowrap";
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Screen reader-friendly route announcement.
|
|
68
|
+
*/
|
|
69
|
+
export declare function useRouteAnnouncement(): {
|
|
70
|
+
announcePageChange: (pageTitle: string) => void;
|
|
71
|
+
regionProps: {
|
|
72
|
+
role: "status";
|
|
73
|
+
'aria-live': "off" | "polite" | "assertive";
|
|
74
|
+
'aria-atomic': boolean;
|
|
75
|
+
'aria-relevant': "text" | "all" | "additions" | "removals" | "additions text";
|
|
76
|
+
style: {
|
|
77
|
+
position: "absolute";
|
|
78
|
+
width: number;
|
|
79
|
+
height: number;
|
|
80
|
+
overflow: "hidden";
|
|
81
|
+
clip: string;
|
|
82
|
+
whiteSpace: "nowrap";
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
message: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Enhanced focus management for complex widgets.
|
|
89
|
+
*/
|
|
90
|
+
export declare function useFocusManagement(): {
|
|
91
|
+
containerRef: import("react").RefObject<HTMLElement>;
|
|
92
|
+
focusFirst: () => void;
|
|
93
|
+
focusElement: (selector: string) => void;
|
|
94
|
+
getFocusableElements: () => HTMLElement[];
|
|
95
|
+
};
|
|
96
|
+
export interface CognitiveAccessibilityOptions {
|
|
97
|
+
/** Simplify interface by hiding non-essential elements. */
|
|
98
|
+
simplifiedMode?: boolean;
|
|
99
|
+
/** Increase spacing between interactive elements. */
|
|
100
|
+
increasedSpacing?: boolean;
|
|
101
|
+
/** Show reading guides (horizontal line that follows cursor). */
|
|
102
|
+
readingGuide?: boolean;
|
|
103
|
+
/** Highlight focused element with thick outline. */
|
|
104
|
+
enhancedFocus?: boolean;
|
|
105
|
+
/** Reduce animation motion. */
|
|
106
|
+
reduceMotion?: boolean;
|
|
107
|
+
/** Show text labels alongside icons. */
|
|
108
|
+
iconLabels?: boolean;
|
|
109
|
+
/** Larger click targets (56px minimum). */
|
|
110
|
+
largeTargets?: boolean;
|
|
111
|
+
/** Dyslexia-friendly font. */
|
|
112
|
+
dyslexiaFont?: boolean;
|
|
113
|
+
/** Line spacing multiplier (1.0 - 3.0). */
|
|
114
|
+
lineSpacing?: number;
|
|
115
|
+
/** Word spacing multiplier (1.0 - 3.0). */
|
|
116
|
+
wordSpacing?: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Hook for cognitive accessibility features.
|
|
120
|
+
*
|
|
121
|
+
* Returns CSS class names and inline styles to apply to the app root.
|
|
122
|
+
*/
|
|
123
|
+
export declare function useCognitiveAccessibility(options?: CognitiveAccessibilityOptions): {
|
|
124
|
+
settings: {
|
|
125
|
+
simplifiedMode?: boolean;
|
|
126
|
+
increasedSpacing?: boolean;
|
|
127
|
+
readingGuide?: boolean;
|
|
128
|
+
enhancedFocus?: boolean;
|
|
129
|
+
reduceMotion?: boolean;
|
|
130
|
+
iconLabels?: boolean;
|
|
131
|
+
largeTargets?: boolean;
|
|
132
|
+
dyslexiaFont?: boolean;
|
|
133
|
+
lineSpacing?: number;
|
|
134
|
+
wordSpacing?: number;
|
|
135
|
+
};
|
|
136
|
+
updateSetting: <K extends keyof CognitiveAccessibilityOptions>(key: K, value: CognitiveAccessibilityOptions[K]) => void;
|
|
137
|
+
css: string;
|
|
138
|
+
rootClasses: string;
|
|
139
|
+
rootStyle: Record<string, string>;
|
|
140
|
+
};
|
|
141
|
+
export interface WCAGCheckResult {
|
|
142
|
+
rule: string;
|
|
143
|
+
level: 'A' | 'AA' | 'AAA';
|
|
144
|
+
passed: boolean;
|
|
145
|
+
message: string;
|
|
146
|
+
element?: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Check color contrast against WCAG AAA requirements.
|
|
150
|
+
* AAA requires 7:1 for normal text, 4.5:1 for large text.
|
|
151
|
+
*/
|
|
152
|
+
export declare function checkContrastAAA(foreground: string, background: string, isLargeText?: boolean): WCAGCheckResult;
|
|
153
|
+
/**
|
|
154
|
+
* Run a comprehensive WCAG 2.2 AAA audit on the current document.
|
|
155
|
+
*/
|
|
156
|
+
export declare function auditWCAG22AAA(): WCAGCheckResult[];
|
|
157
|
+
//# sourceMappingURL=a11y-advanced.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y-advanced.d.ts","sourceRoot":"","sources":["../../src/core/a11y-advanced.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA8BH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,mBAAwB,GAAG,eAAe,CA8FlF;AAID,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC;IACrD,YAAY,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,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,UAAQ,GAClB,eAAe,CAYjB;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,eAAe,EAAE,CAiFlD"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface NiceA11yConfig {
|
|
3
|
+
/** Announce state changes to screen readers (default: true) */
|
|
4
|
+
announceChanges: boolean;
|
|
5
|
+
/** Reduce motion for users with vestibular motion disorders (default: 'auto' = respect OS setting) */
|
|
6
|
+
reduceMotion: 'auto' | 'always' | 'never';
|
|
7
|
+
/** High contrast mode (default: 'auto' = respect OS setting) */
|
|
8
|
+
highContrast: 'auto' | 'always' | 'never';
|
|
9
|
+
/** Focus visible style: 'auto' uses :focus-visible, 'always' shows on any focus */
|
|
10
|
+
focusStyle: 'auto' | 'always';
|
|
11
|
+
/** Whether keyboard shortcuts are enabled (default: true) */
|
|
12
|
+
keyboardShortcuts: boolean;
|
|
13
|
+
/** Minimum touch target size in px (WCAG 2.5.8 — 24px minimum) */
|
|
14
|
+
minTouchTarget: number;
|
|
15
|
+
}
|
|
16
|
+
interface A11yContextValue {
|
|
17
|
+
config: NiceA11yConfig;
|
|
18
|
+
announce: (message: string, priority?: 'polite' | 'assertive') => void;
|
|
19
|
+
prefersReducedMotion: boolean;
|
|
20
|
+
prefersHighContrast: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface NiceA11yProviderProps {
|
|
23
|
+
config?: Partial<NiceA11yConfig>;
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export declare const NiceA11yProvider: React.FC<NiceA11yProviderProps>;
|
|
27
|
+
export declare function useNiceA11y(): A11yContextValue;
|
|
28
|
+
/** Build aria-describedby from helper/error text ids */
|
|
29
|
+
export declare function buildAriaDescribedBy(...ids: (string | undefined | null | false)[]): string | undefined;
|
|
30
|
+
/** Build standard form field ARIA attributes */
|
|
31
|
+
export declare function buildFormFieldAria(props: {
|
|
32
|
+
id: string;
|
|
33
|
+
label?: string;
|
|
34
|
+
error?: string;
|
|
35
|
+
helperText?: string;
|
|
36
|
+
required?: boolean;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
readOnly?: boolean;
|
|
39
|
+
}): Record<string, string | boolean | undefined>;
|
|
40
|
+
export type ArrowDirection = 'horizontal' | 'vertical' | 'both' | 'grid';
|
|
41
|
+
export interface UseRovingTabIndexOptions {
|
|
42
|
+
/** Direction of arrow key navigation */
|
|
43
|
+
direction: ArrowDirection;
|
|
44
|
+
/** Wrap around from last to first and vice versa (default: true) */
|
|
45
|
+
wrap?: boolean;
|
|
46
|
+
/** Selector for focusable items within the container */
|
|
47
|
+
itemSelector?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Roving tabindex for keyboard navigation in composite widgets
|
|
51
|
+
* (toolbars, radio groups, menu bars, tab lists, grids).
|
|
52
|
+
*
|
|
53
|
+
* Only one item has tabIndex=0 (the active one); others have tabIndex=-1.
|
|
54
|
+
* Arrow keys move focus between items.
|
|
55
|
+
*/
|
|
56
|
+
export declare function useRovingTabIndex(containerRef: React.RefObject<HTMLElement | null>, options: UseRovingTabIndexOptions): void;
|
|
57
|
+
/** Return focus to the element that was focused before the component mounted */
|
|
58
|
+
export declare function useRestoreFocus(active: boolean): void;
|
|
59
|
+
/** VisuallyHidden component for screen-reader-only text */
|
|
60
|
+
export declare const NiceVisuallyHidden: React.FC<{
|
|
61
|
+
children: React.ReactNode;
|
|
62
|
+
as?: keyof JSX.IntrinsicElements;
|
|
63
|
+
}>;
|
|
64
|
+
export interface NiceSkipLinkProps {
|
|
65
|
+
/** Target element id (without #) */
|
|
66
|
+
targetId: string;
|
|
67
|
+
/** Link text (default: 'Skip to main content') */
|
|
68
|
+
children?: React.ReactNode;
|
|
69
|
+
}
|
|
70
|
+
export declare const NiceSkipLink: React.FC<NiceSkipLinkProps>;
|
|
71
|
+
/** Standard keyboard shortcut definition for a control */
|
|
72
|
+
export interface KeyboardShortcut {
|
|
73
|
+
/** Key combination (e.g., 'Enter', 'Ctrl+S', 'Escape') */
|
|
74
|
+
key: string;
|
|
75
|
+
/** Description of what the shortcut does */
|
|
76
|
+
description: string;
|
|
77
|
+
/** i18n key for the description */
|
|
78
|
+
descriptionKey?: string;
|
|
79
|
+
/** Modifier keys required */
|
|
80
|
+
modifiers?: ('ctrl' | 'alt' | 'shift' | 'meta')[];
|
|
81
|
+
}
|
|
82
|
+
/** Common keyboard shortcuts used across controls */
|
|
83
|
+
export declare const COMMON_SHORTCUTS: {
|
|
84
|
+
readonly submit: {
|
|
85
|
+
readonly key: "Enter";
|
|
86
|
+
readonly description: "Submit / Confirm";
|
|
87
|
+
readonly descriptionKey: "shortcuts.submit";
|
|
88
|
+
};
|
|
89
|
+
readonly cancel: {
|
|
90
|
+
readonly key: "Escape";
|
|
91
|
+
readonly description: "Cancel / Close";
|
|
92
|
+
readonly descriptionKey: "shortcuts.cancel";
|
|
93
|
+
};
|
|
94
|
+
readonly clear: {
|
|
95
|
+
readonly key: "Delete";
|
|
96
|
+
readonly description: "Clear value";
|
|
97
|
+
readonly descriptionKey: "shortcuts.clear";
|
|
98
|
+
readonly modifiers: readonly ["ctrl"];
|
|
99
|
+
};
|
|
100
|
+
readonly moveUp: {
|
|
101
|
+
readonly key: "ArrowUp";
|
|
102
|
+
readonly description: "Move up";
|
|
103
|
+
readonly descriptionKey: "shortcuts.moveUp";
|
|
104
|
+
};
|
|
105
|
+
readonly moveDown: {
|
|
106
|
+
readonly key: "ArrowDown";
|
|
107
|
+
readonly description: "Move down";
|
|
108
|
+
readonly descriptionKey: "shortcuts.moveDown";
|
|
109
|
+
};
|
|
110
|
+
readonly moveLeft: {
|
|
111
|
+
readonly key: "ArrowLeft";
|
|
112
|
+
readonly description: "Move left";
|
|
113
|
+
readonly descriptionKey: "shortcuts.moveLeft";
|
|
114
|
+
};
|
|
115
|
+
readonly moveRight: {
|
|
116
|
+
readonly key: "ArrowRight";
|
|
117
|
+
readonly description: "Move right";
|
|
118
|
+
readonly descriptionKey: "shortcuts.moveRight";
|
|
119
|
+
};
|
|
120
|
+
readonly first: {
|
|
121
|
+
readonly key: "Home";
|
|
122
|
+
readonly description: "Go to first";
|
|
123
|
+
readonly descriptionKey: "shortcuts.first";
|
|
124
|
+
};
|
|
125
|
+
readonly last: {
|
|
126
|
+
readonly key: "End";
|
|
127
|
+
readonly description: "Go to last";
|
|
128
|
+
readonly descriptionKey: "shortcuts.last";
|
|
129
|
+
};
|
|
130
|
+
readonly pageUp: {
|
|
131
|
+
readonly key: "PageUp";
|
|
132
|
+
readonly description: "Page up";
|
|
133
|
+
readonly descriptionKey: "shortcuts.pageUp";
|
|
134
|
+
};
|
|
135
|
+
readonly pageDown: {
|
|
136
|
+
readonly key: "PageDown";
|
|
137
|
+
readonly description: "Page down";
|
|
138
|
+
readonly descriptionKey: "shortcuts.pageDown";
|
|
139
|
+
};
|
|
140
|
+
readonly selectAll: {
|
|
141
|
+
readonly key: "A";
|
|
142
|
+
readonly description: "Select all";
|
|
143
|
+
readonly descriptionKey: "shortcuts.selectAll";
|
|
144
|
+
readonly modifiers: readonly ["ctrl"];
|
|
145
|
+
};
|
|
146
|
+
readonly toggleSelect: {
|
|
147
|
+
readonly key: "Space";
|
|
148
|
+
readonly description: "Toggle selection";
|
|
149
|
+
readonly descriptionKey: "shortcuts.toggleSelect";
|
|
150
|
+
};
|
|
151
|
+
readonly undo: {
|
|
152
|
+
readonly key: "Z";
|
|
153
|
+
readonly description: "Undo";
|
|
154
|
+
readonly descriptionKey: "shortcuts.undo";
|
|
155
|
+
readonly modifiers: readonly ["ctrl"];
|
|
156
|
+
};
|
|
157
|
+
readonly redo: {
|
|
158
|
+
readonly key: "Y";
|
|
159
|
+
readonly description: "Redo";
|
|
160
|
+
readonly descriptionKey: "shortcuts.redo";
|
|
161
|
+
readonly modifiers: readonly ["ctrl"];
|
|
162
|
+
};
|
|
163
|
+
readonly copy: {
|
|
164
|
+
readonly key: "C";
|
|
165
|
+
readonly description: "Copy";
|
|
166
|
+
readonly descriptionKey: "shortcuts.copy";
|
|
167
|
+
readonly modifiers: readonly ["ctrl"];
|
|
168
|
+
};
|
|
169
|
+
readonly paste: {
|
|
170
|
+
readonly key: "V";
|
|
171
|
+
readonly description: "Paste";
|
|
172
|
+
readonly descriptionKey: "shortcuts.paste";
|
|
173
|
+
readonly modifiers: readonly ["ctrl"];
|
|
174
|
+
};
|
|
175
|
+
readonly cut: {
|
|
176
|
+
readonly key: "X";
|
|
177
|
+
readonly description: "Cut";
|
|
178
|
+
readonly descriptionKey: "shortcuts.cut";
|
|
179
|
+
readonly modifiers: readonly ["ctrl"];
|
|
180
|
+
};
|
|
181
|
+
readonly edit: {
|
|
182
|
+
readonly key: "Enter";
|
|
183
|
+
readonly description: "Edit cell";
|
|
184
|
+
readonly descriptionKey: "shortcuts.edit";
|
|
185
|
+
};
|
|
186
|
+
readonly tab: {
|
|
187
|
+
readonly key: "Tab";
|
|
188
|
+
readonly description: "Next cell";
|
|
189
|
+
readonly descriptionKey: "shortcuts.tab";
|
|
190
|
+
};
|
|
191
|
+
readonly shiftTab: {
|
|
192
|
+
readonly key: "Tab";
|
|
193
|
+
readonly description: "Previous cell";
|
|
194
|
+
readonly descriptionKey: "shortcuts.shiftTab";
|
|
195
|
+
readonly modifiers: readonly ["shift"];
|
|
196
|
+
};
|
|
197
|
+
readonly open: {
|
|
198
|
+
readonly key: "ArrowDown";
|
|
199
|
+
readonly description: "Open dropdown";
|
|
200
|
+
readonly descriptionKey: "shortcuts.open";
|
|
201
|
+
};
|
|
202
|
+
readonly close: {
|
|
203
|
+
readonly key: "Escape";
|
|
204
|
+
readonly description: "Close popup";
|
|
205
|
+
readonly descriptionKey: "shortcuts.close";
|
|
206
|
+
};
|
|
207
|
+
readonly increment: {
|
|
208
|
+
readonly key: "ArrowUp";
|
|
209
|
+
readonly description: "Increase value";
|
|
210
|
+
readonly descriptionKey: "shortcuts.increment";
|
|
211
|
+
};
|
|
212
|
+
readonly decrement: {
|
|
213
|
+
readonly key: "ArrowDown";
|
|
214
|
+
readonly description: "Decrease value";
|
|
215
|
+
readonly descriptionKey: "shortcuts.decrement";
|
|
216
|
+
};
|
|
217
|
+
readonly incrementBig: {
|
|
218
|
+
readonly key: "PageUp";
|
|
219
|
+
readonly description: "Increase by 10";
|
|
220
|
+
readonly descriptionKey: "shortcuts.incrementBig";
|
|
221
|
+
};
|
|
222
|
+
readonly decrementBig: {
|
|
223
|
+
readonly key: "PageDown";
|
|
224
|
+
readonly description: "Decrease by 10";
|
|
225
|
+
readonly descriptionKey: "shortcuts.decrementBig";
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
/** Format a keyboard shortcut for display */
|
|
229
|
+
export declare function formatShortcut(shortcut: KeyboardShortcut): string;
|
|
230
|
+
/** Check if a keyboard event matches a shortcut */
|
|
231
|
+
export declare function matchesShortcut(e: React.KeyboardEvent | KeyboardEvent, shortcut: KeyboardShortcut): boolean;
|
|
232
|
+
export interface NiceKeyboardHintProps {
|
|
233
|
+
/** Array of keyboard shortcuts to display */
|
|
234
|
+
shortcuts: KeyboardShortcut[];
|
|
235
|
+
/** Position of the tooltip */
|
|
236
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
237
|
+
/** Custom trigger icon (default: ?) */
|
|
238
|
+
icon?: React.ReactNode;
|
|
239
|
+
/** Size of the hint trigger */
|
|
240
|
+
size?: 'sm' | 'md';
|
|
241
|
+
/** Additional class name */
|
|
242
|
+
className?: string;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* A small question mark icon that shows keyboard shortcuts on hover.
|
|
246
|
+
* Use this to inform users about available keyboard interactions.
|
|
247
|
+
*/
|
|
248
|
+
export declare const NiceKeyboardHint: React.FC<NiceKeyboardHintProps>;
|
|
249
|
+
export interface UseSubmitOnEnterOptions {
|
|
250
|
+
/** Enable submit on Enter (default: false) */
|
|
251
|
+
enabled?: boolean;
|
|
252
|
+
/** Callback to execute on Enter */
|
|
253
|
+
onSubmit?: () => void;
|
|
254
|
+
/** Prevent default behavior (default: true) */
|
|
255
|
+
preventDefault?: boolean;
|
|
256
|
+
/** Require Ctrl+Enter instead of just Enter (default: false) */
|
|
257
|
+
requireCtrl?: boolean;
|
|
258
|
+
/** Skip if in a textarea (default: true) */
|
|
259
|
+
skipTextarea?: boolean;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Hook to handle Enter key as submit trigger.
|
|
263
|
+
* Returns a keydown handler to attach to the control.
|
|
264
|
+
*/
|
|
265
|
+
export declare function useSubmitOnEnter(options?: UseSubmitOnEnterOptions): (e: React.KeyboardEvent) => void;
|
|
266
|
+
export interface UseAccessibleClickOptions {
|
|
267
|
+
/** Click handler invoked on mouse click, Enter, or Space */
|
|
268
|
+
onClick?: (e: React.SyntheticEvent) => void;
|
|
269
|
+
/** Disable interaction (default: false) */
|
|
270
|
+
disabled?: boolean;
|
|
271
|
+
/** ARIA role to apply (default: 'button') */
|
|
272
|
+
role?: string;
|
|
273
|
+
/** Override tabIndex (default: 0 when enabled, -1 when disabled) */
|
|
274
|
+
tabIndex?: number;
|
|
275
|
+
/** Trigger on Space key in addition to Enter (default: true) */
|
|
276
|
+
triggerOnSpace?: boolean;
|
|
277
|
+
}
|
|
278
|
+
export interface AccessibleClickProps {
|
|
279
|
+
role: string;
|
|
280
|
+
tabIndex: number;
|
|
281
|
+
onClick: (e: React.MouseEvent) => void;
|
|
282
|
+
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
283
|
+
'aria-disabled'?: boolean;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Returns props to attach to a non-semantic element (e.g. <div>) to make it
|
|
287
|
+
* keyboard-accessible — handles Enter / Space activation, role, tabIndex,
|
|
288
|
+
* and respects the disabled state. Prefer a real <button> when possible;
|
|
289
|
+
* use this hook only when semantic elements are not feasible.
|
|
290
|
+
*
|
|
291
|
+
* Example:
|
|
292
|
+
* ```tsx
|
|
293
|
+
* const clickProps = useAccessibleClick({ onClick: handleSelect });
|
|
294
|
+
* return <div {...clickProps}>Click me</div>;
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
export declare function useAccessibleClick(options?: UseAccessibleClickOptions): AccessibleClickProps;
|
|
298
|
+
export {};
|
|
299
|
+
//# sourceMappingURL=a11y.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["../../src/core/a11y.tsx"],"names":[],"mappings":"AAKA,OAAO,KAQN,MAAM,OAAO,CAAC;AAIf,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,eAAe,EAAE,OAAO,CAAC;IACzB,sGAAsG;IACtG,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC1C,gEAAgE;IAChE,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC1C,mFAAmF;IACnF,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC9B,6DAA6D;IAC7D,iBAAiB,EAAE,OAAO,CAAC;IAC3B,kEAAkE;IAClE,cAAc,EAAE,MAAM,CAAC;CACxB;AAaD,UAAU,gBAAgB;IACxB,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW,KAAK,IAAI,CAAC;IACvE,oBAAoB,EAAE,OAAO,CAAC;IAC9B,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAMD,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACjC,QAAQ,EAAE,KAAK,CAAC,SAAS,C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,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,oBAAoB,CAqChG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NiceAccessMode } from './types';
|
|
3
|
+
export type { NiceAccessMode };
|
|
4
|
+
export interface NiceAccessPermissions {
|
|
5
|
+
/** Default access mode for all components under this provider */
|
|
6
|
+
defaultMode?: NiceAccessMode;
|
|
7
|
+
/** Per-component overrides: componentId → accessMode */
|
|
8
|
+
components?: Record<string, NiceAccessMode>;
|
|
9
|
+
/** Per-field overrides: "component.field" → accessMode */
|
|
10
|
+
fields?: Record<string, NiceAccessMode>;
|
|
11
|
+
}
|
|
12
|
+
export interface NiceAccessControlProps {
|
|
13
|
+
permissions: NiceAccessPermissions;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Provider that sets access control policies for all NiceToDev components
|
|
18
|
+
* within its tree. Components auto-check permissions via `useNiceAccessMode`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <NiceAccessControl permissions={{
|
|
23
|
+
* defaultMode: 'readOnly',
|
|
24
|
+
* components: { 'userForm': 'full', 'adminGrid': 'hidden' },
|
|
25
|
+
* fields: { 'userForm.email': 'disabled' },
|
|
26
|
+
* }}>
|
|
27
|
+
* <App />
|
|
28
|
+
* </NiceAccessControl>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const NiceAccessControl: React.FC<NiceAccessControlProps>;
|
|
32
|
+
/**
|
|
33
|
+
* Hook to resolve the effective access mode for the current component.
|
|
34
|
+
* Merges provider-level and prop-level access settings.
|
|
35
|
+
*
|
|
36
|
+
* @param propAccessMode - Explicit prop passed to the component (highest priority)
|
|
37
|
+
* @param componentId - Optional ID to look up in provider permissions
|
|
38
|
+
* @param fieldId - Optional field-level ID for form field granularity
|
|
39
|
+
* @returns The resolved NiceAccessMode
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const accessMode = useNiceAccessMode(props.accessMode, props.id);
|
|
44
|
+
* if (accessMode === 'hidden') return null;
|
|
45
|
+
* const isReadOnly = accessMode === 'readOnly' || accessMode === 'disabled';
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function useNiceAccessMode(propAccessMode?: NiceAccessMode, componentId?: string, fieldId?: string): NiceAccessMode;
|
|
49
|
+
/**
|
|
50
|
+
* Utility: apply access mode effects on HTML attributes.
|
|
51
|
+
* Returns props to spread onto interactive elements.
|
|
52
|
+
*/
|
|
53
|
+
export declare function accessModeAttrs(mode: NiceAccessMode): {
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
readOnly?: boolean;
|
|
56
|
+
'aria-disabled'?: boolean;
|
|
57
|
+
tabIndex?: number;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=access-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-control.d.ts","sourceRoot":"","sources":["../../src/core/access-control.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAM9C,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,qBAAqB;IACpC,iEAAiE;IACjE,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACzC;AAaD,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,qBAAqB,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAmB9D,CAAC;AAIF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,CAAC,EAAE,cAAc,EAC/B,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,GACf,cAAc,CAOhB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CASA"}
|