@pecb-ui/components 1.1.2 → 1.2.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/README.md +556 -556
- package/fesm2022/pecb-ui-components.mjs +3826 -1945
- package/fesm2022/pecb-ui-components.mjs.map +1 -1
- package/index.d.ts +3937 -3
- package/package.json +6 -8
- package/esm2022/lib/components/button/button.component.mjs +0 -171
- package/esm2022/lib/components/card/card.component.mjs +0 -182
- package/esm2022/lib/components/checkbox/checkbox.component.mjs +0 -126
- package/esm2022/lib/components/datepicker/datepicker.component.mjs +0 -349
- package/esm2022/lib/components/dropdown/dropdown.component.mjs +0 -329
- package/esm2022/lib/components/input/input.component.mjs +0 -321
- package/esm2022/lib/components/pagination/pagination.component.mjs +0 -197
- package/esm2022/lib/components/radio/radio.component.mjs +0 -147
- package/esm2022/lib/components/right-modal/right-modal.component.mjs +0 -234
- package/esm2022/lib/components/sidebar/sidebar.component.mjs +0 -155
- package/esm2022/lib/components/status/status.component.mjs +0 -50
- package/esm2022/lib/components/tab/tab.component.mjs +0 -151
- package/esm2022/lib/components/table/table.component.mjs +0 -503
- package/esm2022/lib/components/toggle/toggle.component.mjs +0 -126
- package/esm2022/lib/pecb-components.module.mjs +0 -118
- package/esm2022/lib/services/loading.service.mjs +0 -182
- package/esm2022/lib/services/notification.service.mjs +0 -144
- package/esm2022/lib/services/theme.service.mjs +0 -232
- package/esm2022/lib/shared/interfaces/component.interfaces.mjs +0 -2
- package/esm2022/lib/shared/types/common.types.mjs +0 -6
- package/esm2022/lib/shared/utils/accessibility.utils.mjs +0 -223
- package/esm2022/lib/shared/utils/dom.utils.mjs +0 -240
- package/esm2022/lib/shared/utils/error.utils.mjs +0 -277
- package/esm2022/lib/shared/utils/string.utils.mjs +0 -204
- package/esm2022/pecb-ui-components.mjs +0 -5
- package/esm2022/public-api.mjs +0 -53
- package/lib/components/button/button.component.d.ts +0 -130
- package/lib/components/card/card.component.d.ts +0 -140
- package/lib/components/checkbox/checkbox.component.d.ts +0 -74
- package/lib/components/datepicker/datepicker.component.d.ts +0 -155
- package/lib/components/dropdown/dropdown.component.d.ts +0 -144
- package/lib/components/input/input.component.d.ts +0 -215
- package/lib/components/pagination/pagination.component.d.ts +0 -53
- package/lib/components/radio/radio.component.d.ts +0 -93
- package/lib/components/right-modal/right-modal.component.d.ts +0 -137
- package/lib/components/sidebar/sidebar.component.d.ts +0 -97
- package/lib/components/status/status.component.d.ts +0 -19
- package/lib/components/tab/tab.component.d.ts +0 -102
- package/lib/components/table/table.component.d.ts +0 -403
- package/lib/components/toggle/toggle.component.d.ts +0 -74
- package/lib/pecb-components.module.d.ts +0 -37
- package/lib/services/loading.service.d.ts +0 -129
- package/lib/services/notification.service.d.ts +0 -136
- package/lib/services/theme.service.d.ts +0 -142
- package/lib/shared/interfaces/component.interfaces.d.ts +0 -283
- package/lib/shared/types/common.types.d.ts +0 -86
- package/lib/shared/utils/accessibility.utils.d.ts +0 -167
- package/lib/shared/utils/dom.utils.d.ts +0 -108
- package/lib/shared/utils/error.utils.d.ts +0 -191
- package/lib/shared/utils/string.utils.d.ts +0 -144
- package/public-api.d.ts +0 -24
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accessibility utility functions for PECB UI Components
|
|
3
|
-
* Helps ensure WCAG 2.1 compliance
|
|
4
|
-
* @module utils/accessibility
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ARIA live region politeness levels
|
|
8
|
-
*/
|
|
9
|
-
export type AriaLive = 'off' | 'polite' | 'assertive';
|
|
10
|
-
/**
|
|
11
|
-
* ARIA roles commonly used in components
|
|
12
|
-
*/
|
|
13
|
-
export type AriaRole = 'alert' | 'alertdialog' | 'button' | 'checkbox' | 'combobox' | 'dialog' | 'grid' | 'gridcell' | 'link' | 'listbox' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'option' | 'progressbar' | 'radio' | 'radiogroup' | 'scrollbar' | 'searchbox' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'tablist' | 'tabpanel' | 'textbox' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem';
|
|
14
|
-
/**
|
|
15
|
-
* Standard ARIA attributes interface for components
|
|
16
|
-
*/
|
|
17
|
-
export interface AriaAttributes {
|
|
18
|
-
role?: AriaRole;
|
|
19
|
-
'aria-label'?: string;
|
|
20
|
-
'aria-labelledby'?: string;
|
|
21
|
-
'aria-describedby'?: string;
|
|
22
|
-
'aria-expanded'?: boolean;
|
|
23
|
-
'aria-selected'?: boolean;
|
|
24
|
-
'aria-checked'?: boolean | 'mixed';
|
|
25
|
-
'aria-disabled'?: boolean;
|
|
26
|
-
'aria-hidden'?: boolean;
|
|
27
|
-
'aria-invalid'?: boolean;
|
|
28
|
-
'aria-required'?: boolean;
|
|
29
|
-
'aria-readonly'?: boolean;
|
|
30
|
-
'aria-pressed'?: boolean | 'mixed';
|
|
31
|
-
'aria-current'?: boolean | 'page' | 'step' | 'location' | 'date' | 'time';
|
|
32
|
-
'aria-haspopup'?: boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
33
|
-
'aria-controls'?: string;
|
|
34
|
-
'aria-owns'?: string;
|
|
35
|
-
'aria-live'?: AriaLive;
|
|
36
|
-
'aria-atomic'?: boolean;
|
|
37
|
-
'aria-busy'?: boolean;
|
|
38
|
-
'aria-valuemin'?: number;
|
|
39
|
-
'aria-valuemax'?: number;
|
|
40
|
-
'aria-valuenow'?: number;
|
|
41
|
-
'aria-valuetext'?: string;
|
|
42
|
-
'aria-orientation'?: 'horizontal' | 'vertical';
|
|
43
|
-
'aria-activedescendant'?: string;
|
|
44
|
-
'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both';
|
|
45
|
-
'aria-multiselectable'?: boolean;
|
|
46
|
-
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other';
|
|
47
|
-
'aria-level'?: number;
|
|
48
|
-
'aria-setsize'?: number;
|
|
49
|
-
'aria-posinset'?: number;
|
|
50
|
-
tabindex?: number;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Generate ARIA attributes for a button component
|
|
54
|
-
* @param options - Button accessibility options
|
|
55
|
-
* @returns ARIA attributes object
|
|
56
|
-
*/
|
|
57
|
-
export declare function getButtonAriaAttributes(options: {
|
|
58
|
-
label?: string;
|
|
59
|
-
pressed?: boolean;
|
|
60
|
-
expanded?: boolean;
|
|
61
|
-
disabled?: boolean;
|
|
62
|
-
controls?: string;
|
|
63
|
-
haspopup?: AriaAttributes['aria-haspopup'];
|
|
64
|
-
describedby?: string;
|
|
65
|
-
}): AriaAttributes;
|
|
66
|
-
/**
|
|
67
|
-
* Generate ARIA attributes for a dialog/modal component
|
|
68
|
-
* @param options - Dialog accessibility options
|
|
69
|
-
* @returns ARIA attributes object
|
|
70
|
-
*/
|
|
71
|
-
export declare function getDialogAriaAttributes(options: {
|
|
72
|
-
labelledby?: string;
|
|
73
|
-
describedby?: string;
|
|
74
|
-
modal?: boolean;
|
|
75
|
-
}): AriaAttributes;
|
|
76
|
-
/**
|
|
77
|
-
* Generate ARIA attributes for a form input
|
|
78
|
-
* @param options - Input accessibility options
|
|
79
|
-
* @returns ARIA attributes object
|
|
80
|
-
*/
|
|
81
|
-
export declare function getInputAriaAttributes(options: {
|
|
82
|
-
label?: string;
|
|
83
|
-
labelledby?: string;
|
|
84
|
-
describedby?: string;
|
|
85
|
-
invalid?: boolean;
|
|
86
|
-
required?: boolean;
|
|
87
|
-
readonly?: boolean;
|
|
88
|
-
disabled?: boolean;
|
|
89
|
-
errorId?: string;
|
|
90
|
-
helperId?: string;
|
|
91
|
-
}): AriaAttributes;
|
|
92
|
-
/**
|
|
93
|
-
* Generate ARIA attributes for a progress bar
|
|
94
|
-
* @param options - Progress accessibility options
|
|
95
|
-
* @returns ARIA attributes object
|
|
96
|
-
*/
|
|
97
|
-
export declare function getProgressAriaAttributes(options: {
|
|
98
|
-
value: number;
|
|
99
|
-
min?: number;
|
|
100
|
-
max?: number;
|
|
101
|
-
label?: string;
|
|
102
|
-
valueText?: string;
|
|
103
|
-
}): AriaAttributes;
|
|
104
|
-
/**
|
|
105
|
-
* Generate ARIA attributes for a tab component
|
|
106
|
-
* @param options - Tab accessibility options
|
|
107
|
-
* @returns ARIA attributes for tab and tabpanel
|
|
108
|
-
*/
|
|
109
|
-
export declare function getTabAriaAttributes(options: {
|
|
110
|
-
tabId: string;
|
|
111
|
-
panelId: string;
|
|
112
|
-
selected: boolean;
|
|
113
|
-
disabled?: boolean;
|
|
114
|
-
}): {
|
|
115
|
-
tab: AriaAttributes;
|
|
116
|
-
panel: AriaAttributes;
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Generate ARIA attributes for a listbox option
|
|
120
|
-
* @param options - Option accessibility options
|
|
121
|
-
* @returns ARIA attributes object
|
|
122
|
-
*/
|
|
123
|
-
export declare function getOptionAriaAttributes(options: {
|
|
124
|
-
selected: boolean;
|
|
125
|
-
disabled?: boolean;
|
|
126
|
-
setsize?: number;
|
|
127
|
-
posinset?: number;
|
|
128
|
-
}): AriaAttributes;
|
|
129
|
-
/**
|
|
130
|
-
* Generate linked IDs for label and input association
|
|
131
|
-
* @param baseName - Base name for generating IDs
|
|
132
|
-
* @returns Object with inputId, labelId, errorId, and helperId
|
|
133
|
-
*/
|
|
134
|
-
export declare function generateLinkedIds(baseName?: string): {
|
|
135
|
-
inputId: string;
|
|
136
|
-
labelId: string;
|
|
137
|
-
errorId: string;
|
|
138
|
-
helperId: string;
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Create a visually hidden element for screen readers
|
|
142
|
-
* @returns CSS styles for visually hidden content
|
|
143
|
-
*/
|
|
144
|
-
export declare function getVisuallyHiddenStyles(): Record<string, string>;
|
|
145
|
-
/**
|
|
146
|
-
* Check if the user has enabled reduced motion preference
|
|
147
|
-
* @returns True if user prefers reduced motion
|
|
148
|
-
*/
|
|
149
|
-
export declare function prefersReducedMotion(): boolean;
|
|
150
|
-
/**
|
|
151
|
-
* Check if the user has enabled high contrast mode
|
|
152
|
-
* @returns True if high contrast mode is enabled
|
|
153
|
-
*/
|
|
154
|
-
export declare function prefersHighContrast(): boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Announce a message to screen readers using aria-live regions
|
|
157
|
-
* @param message - The message to announce
|
|
158
|
-
* @param politeness - The urgency level (polite or assertive)
|
|
159
|
-
*/
|
|
160
|
-
export declare function announceToScreenReader(message: string, politeness?: 'polite' | 'assertive'): void;
|
|
161
|
-
/**
|
|
162
|
-
* Get the appropriate aria-current value for navigation items
|
|
163
|
-
* @param isActive - Whether the item is active/current
|
|
164
|
-
* @param type - The type of current indicator
|
|
165
|
-
* @returns The aria-current value or undefined
|
|
166
|
-
*/
|
|
167
|
-
export declare function getAriaCurrent(isActive: boolean, type?: 'page' | 'step' | 'location' | 'date' | 'time'): AriaAttributes['aria-current'];
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOM utility functions for PECB UI Components
|
|
3
|
-
* @module utils/dom
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Check if code is running in a browser environment
|
|
7
|
-
* @returns True if running in browser
|
|
8
|
-
*/
|
|
9
|
-
export declare function isBrowser(): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Generate a unique ID for DOM elements
|
|
12
|
-
* @param prefix - Optional prefix for the ID
|
|
13
|
-
* @returns A unique ID string
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* generateUniqueId('btn') // 'btn-a1b2c3d4'
|
|
17
|
-
*/
|
|
18
|
-
export declare function generateUniqueId(prefix?: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Check if an element matches a CSS selector
|
|
21
|
-
* @param element - The element to check
|
|
22
|
-
* @param selector - The CSS selector
|
|
23
|
-
* @returns True if the element matches
|
|
24
|
-
*/
|
|
25
|
-
export declare function matchesSelector(element: Element, selector: string): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Find the closest ancestor matching a selector
|
|
28
|
-
* @param element - Starting element
|
|
29
|
-
* @param selector - CSS selector to match
|
|
30
|
-
* @returns The matching ancestor or null
|
|
31
|
-
*/
|
|
32
|
-
export declare function closestElement<T extends Element>(element: Element, selector: string): T | null;
|
|
33
|
-
/**
|
|
34
|
-
* Check if an element is visible in the viewport
|
|
35
|
-
* @param element - The element to check
|
|
36
|
-
* @param partial - Whether partial visibility counts
|
|
37
|
-
* @returns True if visible
|
|
38
|
-
*/
|
|
39
|
-
export declare function isElementVisible(element: Element, partial?: boolean): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Get all focusable elements within a container
|
|
42
|
-
* @param container - The container element
|
|
43
|
-
* @returns Array of focusable elements
|
|
44
|
-
*/
|
|
45
|
-
export declare function getFocusableElements(container: Element): HTMLElement[];
|
|
46
|
-
/**
|
|
47
|
-
* Trap focus within a container (useful for modals)
|
|
48
|
-
* @param container - The container to trap focus in
|
|
49
|
-
* @returns Cleanup function to remove the trap
|
|
50
|
-
*/
|
|
51
|
-
export declare function trapFocus(container: HTMLElement): () => void;
|
|
52
|
-
/**
|
|
53
|
-
* Scroll an element into view smoothly
|
|
54
|
-
* @param element - The element to scroll to
|
|
55
|
-
* @param options - Scroll options
|
|
56
|
-
*/
|
|
57
|
-
export declare function scrollIntoView(element: Element, options?: ScrollIntoViewOptions): void;
|
|
58
|
-
/**
|
|
59
|
-
* Get the scroll parent of an element
|
|
60
|
-
* @param element - The element to find scroll parent for
|
|
61
|
-
* @returns The scroll parent element
|
|
62
|
-
*/
|
|
63
|
-
export declare function getScrollParent(element: Element): Element | null;
|
|
64
|
-
/**
|
|
65
|
-
* Disable body scroll (useful for modals)
|
|
66
|
-
* @returns Cleanup function to re-enable scroll
|
|
67
|
-
*/
|
|
68
|
-
export declare function disableBodyScroll(): () => void;
|
|
69
|
-
/**
|
|
70
|
-
* Copy text to clipboard
|
|
71
|
-
* @param text - The text to copy
|
|
72
|
-
* @returns Promise that resolves when copied
|
|
73
|
-
*/
|
|
74
|
-
export declare function copyToClipboard(text: string): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Check if an element has a specific CSS class
|
|
77
|
-
* @param element - The element to check
|
|
78
|
-
* @param className - The class name
|
|
79
|
-
* @returns True if the element has the class
|
|
80
|
-
*/
|
|
81
|
-
export declare function hasClass(element: Element, className: string): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Add CSS class(es) to an element
|
|
84
|
-
* @param element - The element to modify
|
|
85
|
-
* @param classNames - Class name(s) to add
|
|
86
|
-
*/
|
|
87
|
-
export declare function addClass(element: Element, ...classNames: string[]): void;
|
|
88
|
-
/**
|
|
89
|
-
* Remove CSS class(es) from an element
|
|
90
|
-
* @param element - The element to modify
|
|
91
|
-
* @param classNames - Class name(s) to remove
|
|
92
|
-
*/
|
|
93
|
-
export declare function removeClass(element: Element, ...classNames: string[]): void;
|
|
94
|
-
/**
|
|
95
|
-
* Toggle a CSS class on an element
|
|
96
|
-
* @param element - The element to modify
|
|
97
|
-
* @param className - The class name to toggle
|
|
98
|
-
* @param force - Optional force add (true) or remove (false)
|
|
99
|
-
* @returns True if the class is now present
|
|
100
|
-
*/
|
|
101
|
-
export declare function toggleClass(element: Element, className: string, force?: boolean): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Get computed CSS property value
|
|
104
|
-
* @param element - The element to check
|
|
105
|
-
* @param property - CSS property name
|
|
106
|
-
* @returns The computed value
|
|
107
|
-
*/
|
|
108
|
-
export declare function getComputedStyleValue(element: Element, property: string): string;
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error handling utility functions for PECB UI Components
|
|
3
|
-
* Provides standardized error handling patterns
|
|
4
|
-
* @module utils/error
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Error severity levels
|
|
8
|
-
*/
|
|
9
|
-
export type ErrorSeverity = 'info' | 'warning' | 'error' | 'critical';
|
|
10
|
-
/**
|
|
11
|
-
* Error categories for classification
|
|
12
|
-
*/
|
|
13
|
-
export type ErrorCategory = 'validation' | 'network' | 'authentication' | 'authorization' | 'configuration' | 'runtime' | 'unknown';
|
|
14
|
-
/**
|
|
15
|
-
* Standard error interface for PECB components
|
|
16
|
-
*/
|
|
17
|
-
export interface PecbError {
|
|
18
|
-
/** Unique error code */
|
|
19
|
-
code: string;
|
|
20
|
-
/** Human-readable error message */
|
|
21
|
-
message: string;
|
|
22
|
-
/** Error severity level */
|
|
23
|
-
severity: ErrorSeverity;
|
|
24
|
-
/** Error category */
|
|
25
|
-
category: ErrorCategory;
|
|
26
|
-
/** Original error if wrapping another error */
|
|
27
|
-
originalError?: Error;
|
|
28
|
-
/** Additional context data */
|
|
29
|
-
context?: Record<string, unknown>;
|
|
30
|
-
/** Timestamp when error occurred */
|
|
31
|
-
timestamp: Date;
|
|
32
|
-
/** Suggested recovery action */
|
|
33
|
-
recoveryAction?: string;
|
|
34
|
-
/** Whether the error is recoverable */
|
|
35
|
-
recoverable: boolean;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Validation error details
|
|
39
|
-
*/
|
|
40
|
-
export interface ValidationError {
|
|
41
|
-
/** Field name that failed validation */
|
|
42
|
-
field: string;
|
|
43
|
-
/** Validation rule that failed */
|
|
44
|
-
rule: string;
|
|
45
|
-
/** Error message */
|
|
46
|
-
message: string;
|
|
47
|
-
/** Expected value or format */
|
|
48
|
-
expected?: string;
|
|
49
|
-
/** Actual value received */
|
|
50
|
-
actual?: unknown;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Error factory options
|
|
54
|
-
*/
|
|
55
|
-
export interface ErrorOptions {
|
|
56
|
-
code?: string;
|
|
57
|
-
severity?: ErrorSeverity;
|
|
58
|
-
category?: ErrorCategory;
|
|
59
|
-
context?: Record<string, unknown>;
|
|
60
|
-
recoveryAction?: string;
|
|
61
|
-
recoverable?: boolean;
|
|
62
|
-
originalError?: Error;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Create a standardized PECB error
|
|
66
|
-
* @param message - Error message
|
|
67
|
-
* @param options - Additional error options
|
|
68
|
-
* @returns A standardized PecbError object
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* const error = createError('Invalid input', {
|
|
72
|
-
* code: 'VALIDATION_001',
|
|
73
|
-
* category: 'validation',
|
|
74
|
-
* severity: 'warning',
|
|
75
|
-
* recoverable: true
|
|
76
|
-
* });
|
|
77
|
-
*/
|
|
78
|
-
export declare function createError(message: string, options?: ErrorOptions): PecbError;
|
|
79
|
-
/**
|
|
80
|
-
* Create a validation error
|
|
81
|
-
* @param field - Field name that failed validation
|
|
82
|
-
* @param rule - Validation rule that failed
|
|
83
|
-
* @param message - Error message
|
|
84
|
-
* @returns A ValidationError object
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* const error = createValidationError('email', 'format', 'Invalid email format');
|
|
88
|
-
*/
|
|
89
|
-
export declare function createValidationError(field: string, rule: string, message: string, details?: {
|
|
90
|
-
expected?: string;
|
|
91
|
-
actual?: unknown;
|
|
92
|
-
}): ValidationError;
|
|
93
|
-
/**
|
|
94
|
-
* Wrap an unknown error in a PecbError
|
|
95
|
-
* @param error - The error to wrap
|
|
96
|
-
* @param options - Additional options
|
|
97
|
-
* @returns A standardized PecbError
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* try {
|
|
101
|
-
* await riskyOperation();
|
|
102
|
-
* } catch (e) {
|
|
103
|
-
* const error = wrapError(e, { category: 'network' });
|
|
104
|
-
* handleError(error);
|
|
105
|
-
* }
|
|
106
|
-
*/
|
|
107
|
-
export declare function wrapError(error: unknown, options?: ErrorOptions): PecbError;
|
|
108
|
-
/**
|
|
109
|
-
* Type guard to check if an object is a PecbError
|
|
110
|
-
* @param error - The object to check
|
|
111
|
-
* @returns True if the object is a PecbError
|
|
112
|
-
*/
|
|
113
|
-
export declare function isPecbError(error: unknown): error is PecbError;
|
|
114
|
-
/**
|
|
115
|
-
* Type guard to check if an error is recoverable
|
|
116
|
-
* @param error - The error to check
|
|
117
|
-
* @returns True if the error is recoverable
|
|
118
|
-
*/
|
|
119
|
-
export declare function isRecoverableError(error: PecbError): boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Format an error for display to users
|
|
122
|
-
* @param error - The error to format
|
|
123
|
-
* @param includeCode - Whether to include the error code
|
|
124
|
-
* @returns Formatted error message
|
|
125
|
-
*/
|
|
126
|
-
export declare function formatErrorMessage(error: PecbError, includeCode?: boolean): string;
|
|
127
|
-
/**
|
|
128
|
-
* Format an error for logging
|
|
129
|
-
* @param error - The error to format
|
|
130
|
-
* @returns Formatted error string for logging
|
|
131
|
-
*/
|
|
132
|
-
export declare function formatErrorForLog(error: PecbError): string;
|
|
133
|
-
/**
|
|
134
|
-
* Create a network error
|
|
135
|
-
* @param message - Error message
|
|
136
|
-
* @param statusCode - HTTP status code if applicable
|
|
137
|
-
* @param originalError - Original error
|
|
138
|
-
* @returns A network category PecbError
|
|
139
|
-
*/
|
|
140
|
-
export declare function createNetworkError(message: string, statusCode?: number, originalError?: Error): PecbError;
|
|
141
|
-
/**
|
|
142
|
-
* Create an authentication error
|
|
143
|
-
* @param message - Error message
|
|
144
|
-
* @param originalError - Original error
|
|
145
|
-
* @returns An authentication category PecbError
|
|
146
|
-
*/
|
|
147
|
-
export declare function createAuthError(message: string, originalError?: Error): PecbError;
|
|
148
|
-
/**
|
|
149
|
-
* Create an authorization error
|
|
150
|
-
* @param message - Error message
|
|
151
|
-
* @param resource - The resource that access was denied to
|
|
152
|
-
* @returns An authorization category PecbError
|
|
153
|
-
*/
|
|
154
|
-
export declare function createAuthorizationError(message: string, resource?: string): PecbError;
|
|
155
|
-
/**
|
|
156
|
-
* Create a configuration error
|
|
157
|
-
* @param message - Error message
|
|
158
|
-
* @param configKey - The configuration key that is invalid
|
|
159
|
-
* @returns A configuration category PecbError
|
|
160
|
-
*/
|
|
161
|
-
export declare function createConfigError(message: string, configKey?: string): PecbError;
|
|
162
|
-
/**
|
|
163
|
-
* Error handler type
|
|
164
|
-
*/
|
|
165
|
-
export type ErrorHandler = (error: PecbError) => void;
|
|
166
|
-
/**
|
|
167
|
-
* Register an error handler for a category
|
|
168
|
-
* @param category - The error category to handle
|
|
169
|
-
* @param handler - The handler function
|
|
170
|
-
* @returns Cleanup function to unregister
|
|
171
|
-
*/
|
|
172
|
-
export declare function registerErrorHandler(category: ErrorCategory, handler: ErrorHandler): () => void;
|
|
173
|
-
/**
|
|
174
|
-
* Handle an error by invoking registered handlers
|
|
175
|
-
* @param error - The error to handle
|
|
176
|
-
*/
|
|
177
|
-
export declare function handleError(error: PecbError): void;
|
|
178
|
-
/**
|
|
179
|
-
* Try to execute an operation and return a result or error
|
|
180
|
-
* @param operation - The operation to execute
|
|
181
|
-
* @param errorOptions - Options for error wrapping
|
|
182
|
-
* @returns A tuple of [result, null] or [null, error]
|
|
183
|
-
*/
|
|
184
|
-
export declare function tryAsync<T>(operation: () => Promise<T>, errorOptions?: ErrorOptions): Promise<[T, null] | [null, PecbError]>;
|
|
185
|
-
/**
|
|
186
|
-
* Synchronous version of tryAsync
|
|
187
|
-
* @param operation - The operation to execute
|
|
188
|
-
* @param errorOptions - Options for error wrapping
|
|
189
|
-
* @returns A tuple of [result, null] or [null, error]
|
|
190
|
-
*/
|
|
191
|
-
export declare function trySync<T>(operation: () => T, errorOptions?: ErrorOptions): [T, null] | [null, PecbError];
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String utility functions for PECB UI Components
|
|
3
|
-
* @module utils/string
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Convert a string to kebab-case
|
|
7
|
-
* @param str - The string to convert
|
|
8
|
-
* @returns The kebab-case string
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* toKebabCase('myComponentName') // 'my-component-name'
|
|
12
|
-
* toKebabCase('MyComponentName') // 'my-component-name'
|
|
13
|
-
*/
|
|
14
|
-
export declare function toKebabCase(str: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Convert a string to camelCase
|
|
17
|
-
* @param str - The string to convert
|
|
18
|
-
* @returns The camelCase string
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* toCamelCase('my-component-name') // 'myComponentName'
|
|
22
|
-
* toCamelCase('my_component_name') // 'myComponentName'
|
|
23
|
-
*/
|
|
24
|
-
export declare function toCamelCase(str: string): string;
|
|
25
|
-
/**
|
|
26
|
-
* Convert a string to PascalCase
|
|
27
|
-
* @param str - The string to convert
|
|
28
|
-
* @returns The PascalCase string
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* toPascalCase('my-component-name') // 'MyComponentName'
|
|
32
|
-
*/
|
|
33
|
-
export declare function toPascalCase(str: string): string;
|
|
34
|
-
/**
|
|
35
|
-
* Convert a string to snake_case
|
|
36
|
-
* @param str - The string to convert
|
|
37
|
-
* @returns The snake_case string
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* toSnakeCase('myComponentName') // 'my_component_name'
|
|
41
|
-
*/
|
|
42
|
-
export declare function toSnakeCase(str: string): string;
|
|
43
|
-
/**
|
|
44
|
-
* Capitalize the first letter of a string
|
|
45
|
-
* @param str - The string to capitalize
|
|
46
|
-
* @returns The capitalized string
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* capitalize('hello world') // 'Hello world'
|
|
50
|
-
*/
|
|
51
|
-
export declare function capitalize(str: string): string;
|
|
52
|
-
/**
|
|
53
|
-
* Truncate a string to a specified length
|
|
54
|
-
* @param str - The string to truncate
|
|
55
|
-
* @param maxLength - Maximum length
|
|
56
|
-
* @param suffix - Suffix to append when truncated (default: '...')
|
|
57
|
-
* @returns The truncated string
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* truncate('Hello World', 8) // 'Hello...'
|
|
61
|
-
* truncate('Hello World', 8, '…') // 'Hello W…'
|
|
62
|
-
*/
|
|
63
|
-
export declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
64
|
-
/**
|
|
65
|
-
* Check if a string is empty or contains only whitespace
|
|
66
|
-
* @param str - The string to check
|
|
67
|
-
* @returns True if the string is empty or whitespace
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* isBlank('') // true
|
|
71
|
-
* isBlank(' ') // true
|
|
72
|
-
* isBlank('hello') // false
|
|
73
|
-
*/
|
|
74
|
-
export declare function isBlank(str: string | null | undefined): boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Check if a string is not empty and contains non-whitespace characters
|
|
77
|
-
* @param str - The string to check
|
|
78
|
-
* @returns True if the string is not empty
|
|
79
|
-
*/
|
|
80
|
-
export declare function isNotBlank(str: string | null | undefined): str is string;
|
|
81
|
-
/**
|
|
82
|
-
* Generate a slug from a string (URL-friendly)
|
|
83
|
-
* @param str - The string to convert
|
|
84
|
-
* @returns URL-friendly slug
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* slugify('Hello World!') // 'hello-world'
|
|
88
|
-
* slugify('Café Latte') // 'cafe-latte'
|
|
89
|
-
*/
|
|
90
|
-
export declare function slugify(str: string): string;
|
|
91
|
-
/**
|
|
92
|
-
* Escape HTML special characters
|
|
93
|
-
* @param str - The string to escape
|
|
94
|
-
* @returns The escaped string
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* escapeHtml('<script>alert("XSS")</script>') // '<script>alert("XSS")</script>'
|
|
98
|
-
*/
|
|
99
|
-
export declare function escapeHtml(str: string): string;
|
|
100
|
-
/**
|
|
101
|
-
* Strip HTML tags from a string
|
|
102
|
-
* @param str - The string containing HTML
|
|
103
|
-
* @returns The string without HTML tags
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* stripHtml('<p>Hello <strong>World</strong></p>') // 'Hello World'
|
|
107
|
-
*/
|
|
108
|
-
export declare function stripHtml(str: string): string;
|
|
109
|
-
/**
|
|
110
|
-
* Generate initials from a name
|
|
111
|
-
* @param name - The name to extract initials from
|
|
112
|
-
* @param maxLength - Maximum number of initials (default: 2)
|
|
113
|
-
* @returns The initials in uppercase
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* getInitials('John Doe') // 'JD'
|
|
117
|
-
* getInitials('John Michael Doe', 3) // 'JMD'
|
|
118
|
-
*/
|
|
119
|
-
export declare function getInitials(name: string, maxLength?: number): string;
|
|
120
|
-
/**
|
|
121
|
-
* Pluralize a word based on count
|
|
122
|
-
* @param count - The count to check
|
|
123
|
-
* @param singular - Singular form
|
|
124
|
-
* @param plural - Plural form (optional, defaults to singular + 's')
|
|
125
|
-
* @returns The appropriate form of the word
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* pluralize(1, 'item') // 'item'
|
|
129
|
-
* pluralize(5, 'item') // 'items'
|
|
130
|
-
* pluralize(2, 'child', 'children') // 'children'
|
|
131
|
-
*/
|
|
132
|
-
export declare function pluralize(count: number, singular: string, plural?: string): string;
|
|
133
|
-
/**
|
|
134
|
-
* Format a number as a string with count and pluralized label
|
|
135
|
-
* @param count - The count
|
|
136
|
-
* @param singular - Singular form of the label
|
|
137
|
-
* @param plural - Plural form (optional)
|
|
138
|
-
* @returns Formatted string like "5 items"
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* formatCount(1, 'item') // '1 item'
|
|
142
|
-
* formatCount(5, 'item') // '5 items'
|
|
143
|
-
*/
|
|
144
|
-
export declare function formatCount(count: number, singular: string, plural?: string): string;
|
package/public-api.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export * from './lib/pecb-components.module';
|
|
2
|
-
export * from './lib/components/button/button.component';
|
|
3
|
-
export * from './lib/components/card/card.component';
|
|
4
|
-
export * from './lib/components/status/status.component';
|
|
5
|
-
export * from './lib/components/pagination/pagination.component';
|
|
6
|
-
export * from './lib/components/table/table.component';
|
|
7
|
-
export * from './lib/components/tab/tab.component';
|
|
8
|
-
export * from './lib/components/datepicker/datepicker.component';
|
|
9
|
-
export * from './lib/components/input/input.component';
|
|
10
|
-
export * from './lib/components/radio/radio.component';
|
|
11
|
-
export * from './lib/components/checkbox/checkbox.component';
|
|
12
|
-
export * from './lib/components/toggle/toggle.component';
|
|
13
|
-
export * from './lib/components/dropdown/dropdown.component';
|
|
14
|
-
export * from './lib/components/right-modal/right-modal.component';
|
|
15
|
-
export * from './lib/components/sidebar/sidebar.component';
|
|
16
|
-
export * from './lib/services/notification.service';
|
|
17
|
-
export * from './lib/services/theme.service';
|
|
18
|
-
export * from './lib/services/loading.service';
|
|
19
|
-
export * from './lib/shared/types/common.types';
|
|
20
|
-
export * from './lib/shared/interfaces/component.interfaces';
|
|
21
|
-
export { toKebabCase, toCamelCase, toPascalCase, toSnakeCase, capitalize, truncate, isBlank, isNotBlank, slugify, escapeHtml, stripHtml, getInitials, pluralize, formatCount } from './lib/shared/utils/string.utils';
|
|
22
|
-
export { isBrowser, generateUniqueId, matchesSelector, closestElement, isElementVisible, getFocusableElements, trapFocus, scrollIntoView, getScrollParent, disableBodyScroll, copyToClipboard, hasClass, addClass, removeClass, toggleClass, getComputedStyleValue } from './lib/shared/utils/dom.utils';
|
|
23
|
-
export { AriaLive, AriaRole, AriaAttributes, getButtonAriaAttributes, getDialogAriaAttributes, getInputAriaAttributes, getProgressAriaAttributes, getTabAriaAttributes, getOptionAriaAttributes, generateLinkedIds, getVisuallyHiddenStyles, prefersReducedMotion, prefersHighContrast, announceToScreenReader, getAriaCurrent } from './lib/shared/utils/accessibility.utils';
|
|
24
|
-
export { ErrorSeverity, ErrorCategory, PecbError, ValidationError, ErrorOptions, ErrorHandler, createError, createValidationError, wrapError, isPecbError, isRecoverableError, formatErrorMessage, formatErrorForLog, createNetworkError, createAuthError, createAuthorizationError, createConfigError, registerErrorHandler, handleError, tryAsync, trySync } from './lib/shared/utils/error.utils';
|