hazo_ui 2.6.1 → 2.6.3

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 CHANGED
@@ -65,6 +65,104 @@ Tailwind v4 uses JIT compilation and only generates CSS for classes found in sca
65
65
 
66
66
  ---
67
67
 
68
+ ## Color Configuration
69
+
70
+ hazo_ui provides a centralized configuration system for customizing button and header colors across all components. You can set colors globally using `set_hazo_ui_config()` or override them per-component using props.
71
+
72
+ ### Global Configuration
73
+
74
+ Set default colors for all components in your app:
75
+
76
+ ```tsx
77
+ import { set_hazo_ui_config } from 'hazo_ui';
78
+
79
+ // Set custom colors globally (typically in your app's entry point)
80
+ set_hazo_ui_config({
81
+ // Dialog headers
82
+ header_background_color: '#1e3a8a',
83
+ header_text_color: '#ffffff',
84
+
85
+ // Submit/Apply buttons
86
+ submit_button_background_color: '#10b981',
87
+ submit_button_text_color: '#ffffff',
88
+
89
+ // Cancel buttons
90
+ cancel_button_border_color: '#6b7280',
91
+ cancel_button_text_color: '#374151',
92
+
93
+ // Clear/Delete buttons
94
+ clear_button_border_color: '#ef4444',
95
+ clear_button_text_color: '#ef4444',
96
+ });
97
+ ```
98
+
99
+ ### Per-Component Override
100
+
101
+ Override colors for individual component instances using props:
102
+
103
+ ```tsx
104
+ <HazoUiMultiFilterDialog
105
+ availableFields={fields}
106
+ onFilterChange={handleFilterChange}
107
+ // Color overrides (these take precedence over global config)
108
+ headerBackgroundColor="#7c3aed"
109
+ headerTextColor="#ffffff"
110
+ submitButtonBackgroundColor="#f59e0b"
111
+ submitButtonTextColor="#ffffff"
112
+ cancelButtonBorderColor="#ec4899"
113
+ cancelButtonTextColor="#ec4899"
114
+ />
115
+ ```
116
+
117
+ ### Available Color Properties
118
+
119
+ **HazoUiConfig Interface:**
120
+ ```tsx
121
+ interface HazoUiConfig {
122
+ // Dialog Header Colors
123
+ header_background_color?: string;
124
+ header_text_color?: string;
125
+
126
+ // Submit/Action Button Colors
127
+ submit_button_background_color?: string;
128
+ submit_button_text_color?: string;
129
+ submit_button_hover_color?: string;
130
+
131
+ // Cancel Button Colors
132
+ cancel_button_background_color?: string;
133
+ cancel_button_text_color?: string;
134
+ cancel_button_border_color?: string;
135
+ cancel_button_hover_color?: string;
136
+
137
+ // Clear/Delete Button Colors
138
+ clear_button_background_color?: string;
139
+ clear_button_text_color?: string;
140
+ clear_button_border_color?: string;
141
+ clear_button_hover_color?: string;
142
+ }
143
+ ```
144
+
145
+ ### Configuration Functions
146
+
147
+ **`set_hazo_ui_config(config: Partial<HazoUiConfig>)`**
148
+ - Merges provided config with existing global config
149
+ - Accepts partial config (you can set only the colors you want to customize)
150
+
151
+ **`get_hazo_ui_config(): Readonly<HazoUiConfig>`**
152
+ - Returns the current global configuration (read-only)
153
+
154
+ **`reset_hazo_ui_config()`**
155
+ - Resets all colors to default (undefined, using theme defaults)
156
+
157
+ ### Components Supporting Color Configuration
158
+
159
+ The following components support both global config and prop-level color overrides:
160
+ - `HazoUiDialog` - via `headerBackgroundColor`, `headerTextColor`, `accentColor` props
161
+ - `HazoUiMultiFilterDialog` - via header/submit/cancel/clear color props
162
+ - `HazoUiMultiSortDialog` - via header/submit/cancel/clear color props
163
+
164
+ ---
165
+
68
166
  ## Components
69
167
 
70
168
  ### Component Overview
@@ -1707,6 +1805,27 @@ function CustomHeightExample() {
1707
1805
 
1708
1806
  A flexible, standardized dialog component with customizable animations, sizes, and theming. Built on Radix UI Dialog primitives with a consistent header/body/footer layout.
1709
1807
 
1808
+ ### Two Usage Patterns
1809
+
1810
+ HazoUiDialog offers two approaches depending on your needs:
1811
+
1812
+ 1. **Props-based API (HazoUiDialog)** - For simple confirmations, alerts, and standard forms with predefined header/body/footer layout
1813
+ 2. **Compositional API (Primitives)** - For complex layouts with custom headers, tabs, avatars, and full layout control
1814
+
1815
+ #### When to Use Each Approach
1816
+
1817
+ **Use HazoUiDialog (props-based) when:**
1818
+ - You need a standard confirmation dialog
1819
+ - Your content fits a simple header/body/footer layout
1820
+ - You want quick implementation with minimal code
1821
+ - Examples: confirmations, alerts, simple forms
1822
+
1823
+ **Use Compositional API (primitives) when:**
1824
+ - You need custom headers with avatars, icons, or complex layouts
1825
+ - Your dialog has tabs or multi-section content
1826
+ - You want full control over the dialog structure
1827
+ - Examples: client details with tabs, complex forms, custom workflows
1828
+
1710
1829
  #### Features
1711
1830
 
1712
1831
  - **Flexible Sizing**: 5 size presets from small (400px) to full-width (98vw), plus custom sizing
@@ -1759,8 +1878,13 @@ interface HazoUiDialogProps {
1759
1878
  openAnimation?: AnimationPreset | string; // default: "zoom"
1760
1879
  closeAnimation?: AnimationPreset | string; // default: "zoom"
1761
1880
 
1762
- // Color Customization
1881
+ // Variant (preset color theme)
1882
+ variant?: DialogVariant; // default: "default"
1883
+ splitHeader?: boolean; // default: true - When true, title/description get separate bg rows; false = single bg, italic description
1884
+
1885
+ // Color Customization (overrides variant preset if both provided)
1763
1886
  headerBackgroundColor?: string;
1887
+ descriptionBackgroundColor?: string;
1764
1888
  headerTextColor?: string;
1765
1889
  bodyBackgroundColor?: string;
1766
1890
  footerBackgroundColor?: string;
@@ -1780,11 +1904,14 @@ interface HazoUiDialogProps {
1780
1904
  showCloseButton?: boolean; // default: true
1781
1905
  }
1782
1906
 
1907
+ type DialogVariant = 'default' | 'info' | 'success' | 'warning' | 'danger';
1783
1908
  type AnimationPreset = 'zoom' | 'slide' | 'fade' | 'bounce' | 'scale-up' | 'flip' | 'slide-left' | 'slide-right' | 'slide-top' | 'none';
1784
1909
  type ButtonVariant = "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
1785
1910
  ```
1786
1911
 
1787
- #### Basic Usage
1912
+ #### Pattern 1: Basic Usage (Props-based API)
1913
+
1914
+ For simple dialogs with standard layout:
1788
1915
 
1789
1916
  ```tsx
1790
1917
  import { HazoUiDialog } from 'hazo_ui';
@@ -1819,6 +1946,170 @@ function ConfirmDialog() {
1819
1946
  }
1820
1947
  ```
1821
1948
 
1949
+ #### Pattern 2: Compositional API (Complex Layouts)
1950
+
1951
+ For dialogs with custom headers, tabs, or complex layouts:
1952
+
1953
+ ```tsx
1954
+ import {
1955
+ HazoUiDialogRoot,
1956
+ HazoUiDialogContent,
1957
+ HazoUiDialogHeader,
1958
+ HazoUiDialogTitle,
1959
+ HazoUiDialogDescription,
1960
+ HazoUiDialogFooter,
1961
+ } from 'hazo_ui';
1962
+ import { useState } from 'react';
1963
+ import { User } from 'lucide-react';
1964
+
1965
+ function ClientDetailsDialog() {
1966
+ const [isOpen, setIsOpen] = useState(false);
1967
+ const [activeTab, setActiveTab] = useState('personal');
1968
+
1969
+ return (
1970
+ <>
1971
+ <button onClick={() => setIsOpen(true)}>
1972
+ Open Client Details
1973
+ </button>
1974
+
1975
+ <HazoUiDialogRoot open={isOpen} onOpenChange={setIsOpen}>
1976
+ <HazoUiDialogContent className="sm:max-w-2xl w-[90vw] h-[80vh] flex flex-col p-0">
1977
+ {/* Custom Header with Avatar */}
1978
+ <HazoUiDialogHeader className="bg-navbar text-navbar-foreground p-6 rounded-t-lg">
1979
+ <div className="flex items-center gap-3">
1980
+ <div className="w-12 h-12 rounded-full bg-primary/20 flex items-center justify-center">
1981
+ <User className="h-6 w-6 text-primary-foreground" />
1982
+ </div>
1983
+ <div>
1984
+ <HazoUiDialogTitle className="text-white text-left">
1985
+ John Doe
1986
+ </HazoUiDialogTitle>
1987
+ <HazoUiDialogDescription className="text-white/80 text-left">
1988
+ john.doe@example.com
1989
+ </HazoUiDialogDescription>
1990
+ </div>
1991
+ </div>
1992
+ </HazoUiDialogHeader>
1993
+
1994
+ {/* Tabs Navigation */}
1995
+ <div className="border-b px-6">
1996
+ <div className="flex gap-4">
1997
+ <button
1998
+ onClick={() => setActiveTab('personal')}
1999
+ className={`py-3 px-1 text-sm font-medium border-b-2 ${
2000
+ activeTab === 'personal'
2001
+ ? 'border-primary text-primary'
2002
+ : 'border-transparent text-muted-foreground'
2003
+ }`}
2004
+ >
2005
+ Personal
2006
+ </button>
2007
+ <button
2008
+ onClick={() => setActiveTab('address')}
2009
+ className={`py-3 px-1 text-sm font-medium border-b-2 ${
2010
+ activeTab === 'address'
2011
+ ? 'border-primary text-primary'
2012
+ : 'border-transparent text-muted-foreground'
2013
+ }`}
2014
+ >
2015
+ Address
2016
+ </button>
2017
+ <button
2018
+ onClick={() => setActiveTab('contact')}
2019
+ className={`py-3 px-1 text-sm font-medium border-b-2 ${
2020
+ activeTab === 'contact'
2021
+ ? 'border-primary text-primary'
2022
+ : 'border-transparent text-muted-foreground'
2023
+ }`}
2024
+ >
2025
+ Contact
2026
+ </button>
2027
+ </div>
2028
+ </div>
2029
+
2030
+ {/* Scrollable Tab Content */}
2031
+ <div className="flex-1 overflow-y-auto p-6">
2032
+ {activeTab === 'personal' && (
2033
+ <div className="space-y-4">
2034
+ <div>
2035
+ <label className="text-sm font-medium">Full Name</label>
2036
+ <input
2037
+ type="text"
2038
+ className="w-full px-3 py-2 border rounded-md mt-1"
2039
+ />
2040
+ </div>
2041
+ {/* More personal fields */}
2042
+ </div>
2043
+ )}
2044
+ {activeTab === 'address' && (
2045
+ <div className="space-y-4">
2046
+ {/* Address fields */}
2047
+ </div>
2048
+ )}
2049
+ {activeTab === 'contact' && (
2050
+ <div className="space-y-4">
2051
+ {/* Contact fields */}
2052
+ </div>
2053
+ )}
2054
+ </div>
2055
+
2056
+ {/* Footer */}
2057
+ <HazoUiDialogFooter className="p-6 border-t">
2058
+ <button
2059
+ onClick={() => setIsOpen(false)}
2060
+ className="px-4 py-2 border rounded-md hover:bg-accent"
2061
+ >
2062
+ Cancel
2063
+ </button>
2064
+ <button
2065
+ onClick={() => setIsOpen(false)}
2066
+ className="px-4 py-2 bg-primary text-primary-foreground rounded-md"
2067
+ >
2068
+ Save Changes
2069
+ </button>
2070
+ </HazoUiDialogFooter>
2071
+ </HazoUiDialogContent>
2072
+ </HazoUiDialogRoot>
2073
+ </>
2074
+ );
2075
+ }
2076
+ ```
2077
+
2078
+ **Available Compositional Components:**
2079
+
2080
+ ```tsx
2081
+ import {
2082
+ HazoUiDialogRoot, // Root dialog container (replaces Dialog)
2083
+ HazoUiDialogTrigger, // Trigger button (optional)
2084
+ HazoUiDialogContent, // Dialog content wrapper
2085
+ HazoUiDialogHeader, // Header section
2086
+ HazoUiDialogTitle, // Title text
2087
+ HazoUiDialogDescription, // Description text
2088
+ HazoUiDialogFooter, // Footer section
2089
+ HazoUiDialogPortal, // Portal wrapper
2090
+ HazoUiDialogOverlay, // Backdrop overlay
2091
+ HazoUiDialogClose, // Close button
2092
+ } from 'hazo_ui';
2093
+ ```
2094
+
2095
+ **Key Differences:**
2096
+
2097
+ | Feature | Props-based API | Compositional API |
2098
+ |---------|----------------|-------------------|
2099
+ | **Layout** | Predefined header/body/footer | Build your own structure |
2100
+ | **Configuration** | Via props | Via component composition |
2101
+ | **Complexity** | Simple, quick | Flexible, powerful |
2102
+ | **Best for** | Confirmations, alerts | Tabs, avatars, custom layouts |
2103
+ | **Code** | Minimal | More verbose |
2104
+
2105
+ **Compositional API Tips:**
2106
+
2107
+ - Use `flex flex-col` on `HazoUiDialogContent` for layouts with headers/footers
2108
+ - Set `p-0` on `HazoUiDialogContent` and add padding to individual sections
2109
+ - Use `overflow-y-auto` on the scrollable content area
2110
+ - Apply `bg-navbar text-navbar-foreground` for dark headers
2111
+ - Use `border-t` on footer for visual separation
2112
+
1822
2113
  #### Action Button States and Custom Footers
1823
2114
 
1824
2115
  The dialog supports enhanced action buttons with loading states, icons, and fully custom footers for complex UX scenarios.
@@ -2146,75 +2437,69 @@ function ProgressDialog() {
2146
2437
  />
2147
2438
  ```
2148
2439
 
2149
- #### Themed Dialogs
2440
+ #### Themed Dialogs (Variant Prop)
2441
+
2442
+ Use the `variant` prop to apply preset color themes with a single prop instead of specifying individual colors. Available variants: `info`, `success`, `warning`, `danger`.
2443
+
2444
+ Each variant auto-applies: header background tint, header text color, border color, accent color, tinted overlay, and (for `danger`) destructive button variant.
2445
+
2446
+ **Override chain:** Individual prop > Variant preset > Global config. You can use a variant and still override specific colors via props.
2150
2447
 
2151
- **Success Theme**
2152
2448
  ```tsx
2153
- <HazoUiDialog
2154
- title="✓ Success"
2155
- description="Operation completed successfully"
2156
- actionButtonText="Done"
2157
- showCancelButton={false}
2158
- borderColor="rgb(34, 197, 94)"
2159
- headerBackgroundColor="rgb(220, 252, 231)"
2160
- headerTextColor="rgb(22, 101, 52)"
2161
- accentColor="rgb(34, 197, 94)"
2162
- overlayClassName="bg-green-950/50"
2163
- {...props}
2164
- >
2449
+ // Success variant
2450
+ <HazoUiDialog variant="success" title="✓ Success" actionButtonText="Done" showCancelButton={false} {...props}>
2165
2451
  <p>Your changes have been saved.</p>
2166
2452
  </HazoUiDialog>
2167
- ```
2168
2453
 
2169
- **Warning Theme**
2170
- ```tsx
2171
- <HazoUiDialog
2172
- title="⚠ Warning"
2173
- description="Please review before proceeding"
2174
- actionButtonText="I Understand"
2175
- borderColor="rgb(234, 179, 8)"
2176
- headerBackgroundColor="rgb(254, 249, 195)"
2177
- headerTextColor="rgb(113, 63, 18)"
2178
- accentColor="rgb(234, 179, 8)"
2179
- overlayClassName="bg-yellow-950/50"
2180
- {...props}
2181
- >
2454
+ // Warning variant
2455
+ <HazoUiDialog variant="warning" title="⚠ Warning" actionButtonText="I Understand" {...props}>
2182
2456
  <p>You have unsaved changes that will be lost.</p>
2183
2457
  </HazoUiDialog>
2458
+
2459
+ // Danger variant (auto-sets destructive button)
2460
+ <HazoUiDialog variant="danger" title="⛔ Delete" actionButtonText="Delete Permanently" {...props}>
2461
+ <p>All data will be permanently deleted.</p>
2462
+ </HazoUiDialog>
2463
+
2464
+ // Info variant
2465
+ <HazoUiDialog variant="info" title="ℹ Information" actionButtonText="Got It" showCancelButton={false} {...props}>
2466
+ <p>New features are now available.</p>
2467
+ </HazoUiDialog>
2184
2468
  ```
2185
2469
 
2186
- **Danger Theme**
2470
+ ##### Split Header vs Merged Header
2471
+
2472
+ By default (`splitHeader={true}`), variant dialogs render the title and description as two separate rows with different background intensities. Set `splitHeader={false}` for a single header background with the description as italic subtext.
2473
+
2187
2474
  ```tsx
2188
- <HazoUiDialog
2189
- title=" Destructive Action"
2190
- description="This cannot be undone"
2191
- actionButtonText="Delete Permanently"
2192
- actionButtonVariant="destructive"
2193
- borderColor="rgb(239, 68, 68)"
2194
- headerBackgroundColor="rgb(254, 226, 226)"
2195
- headerTextColor="rgb(127, 29, 29)"
2196
- overlayClassName="bg-red-950/50"
2197
- {...props}
2198
- >
2199
- <p>All data will be permanently deleted.</p>
2475
+ // Split header (default) - two background rows
2476
+ <HazoUiDialog variant="info" splitHeader={true} title="Title" description="Description" {...props}>
2477
+ <p>Title row has stronger blue, description row has lighter blue.</p>
2478
+ </HazoUiDialog>
2479
+
2480
+ // Merged header - single background, italic description
2481
+ <HazoUiDialog variant="danger" splitHeader={false} title="Delete" description="This is permanent." {...props}>
2482
+ <p>One red header background with italic description text.</p>
2200
2483
  </HazoUiDialog>
2201
2484
  ```
2202
2485
 
2203
- **Info Theme**
2486
+ ##### Overriding Variant Colors
2487
+
2204
2488
  ```tsx
2489
+ // Use info variant but override header to purple
2205
2490
  <HazoUiDialog
2206
- title="ℹ Information"
2207
- description="Learn more about this feature"
2208
- actionButtonText="Got It"
2209
- showCancelButton={false}
2210
- borderColor="rgb(59, 130, 246)"
2211
- headerBackgroundColor="rgb(219, 234, 254)"
2212
- headerTextColor="rgb(30, 58, 138)"
2213
- accentColor="rgb(59, 130, 246)"
2214
- overlayClassName="bg-blue-950/50"
2491
+ variant="info"
2492
+ headerBackgroundColor="rgb(243, 232, 255)"
2493
+ headerTextColor="rgb(88, 28, 135)"
2494
+ title="Custom Header"
2215
2495
  {...props}
2216
2496
  >
2217
- <p>New features are now available.</p>
2497
+ <p>Blue border/accent from variant, purple header from props.</p>
2498
+ </HazoUiDialog>
2499
+
2500
+ // Danger variant with non-destructive button override
2501
+ <HazoUiDialog variant="danger" actionButtonVariant="default" title="Acknowledge" {...props}>
2502
+ <p>Red colors from variant, default button from prop override.</p>
2218
2503
  </HazoUiDialog>
2219
2504
  ```
2220
2505