@trinityui/design-system 1.0.3 → 1.0.5
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 +36 -0
- package/README.md +6 -0
- package/dist/Legend.js +1455 -0
- package/dist/accessibility.d.ts +119 -0
- package/dist/accessibility.d.ts.map +1 -0
- package/dist/assets/index.d.ts +234 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/components/AI/AIActions.d.ts +104 -0
- package/dist/components/AI/AIActions.d.ts.map +1 -0
- package/dist/components/AI/AIAvatar.d.ts +32 -0
- package/dist/components/AI/AIAvatar.d.ts.map +1 -0
- package/dist/components/AI/AIChat.d.ts +142 -0
- package/dist/components/AI/AIChat.d.ts.map +1 -0
- package/dist/components/AI/AIContainer.d.ts +97 -0
- package/dist/components/AI/AIContainer.d.ts.map +1 -0
- package/dist/components/AI/AIExplainability.d.ts +46 -0
- package/dist/components/AI/AIExplainability.d.ts.map +1 -0
- package/dist/components/AI/AILabel.d.ts +43 -0
- package/dist/components/AI/AILabel.d.ts.map +1 -0
- package/dist/components/AI/AIMessage.d.ts +93 -0
- package/dist/components/AI/AIMessage.d.ts.map +1 -0
- package/dist/components/AI/AIRelatedQuestions.d.ts +53 -0
- package/dist/components/AI/AIRelatedQuestions.d.ts.map +1 -0
- package/dist/components/AI/AIResponseRenderer.d.ts +50 -0
- package/dist/components/AI/AIResponseRenderer.d.ts.map +1 -0
- package/dist/components/AI/AISources.d.ts +66 -0
- package/dist/components/AI/AISources.d.ts.map +1 -0
- package/dist/components/AI/AISourcesPanel.d.ts +84 -0
- package/dist/components/AI/AISourcesPanel.d.ts.map +1 -0
- package/dist/components/AI/AITextBlock.d.ts +56 -0
- package/dist/components/AI/AITextBlock.d.ts.map +1 -0
- package/dist/components/AI/AIVisuals.d.ts +104 -0
- package/dist/components/AI/AIVisuals.d.ts.map +1 -0
- package/dist/components/AI/AIVoiceInput.d.ts +66 -0
- package/dist/components/AI/AIVoiceInput.d.ts.map +1 -0
- package/dist/components/AI/ChatHeader.d.ts +52 -0
- package/dist/components/AI/ChatHeader.d.ts.map +1 -0
- package/dist/components/AI/ChatHistoryList.d.ts +80 -0
- package/dist/components/AI/ChatHistoryList.d.ts.map +1 -0
- package/dist/components/AI/ChatThread.d.ts +74 -0
- package/dist/components/AI/ChatThread.d.ts.map +1 -0
- package/dist/components/AI/InsightEngine.d.ts +147 -0
- package/dist/components/AI/InsightEngine.d.ts.map +1 -0
- package/dist/components/AI/InsightEngineInput.d.ts +94 -0
- package/dist/components/AI/InsightEngineInput.d.ts.map +1 -0
- package/dist/components/AI/QueryInput.d.ts +114 -0
- package/dist/components/AI/QueryInput.d.ts.map +1 -0
- package/dist/components/AI/UserAvatar.d.ts +24 -0
- package/dist/components/AI/UserAvatar.d.ts.map +1 -0
- package/dist/components/AI/UserMessage.d.ts +26 -0
- package/dist/components/AI/UserMessage.d.ts.map +1 -0
- package/dist/components/AI/index.d.ts +39 -0
- package/dist/components/AI/index.d.ts.map +1 -0
- package/dist/components/AI/tokens.d.ts +132 -0
- package/dist/components/AI/tokens.d.ts.map +1 -0
- package/dist/components/AI/types/index.d.ts +6 -0
- package/dist/components/AI/types/index.d.ts.map +1 -0
- package/dist/components/AI/types/response.d.ts +312 -0
- package/dist/components/AI/types/response.d.ts.map +1 -0
- package/dist/components/AppLayout/AIFab.d.ts +50 -0
- package/dist/components/AppLayout/AIFab.d.ts.map +1 -0
- package/dist/components/AppLayout/AIFabLayout.deprecated.d.ts +32 -0
- package/dist/components/AppLayout/AIFabLayout.deprecated.d.ts.map +1 -0
- package/dist/components/AppLayout/AppLayout.d.ts +154 -0
- package/dist/components/AppLayout/AppLayout.d.ts.map +1 -0
- package/dist/components/AppLayout/InsightEnginePanel.d.ts +141 -0
- package/dist/components/AppLayout/InsightEnginePanel.d.ts.map +1 -0
- package/dist/components/AppLayout/ResizablePanel.d.ts +52 -0
- package/dist/components/AppLayout/ResizablePanel.d.ts.map +1 -0
- package/dist/components/AppLayout/ThreadHistorySidebar.d.ts +53 -0
- package/dist/components/AppLayout/ThreadHistorySidebar.d.ts.map +1 -0
- package/dist/components/AppLayout/index.d.ts +27 -0
- package/dist/components/AppLayout/index.d.ts.map +1 -0
- package/dist/components/Charts/AreaChart.d.ts +38 -0
- package/dist/components/Charts/AreaChart.d.ts.map +1 -0
- package/dist/components/Charts/BarChart.d.ts +47 -0
- package/dist/components/Charts/BarChart.d.ts.map +1 -0
- package/dist/components/Charts/ChartWrapper.d.ts +48 -0
- package/dist/components/Charts/ChartWrapper.d.ts.map +1 -0
- package/dist/components/Charts/ComposedChart.d.ts +34 -0
- package/dist/components/Charts/ComposedChart.d.ts.map +1 -0
- package/dist/components/Charts/CustomLegend.d.ts +69 -0
- package/dist/components/Charts/CustomLegend.d.ts.map +1 -0
- package/dist/components/Charts/CustomTooltip.d.ts +55 -0
- package/dist/components/Charts/CustomTooltip.d.ts.map +1 -0
- package/dist/components/Charts/LineChart.d.ts +36 -0
- package/dist/components/Charts/LineChart.d.ts.map +1 -0
- package/dist/components/Charts/PieChart.d.ts +52 -0
- package/dist/components/Charts/PieChart.d.ts.map +1 -0
- package/dist/components/Charts/RadialChart.d.ts +51 -0
- package/dist/components/Charts/RadialChart.d.ts.map +1 -0
- package/dist/components/Charts/ScatterChart.d.ts +55 -0
- package/dist/components/Charts/ScatterChart.d.ts.map +1 -0
- package/dist/components/Charts/Sparkline.d.ts +44 -0
- package/dist/components/Charts/Sparkline.d.ts.map +1 -0
- package/dist/components/Charts/index.d.ts +48 -0
- package/dist/components/Charts/index.d.ts.map +1 -0
- package/dist/components/Charts/tokens.d.ts +200 -0
- package/dist/components/Charts/tokens.d.ts.map +1 -0
- package/dist/components/Charts/types.d.ts +595 -0
- package/dist/components/Charts/types.d.ts.map +1 -0
- package/dist/components/Combobox/Combobox.d.ts +99 -0
- package/dist/components/Combobox/Combobox.d.ts.map +1 -0
- package/dist/components/Combobox/index.d.ts +3 -0
- package/dist/components/Combobox/index.d.ts.map +1 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +76 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts.map +1 -0
- package/dist/components/CommandPalette/index.d.ts +2 -0
- package/dist/components/CommandPalette/index.d.ts.map +1 -0
- package/dist/components/DataCard/DataCard.d.ts +60 -0
- package/dist/components/DataCard/DataCard.d.ts.map +1 -0
- package/dist/components/DataCard/index.d.ts +2 -0
- package/dist/components/DataCard/index.d.ts.map +1 -0
- package/dist/components/DataTable/CellRenderers.d.ts +78 -0
- package/dist/components/DataTable/CellRenderers.d.ts.map +1 -0
- package/dist/components/DataTable/DataTable.d.ts +36 -0
- package/dist/components/DataTable/DataTable.d.ts.map +1 -0
- package/dist/components/DataTable/InlineAddRow.d.ts +27 -0
- package/dist/components/DataTable/InlineAddRow.d.ts.map +1 -0
- package/dist/components/DataTable/index.d.ts +6 -0
- package/dist/components/DataTable/index.d.ts.map +1 -0
- package/dist/components/DataTable/tokens.d.ts +132 -0
- package/dist/components/DataTable/tokens.d.ts.map +1 -0
- package/dist/components/DataTable/types.d.ts +334 -0
- package/dist/components/DataTable/types.d.ts.map +1 -0
- package/dist/components/DiffViewer/DiffViewer.d.ts +63 -0
- package/dist/components/DiffViewer/DiffViewer.d.ts.map +1 -0
- package/dist/components/DiffViewer/index.d.ts +3 -0
- package/dist/components/DiffViewer/index.d.ts.map +1 -0
- package/dist/components/DockLayout/DockLayout.d.ts +78 -0
- package/dist/components/DockLayout/DockLayout.d.ts.map +1 -0
- package/dist/components/DockLayout/index.d.ts +3 -0
- package/dist/components/DockLayout/index.d.ts.map +1 -0
- package/dist/components/FileUpload/FileUpload.d.ts +93 -0
- package/dist/components/FileUpload/FileUpload.d.ts.map +1 -0
- package/dist/components/FileUpload/index.d.ts +2 -0
- package/dist/components/FileUpload/index.d.ts.map +1 -0
- package/dist/components/FilterBar/FilterBar.d.ts +76 -0
- package/dist/components/FilterBar/FilterBar.d.ts.map +1 -0
- package/dist/components/FilterBar/index.d.ts +2 -0
- package/dist/components/FilterBar/index.d.ts.map +1 -0
- package/dist/components/Footer.d.ts +30 -0
- package/dist/components/Footer.d.ts.map +1 -0
- package/dist/components/Icon.d.ts +67 -0
- package/dist/components/Icon.d.ts.map +1 -0
- package/dist/components/IllustratedMessage.d.ts +99 -0
- package/dist/components/IllustratedMessage.d.ts.map +1 -0
- package/dist/components/LandingPage/FeatureCard.d.ts +89 -0
- package/dist/components/LandingPage/FeatureCard.d.ts.map +1 -0
- package/dist/components/LandingPage/LandingPage.d.ts +126 -0
- package/dist/components/LandingPage/LandingPage.d.ts.map +1 -0
- package/dist/components/LandingPage/index.d.ts +11 -0
- package/dist/components/LandingPage/index.d.ts.map +1 -0
- package/dist/components/Modal/Modal.d.ts +181 -0
- package/dist/components/Modal/Modal.d.ts.map +1 -0
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/Modal/index.d.ts.map +1 -0
- package/dist/components/PageHeader/PageHeader.d.ts +91 -0
- package/dist/components/PageHeader/PageHeader.d.ts.map +1 -0
- package/dist/components/PageHeader/index.d.ts +2 -0
- package/dist/components/PageHeader/index.d.ts.map +1 -0
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +52 -0
- package/dist/components/RichTextEditor/RichTextEditor.d.ts.map +1 -0
- package/dist/components/RichTextEditor/index.d.ts +3 -0
- package/dist/components/RichTextEditor/index.d.ts.map +1 -0
- package/dist/components/SearchInput/SearchInput.d.ts +66 -0
- package/dist/components/SearchInput/SearchInput.d.ts.map +1 -0
- package/dist/components/SearchInput/index.d.ts +2 -0
- package/dist/components/SearchInput/index.d.ts.map +1 -0
- package/dist/components/SimpleTable/SimpleTable.d.ts +93 -0
- package/dist/components/SimpleTable/SimpleTable.d.ts.map +1 -0
- package/dist/components/SimpleTable/index.d.ts +3 -0
- package/dist/components/SimpleTable/index.d.ts.map +1 -0
- package/dist/components/SplitPane/SplitPane.d.ts +52 -0
- package/dist/components/SplitPane/SplitPane.d.ts.map +1 -0
- package/dist/components/SplitPane/index.d.ts +3 -0
- package/dist/components/SplitPane/index.d.ts.map +1 -0
- package/dist/components/StatusIndicator/Badge.d.ts +71 -0
- package/dist/components/StatusIndicator/Badge.d.ts.map +1 -0
- package/dist/components/StatusIndicator/Chip.d.ts +64 -0
- package/dist/components/StatusIndicator/Chip.d.ts.map +1 -0
- package/dist/components/StatusIndicator/Indicators.d.ts +81 -0
- package/dist/components/StatusIndicator/Indicators.d.ts.map +1 -0
- package/dist/components/StatusIndicator/Legend.d.ts +42 -0
- package/dist/components/StatusIndicator/Legend.d.ts.map +1 -0
- package/dist/components/StatusIndicator/Shapes.d.ts +32 -0
- package/dist/components/StatusIndicator/Shapes.d.ts.map +1 -0
- package/dist/components/StatusIndicator/StatusIndicator.d.ts +183 -0
- package/dist/components/StatusIndicator/StatusIndicator.d.ts.map +1 -0
- package/dist/components/StatusIndicator/index.d.ts +55 -0
- package/dist/components/StatusIndicator/index.d.ts.map +1 -0
- package/dist/components/StatusIndicator/types.d.ts +37 -0
- package/dist/components/StatusIndicator/types.d.ts.map +1 -0
- package/dist/components/Timeline/Timeline.d.ts +89 -0
- package/dist/components/Timeline/Timeline.d.ts.map +1 -0
- package/dist/components/Timeline/index.d.ts +2 -0
- package/dist/components/Timeline/index.d.ts.map +1 -0
- package/dist/components/Toast/Toast.d.ts +124 -0
- package/dist/components/Toast/Toast.d.ts.map +1 -0
- package/dist/components/Toast/index.d.ts +2 -0
- package/dist/components/Toast/index.d.ts.map +1 -0
- package/dist/components/TopNavHeader.d.ts +55 -0
- package/dist/components/TopNavHeader.d.ts.map +1 -0
- package/dist/components/TopNavWithSidebar.d.ts +64 -0
- package/dist/components/TopNavWithSidebar.d.ts.map +1 -0
- package/dist/components/TransferList/TransferList.d.ts +62 -0
- package/dist/components/TransferList/TransferList.d.ts.map +1 -0
- package/dist/components/TransferList/index.d.ts +3 -0
- package/dist/components/TransferList/index.d.ts.map +1 -0
- package/dist/components/TreeView/TreeView.d.ts +89 -0
- package/dist/components/TreeView/TreeView.d.ts.map +1 -0
- package/dist/components/TreeView/index.d.ts +3 -0
- package/dist/components/TreeView/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +119 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/internal/index.d.ts +27 -0
- package/dist/components/internal/index.d.ts.map +1 -0
- package/dist/components/navigation/components.d.ts +85 -0
- package/dist/components/navigation/components.d.ts.map +1 -0
- package/dist/components/navigation/hooks.d.ts +65 -0
- package/dist/components/navigation/hooks.d.ts.map +1 -0
- package/dist/components/navigation/index.d.ts +28 -0
- package/dist/components/navigation/index.d.ts.map +1 -0
- package/dist/components/navigation/styled.d.ts +13 -0
- package/dist/components/navigation/styled.d.ts.map +1 -0
- package/dist/components/navigation/types.d.ts +58 -0
- package/dist/components/navigation/types.d.ts.map +1 -0
- package/dist/components/shared/TrinityLogoSvg.d.ts +29 -0
- package/dist/components/shared/TrinityLogoSvg.d.ts.map +1 -0
- package/dist/components/shared.d.ts +92 -0
- package/dist/components/shared.d.ts.map +1 -0
- package/dist/components/templates/Dashboard/DashboardTemplate.d.ts +66 -0
- package/dist/components/templates/Dashboard/DashboardTemplate.d.ts.map +1 -0
- package/dist/components/templates/Dashboard/index.d.ts +2 -0
- package/dist/components/templates/Dashboard/index.d.ts.map +1 -0
- package/dist/components/templates/ListDetail/ListDetailTemplate.d.ts +88 -0
- package/dist/components/templates/ListDetail/ListDetailTemplate.d.ts.map +1 -0
- package/dist/components/templates/ListDetail/index.d.ts +2 -0
- package/dist/components/templates/ListDetail/index.d.ts.map +1 -0
- package/dist/components/templates/Settings/SettingsTemplate.d.ts +78 -0
- package/dist/components/templates/Settings/SettingsTemplate.d.ts.map +1 -0
- package/dist/components/templates/Settings/index.d.ts +2 -0
- package/dist/components/templates/Settings/index.d.ts.map +1 -0
- package/dist/components/templates/index.d.ts +5 -0
- package/dist/components/templates/index.d.ts.map +1 -0
- package/dist/essentials.d.ts +49 -0
- package/dist/essentials.d.ts.map +1 -0
- package/dist/essentials.js +256 -0
- package/dist/form.d.ts +212 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/hierarchy.d.ts +371 -0
- package/dist/hierarchy.d.ts.map +1 -0
- package/dist/hooks/useTrinityPalette.d.ts +54 -0
- package/dist/hooks/useTrinityPalette.d.ts.map +1 -0
- package/dist/hooks.d.ts +217 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2293 -3731
- package/dist/presets/analytics.d.ts +197 -0
- package/dist/presets/analytics.d.ts.map +1 -0
- package/dist/presets/crm.d.ts +67 -0
- package/dist/presets/crm.d.ts.map +1 -0
- package/dist/presets/index.d.ts +21 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/portal.d.ts +67 -0
- package/dist/presets/portal.d.ts.map +1 -0
- package/dist/theme.d.ts +221 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/tokens.d.ts +4760 -0
- package/dist/tokens.d.ts.map +1 -0
- package/package.json +6 -9
package/dist/form.d.ts
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trinity Form Utilities
|
|
3
|
+
* Helpers for building consistent, accessible forms
|
|
4
|
+
*
|
|
5
|
+
* @module form
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
export type ValidationRule<T = unknown> = {
|
|
9
|
+
/** Validation function - return true if valid, false or error message if invalid */
|
|
10
|
+
validate: (value: T) => boolean | string;
|
|
11
|
+
/** Error message if validate returns false */
|
|
12
|
+
message?: string;
|
|
13
|
+
};
|
|
14
|
+
export type FieldState = {
|
|
15
|
+
/** Current field value */
|
|
16
|
+
value: unknown;
|
|
17
|
+
/** Whether field has been touched/interacted with */
|
|
18
|
+
touched: boolean;
|
|
19
|
+
/** Whether field is currently being edited */
|
|
20
|
+
dirty: boolean;
|
|
21
|
+
/** Current error message (if any) */
|
|
22
|
+
error: string | null;
|
|
23
|
+
/** Whether field is currently validating (async) */
|
|
24
|
+
validating: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type FieldConfig<T = unknown> = {
|
|
27
|
+
/** Initial value */
|
|
28
|
+
initialValue?: T;
|
|
29
|
+
/** Validation rules */
|
|
30
|
+
rules?: ValidationRule<T>[];
|
|
31
|
+
/** Whether to validate on change */
|
|
32
|
+
validateOnChange?: boolean;
|
|
33
|
+
/** Whether to validate on blur */
|
|
34
|
+
validateOnBlur?: boolean;
|
|
35
|
+
/** Custom transform function for value */
|
|
36
|
+
transform?: (value: T) => T;
|
|
37
|
+
};
|
|
38
|
+
export type FormState = {
|
|
39
|
+
/** All field states */
|
|
40
|
+
fields: Record<string, FieldState>;
|
|
41
|
+
/** Whether form is submitting */
|
|
42
|
+
isSubmitting: boolean;
|
|
43
|
+
/** Whether form is valid */
|
|
44
|
+
isValid: boolean;
|
|
45
|
+
/** Whether form has been submitted */
|
|
46
|
+
isSubmitted: boolean;
|
|
47
|
+
/** Whether any field has been touched */
|
|
48
|
+
isTouched: boolean;
|
|
49
|
+
/** Whether any field is dirty */
|
|
50
|
+
isDirty: boolean;
|
|
51
|
+
};
|
|
52
|
+
export type FormContextValue = {
|
|
53
|
+
/** Form state */
|
|
54
|
+
state: FormState;
|
|
55
|
+
/** Register a field */
|
|
56
|
+
registerField: (name: string, config?: FieldConfig) => void;
|
|
57
|
+
/** Unregister a field */
|
|
58
|
+
unregisterField: (name: string) => void;
|
|
59
|
+
/** Get field state */
|
|
60
|
+
getFieldState: (name: string) => FieldState | undefined;
|
|
61
|
+
/** Set field value */
|
|
62
|
+
setFieldValue: (name: string, value: unknown) => void;
|
|
63
|
+
/** Set field touched */
|
|
64
|
+
setFieldTouched: (name: string, touched?: boolean) => void;
|
|
65
|
+
/** Set field error */
|
|
66
|
+
setFieldError: (name: string, error: string | null) => void;
|
|
67
|
+
/** Validate a field */
|
|
68
|
+
validateField: (name: string) => Promise<boolean>;
|
|
69
|
+
/** Validate all fields */
|
|
70
|
+
validateForm: () => Promise<boolean>;
|
|
71
|
+
/** Reset form to initial values */
|
|
72
|
+
resetForm: () => void;
|
|
73
|
+
/** Submit handler */
|
|
74
|
+
handleSubmit: (onSubmit: (values: Record<string, unknown>) => void | Promise<void>) => (e?: React.FormEvent) => Promise<void>;
|
|
75
|
+
/** Get all form values */
|
|
76
|
+
getValues: () => Record<string, unknown>;
|
|
77
|
+
};
|
|
78
|
+
export interface FormProviderProps {
|
|
79
|
+
/** Form content */
|
|
80
|
+
children: React.ReactNode;
|
|
81
|
+
/** Initial form values */
|
|
82
|
+
initialValues?: Record<string, unknown>;
|
|
83
|
+
/** Called when form is submitted successfully */
|
|
84
|
+
onSubmit?: (values: Record<string, unknown>) => void | Promise<void>;
|
|
85
|
+
/** Called when validation fails */
|
|
86
|
+
onValidationError?: (errors: Record<string, string>) => void;
|
|
87
|
+
/** Whether to validate all fields on submit */
|
|
88
|
+
validateOnSubmit?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* FormProvider - Provides form context to child components.
|
|
92
|
+
* Manages form state, validation, and submission.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* <FormProvider
|
|
97
|
+
* initialValues={{ email: '', password: '' }}
|
|
98
|
+
* onSubmit={(values) => console.log(values)}
|
|
99
|
+
* >
|
|
100
|
+
* <FormField name="email" label="Email" rules={[required()]} />
|
|
101
|
+
* <FormField name="password" label="Password" rules={[required()]} />
|
|
102
|
+
* <button type="submit">Submit</button>
|
|
103
|
+
* </FormProvider>
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare const FormProvider: React.FC<FormProviderProps>;
|
|
107
|
+
/**
|
|
108
|
+
* Hook to access form context.
|
|
109
|
+
* Must be used within a FormProvider.
|
|
110
|
+
*/
|
|
111
|
+
export declare const useForm: () => FormContextValue;
|
|
112
|
+
export interface UseFormFieldOptions<T = unknown> {
|
|
113
|
+
/** Field name (required) */
|
|
114
|
+
name: string;
|
|
115
|
+
/** Initial value */
|
|
116
|
+
initialValue?: T;
|
|
117
|
+
/** Validation rules */
|
|
118
|
+
rules?: ValidationRule<T>[];
|
|
119
|
+
/** Whether to validate on change */
|
|
120
|
+
validateOnChange?: boolean;
|
|
121
|
+
/** Whether to validate on blur */
|
|
122
|
+
validateOnBlur?: boolean;
|
|
123
|
+
/** Custom transform function */
|
|
124
|
+
transform?: (value: T) => T;
|
|
125
|
+
}
|
|
126
|
+
export interface UseFormFieldReturn<T = unknown> {
|
|
127
|
+
/** Field value */
|
|
128
|
+
value: T;
|
|
129
|
+
/** Field error */
|
|
130
|
+
error: string | null;
|
|
131
|
+
/** Whether field has been touched */
|
|
132
|
+
touched: boolean;
|
|
133
|
+
/** Whether field is dirty */
|
|
134
|
+
dirty: boolean;
|
|
135
|
+
/** Whether field is validating */
|
|
136
|
+
validating: boolean;
|
|
137
|
+
/** Whether field has an error and has been touched */
|
|
138
|
+
showError: boolean;
|
|
139
|
+
/** Input props to spread */
|
|
140
|
+
inputProps: {
|
|
141
|
+
name: string;
|
|
142
|
+
value: T;
|
|
143
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | T) => void;
|
|
144
|
+
onBlur: () => void;
|
|
145
|
+
'aria-invalid': boolean;
|
|
146
|
+
'aria-describedby': string | undefined;
|
|
147
|
+
};
|
|
148
|
+
/** Error message ID for aria-describedby */
|
|
149
|
+
errorId: string;
|
|
150
|
+
/** Set field value directly */
|
|
151
|
+
setValue: (value: T) => void;
|
|
152
|
+
/** Set touched state */
|
|
153
|
+
setTouched: (touched?: boolean) => void;
|
|
154
|
+
/** Validate field */
|
|
155
|
+
validate: () => Promise<boolean>;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Hook for connecting a form field to FormProvider.
|
|
159
|
+
* Handles registration, validation, and state management.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```tsx
|
|
163
|
+
* const EmailInput = () => {
|
|
164
|
+
* const { inputProps, error, showError } = useFormField({
|
|
165
|
+
* name: 'email',
|
|
166
|
+
* rules: [required(), email()],
|
|
167
|
+
* });
|
|
168
|
+
*
|
|
169
|
+
* return (
|
|
170
|
+
* <TextField
|
|
171
|
+
* {...inputProps}
|
|
172
|
+
* error={showError}
|
|
173
|
+
* helperText={showError ? error : undefined}
|
|
174
|
+
* />
|
|
175
|
+
* );
|
|
176
|
+
* };
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export declare const useFormField: <T = unknown>({ name, initialValue, rules, validateOnChange, validateOnBlur, transform, }: UseFormFieldOptions<T>) => UseFormFieldReturn<T>;
|
|
180
|
+
/**
|
|
181
|
+
* Required field validation rule.
|
|
182
|
+
*/
|
|
183
|
+
export declare const required: (message?: string) => ValidationRule;
|
|
184
|
+
/**
|
|
185
|
+
* Email validation rule.
|
|
186
|
+
*/
|
|
187
|
+
export declare const email: (message?: string) => ValidationRule<string>;
|
|
188
|
+
/**
|
|
189
|
+
* Minimum length validation rule.
|
|
190
|
+
*/
|
|
191
|
+
export declare const minLength: (min: number, message?: string) => ValidationRule<string>;
|
|
192
|
+
/**
|
|
193
|
+
* Maximum length validation rule.
|
|
194
|
+
*/
|
|
195
|
+
export declare const maxLength: (max: number, message?: string) => ValidationRule<string>;
|
|
196
|
+
/**
|
|
197
|
+
* Pattern validation rule.
|
|
198
|
+
*/
|
|
199
|
+
export declare const pattern: (regex: RegExp, message?: string) => ValidationRule<string>;
|
|
200
|
+
/**
|
|
201
|
+
* Minimum number validation rule.
|
|
202
|
+
*/
|
|
203
|
+
export declare const min: (minValue: number, message?: string) => ValidationRule<number>;
|
|
204
|
+
/**
|
|
205
|
+
* Maximum number validation rule.
|
|
206
|
+
*/
|
|
207
|
+
export declare const max: (maxValue: number, message?: string) => ValidationRule<number>;
|
|
208
|
+
/**
|
|
209
|
+
* Custom validation rule.
|
|
210
|
+
*/
|
|
211
|
+
export declare const custom: <T>(validateFn: (value: T) => boolean | string, message?: string) => ValidationRule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,CAOlF,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,KAAG,cAAc,CAAC,MAAM,CAG7E,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,KAAG,cAAc,CAAC,MAAM,CAG7E,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,EAAE,gBAA0B,KAAG,cAAc,CAAC,MAAM,CAGvF,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,GAAG,GAAI,UAAU,MAAM,EAAE,UAAU,MAAM,KAAG,cAAc,CAAC,MAAM,CAG5E,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,GAAG,GAAI,UAAU,MAAM,EAAE,UAAU,MAAM,KAAG,cAAc,CAAC,MAAM,CAG5E,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EACtB,YAAY,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,EAC1C,gBAAyB,KACxB,cAAc,CAAC,CAAC,CAGjB,CAAC"}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { hierarchy, elevationHierarchy, typographicHierarchy, attentionHierarchy, scaleHierarchy, contrastHierarchy, interactiveHierarchy, spacingHierarchy, getElevation, getTypography, getAttentionColor, getHierarchySpacing } from './tokens';
|
|
2
|
+
export { hierarchy, elevationHierarchy, typographicHierarchy, attentionHierarchy, scaleHierarchy, contrastHierarchy, interactiveHierarchy, spacingHierarchy, getElevation, getTypography, getAttentionColor, getHierarchySpacing, };
|
|
3
|
+
export type ElevationLevel = keyof typeof elevationHierarchy;
|
|
4
|
+
export type AttentionLevel = keyof typeof attentionHierarchy;
|
|
5
|
+
export type TypographyCategory = keyof typeof typographicHierarchy;
|
|
6
|
+
export type SpacingCategory = keyof typeof spacingHierarchy;
|
|
7
|
+
export type ContrastLevel = keyof typeof contrastHierarchy;
|
|
8
|
+
export type InteractiveState = keyof typeof interactiveHierarchy;
|
|
9
|
+
export interface HierarchyStyles {
|
|
10
|
+
elevation?: ElevationLevel;
|
|
11
|
+
attention?: AttentionLevel;
|
|
12
|
+
typography?: {
|
|
13
|
+
category: TypographyCategory;
|
|
14
|
+
variant: string;
|
|
15
|
+
};
|
|
16
|
+
spacing?: {
|
|
17
|
+
category: SpacingCategory;
|
|
18
|
+
size: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get CSS properties for an elevation level
|
|
23
|
+
* @param level - Elevation level name
|
|
24
|
+
* @returns Object with zIndex and boxShadow CSS properties
|
|
25
|
+
*/
|
|
26
|
+
export declare function getElevationStyles(level: ElevationLevel): {
|
|
27
|
+
zIndex: number | string;
|
|
28
|
+
boxShadow: string;
|
|
29
|
+
position?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Get elevation for common UI patterns
|
|
33
|
+
*/
|
|
34
|
+
export declare const uiElevation: {
|
|
35
|
+
/** For sunken/recessed areas like code blocks, wells */
|
|
36
|
+
sunken: () => {
|
|
37
|
+
zIndex: number | string;
|
|
38
|
+
boxShadow: string;
|
|
39
|
+
position?: string;
|
|
40
|
+
};
|
|
41
|
+
/** For standard cards at rest */
|
|
42
|
+
card: () => {
|
|
43
|
+
zIndex: number | string;
|
|
44
|
+
boxShadow: string;
|
|
45
|
+
position?: string;
|
|
46
|
+
};
|
|
47
|
+
/** For hovered/focused cards */
|
|
48
|
+
cardHover: () => {
|
|
49
|
+
zIndex: number | string;
|
|
50
|
+
boxShadow: string;
|
|
51
|
+
position?: string;
|
|
52
|
+
};
|
|
53
|
+
/** For dropdown menus */
|
|
54
|
+
dropdown: () => {
|
|
55
|
+
zIndex: number | string;
|
|
56
|
+
boxShadow: string;
|
|
57
|
+
position?: string;
|
|
58
|
+
};
|
|
59
|
+
/** For sticky headers */
|
|
60
|
+
header: () => {
|
|
61
|
+
zIndex: number | string;
|
|
62
|
+
boxShadow: string;
|
|
63
|
+
position?: string;
|
|
64
|
+
};
|
|
65
|
+
/** For modal backdrops */
|
|
66
|
+
backdrop: () => {
|
|
67
|
+
zIndex: number | string;
|
|
68
|
+
boxShadow: string;
|
|
69
|
+
position?: string;
|
|
70
|
+
};
|
|
71
|
+
/** For modal dialogs */
|
|
72
|
+
modal: () => {
|
|
73
|
+
zIndex: number | string;
|
|
74
|
+
boxShadow: string;
|
|
75
|
+
position?: string;
|
|
76
|
+
};
|
|
77
|
+
/** For popovers */
|
|
78
|
+
popover: () => {
|
|
79
|
+
zIndex: number | string;
|
|
80
|
+
boxShadow: string;
|
|
81
|
+
position?: string;
|
|
82
|
+
};
|
|
83
|
+
/** For tooltips */
|
|
84
|
+
tooltip: () => {
|
|
85
|
+
zIndex: number | string;
|
|
86
|
+
boxShadow: string;
|
|
87
|
+
position?: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Get typography CSS properties
|
|
92
|
+
* @param category - Typography category (display, heading, body, label, caption, overline)
|
|
93
|
+
* @param variant - Variant within the category
|
|
94
|
+
* @returns CSS properties object
|
|
95
|
+
*/
|
|
96
|
+
export declare function getTypographyStyles(category: TypographyCategory, variant: string): Record<string, string | number> | null;
|
|
97
|
+
/**
|
|
98
|
+
* Commonly used typography presets
|
|
99
|
+
*/
|
|
100
|
+
export declare const typographyPresets: {
|
|
101
|
+
heroTitle: () => Record<string, string | number> | null;
|
|
102
|
+
pageTitle: () => Record<string, string | number> | null;
|
|
103
|
+
sectionTitle: () => Record<string, string | number> | null;
|
|
104
|
+
h1: () => Record<string, string | number> | null;
|
|
105
|
+
h2: () => Record<string, string | number> | null;
|
|
106
|
+
h3: () => Record<string, string | number> | null;
|
|
107
|
+
h4: () => Record<string, string | number> | null;
|
|
108
|
+
h5: () => Record<string, string | number> | null;
|
|
109
|
+
h6: () => Record<string, string | number> | null;
|
|
110
|
+
bodyLarge: () => Record<string, string | number> | null;
|
|
111
|
+
body: () => Record<string, string | number> | null;
|
|
112
|
+
bodySmall: () => Record<string, string | number> | null;
|
|
113
|
+
labelLarge: () => Record<string, string | number> | null;
|
|
114
|
+
label: () => Record<string, string | number> | null;
|
|
115
|
+
labelSmall: () => Record<string, string | number> | null;
|
|
116
|
+
caption: () => Record<string, string | number> | null;
|
|
117
|
+
captionEmphasis: () => Record<string, string | number> | null;
|
|
118
|
+
overline: () => Record<string, string | number> | null;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Get color for attention level
|
|
122
|
+
* @param level - Attention level
|
|
123
|
+
* @param mode - Light or dark mode
|
|
124
|
+
* @returns Color value
|
|
125
|
+
*/
|
|
126
|
+
export declare function getAttentionStyles(level: AttentionLevel, mode?: 'light' | 'dark'): {
|
|
127
|
+
color: string;
|
|
128
|
+
opacity?: number;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Apply attention-based styling to content
|
|
132
|
+
*/
|
|
133
|
+
export declare const attentionStyles: {
|
|
134
|
+
/** Primary importance - CTAs, titles, critical info */
|
|
135
|
+
primary: (mode?: "light" | "dark") => {
|
|
136
|
+
color: string;
|
|
137
|
+
fontWeight: number;
|
|
138
|
+
};
|
|
139
|
+
/** Secondary importance - section headers, key info */
|
|
140
|
+
secondary: (mode?: "light" | "dark") => {
|
|
141
|
+
color: string;
|
|
142
|
+
fontWeight: number;
|
|
143
|
+
};
|
|
144
|
+
/** Tertiary - body text, regular content */
|
|
145
|
+
tertiary: (mode?: "light" | "dark") => {
|
|
146
|
+
color: string;
|
|
147
|
+
fontWeight: number;
|
|
148
|
+
};
|
|
149
|
+
/** Muted - helper text, metadata */
|
|
150
|
+
muted: (mode?: "light" | "dark") => {
|
|
151
|
+
color: string;
|
|
152
|
+
fontWeight: number;
|
|
153
|
+
};
|
|
154
|
+
/** Disabled - unavailable items */
|
|
155
|
+
disabled: (mode?: "light" | "dark") => {
|
|
156
|
+
color: string;
|
|
157
|
+
fontWeight: number;
|
|
158
|
+
opacity: number;
|
|
159
|
+
cursor: string;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Get spacing value from hierarchy
|
|
164
|
+
*/
|
|
165
|
+
export declare function getSpacing(category: SpacingCategory, size: number): number | null;
|
|
166
|
+
/**
|
|
167
|
+
* Spacing presets for common use cases
|
|
168
|
+
*/
|
|
169
|
+
export declare const spacing: {
|
|
170
|
+
inline: 4;
|
|
171
|
+
inlineRelaxed: 8;
|
|
172
|
+
componentTight: 12;
|
|
173
|
+
component: 16;
|
|
174
|
+
componentRelaxed: 20;
|
|
175
|
+
sectionTight: 24;
|
|
176
|
+
section: 32;
|
|
177
|
+
sectionRelaxed: 40;
|
|
178
|
+
layoutTight: 48;
|
|
179
|
+
layout: 64;
|
|
180
|
+
layoutRelaxed: 96;
|
|
181
|
+
layoutHero: 128;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Get scaled size based on base value and scale step
|
|
185
|
+
*/
|
|
186
|
+
export declare function getScaledSize(base: number, step: keyof typeof scaleHierarchy.sizes): number;
|
|
187
|
+
/**
|
|
188
|
+
* Get icon size
|
|
189
|
+
*/
|
|
190
|
+
export declare function getIconSize(size: keyof typeof scaleHierarchy.icons): number;
|
|
191
|
+
/**
|
|
192
|
+
* Ensure touch target meets accessibility requirements
|
|
193
|
+
*/
|
|
194
|
+
export declare function ensureTouchTarget(size: number, level?: 'minimum' | 'comfortable' | 'spacious'): number;
|
|
195
|
+
/**
|
|
196
|
+
* Get interactive state styles
|
|
197
|
+
*/
|
|
198
|
+
export declare function getInteractiveStyles(state: InteractiveState): Record<string, string | number>;
|
|
199
|
+
/**
|
|
200
|
+
* Get focus ring styles for accessibility
|
|
201
|
+
*/
|
|
202
|
+
export declare function getFocusRingStyles(color?: string): Record<string, string | number>;
|
|
203
|
+
/**
|
|
204
|
+
* CSS for interactive hover effects
|
|
205
|
+
*/
|
|
206
|
+
export declare const hoverEffect: {
|
|
207
|
+
/** Subtle lift effect */
|
|
208
|
+
lift: {
|
|
209
|
+
transition: string;
|
|
210
|
+
'&:hover': {
|
|
211
|
+
transform: string;
|
|
212
|
+
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)";
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
/** Scale effect */
|
|
216
|
+
scale: {
|
|
217
|
+
transition: string;
|
|
218
|
+
'&:hover': {
|
|
219
|
+
transform: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
/** Highlight effect */
|
|
223
|
+
highlight: {
|
|
224
|
+
transition: string;
|
|
225
|
+
'&:hover': {
|
|
226
|
+
backgroundColor: string;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Get contrast pair colors
|
|
232
|
+
*/
|
|
233
|
+
export declare function getContrastColors(level: ContrastLevel): {
|
|
234
|
+
foreground: string;
|
|
235
|
+
background: string;
|
|
236
|
+
ratio: number;
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Check if a contrast ratio meets WCAG requirements
|
|
240
|
+
*/
|
|
241
|
+
export declare function meetsWCAG(ratio: number, level?: 'AA' | 'AAA', isLargeText?: boolean): boolean;
|
|
242
|
+
/**
|
|
243
|
+
* Apply multiple hierarchy aspects at once
|
|
244
|
+
*/
|
|
245
|
+
export declare function applyHierarchy(config: HierarchyStyles): Record<string, unknown>;
|
|
246
|
+
/**
|
|
247
|
+
* Get presets for common UI patterns
|
|
248
|
+
*/
|
|
249
|
+
export declare const uiPatterns: {
|
|
250
|
+
/** Card with hover effect */
|
|
251
|
+
interactiveCard: () => {
|
|
252
|
+
borderRadius: number;
|
|
253
|
+
transition: string;
|
|
254
|
+
cursor: string;
|
|
255
|
+
'&:hover': {
|
|
256
|
+
transform: string;
|
|
257
|
+
zIndex: number | string;
|
|
258
|
+
boxShadow: string;
|
|
259
|
+
position?: string;
|
|
260
|
+
};
|
|
261
|
+
'&:focus-visible': Record<string, string | number>;
|
|
262
|
+
zIndex: number | string;
|
|
263
|
+
boxShadow: string;
|
|
264
|
+
position?: string;
|
|
265
|
+
};
|
|
266
|
+
/** Modal dialog */
|
|
267
|
+
modal: () => {
|
|
268
|
+
borderRadius: number;
|
|
269
|
+
padding: 32;
|
|
270
|
+
zIndex: number | string;
|
|
271
|
+
boxShadow: string;
|
|
272
|
+
position?: string;
|
|
273
|
+
};
|
|
274
|
+
/** Dropdown menu */
|
|
275
|
+
dropdown: () => {
|
|
276
|
+
borderRadius: number;
|
|
277
|
+
padding: 4;
|
|
278
|
+
zIndex: number | string;
|
|
279
|
+
boxShadow: string;
|
|
280
|
+
position?: string;
|
|
281
|
+
};
|
|
282
|
+
/** Tooltip */
|
|
283
|
+
tooltip: () => {
|
|
284
|
+
borderRadius: number;
|
|
285
|
+
padding: string;
|
|
286
|
+
zIndex: number | string;
|
|
287
|
+
boxShadow: string;
|
|
288
|
+
position?: string;
|
|
289
|
+
};
|
|
290
|
+
/** Primary button */
|
|
291
|
+
primaryButton: () => {
|
|
292
|
+
padding: string;
|
|
293
|
+
borderRadius: number;
|
|
294
|
+
fontWeight: number;
|
|
295
|
+
transition: string;
|
|
296
|
+
'&:hover': {
|
|
297
|
+
transform: string;
|
|
298
|
+
};
|
|
299
|
+
'&:active': {
|
|
300
|
+
transform: string;
|
|
301
|
+
};
|
|
302
|
+
'&:focus-visible': Record<string, string | number>;
|
|
303
|
+
};
|
|
304
|
+
/** Section container */
|
|
305
|
+
section: () => {
|
|
306
|
+
paddingTop: 32;
|
|
307
|
+
paddingBottom: 32;
|
|
308
|
+
display: string;
|
|
309
|
+
flexDirection: "column";
|
|
310
|
+
gap: 20;
|
|
311
|
+
};
|
|
312
|
+
/** Page container */
|
|
313
|
+
page: () => {
|
|
314
|
+
maxWidth: number;
|
|
315
|
+
margin: string;
|
|
316
|
+
padding: 32;
|
|
317
|
+
display: string;
|
|
318
|
+
flexDirection: "column";
|
|
319
|
+
gap: 64;
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Design System Architecture Reference
|
|
324
|
+
*
|
|
325
|
+
* Layer 1: FOUNDATIONS (baseTokens)
|
|
326
|
+
* - Color palettes (navy, purple, coral, azure, gray)
|
|
327
|
+
* - Typography scales (font sizes, weights, line heights)
|
|
328
|
+
* - Spacing scale (0-32, in 4px increments)
|
|
329
|
+
* - Border radius scale (none through full)
|
|
330
|
+
* - Shadow definitions
|
|
331
|
+
* - Motion/animation values
|
|
332
|
+
*
|
|
333
|
+
* Layer 2: DESIGN TOKENS (semanticTokens)
|
|
334
|
+
* - Semantic color mappings (brand, text, background, border, status)
|
|
335
|
+
* - Typography presets (display, heading, body, label)
|
|
336
|
+
* - Semantic spacing (component, layout)
|
|
337
|
+
* - Semantic borders and shadows
|
|
338
|
+
*
|
|
339
|
+
* Layer 3: COMPONENT TOKENS (componentTokens)
|
|
340
|
+
* - Button sizes, colors, radii
|
|
341
|
+
* - Input specifications
|
|
342
|
+
* - Card tokens
|
|
343
|
+
* - Avatar, badge, chip tokens
|
|
344
|
+
* - Modal, tooltip tokens
|
|
345
|
+
* - Navigation tokens
|
|
346
|
+
*
|
|
347
|
+
* Layer 4: HIERARCHY (hierarchy)
|
|
348
|
+
* - Attention hierarchy (primary → disabled)
|
|
349
|
+
* - Typography hierarchy (display → overline)
|
|
350
|
+
* - Elevation hierarchy (ground → tooltip)
|
|
351
|
+
* - Scale hierarchy (size ratios)
|
|
352
|
+
* - Contrast hierarchy (accessibility)
|
|
353
|
+
* - Interactive hierarchy (states)
|
|
354
|
+
* - Spacing hierarchy (micro → layout)
|
|
355
|
+
*
|
|
356
|
+
* Layer 5: PATTERNS (uiPatterns)
|
|
357
|
+
* - Interactive card pattern
|
|
358
|
+
* - Modal pattern
|
|
359
|
+
* - Dropdown pattern
|
|
360
|
+
* - Button patterns
|
|
361
|
+
* - Section/page layouts
|
|
362
|
+
*/
|
|
363
|
+
export declare const architectureLayers: {
|
|
364
|
+
readonly foundations: "Layer 1: Raw design primitives (colors, spacing, typography scales)";
|
|
365
|
+
readonly tokens: "Layer 2: Semantic mappings of foundations to use cases";
|
|
366
|
+
readonly components: "Layer 3: UI component specifications";
|
|
367
|
+
readonly hierarchy: "Layer 4: Visual hierarchy rules for consistent importance";
|
|
368
|
+
readonly patterns: "Layer 5: Composed solutions for common UI tasks";
|
|
369
|
+
};
|
|
370
|
+
export default hierarchy;
|
|
371
|
+
//# sourceMappingURL=hierarchy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hierarchy.d.ts","sourceRoot":"","sources":["../src/hierarchy.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EAEpB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAC7D,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,oBAAoB,CAAC;AACnE,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAC5D,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAC3D,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAEjE,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,cAAc,CAAC;IA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C;AAEX,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trinity Theme Utilities
|
|
3
|
+
*
|
|
4
|
+
* These hooks provide access to Trinity's extended palette in a type-safe way.
|
|
5
|
+
* Use these instead of importing tokens directly when you need colors that
|
|
6
|
+
* should respond to light/dark mode.
|
|
7
|
+
*/
|
|
8
|
+
import { Theme } from '@mui/material';
|
|
9
|
+
/**
|
|
10
|
+
* Trinity palette types
|
|
11
|
+
*/
|
|
12
|
+
export interface TrinityStatusColor {
|
|
13
|
+
text: string;
|
|
14
|
+
background: string;
|
|
15
|
+
border: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TrinityInteractive {
|
|
18
|
+
default: string;
|
|
19
|
+
hover: string;
|
|
20
|
+
active: string;
|
|
21
|
+
disabled: string;
|
|
22
|
+
focus: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TrinityBorder {
|
|
25
|
+
default: string;
|
|
26
|
+
subtle: string;
|
|
27
|
+
strong: string;
|
|
28
|
+
}
|
|
29
|
+
export interface TrinityPalette {
|
|
30
|
+
interactive: TrinityInteractive;
|
|
31
|
+
status: {
|
|
32
|
+
success: TrinityStatusColor;
|
|
33
|
+
warning: TrinityStatusColor;
|
|
34
|
+
error: TrinityStatusColor;
|
|
35
|
+
info: TrinityStatusColor;
|
|
36
|
+
};
|
|
37
|
+
border: TrinityBorder;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Hook to access Trinity's semantic colors from the theme.
|
|
41
|
+
* Returns mode-aware colors that automatically adjust for light/dark mode.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* const trinity = useTrinityPalette();
|
|
46
|
+
* <Box color={trinity.status.success.text} />
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function useTrinityPalette(): TrinityPalette;
|
|
50
|
+
/**
|
|
51
|
+
* Get Trinity palette from a theme object (for use outside React components)
|
|
52
|
+
*/
|
|
53
|
+
export declare function getTrinityPalette(theme: Theme): TrinityPalette;
|
|
54
|
+
//# sourceMappingURL=useTrinityPalette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrinityPalette.d.ts","sourceRoot":"","sources":["../../src/hooks/useTrinityPalette.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAY,KAAK,EAAE,MAAM,eAAe,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,kBAAkB,CAAC;IAChC,MAAM,EAAE;QACN,OAAO,EAAE,kBAAkB,CAAC;QAC5B,OAAO,EAAE,kBAAkB,CAAC;QAC5B,KAAK,EAAE,kBAAkB,CAAC;QAC1B,IAAI,EAAE,kBAAkB,CAAC;KAC1B,CAAC;IACF,MAAM,EAAE,aAAa,CAAC;CACvB;AAoCD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CASlD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAO9D"}
|