@abpjs/theme-shared 0.7.6
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/LICENSE +165 -0
- package/README.md +568 -0
- package/dist/components/confirmation/Confirmation.d.ts +27 -0
- package/dist/components/confirmation/index.d.ts +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/modal/Modal.d.ts +114 -0
- package/dist/components/modal/index.d.ts +1 -0
- package/dist/components/toast/Toast.d.ts +43 -0
- package/dist/components/toast/index.d.ts +1 -0
- package/dist/components/ui/Alert.d.ts +50 -0
- package/dist/components/ui/Button.d.ts +70 -0
- package/dist/components/ui/Checkbox.d.ts +64 -0
- package/dist/components/ui/FormField.d.ts +50 -0
- package/dist/components/ui/color-mode.d.ts +19 -0
- package/dist/components/ui/index.d.ts +16 -0
- package/dist/components/ui/provider.d.ts +2 -0
- package/dist/components/ui/toaster.d.ts +3 -0
- package/dist/components/ui/tooltip.d.ts +11 -0
- package/dist/contexts/confirmation.context.d.ts +100 -0
- package/dist/contexts/index.d.ts +2 -0
- package/dist/contexts/toaster.context.d.ts +91 -0
- package/dist/handlers/error.handler.d.ts +110 -0
- package/dist/handlers/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +1305 -0
- package/dist/index.mjs +1281 -0
- package/dist/models/confirmation.d.ts +21 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/toaster.d.ts +48 -0
- package/dist/providers/ThemeSharedProvider.d.ts +135 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/theme/index.d.ts +42 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/styles.d.ts +14 -0
- package/package.json +57 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { Dialog } from '@chakra-ui/react';
|
|
3
|
+
/**
|
|
4
|
+
* Modal size options.
|
|
5
|
+
*/
|
|
6
|
+
export type ModalSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
7
|
+
export interface ModalProps {
|
|
8
|
+
/** Whether the modal is visible */
|
|
9
|
+
visible: boolean;
|
|
10
|
+
/** Callback when visibility changes */
|
|
11
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
12
|
+
/** Modal size */
|
|
13
|
+
size?: ModalSize;
|
|
14
|
+
/** Center the modal vertically */
|
|
15
|
+
centered?: boolean;
|
|
16
|
+
/** Custom CSS class for the modal container */
|
|
17
|
+
modalClass?: string;
|
|
18
|
+
/** Header content */
|
|
19
|
+
header?: ReactNode;
|
|
20
|
+
/** Body content (children) */
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
/** Footer content */
|
|
23
|
+
footer?: ReactNode;
|
|
24
|
+
/** Custom close button content */
|
|
25
|
+
closeButton?: ReactNode;
|
|
26
|
+
/** Whether to show the close button */
|
|
27
|
+
showCloseButton?: boolean;
|
|
28
|
+
/** Whether clicking the overlay closes the modal */
|
|
29
|
+
closeOnOverlayClick?: boolean;
|
|
30
|
+
/** Whether pressing Escape closes the modal */
|
|
31
|
+
closeOnEscape?: boolean;
|
|
32
|
+
/** Whether to scroll the modal body if content overflows */
|
|
33
|
+
scrollBehavior?: 'inside' | 'outside';
|
|
34
|
+
/**
|
|
35
|
+
* Motion preset for modal animation.
|
|
36
|
+
* @default 'scale'
|
|
37
|
+
*/
|
|
38
|
+
motionPreset?: 'scale' | 'slide-in-bottom' | 'slide-in-right' | 'none';
|
|
39
|
+
/**
|
|
40
|
+
* Whether to trap focus within the modal.
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
trapFocus?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to prevent scrolling on the body when modal is open.
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
preventScroll?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Modal component - Generic modal/dialog container.
|
|
52
|
+
*
|
|
53
|
+
* This is the React equivalent of Angular's ModalComponent.
|
|
54
|
+
* It uses Chakra UI Dialog (v3) for accessibility and styling,
|
|
55
|
+
* while maintaining the ABP-compatible API.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* function MyComponent() {
|
|
60
|
+
* const [visible, setVisible] = useState(false);
|
|
61
|
+
*
|
|
62
|
+
* return (
|
|
63
|
+
* <>
|
|
64
|
+
* <button onClick={() => setVisible(true)}>Open Modal</button>
|
|
65
|
+
* <Modal
|
|
66
|
+
* visible={visible}
|
|
67
|
+
* onVisibleChange={setVisible}
|
|
68
|
+
* size="md"
|
|
69
|
+
* header="Modal Title"
|
|
70
|
+
* footer={
|
|
71
|
+
* <button onClick={() => setVisible(false)}>Close</button>
|
|
72
|
+
* }
|
|
73
|
+
* >
|
|
74
|
+
* <p>Modal content goes here</p>
|
|
75
|
+
* </Modal>
|
|
76
|
+
* </>
|
|
77
|
+
* );
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function Modal({ visible, onVisibleChange, size, centered, modalClass, header, children, footer, showCloseButton, closeOnOverlayClick, closeOnEscape, scrollBehavior, motionPreset, trapFocus, preventScroll, }: ModalProps): React.ReactElement;
|
|
82
|
+
/**
|
|
83
|
+
* Re-export Chakra v3 dialog parts for convenience.
|
|
84
|
+
* Users can use these for more custom modal layouts.
|
|
85
|
+
*/
|
|
86
|
+
export { Dialog as ChakraDialog, };
|
|
87
|
+
/**
|
|
88
|
+
* ModalHeader - Convenience component for modal headers.
|
|
89
|
+
*/
|
|
90
|
+
export interface ModalHeaderProps {
|
|
91
|
+
children: ReactNode;
|
|
92
|
+
className?: string;
|
|
93
|
+
}
|
|
94
|
+
export declare function AbpModalHeader({ children, className }: ModalHeaderProps): React.ReactElement;
|
|
95
|
+
/**
|
|
96
|
+
* ModalBody - Convenience component for modal body content.
|
|
97
|
+
*/
|
|
98
|
+
export interface ModalBodyProps {
|
|
99
|
+
children: ReactNode;
|
|
100
|
+
className?: string;
|
|
101
|
+
}
|
|
102
|
+
export declare function AbpModalBody({ children, className }: ModalBodyProps): React.ReactElement;
|
|
103
|
+
/**
|
|
104
|
+
* ModalFooter - Convenience component for modal footers.
|
|
105
|
+
*/
|
|
106
|
+
export interface ModalFooterProps {
|
|
107
|
+
children: ReactNode;
|
|
108
|
+
className?: string;
|
|
109
|
+
}
|
|
110
|
+
export declare function AbpModalFooter({ children, className }: ModalFooterProps): React.ReactElement;
|
|
111
|
+
export { AbpModalHeader as ModalHeader };
|
|
112
|
+
export { AbpModalBody as ModalBody };
|
|
113
|
+
export { AbpModalFooter as ModalFooter };
|
|
114
|
+
export default Modal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Modal';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Toaster } from '../../models';
|
|
3
|
+
/**
|
|
4
|
+
* Get Chakra color palette for severity.
|
|
5
|
+
*/
|
|
6
|
+
declare function getSeverityColorPalette(severity: Toaster.Severity): string;
|
|
7
|
+
/**
|
|
8
|
+
* Get background color for severity.
|
|
9
|
+
*/
|
|
10
|
+
declare function getSeverityBg(severity: Toaster.Severity): string;
|
|
11
|
+
/**
|
|
12
|
+
* Get border color for severity.
|
|
13
|
+
*/
|
|
14
|
+
declare function getSeverityBorderColor(severity: Toaster.Severity): string;
|
|
15
|
+
export interface ToastContainerProps {
|
|
16
|
+
/** Position of toasts */
|
|
17
|
+
position?: 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* ToastContainer - Syncs toaster state with Chakra v3's toast system.
|
|
21
|
+
*
|
|
22
|
+
* This is the React equivalent of Angular's ToastComponent.
|
|
23
|
+
* Place this component once in your app to display toasts.
|
|
24
|
+
*
|
|
25
|
+
* The toast position uses logical values (start/end) which automatically
|
|
26
|
+
* handle RTL languages - toasts will appear on the correct side based on
|
|
27
|
+
* the current text direction.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* function App() {
|
|
32
|
+
* return (
|
|
33
|
+
* <ThemeSharedProvider>
|
|
34
|
+
* <MainContent />
|
|
35
|
+
* <ToastContainer />
|
|
36
|
+
* </ThemeSharedProvider>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function ToastContainer({ position }: ToastContainerProps): React.ReactElement;
|
|
42
|
+
export { getSeverityColorPalette as getSeverityColorScheme, getSeverityBg, getSeverityBorderColor };
|
|
43
|
+
export default ToastContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Toast';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Alert status types
|
|
4
|
+
*/
|
|
5
|
+
export type AlertStatus = 'info' | 'warning' | 'success' | 'error';
|
|
6
|
+
/**
|
|
7
|
+
* Alert component props
|
|
8
|
+
*/
|
|
9
|
+
export interface AlertProps {
|
|
10
|
+
/** The status/type of alert */
|
|
11
|
+
status?: AlertStatus;
|
|
12
|
+
/** Alert content */
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
/** Optional title (displayed prominently) */
|
|
15
|
+
title?: ReactNode;
|
|
16
|
+
/** Optional description (displayed below title) */
|
|
17
|
+
description?: ReactNode;
|
|
18
|
+
/** Whether to show the status indicator icon */
|
|
19
|
+
showIcon?: boolean;
|
|
20
|
+
/** Additional CSS class */
|
|
21
|
+
className?: string;
|
|
22
|
+
/** Margin bottom */
|
|
23
|
+
mb?: number | string;
|
|
24
|
+
/** Border radius */
|
|
25
|
+
borderRadius?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Alert - Wrapper component for displaying alerts/notifications.
|
|
29
|
+
*
|
|
30
|
+
* This component wraps Chakra UI's Alert and provides a simplified API
|
|
31
|
+
* that shields consumers from Chakra's compound component pattern.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* // Simple usage
|
|
36
|
+
* <Alert status="error">Something went wrong!</Alert>
|
|
37
|
+
*
|
|
38
|
+
* // With title
|
|
39
|
+
* <Alert status="success" title="Success!">
|
|
40
|
+
* Your changes have been saved.
|
|
41
|
+
* </Alert>
|
|
42
|
+
*
|
|
43
|
+
* // Without icon
|
|
44
|
+
* <Alert status="info" showIcon={false}>
|
|
45
|
+
* Information message
|
|
46
|
+
* </Alert>
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function Alert({ status, children, title, description, showIcon, className, mb, borderRadius, }: AlertProps): React.ReactElement;
|
|
50
|
+
export default Alert;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Button color palette options
|
|
4
|
+
*/
|
|
5
|
+
export type ButtonColorPalette = 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink';
|
|
6
|
+
/**
|
|
7
|
+
* Button variant options
|
|
8
|
+
*/
|
|
9
|
+
export type ButtonVariant = 'solid' | 'outline' | 'ghost' | 'plain';
|
|
10
|
+
/**
|
|
11
|
+
* Button size options
|
|
12
|
+
*/
|
|
13
|
+
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
14
|
+
/**
|
|
15
|
+
* Button component props
|
|
16
|
+
*/
|
|
17
|
+
export interface ButtonProps {
|
|
18
|
+
/** Button content */
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/** Button type */
|
|
21
|
+
type?: 'button' | 'submit' | 'reset';
|
|
22
|
+
/** Button variant */
|
|
23
|
+
variant?: ButtonVariant;
|
|
24
|
+
/** Color palette (replaces colorScheme from v2) */
|
|
25
|
+
colorPalette?: ButtonColorPalette;
|
|
26
|
+
/** Button size */
|
|
27
|
+
size?: ButtonSize;
|
|
28
|
+
/** Whether the button is disabled */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** Whether the button is in loading state */
|
|
31
|
+
loading?: boolean;
|
|
32
|
+
/** Text to display when loading */
|
|
33
|
+
loadingText?: string;
|
|
34
|
+
/** Click handler */
|
|
35
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
36
|
+
/** Additional CSS class */
|
|
37
|
+
className?: string;
|
|
38
|
+
/** Full width button */
|
|
39
|
+
width?: string | number;
|
|
40
|
+
/** Margin right */
|
|
41
|
+
mr?: number | string;
|
|
42
|
+
/** Margin left */
|
|
43
|
+
ml?: number | string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Button - Wrapper component for buttons.
|
|
47
|
+
*
|
|
48
|
+
* This component wraps Chakra UI's Button and provides a simplified API
|
|
49
|
+
* that maintains v2-like props while using v3 internally.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* // Primary button
|
|
54
|
+
* <Button colorPalette="blue" onClick={handleSubmit}>
|
|
55
|
+
* Submit
|
|
56
|
+
* </Button>
|
|
57
|
+
*
|
|
58
|
+
* // Outline button
|
|
59
|
+
* <Button variant="outline" colorPalette="gray">
|
|
60
|
+
* Cancel
|
|
61
|
+
* </Button>
|
|
62
|
+
*
|
|
63
|
+
* // Loading button
|
|
64
|
+
* <Button loading loadingText="Submitting...">
|
|
65
|
+
* Submit
|
|
66
|
+
* </Button>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
70
|
+
export default Button;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Checkbox color palette options
|
|
4
|
+
*/
|
|
5
|
+
export type CheckboxColorPalette = 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink';
|
|
6
|
+
/**
|
|
7
|
+
* Checkbox size options
|
|
8
|
+
*/
|
|
9
|
+
export type CheckboxSize = 'sm' | 'md' | 'lg';
|
|
10
|
+
/**
|
|
11
|
+
* Checkbox component props
|
|
12
|
+
*/
|
|
13
|
+
export interface CheckboxProps {
|
|
14
|
+
/** Checkbox label */
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
/** Whether the checkbox is checked */
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
/** Default checked state (uncontrolled) */
|
|
19
|
+
defaultChecked?: boolean;
|
|
20
|
+
/** Whether the checkbox is disabled */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** Whether the checkbox is invalid */
|
|
23
|
+
invalid?: boolean;
|
|
24
|
+
/** Whether the checkbox is required */
|
|
25
|
+
required?: boolean;
|
|
26
|
+
/** Whether the checkbox is read-only */
|
|
27
|
+
readOnly?: boolean;
|
|
28
|
+
/** Color palette */
|
|
29
|
+
colorPalette?: CheckboxColorPalette;
|
|
30
|
+
/** Checkbox size */
|
|
31
|
+
size?: CheckboxSize;
|
|
32
|
+
/** HTML id */
|
|
33
|
+
id?: string;
|
|
34
|
+
/** HTML name */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** Value for form submission */
|
|
37
|
+
value?: string;
|
|
38
|
+
/** Change handler */
|
|
39
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
40
|
+
/** Additional CSS class */
|
|
41
|
+
className?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checkbox - Wrapper component for checkboxes.
|
|
45
|
+
*
|
|
46
|
+
* This component wraps Chakra UI's Checkbox and provides a simplified API
|
|
47
|
+
* that shields consumers from Chakra's compound component pattern.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* // Basic usage
|
|
52
|
+
* <Checkbox onChange={handleChange}>Remember me</Checkbox>
|
|
53
|
+
*
|
|
54
|
+
* // Controlled
|
|
55
|
+
* <Checkbox checked={isChecked} onChange={(e) => setIsChecked(e.target.checked)}>
|
|
56
|
+
* Accept terms
|
|
57
|
+
* </Checkbox>
|
|
58
|
+
*
|
|
59
|
+
* // With react-hook-form
|
|
60
|
+
* <Checkbox {...register('remember')}>Remember me</Checkbox>
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
64
|
+
export default Checkbox;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* FormField component props
|
|
4
|
+
*/
|
|
5
|
+
export interface FormFieldProps {
|
|
6
|
+
/** Field label */
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
/** Whether the field is invalid */
|
|
9
|
+
invalid?: boolean;
|
|
10
|
+
/** Whether the field is required */
|
|
11
|
+
required?: boolean;
|
|
12
|
+
/** Whether the field is disabled */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Error message to display when invalid */
|
|
15
|
+
errorText?: ReactNode;
|
|
16
|
+
/** Helper text displayed below the input */
|
|
17
|
+
helperText?: ReactNode;
|
|
18
|
+
/** The form input element(s) */
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/** HTML id for the label's htmlFor attribute */
|
|
21
|
+
htmlFor?: string;
|
|
22
|
+
/** Additional CSS class */
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* FormField - Wrapper component for form fields with label, error, and helper text.
|
|
27
|
+
*
|
|
28
|
+
* This component wraps Chakra UI's Field and provides a simplified API
|
|
29
|
+
* that shields consumers from Chakra's compound component pattern.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // Basic usage
|
|
34
|
+
* <FormField label="Username" invalid={!!errors.username} errorText={errors.username?.message}>
|
|
35
|
+
* <Input {...register('username')} />
|
|
36
|
+
* </FormField>
|
|
37
|
+
*
|
|
38
|
+
* // With required indicator
|
|
39
|
+
* <FormField label="Email" required>
|
|
40
|
+
* <Input type="email" />
|
|
41
|
+
* </FormField>
|
|
42
|
+
*
|
|
43
|
+
* // With helper text
|
|
44
|
+
* <FormField label="Password" helperText="Must be at least 8 characters">
|
|
45
|
+
* <Input type="password" />
|
|
46
|
+
* </FormField>
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function FormField({ label, invalid, required, disabled, errorText, helperText, children, htmlFor, className, }: FormFieldProps): React.ReactElement;
|
|
50
|
+
export default FormField;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IconButtonProps, SpanProps } from "@chakra-ui/react";
|
|
2
|
+
import type { ThemeProviderProps } from "next-themes";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export type ColorModeProviderProps = ThemeProviderProps;
|
|
5
|
+
export declare function ColorModeProvider(props: ColorModeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export type ColorMode = "light" | "dark";
|
|
7
|
+
export interface UseColorModeReturn {
|
|
8
|
+
colorMode: ColorMode;
|
|
9
|
+
setColorMode: (colorMode: ColorMode) => void;
|
|
10
|
+
toggleColorMode: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function useColorMode(): UseColorModeReturn;
|
|
13
|
+
export declare function useColorModeValue<T>(light: T, dark: T): T;
|
|
14
|
+
export declare function ColorModeIcon(): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
type ColorModeButtonProps = Omit<IconButtonProps, "aria-label">;
|
|
16
|
+
export declare const ColorModeButton: React.ForwardRefExoticComponent<ColorModeButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
export declare const LightMode: React.ForwardRefExoticComponent<SpanProps & React.RefAttributes<HTMLSpanElement>>;
|
|
18
|
+
export declare const DarkMode: React.ForwardRefExoticComponent<SpanProps & React.RefAttributes<HTMLSpanElement>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI Component Wrappers
|
|
3
|
+
*
|
|
4
|
+
* These components wrap Chakra UI v3 components and provide a simplified,
|
|
5
|
+
* stable API that shields consumers from Chakra's compound component patterns.
|
|
6
|
+
*
|
|
7
|
+
* Benefits:
|
|
8
|
+
* - Library independence: Only theme-shared needs to know about Chakra internals
|
|
9
|
+
* - Simpler API: No need for .Root, .Content, .Trigger patterns
|
|
10
|
+
* - Easier upgrades: Changes to Chakra v4+ only affect these wrappers
|
|
11
|
+
* - Consistent styling: ABP-specific defaults and styling applied here
|
|
12
|
+
*/
|
|
13
|
+
export * from './Alert';
|
|
14
|
+
export * from './Button';
|
|
15
|
+
export * from './Checkbox';
|
|
16
|
+
export * from './FormField';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Tooltip as ChakraTooltip } from "@chakra-ui/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export interface TooltipProps extends ChakraTooltip.RootProps {
|
|
4
|
+
showArrow?: boolean;
|
|
5
|
+
portalled?: boolean;
|
|
6
|
+
portalRef?: React.RefObject<HTMLElement | null>;
|
|
7
|
+
content: React.ReactNode;
|
|
8
|
+
contentProps?: ChakraTooltip.ContentProps;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { Confirmation, Toaster } from '../models';
|
|
3
|
+
/**
|
|
4
|
+
* Internal confirmation message structure.
|
|
5
|
+
*/
|
|
6
|
+
export interface ConfirmationMessage {
|
|
7
|
+
/** Unique ID for this confirmation */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Message content (can be localization key) */
|
|
10
|
+
message: string;
|
|
11
|
+
/** Title (can be localization key) */
|
|
12
|
+
title?: string;
|
|
13
|
+
/** Severity level affects the styling */
|
|
14
|
+
severity: Toaster.Severity;
|
|
15
|
+
/** Options for the confirmation */
|
|
16
|
+
options: Confirmation.Options;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* ConfirmationService interface - matches the Angular service API.
|
|
20
|
+
*/
|
|
21
|
+
export interface ConfirmationService {
|
|
22
|
+
/** Show an info confirmation */
|
|
23
|
+
info(message: string, title?: string, options?: Confirmation.Options): Promise<Toaster.Status>;
|
|
24
|
+
/** Show a success confirmation */
|
|
25
|
+
success(message: string, title?: string, options?: Confirmation.Options): Promise<Toaster.Status>;
|
|
26
|
+
/** Show a warning confirmation */
|
|
27
|
+
warn(message: string, title?: string, options?: Confirmation.Options): Promise<Toaster.Status>;
|
|
28
|
+
/** Show an error confirmation */
|
|
29
|
+
error(message: string, title?: string, options?: Confirmation.Options): Promise<Toaster.Status>;
|
|
30
|
+
/** Clear the current confirmation */
|
|
31
|
+
clear(status?: Toaster.Status): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Context value containing the service and current confirmation.
|
|
35
|
+
*/
|
|
36
|
+
export interface ConfirmationContextValue {
|
|
37
|
+
service: ConfirmationService;
|
|
38
|
+
confirmation: ConfirmationMessage | null;
|
|
39
|
+
/** Respond to the current confirmation */
|
|
40
|
+
respond: (status: Toaster.Status) => void;
|
|
41
|
+
}
|
|
42
|
+
export interface ConfirmationProviderProps {
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* ConfirmationProvider - Provides confirmation dialog functionality.
|
|
47
|
+
*
|
|
48
|
+
* This is the React equivalent of Angular's ConfirmationService.
|
|
49
|
+
* Wrap your app with this provider to enable confirmation dialogs.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <ConfirmationProvider>
|
|
54
|
+
* <App />
|
|
55
|
+
* <ConfirmationDialog />
|
|
56
|
+
* </ConfirmationProvider>
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function ConfirmationProvider({ children }: ConfirmationProviderProps): React.ReactElement;
|
|
60
|
+
/**
|
|
61
|
+
* Hook to access the confirmation service.
|
|
62
|
+
*
|
|
63
|
+
* @returns ConfirmationService with methods to show confirmation dialogs
|
|
64
|
+
* @throws Error if used outside of ConfirmationProvider
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* function MyComponent() {
|
|
69
|
+
* const confirmation = useConfirmation();
|
|
70
|
+
*
|
|
71
|
+
* const handleDelete = async () => {
|
|
72
|
+
* const status = await confirmation.warn(
|
|
73
|
+
* 'Are you sure you want to delete this item?',
|
|
74
|
+
* 'Confirm Delete',
|
|
75
|
+
* { yesCopy: 'Delete', cancelCopy: 'Cancel' }
|
|
76
|
+
* );
|
|
77
|
+
*
|
|
78
|
+
* if (status === Toaster.Status.confirm) {
|
|
79
|
+
* await deleteItem();
|
|
80
|
+
* }
|
|
81
|
+
* };
|
|
82
|
+
*
|
|
83
|
+
* return <button onClick={handleDelete}>Delete</button>;
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function useConfirmation(): ConfirmationService;
|
|
88
|
+
/**
|
|
89
|
+
* Hook to access the current confirmation state.
|
|
90
|
+
* This is typically used by the ConfirmationDialog component.
|
|
91
|
+
*
|
|
92
|
+
* @returns Current confirmation message and respond function
|
|
93
|
+
*/
|
|
94
|
+
export declare function useConfirmationState(): Pick<ConfirmationContextValue, 'confirmation' | 'respond'>;
|
|
95
|
+
/**
|
|
96
|
+
* Hook to access the full confirmation context.
|
|
97
|
+
*
|
|
98
|
+
* @returns ConfirmationContextValue with service, confirmation, and respond
|
|
99
|
+
*/
|
|
100
|
+
export declare function useConfirmationContext(): ConfirmationContextValue;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { Toaster } from '../models';
|
|
3
|
+
/**
|
|
4
|
+
* Internal toast message with unique ID for tracking.
|
|
5
|
+
*/
|
|
6
|
+
interface InternalToast extends Toaster.Message {
|
|
7
|
+
id: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ToasterService interface - matches the Angular service API.
|
|
11
|
+
*/
|
|
12
|
+
export interface ToasterService {
|
|
13
|
+
/** Show an info toast */
|
|
14
|
+
info(message: string, title?: string, options?: Toaster.Options): Promise<Toaster.Status>;
|
|
15
|
+
/** Show a success toast */
|
|
16
|
+
success(message: string, title?: string, options?: Toaster.Options): Promise<Toaster.Status>;
|
|
17
|
+
/** Show a warning toast */
|
|
18
|
+
warn(message: string, title?: string, options?: Toaster.Options): Promise<Toaster.Status>;
|
|
19
|
+
/** Show an error toast */
|
|
20
|
+
error(message: string, title?: string, options?: Toaster.Options): Promise<Toaster.Status>;
|
|
21
|
+
/** Add multiple messages at once */
|
|
22
|
+
addAll(messages: Toaster.Message[]): void;
|
|
23
|
+
/** Clear all toasts or a specific one by status */
|
|
24
|
+
clear(status?: Toaster.Status): void;
|
|
25
|
+
/** Remove a specific toast by ID */
|
|
26
|
+
remove(id: string): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Context value containing the service and current toasts.
|
|
30
|
+
*/
|
|
31
|
+
export interface ToasterContextValue {
|
|
32
|
+
service: ToasterService;
|
|
33
|
+
toasts: InternalToast[];
|
|
34
|
+
}
|
|
35
|
+
export interface ToasterProviderProps {
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* ToasterProvider - Provides toast notification functionality.
|
|
40
|
+
*
|
|
41
|
+
* This is the React equivalent of Angular's ToasterService.
|
|
42
|
+
* Wrap your app with this provider to enable toast notifications.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* <ToasterProvider>
|
|
47
|
+
* <App />
|
|
48
|
+
* <ToastContainer />
|
|
49
|
+
* </ToasterProvider>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function ToasterProvider({ children }: ToasterProviderProps): React.ReactElement;
|
|
53
|
+
/**
|
|
54
|
+
* Hook to access the toaster service.
|
|
55
|
+
*
|
|
56
|
+
* @returns ToasterService with methods to show toast notifications
|
|
57
|
+
* @throws Error if used outside of ToasterProvider
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* function MyComponent() {
|
|
62
|
+
* const toaster = useToaster();
|
|
63
|
+
*
|
|
64
|
+
* const handleSave = async () => {
|
|
65
|
+
* try {
|
|
66
|
+
* await saveData();
|
|
67
|
+
* toaster.success('Data saved successfully!', 'Success');
|
|
68
|
+
* } catch (error) {
|
|
69
|
+
* toaster.error('Failed to save data', 'Error');
|
|
70
|
+
* }
|
|
71
|
+
* };
|
|
72
|
+
*
|
|
73
|
+
* return <button onClick={handleSave}>Save</button>;
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function useToaster(): ToasterService;
|
|
78
|
+
/**
|
|
79
|
+
* Hook to access the current toasts (for rendering).
|
|
80
|
+
* This is typically used by the ToastContainer component.
|
|
81
|
+
*
|
|
82
|
+
* @returns Array of current toast messages
|
|
83
|
+
*/
|
|
84
|
+
export declare function useToasts(): InternalToast[];
|
|
85
|
+
/**
|
|
86
|
+
* Hook to access both the service and toasts.
|
|
87
|
+
*
|
|
88
|
+
* @returns ToasterContextValue with service and toasts
|
|
89
|
+
*/
|
|
90
|
+
export declare function useToasterContext(): ToasterContextValue;
|
|
91
|
+
export {};
|