@mt-gloss/ui 0.0.2
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 +33 -0
- package/index.css +1 -0
- package/index.d.ts +80 -0
- package/index.js +17560 -0
- package/lib/Accordion.d.ts +103 -0
- package/lib/AsyncLoader.d.ts +41 -0
- package/lib/Badge.d.ts +42 -0
- package/lib/Button.d.ts +73 -0
- package/lib/ButtonGroup.d.ts +72 -0
- package/lib/Card.d.ts +140 -0
- package/lib/Checkbox.d.ts +70 -0
- package/lib/CheckboxGroup.d.ts +162 -0
- package/lib/Chip.d.ts +68 -0
- package/lib/ColorPicker.d.ts +82 -0
- package/lib/DatePicker.d.ts +102 -0
- package/lib/DateRangePicker.d.ts +109 -0
- package/lib/Dropdown.d.ts +65 -0
- package/lib/FileUpload.d.ts +109 -0
- package/lib/Form.d.ts +119 -0
- package/lib/FormField.d.ts +69 -0
- package/lib/Input.d.ts +89 -0
- package/lib/InputGroup.d.ts +59 -0
- package/lib/Link.d.ts +69 -0
- package/lib/MaskedInput.d.ts +95 -0
- package/lib/Menu.d.ts +132 -0
- package/lib/NumberInput.d.ts +81 -0
- package/lib/Radio.d.ts +60 -0
- package/lib/RadioGroup.d.ts +163 -0
- package/lib/RangeSlider.d.ts +105 -0
- package/lib/Rating.d.ts +115 -0
- package/lib/SegmentedControl.d.ts +96 -0
- package/lib/Select.d.ts +205 -0
- package/lib/Slider.d.ts +111 -0
- package/lib/SplitButton.d.ts +84 -0
- package/lib/Textarea.d.ts +59 -0
- package/lib/TimePicker.d.ts +93 -0
- package/lib/Toggle.d.ts +68 -0
- package/lib/Tooltip.d.ts +89 -0
- package/lib/Transition.d.ts +107 -0
- package/lib/composed/AddressSelect.d.ts +132 -0
- package/lib/composed/PasswordInput.d.ts +75 -0
- package/lib/composed/PaymentMethodSelect.d.ts +96 -0
- package/lib/composed/PhoneInput.d.ts +71 -0
- package/lib/composed/SearchInput.d.ts +80 -0
- package/lib/composed/TagInput.d.ts +98 -0
- package/lib/composed/index.d.ts +12 -0
- package/lib/dashboard/ChartControlBar/ChartControlBar.d.ts +45 -0
- package/lib/dashboard/ChartControlBar/FilterInput.d.ts +34 -0
- package/lib/dashboard/ChartControlBar/FusedShape.d.ts +32 -0
- package/lib/dashboard/ChartControlBar/Row1Controls.d.ts +62 -0
- package/lib/dashboard/ChartControlBar/Row2FilterTray.d.ts +62 -0
- package/lib/dashboard/ChartControlBar/fixtures/controlBarStates.d.ts +4 -0
- package/lib/dashboard/ChartControlBar/index.d.ts +8 -0
- package/lib/dashboard/ChartControlBar/types.d.ts +37 -0
- package/lib/dashboard/ChartControlBar/useFilterLayout.d.ts +51 -0
- package/lib/dashboard/FilterChip/FilterChip.d.ts +26 -0
- package/lib/dashboard/FilterChip/fixtures/filterChips.d.ts +11 -0
- package/lib/dashboard/FilterChip/index.d.ts +3 -0
- package/lib/dashboard/FilterChip/types.d.ts +17 -0
- package/lib/dashboard/MetricCard/CardShell.d.ts +22 -0
- package/lib/dashboard/MetricCard/GutterActions.d.ts +56 -0
- package/lib/dashboard/MetricCard/MetricCard.d.ts +33 -0
- package/lib/dashboard/MetricCard/StackedGroupCard.d.ts +43 -0
- package/lib/dashboard/MetricCard/TrendIndicator.d.ts +20 -0
- package/lib/dashboard/MetricCard/fixtures/allVariants.d.ts +6 -0
- package/lib/dashboard/MetricCard/fixtures/sparklineCard.d.ts +5 -0
- package/lib/dashboard/MetricCard/fixtures/standardCard.d.ts +7 -0
- package/lib/dashboard/MetricCard/fixtures/states.d.ts +19 -0
- package/lib/dashboard/MetricCard/index.d.ts +20 -0
- package/lib/dashboard/MetricCard/types.d.ts +109 -0
- package/lib/dashboard/MetricCard/useSlideOutReveal.d.ts +42 -0
- package/lib/dashboard/MetricCard/utils/formatTrend.d.ts +2 -0
- package/lib/dashboard/MetricCard/utils/formatValue.d.ts +2 -0
- package/lib/dashboard/MetricCard/visualizations/BarsBg.d.ts +25 -0
- package/lib/dashboard/MetricCard/visualizations/DonutChart.d.ts +26 -0
- package/lib/dashboard/MetricCard/visualizations/ObjectArrow.d.ts +28 -0
- package/lib/dashboard/MetricCard/visualizations/SparklineBg.d.ts +24 -0
- package/lib/dashboard/MetricCardGrid/MetricCardGrid.d.ts +28 -0
- package/lib/dashboard/MetricCardGrid/fixtures/gridCards.d.ts +3 -0
- package/lib/dashboard/MetricCardGrid/fixtures/layouts.d.ts +7 -0
- package/lib/dashboard/MetricCardGrid/index.d.ts +4 -0
- package/lib/dashboard/MetricCardGrid/types.d.ts +28 -0
- package/lib/dashboard/Skeleton/Skeleton.d.ts +25 -0
- package/lib/dashboard/Skeleton/SkeletonCard.d.ts +20 -0
- package/lib/dashboard/Skeleton/SkeletonChart.d.ts +18 -0
- package/lib/dashboard/Skeleton/SkeletonTable.d.ts +18 -0
- package/lib/dashboard/Skeleton/fixtures/skeletonSamples.d.ts +7 -0
- package/lib/dashboard/Skeleton/index.d.ts +6 -0
- package/lib/dashboard/Skeleton/types.d.ts +55 -0
- package/lib/dashboard/TabGroup/TabGroup.d.ts +27 -0
- package/lib/dashboard/TabGroup/fixtures/tabGroups.d.ts +7 -0
- package/lib/dashboard/TabGroup/index.d.ts +3 -0
- package/lib/dashboard/TabGroup/types.d.ts +22 -0
- package/lib/dashboard/TabbedDataView/TabbedDataView.d.ts +29 -0
- package/lib/dashboard/TabbedDataView/fixtures/tabConfigs.d.ts +9 -0
- package/lib/dashboard/TabbedDataView/index.d.ts +3 -0
- package/lib/dashboard/TabbedDataView/types.d.ts +20 -0
- package/lib/dashboard/TimeFrame/ExpandableChip.d.ts +22 -0
- package/lib/dashboard/TimeFrame/HybridDatePicker.d.ts +24 -0
- package/lib/dashboard/TimeFrame/MarketPresetRow.d.ts +16 -0
- package/lib/dashboard/TimeFrame/MiniCalendar.d.ts +16 -0
- package/lib/dashboard/TimeFrame/TimeFrame.d.ts +21 -0
- package/lib/dashboard/TimeFrame/fixtures/timeFrameSamples.d.ts +17 -0
- package/lib/dashboard/TimeFrame/index.d.ts +14 -0
- package/lib/dashboard/TimeFrame/types.d.ts +202 -0
- package/lib/dashboard/TimeFrame/utils/dateHelpers.d.ts +1 -0
- package/lib/dashboard/TimeFrame/utils/presets.d.ts +1 -0
- package/lib/dashboard/TimeFrame/utils/smartDateFormat.d.ts +1 -0
- package/lib/dashboard/UnifiedBreakdownTable/UnifiedBreakdownTable.d.ts +24 -0
- package/lib/dashboard/UnifiedBreakdownTable/fixtures/columns.d.ts +5 -0
- package/lib/dashboard/UnifiedBreakdownTable/fixtures/itemRows.d.ts +15 -0
- package/lib/dashboard/UnifiedBreakdownTable/fixtures/orderRows.d.ts +15 -0
- package/lib/dashboard/UnifiedBreakdownTable/index.d.ts +7 -0
- package/lib/dashboard/UnifiedBreakdownTable/types.d.ts +61 -0
- package/lib/dashboard/UnifiedContextMenu/UnifiedContextMenu.d.ts +5 -0
- package/lib/dashboard/UnifiedContextMenu/fixtures/menuActions.d.ts +9 -0
- package/lib/dashboard/UnifiedContextMenu/index.d.ts +3 -0
- package/lib/dashboard/UnifiedContextMenu/types.d.ts +130 -0
- package/lib/dashboard/index.d.ts +10 -0
- package/lib/hooks/index.d.ts +3 -0
- package/lib/hooks/useArrowNavigation.d.ts +106 -0
- package/lib/hooks/useFocusReturn.d.ts +26 -0
- package/lib/hooks/useFocusTrap.d.ts +50 -0
- package/lib/patterns/feedback/DestructiveModal.d.ts +31 -0
- package/lib/patterns/feedback/index.d.ts +1 -0
- package/lib/patterns/forms/AddressGroup.d.ts +37 -0
- package/lib/patterns/forms/CreditCardForm.d.ts +41 -0
- package/lib/patterns/forms/LoginForm.d.ts +38 -0
- package/lib/patterns/forms/index.d.ts +3 -0
- package/lib/patterns/index.d.ts +14 -0
- package/lib/patterns/types.d.ts +63 -0
- package/lib/types/icon.d.ts +27 -0
- package/lib/utils/animations.d.ts +60 -0
- package/lib/utils/renderIcon.d.ts +21 -0
- package/package.json +59 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export interface UseArrowNavigationOptions<T> {
|
|
2
|
+
/**
|
|
3
|
+
* Array of items to navigate through
|
|
4
|
+
*/
|
|
5
|
+
items: T[];
|
|
6
|
+
/**
|
|
7
|
+
* Current active index
|
|
8
|
+
*/
|
|
9
|
+
activeIndex?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Callback when active index changes
|
|
12
|
+
*/
|
|
13
|
+
onActiveIndexChange?: (index: number) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to wrap around when reaching ends
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
loop?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Orientation of the list
|
|
21
|
+
* @default 'vertical'
|
|
22
|
+
*/
|
|
23
|
+
orientation?: 'vertical' | 'horizontal' | 'both';
|
|
24
|
+
/**
|
|
25
|
+
* Whether navigation is enabled
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Filter function to skip disabled items
|
|
31
|
+
*/
|
|
32
|
+
isItemDisabled?: (item: T, index: number) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Callback when Enter/Space is pressed on active item
|
|
35
|
+
*/
|
|
36
|
+
onSelect?: (item: T, index: number) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback when Escape is pressed
|
|
39
|
+
*/
|
|
40
|
+
onEscape?: () => void;
|
|
41
|
+
}
|
|
42
|
+
export interface UseArrowNavigationReturn {
|
|
43
|
+
/**
|
|
44
|
+
* Current focused index
|
|
45
|
+
*/
|
|
46
|
+
focusedIndex: number;
|
|
47
|
+
/**
|
|
48
|
+
* Set focused index manually
|
|
49
|
+
*/
|
|
50
|
+
setFocusedIndex: (index: number) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Key down handler to attach to container
|
|
53
|
+
*/
|
|
54
|
+
handleKeyDown: (event: React.KeyboardEvent) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Move focus to first item
|
|
57
|
+
*/
|
|
58
|
+
focusFirst: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Move focus to last item
|
|
61
|
+
*/
|
|
62
|
+
focusLast: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Move focus to next item
|
|
65
|
+
*/
|
|
66
|
+
focusNext: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Move focus to previous item
|
|
69
|
+
*/
|
|
70
|
+
focusPrevious: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Reset focus to -1 (no item focused)
|
|
73
|
+
*/
|
|
74
|
+
resetFocus: () => void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Hook for keyboard navigation with arrow keys
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```tsx
|
|
81
|
+
* function MenuList({ items, onSelect }) {
|
|
82
|
+
* const {
|
|
83
|
+
* focusedIndex,
|
|
84
|
+
* handleKeyDown,
|
|
85
|
+
* } = useArrowNavigation({
|
|
86
|
+
* items,
|
|
87
|
+
* onSelect: (item) => onSelect(item),
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* return (
|
|
91
|
+
* <ul role="menu" onKeyDown={handleKeyDown}>
|
|
92
|
+
* {items.map((item, index) => (
|
|
93
|
+
* <li
|
|
94
|
+
* key={item.id}
|
|
95
|
+
* role="menuitem"
|
|
96
|
+
* data-focused={index === focusedIndex}
|
|
97
|
+
* >
|
|
98
|
+
* {item.label}
|
|
99
|
+
* </li>
|
|
100
|
+
* ))}
|
|
101
|
+
* </ul>
|
|
102
|
+
* );
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function useArrowNavigation<T>(options: UseArrowNavigationOptions<T>): UseArrowNavigationReturn;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface UseFocusReturnOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Whether focus return is enabled
|
|
4
|
+
* @default true
|
|
5
|
+
*/
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Custom element to return focus to
|
|
9
|
+
*/
|
|
10
|
+
returnTo?: HTMLElement | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Hook to return focus to the previously focused element when component unmounts
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* function Modal({ isOpen, children }) {
|
|
18
|
+
* useFocusReturn({ enabled: isOpen });
|
|
19
|
+
*
|
|
20
|
+
* if (!isOpen) return null;
|
|
21
|
+
*
|
|
22
|
+
* return <div>{children}</div>;
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useFocusReturn(options?: UseFocusReturnOptions): import('react').RefObject<Element | null>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface UseFocusTrapOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Whether the focus trap is active
|
|
4
|
+
* @default true
|
|
5
|
+
*/
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether to auto-focus the first focusable element
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
autoFocus?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to return focus to the previously focused element on deactivation
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
returnFocusOnDeactivate?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Initial element to focus (selector or element)
|
|
19
|
+
*/
|
|
20
|
+
initialFocus?: string | HTMLElement;
|
|
21
|
+
/**
|
|
22
|
+
* Allow focus outside the trap (for click outside handlers)
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
allowOutsideClick?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Callback when escape is pressed
|
|
28
|
+
*/
|
|
29
|
+
onEscape?: () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hook to trap focus within a container element
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* function Modal({ isOpen, onClose, children }) {
|
|
37
|
+
* const trapRef = useFocusTrap<HTMLDivElement>({
|
|
38
|
+
* enabled: isOpen,
|
|
39
|
+
* onEscape: onClose,
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* return (
|
|
43
|
+
* <div ref={trapRef} role="dialog">
|
|
44
|
+
* {children}
|
|
45
|
+
* </div>
|
|
46
|
+
* );
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function useFocusTrap<T extends HTMLElement = HTMLElement>(options?: UseFocusTrapOptions): import('react').RefObject<T | null>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PatternMetadata } from '../types';
|
|
2
|
+
export interface DestructiveModalProps {
|
|
3
|
+
/** Whether the modal is open */
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
/** Called when the modal should close */
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
/** Called when the destructive action is confirmed */
|
|
8
|
+
onConfirm: () => void | Promise<void>;
|
|
9
|
+
/** Title of the modal */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Description/warning message */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Text for the confirm button */
|
|
14
|
+
confirmLabel?: string;
|
|
15
|
+
/** Text for the cancel button */
|
|
16
|
+
cancelLabel?: string;
|
|
17
|
+
/** Require user to type confirmation text */
|
|
18
|
+
requireConfirmation?: boolean;
|
|
19
|
+
/** Text the user must type to confirm (e.g., "DELETE") */
|
|
20
|
+
confirmationText?: string;
|
|
21
|
+
/** Placeholder for the confirmation input */
|
|
22
|
+
confirmationPlaceholder?: string;
|
|
23
|
+
/** Loading state for the confirm button */
|
|
24
|
+
isLoading?: boolean;
|
|
25
|
+
/** The name of the resource being deleted (shown in description) */
|
|
26
|
+
resourceName?: string;
|
|
27
|
+
/** Icon to display (default: alert-triangle) */
|
|
28
|
+
icon?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const metadata: PatternMetadata;
|
|
31
|
+
export default function DestructiveModal({ isOpen, onClose, onConfirm, title, description, confirmLabel, cancelLabel, requireConfirmation, confirmationText, confirmationPlaceholder, isLoading, resourceName, icon, }: DestructiveModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DestructiveModal, metadata as destructiveModalMetadata, type DestructiveModalProps, } from './DestructiveModal';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PatternMetadata } from '../types';
|
|
3
|
+
export declare const addressSchema: z.ZodObject<{
|
|
4
|
+
street: z.ZodString;
|
|
5
|
+
street2: z.ZodOptional<z.ZodString>;
|
|
6
|
+
city: z.ZodString;
|
|
7
|
+
state: z.ZodString;
|
|
8
|
+
zip: z.ZodString;
|
|
9
|
+
country: z.ZodDefault<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type AddressFormValues = z.infer<typeof addressSchema>;
|
|
12
|
+
export interface AddressGroupProps {
|
|
13
|
+
/** Legend/title for the fieldset */
|
|
14
|
+
legend?: string;
|
|
15
|
+
/** Use compact layout (2 columns where possible) */
|
|
16
|
+
compact?: boolean;
|
|
17
|
+
/** Show address line 2 field */
|
|
18
|
+
showStreet2?: boolean;
|
|
19
|
+
/** Show country field */
|
|
20
|
+
showCountry?: boolean;
|
|
21
|
+
/** Default country value */
|
|
22
|
+
defaultCountry?: string;
|
|
23
|
+
/** Disable all fields */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/** Make all fields required */
|
|
26
|
+
required?: boolean;
|
|
27
|
+
/** Default form values */
|
|
28
|
+
defaultValues?: Partial<AddressFormValues>;
|
|
29
|
+
/** Called when any field changes */
|
|
30
|
+
onChange?: (values: Partial<AddressFormValues>) => void;
|
|
31
|
+
/** Called when a field loses focus */
|
|
32
|
+
onBlur?: (field: keyof AddressFormValues) => void;
|
|
33
|
+
/** External validation errors */
|
|
34
|
+
errors?: Partial<Record<keyof AddressFormValues, string>>;
|
|
35
|
+
}
|
|
36
|
+
export declare const metadata: PatternMetadata;
|
|
37
|
+
export default function AddressGroup({ legend, compact, showStreet2, showCountry, defaultCountry, disabled, required, defaultValues, onChange, onBlur, errors: externalErrors, }: AddressGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PatternMetadata } from '../types';
|
|
3
|
+
export declare const creditCardSchema: z.ZodObject<{
|
|
4
|
+
cardNumber: z.ZodString;
|
|
5
|
+
expiryDate: z.ZodString;
|
|
6
|
+
cvv: z.ZodString;
|
|
7
|
+
cardholderName: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type CreditCardFormValues = z.infer<typeof creditCardSchema>;
|
|
10
|
+
export interface CreditCardFormProps {
|
|
11
|
+
/** Title displayed at the top of the form */
|
|
12
|
+
title?: string;
|
|
13
|
+
/** Subtitle/description below the title */
|
|
14
|
+
subtitle?: string;
|
|
15
|
+
/** Text for the submit button */
|
|
16
|
+
submitLabel?: string;
|
|
17
|
+
/** Amount to display on submit button (e.g., "$99.00") */
|
|
18
|
+
amount?: string;
|
|
19
|
+
/** Show cancel button */
|
|
20
|
+
showCancel?: boolean;
|
|
21
|
+
/** Cancel button label */
|
|
22
|
+
cancelLabel?: string;
|
|
23
|
+
/** Loading state for the submit button */
|
|
24
|
+
isLoading?: boolean;
|
|
25
|
+
/** Show async validation indicator on card number */
|
|
26
|
+
isValidating?: boolean;
|
|
27
|
+
/** Disable the entire form */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** Show lock icon on submit button */
|
|
30
|
+
showSecureIcon?: boolean;
|
|
31
|
+
/** Default form values */
|
|
32
|
+
defaultValues?: Partial<CreditCardFormValues>;
|
|
33
|
+
/** Called when form is submitted with valid data */
|
|
34
|
+
onSubmit?: (values: CreditCardFormValues) => void | Promise<void>;
|
|
35
|
+
/** Called when cancel button is clicked */
|
|
36
|
+
onCancel?: () => void;
|
|
37
|
+
/** Called when card number changes (for async BIN validation) */
|
|
38
|
+
onCardNumberChange?: (cardNumber: string) => void;
|
|
39
|
+
}
|
|
40
|
+
export declare const metadata: PatternMetadata;
|
|
41
|
+
export default function CreditCardForm({ title, subtitle, submitLabel, amount, showCancel, cancelLabel, isLoading, isValidating, disabled, showSecureIcon, defaultValues, onSubmit, onCancel, onCardNumberChange, }: CreditCardFormProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PatternMetadata } from '../types';
|
|
3
|
+
export declare const loginSchema: z.ZodObject<{
|
|
4
|
+
email: z.ZodString;
|
|
5
|
+
password: z.ZodString;
|
|
6
|
+
rememberMe: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type LoginFormValues = z.infer<typeof loginSchema>;
|
|
9
|
+
export interface LoginFormProps {
|
|
10
|
+
/** Title displayed at the top of the form */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** Subtitle/description below the title */
|
|
13
|
+
subtitle?: string;
|
|
14
|
+
/** Text for the submit button */
|
|
15
|
+
submitLabel?: string;
|
|
16
|
+
/** Show "Remember me" checkbox */
|
|
17
|
+
showRememberMe?: boolean;
|
|
18
|
+
/** Show "Forgot password" link */
|
|
19
|
+
showForgotPassword?: boolean;
|
|
20
|
+
/** URL for forgot password link */
|
|
21
|
+
forgotPasswordUrl?: string;
|
|
22
|
+
/** Show registration link */
|
|
23
|
+
showRegisterLink?: boolean;
|
|
24
|
+
/** Registration link URL */
|
|
25
|
+
registerUrl?: string;
|
|
26
|
+
/** Loading state for the submit button */
|
|
27
|
+
isLoading?: boolean;
|
|
28
|
+
/** Disable the entire form */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** Default form values */
|
|
31
|
+
defaultValues?: Partial<LoginFormValues>;
|
|
32
|
+
/** Called when form is submitted with valid data */
|
|
33
|
+
onSubmit?: (values: LoginFormValues) => void | Promise<void>;
|
|
34
|
+
/** Called when forgot password link is clicked */
|
|
35
|
+
onForgotPassword?: () => void;
|
|
36
|
+
}
|
|
37
|
+
export declare const metadata: PatternMetadata;
|
|
38
|
+
export default function LoginForm({ title, subtitle, submitLabel, showRememberMe, showForgotPassword, forgotPasswordUrl, showRegisterLink, registerUrl, isLoading, disabled, defaultValues, onSubmit, onForgotPassword, }: LoginFormProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default as LoginForm, metadata as loginFormMetadata, loginSchema, type LoginFormProps, } from './LoginForm';
|
|
2
|
+
export { default as AddressGroup, metadata as addressGroupMetadata, addressSchema, type AddressGroupProps, } from './AddressGroup';
|
|
3
|
+
export { default as CreditCardForm, metadata as creditCardFormMetadata, creditCardSchema, type CreditCardFormProps, } from './CreditCardForm';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gloss UI Patterns
|
|
3
|
+
*
|
|
4
|
+
* Composite, pre-configured component groupings for common use cases.
|
|
5
|
+
* Each pattern exports:
|
|
6
|
+
* - Default: The React component
|
|
7
|
+
* - metadata: PatternMetadata for database sync
|
|
8
|
+
* - schema (optional): Zod validation schema
|
|
9
|
+
*/
|
|
10
|
+
export type { PatternMetadata, PatternPropDefinition, PatternCategory, PatternRecord, } from './types';
|
|
11
|
+
export { default as LoginForm, metadata as loginFormMetadata, loginSchema, type LoginFormProps, } from './forms/LoginForm';
|
|
12
|
+
export { default as AddressGroup, metadata as addressGroupMetadata, addressSchema, type AddressGroupProps, } from './forms/AddressGroup';
|
|
13
|
+
export { default as CreditCardForm, metadata as creditCardFormMetadata, creditCardSchema, type CreditCardFormProps, } from './forms/CreditCardForm';
|
|
14
|
+
export { default as DestructiveModal, metadata as destructiveModalMetadata, type DestructiveModalProps, } from './feedback/DestructiveModal';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern System Types
|
|
3
|
+
*
|
|
4
|
+
* These types define the contract for pattern components and their metadata.
|
|
5
|
+
* Patterns are composite, pre-configured groupings of primitive components
|
|
6
|
+
* designed to be consumed by production developers.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Defines a single prop that can be configured in the Pattern Studio
|
|
10
|
+
*/
|
|
11
|
+
export interface PatternPropDefinition {
|
|
12
|
+
/** The prop name (must match the component prop) */
|
|
13
|
+
name: string;
|
|
14
|
+
/** The prop type for form generation */
|
|
15
|
+
type: 'string' | 'boolean' | 'number' | 'select' | 'object';
|
|
16
|
+
/** Default value for this prop */
|
|
17
|
+
default?: unknown;
|
|
18
|
+
/** Whether this prop is required */
|
|
19
|
+
required?: boolean;
|
|
20
|
+
/** Options for 'select' type props */
|
|
21
|
+
options?: string[];
|
|
22
|
+
/** Human-readable description for the Pattern Studio */
|
|
23
|
+
description?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Pattern categories for organization and filtering
|
|
27
|
+
*/
|
|
28
|
+
export type PatternCategory = 'forms' | 'overlays' | 'feedback' | 'navigation' | 'data-display';
|
|
29
|
+
/**
|
|
30
|
+
* Metadata for a pattern component, used for:
|
|
31
|
+
* - Database sync (Neon)
|
|
32
|
+
* - Pattern Studio props generation
|
|
33
|
+
* - Documentation catalog
|
|
34
|
+
*/
|
|
35
|
+
export interface PatternMetadata {
|
|
36
|
+
/** URL-friendly unique identifier (e.g., 'login-form', 'address-group') */
|
|
37
|
+
slug: string;
|
|
38
|
+
/** Human-readable name (e.g., 'Login Form', 'Address Group') */
|
|
39
|
+
displayName: string;
|
|
40
|
+
/** Brief description of the pattern's purpose */
|
|
41
|
+
description: string;
|
|
42
|
+
/** Category for filtering in the catalog */
|
|
43
|
+
category: PatternCategory;
|
|
44
|
+
/** Tags for search and filtering */
|
|
45
|
+
tags: string[];
|
|
46
|
+
/** Props that can be configured in the Pattern Studio */
|
|
47
|
+
propsDefinition: PatternPropDefinition[];
|
|
48
|
+
/** Optional version string */
|
|
49
|
+
version?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Database row type for patterns table
|
|
53
|
+
*/
|
|
54
|
+
export interface PatternRecord {
|
|
55
|
+
id: number;
|
|
56
|
+
slug: string;
|
|
57
|
+
name: string;
|
|
58
|
+
description: string | null;
|
|
59
|
+
category: string;
|
|
60
|
+
tags: string[];
|
|
61
|
+
props_definition: PatternPropDefinition[];
|
|
62
|
+
updated_at: string;
|
|
63
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Icon value can be either a string (icon name from sprite) or a ReactNode
|
|
4
|
+
*/
|
|
5
|
+
export type IconValue = string | React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Common icon slot props shared across Button, Input, and Select components
|
|
8
|
+
*/
|
|
9
|
+
export interface IconSlotProps {
|
|
10
|
+
/**
|
|
11
|
+
* Icon displayed on the left side of the component
|
|
12
|
+
* Can be an icon name (string) or a custom React element
|
|
13
|
+
*/
|
|
14
|
+
leftIcon?: IconValue;
|
|
15
|
+
/**
|
|
16
|
+
* Icon displayed on the right side of the component
|
|
17
|
+
* Can be an icon name (string) or a custom React element
|
|
18
|
+
*/
|
|
19
|
+
rightIcon?: IconValue;
|
|
20
|
+
/**
|
|
21
|
+
* Vertical alignment of icons relative to content
|
|
22
|
+
* - 'center': Icons are vertically centered (default)
|
|
23
|
+
* - 'top': Icons align to the top (useful for multi-line content)
|
|
24
|
+
* @default 'center'
|
|
25
|
+
*/
|
|
26
|
+
iconAlign?: 'top' | 'center';
|
|
27
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation utilities and presets for Gloss UI components
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Standard animation durations
|
|
6
|
+
*/
|
|
7
|
+
export declare const durations: {
|
|
8
|
+
readonly instant: 0;
|
|
9
|
+
readonly fast: 100;
|
|
10
|
+
readonly normal: 200;
|
|
11
|
+
readonly slow: 300;
|
|
12
|
+
readonly slower: 400;
|
|
13
|
+
};
|
|
14
|
+
export type AnimationDuration = keyof typeof durations;
|
|
15
|
+
/**
|
|
16
|
+
* Standard easing functions
|
|
17
|
+
*/
|
|
18
|
+
export declare const easings: {
|
|
19
|
+
readonly linear: "linear";
|
|
20
|
+
readonly easeIn: "cubic-bezier(0.4, 0, 1, 1)";
|
|
21
|
+
readonly easeOut: "cubic-bezier(0, 0, 0.2, 1)";
|
|
22
|
+
readonly easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
23
|
+
readonly spring: "cubic-bezier(0.175, 0.885, 0.32, 1.275)";
|
|
24
|
+
};
|
|
25
|
+
export type AnimationEasing = keyof typeof easings;
|
|
26
|
+
/**
|
|
27
|
+
* Animation preset configurations
|
|
28
|
+
*/
|
|
29
|
+
export interface AnimationPreset {
|
|
30
|
+
enter: {
|
|
31
|
+
from: React.CSSProperties;
|
|
32
|
+
to: React.CSSProperties;
|
|
33
|
+
};
|
|
34
|
+
exit: {
|
|
35
|
+
from: React.CSSProperties;
|
|
36
|
+
to: React.CSSProperties;
|
|
37
|
+
};
|
|
38
|
+
duration: number;
|
|
39
|
+
easing: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Common animation presets
|
|
43
|
+
*/
|
|
44
|
+
export declare const presets: Record<string, AnimationPreset>;
|
|
45
|
+
export type AnimationPresetName = keyof typeof presets;
|
|
46
|
+
/**
|
|
47
|
+
* Get CSS transition string from animation config
|
|
48
|
+
*/
|
|
49
|
+
export declare function getTransitionStyle(properties: string[], duration?: number, easing?: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Interpolate between two values based on progress (0-1)
|
|
52
|
+
*/
|
|
53
|
+
export declare function interpolate(from: number, to: number, progress: number): number;
|
|
54
|
+
/**
|
|
55
|
+
* Parse a CSS value like "8px" to a number
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseNumericValue(value: string): {
|
|
58
|
+
value: number;
|
|
59
|
+
unit: string;
|
|
60
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IconValue } from '../types/icon';
|
|
3
|
+
type IconSize = 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
+
/**
|
|
5
|
+
* Renders an icon from either a string (icon name) or a ReactNode
|
|
6
|
+
*
|
|
7
|
+
* @param icon - Icon name string or ReactNode
|
|
8
|
+
* @param size - Icon size (only used when icon is a string)
|
|
9
|
+
* @returns ReactNode to render
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // String icon name - renders Icon component
|
|
14
|
+
* renderIcon('check', 'sm')
|
|
15
|
+
*
|
|
16
|
+
* // ReactNode - rendered as-is
|
|
17
|
+
* renderIcon(<CustomIcon />)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function renderIcon(icon: IconValue | undefined, size?: IconSize): React.ReactNode;
|
|
21
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mt-gloss/ui",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"default": "./index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"./styles.css": "./index.css"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"index.js",
|
|
19
|
+
"index.d.ts",
|
|
20
|
+
"index.css",
|
|
21
|
+
"lib/**/*.d.ts",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": [
|
|
25
|
+
"**/*.css",
|
|
26
|
+
"**/*.scss"
|
|
27
|
+
],
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
30
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
31
|
+
"@mui/material": "^6.0.0 || ^7.0.0",
|
|
32
|
+
"@mui/icons-material": "^6.0.0 || ^7.0.0",
|
|
33
|
+
"@emotion/react": "^11.0.0",
|
|
34
|
+
"@emotion/styled": "^11.0.0",
|
|
35
|
+
"date-fns": "^3.0.0 || ^4.0.0",
|
|
36
|
+
"@mt-gloss/utils": ">=0.0.1"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"@mui/material": { "optional": false },
|
|
40
|
+
"@mui/icons-material": { "optional": false },
|
|
41
|
+
"@emotion/react": { "optional": false },
|
|
42
|
+
"@emotion/styled": { "optional": false },
|
|
43
|
+
"date-fns": { "optional": false },
|
|
44
|
+
"@dnd-kit/core": { "optional": true },
|
|
45
|
+
"@dnd-kit/sortable": { "optional": true },
|
|
46
|
+
"@dnd-kit/modifiers": { "optional": true },
|
|
47
|
+
"@dnd-kit/utilities": { "optional": true },
|
|
48
|
+
"@mui/x-data-grid-pro": { "optional": true },
|
|
49
|
+
"@mui/x-date-pickers-pro": { "optional": true }
|
|
50
|
+
},
|
|
51
|
+
"optionalDependencies": {
|
|
52
|
+
"@dnd-kit/core": "^6.0.0",
|
|
53
|
+
"@dnd-kit/sortable": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
54
|
+
"@dnd-kit/modifiers": "^7.0.0 || ^8.0.0 || ^9.0.0",
|
|
55
|
+
"@dnd-kit/utilities": "^3.0.0",
|
|
56
|
+
"@mui/x-data-grid-pro": "^7.0.0 || ^8.0.0",
|
|
57
|
+
"@mui/x-date-pickers-pro": "^7.0.0 || ^8.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|