hazo_ui 2.6.6 → 2.7.1
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 +162 -7
- package/dist/index.cjs +491 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +177 -10
- package/dist/index.d.ts +177 -10
- package/dist/index.js +428 -46
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -158,6 +158,7 @@ interface HazoUiConfig {
|
|
|
158
158
|
|
|
159
159
|
The following components support both global config and prop-level color overrides:
|
|
160
160
|
- `HazoUiDialog` - via `headerBackgroundColor`, `headerTextColor`, `accentColor` props
|
|
161
|
+
- `HazoUiConfirmDialog` - via `accentColor`, `confirmButtonColor` props
|
|
161
162
|
- `HazoUiMultiFilterDialog` - via header/submit/cancel/clear color props
|
|
162
163
|
- `HazoUiMultiSortDialog` - via header/submit/cancel/clear color props
|
|
163
164
|
|
|
@@ -183,6 +184,33 @@ The following components support both global config and prop-level color overrid
|
|
|
183
184
|
|
|
184
185
|
- **[HazoUiDialog](#hazouidialog)** - A standardized dialog component with customizable animations, sizes, and theming. Features header/body/footer layout, color customization props, multiple size variants, and distinct animation presets (zoom, slide, fade).
|
|
185
186
|
|
|
187
|
+
- **[HazoUiConfirmDialog](#hazouiconfirmdialog)** - A compact, opinionated confirmation dialog with accent top border, variant system (destructive, warning, info, success), async loading support, and configurable buttons. Perfect for delete confirmations, unsaved changes warnings, and simple acknowledgments.
|
|
188
|
+
|
|
189
|
+
### shadcn/ui Primitive Re-exports
|
|
190
|
+
|
|
191
|
+
All shadcn/ui base components are re-exported from hazo_ui, so sibling hazo_* packages (and consumers) can import UI primitives from a single source without installing shadcn/ui separately:
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { Button, Input, Label, Checkbox, Switch, Tabs, TabsList, TabsTrigger, TabsContent } from 'hazo_ui';
|
|
195
|
+
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from 'hazo_ui';
|
|
196
|
+
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from 'hazo_ui';
|
|
197
|
+
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from 'hazo_ui';
|
|
198
|
+
import { HoverCard, HoverCardTrigger, HoverCardContent } from 'hazo_ui';
|
|
199
|
+
import { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from 'hazo_ui';
|
|
200
|
+
import { Popover, PopoverTrigger, PopoverContent } from 'hazo_ui';
|
|
201
|
+
import { RadioGroup, RadioGroupItem } from 'hazo_ui';
|
|
202
|
+
import { Calendar, Textarea } from 'hazo_ui';
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Animation Utilities
|
|
206
|
+
|
|
207
|
+
Shared animation presets and resolver function are exported for use in custom dialog implementations:
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
import { ANIMATION_PRESETS, resolve_animation_classes } from 'hazo_ui';
|
|
211
|
+
import type { AnimationPreset } from 'hazo_ui';
|
|
212
|
+
```
|
|
213
|
+
|
|
186
214
|
---
|
|
187
215
|
|
|
188
216
|
## HazoUiMultiFilterDialog
|
|
@@ -1801,6 +1829,133 @@ function CustomHeightExample() {
|
|
|
1801
1829
|
|
|
1802
1830
|
---
|
|
1803
1831
|
|
|
1832
|
+
## HazoUiConfirmDialog
|
|
1833
|
+
|
|
1834
|
+
A compact, opinionated confirmation dialog for destructive actions, warnings, and simple acknowledgments. Features an accent top border colored by variant, configurable buttons, and automatic async loading state management.
|
|
1835
|
+
|
|
1836
|
+
### Basic Usage
|
|
1837
|
+
|
|
1838
|
+
```tsx
|
|
1839
|
+
import { HazoUiConfirmDialog } from 'hazo_ui';
|
|
1840
|
+
|
|
1841
|
+
// Destructive confirmation with two buttons
|
|
1842
|
+
<HazoUiConfirmDialog
|
|
1843
|
+
open={showClear}
|
|
1844
|
+
onOpenChange={setShowClear}
|
|
1845
|
+
variant="destructive"
|
|
1846
|
+
title="Clear Form Data"
|
|
1847
|
+
description="This will permanently delete all uploaded files and reset the status. This action cannot be undone."
|
|
1848
|
+
confirmLabel="Yes, clear everything"
|
|
1849
|
+
onConfirm={handleClear}
|
|
1850
|
+
/>
|
|
1851
|
+
|
|
1852
|
+
// OK-only acknowledgment
|
|
1853
|
+
<HazoUiConfirmDialog
|
|
1854
|
+
open={showSuccess}
|
|
1855
|
+
onOpenChange={setShowSuccess}
|
|
1856
|
+
variant="info"
|
|
1857
|
+
title="Upload Complete"
|
|
1858
|
+
description="Your files have been uploaded successfully."
|
|
1859
|
+
showCancelButton={false}
|
|
1860
|
+
onConfirm={() => setShowSuccess(false)}
|
|
1861
|
+
/>
|
|
1862
|
+
|
|
1863
|
+
// Async with auto-loading spinner
|
|
1864
|
+
<HazoUiConfirmDialog
|
|
1865
|
+
open={showDelete}
|
|
1866
|
+
onOpenChange={setShowDelete}
|
|
1867
|
+
variant="destructive"
|
|
1868
|
+
title="Delete Account"
|
|
1869
|
+
description="This will permanently delete your account."
|
|
1870
|
+
confirmLabel="Delete My Account"
|
|
1871
|
+
onConfirm={async () => {
|
|
1872
|
+
await deleteAccount();
|
|
1873
|
+
// dialog auto-closes on resolve
|
|
1874
|
+
}}
|
|
1875
|
+
/>
|
|
1876
|
+
|
|
1877
|
+
// Custom children content
|
|
1878
|
+
<HazoUiConfirmDialog
|
|
1879
|
+
open={showConfirm}
|
|
1880
|
+
onOpenChange={setShowConfirm}
|
|
1881
|
+
title="Confirm Submission"
|
|
1882
|
+
onConfirm={handleSubmit}
|
|
1883
|
+
>
|
|
1884
|
+
<div>
|
|
1885
|
+
<p>You are about to submit:</p>
|
|
1886
|
+
<ul>
|
|
1887
|
+
<li>3 documents</li>
|
|
1888
|
+
<li>2 images</li>
|
|
1889
|
+
</ul>
|
|
1890
|
+
</div>
|
|
1891
|
+
</HazoUiConfirmDialog>
|
|
1892
|
+
```
|
|
1893
|
+
|
|
1894
|
+
### Variants
|
|
1895
|
+
|
|
1896
|
+
| Variant | Top Border | Button Color | Use Case |
|
|
1897
|
+
|---------|-----------|-------------|----------|
|
|
1898
|
+
| `default` | Slate | Primary | General confirmations |
|
|
1899
|
+
| `destructive` | Red | Red | Delete, clear, remove |
|
|
1900
|
+
| `warning` | Amber | Amber | Unsaved changes, caution |
|
|
1901
|
+
| `info` | Blue | Blue | Notices, acknowledgments |
|
|
1902
|
+
| `success` | Green | Green | Completions, confirmations |
|
|
1903
|
+
|
|
1904
|
+
### Props
|
|
1905
|
+
|
|
1906
|
+
| Prop | Type | Default | Description |
|
|
1907
|
+
|------|------|---------|-------------|
|
|
1908
|
+
| `open` | `boolean` | - | **Required.** Controls dialog visibility |
|
|
1909
|
+
| `onOpenChange` | `(open: boolean) => void` | - | **Required.** Called when dialog open state changes |
|
|
1910
|
+
| `title` | `string` | - | **Required.** Dialog title text |
|
|
1911
|
+
| `description` | `string` | - | Simple text description (alternative to children) |
|
|
1912
|
+
| `children` | `ReactNode` | - | Custom content (overrides description if both provided) |
|
|
1913
|
+
| `variant` | `ConfirmDialogVariant` | `'default'` | Color variant preset |
|
|
1914
|
+
| `confirmLabel` | `string` | `'Confirm'` / `'OK'` | Confirm button text. Defaults to "OK" when `showCancelButton={false}` |
|
|
1915
|
+
| `cancelLabel` | `string` | `'Cancel'` | Cancel button text |
|
|
1916
|
+
| `showCancelButton` | `boolean` | `true` | Whether to show the cancel button |
|
|
1917
|
+
| `onConfirm` | `() => void \| Promise<void>` | - | **Required.** Called on confirm. If returns Promise, auto-shows loading spinner |
|
|
1918
|
+
| `onCancel` | `() => void` | - | Called on cancel (before dialog closes) |
|
|
1919
|
+
| `loading` | `boolean` | - | External loading state (overrides async auto-detection) |
|
|
1920
|
+
| `disabled` | `boolean` | `false` | Disable confirm button |
|
|
1921
|
+
| `accentColor` | `string` | - | Override top border color |
|
|
1922
|
+
| `confirmButtonColor` | `string` | - | Override confirm button background color |
|
|
1923
|
+
| `openAnimation` | `AnimationPreset \| string` | `'zoom'` | Dialog open animation |
|
|
1924
|
+
| `closeAnimation` | `AnimationPreset \| string` | `'zoom'` | Dialog close animation |
|
|
1925
|
+
|
|
1926
|
+
### Async Loading
|
|
1927
|
+
|
|
1928
|
+
When `onConfirm` returns a Promise, the component automatically:
|
|
1929
|
+
1. Shows a spinner on the confirm button
|
|
1930
|
+
2. Disables both buttons
|
|
1931
|
+
3. Closes dialog on resolve
|
|
1932
|
+
4. Restores buttons on reject (dialog stays open)
|
|
1933
|
+
|
|
1934
|
+
Use the `loading` prop to override this behavior with external control.
|
|
1935
|
+
|
|
1936
|
+
### Custom Colors
|
|
1937
|
+
|
|
1938
|
+
```tsx
|
|
1939
|
+
<HazoUiConfirmDialog
|
|
1940
|
+
accentColor="#7c3aed"
|
|
1941
|
+
confirmButtonColor="#7c3aed"
|
|
1942
|
+
title="Custom Styled"
|
|
1943
|
+
description="Purple accent and button colors."
|
|
1944
|
+
onConfirm={handleConfirm}
|
|
1945
|
+
open={open}
|
|
1946
|
+
onOpenChange={setOpen}
|
|
1947
|
+
/>
|
|
1948
|
+
```
|
|
1949
|
+
|
|
1950
|
+
### Accessibility
|
|
1951
|
+
|
|
1952
|
+
- Focus trap within dialog (Radix)
|
|
1953
|
+
- ESC closes dialog
|
|
1954
|
+
- Cancel button receives initial focus for destructive/warning variants (prevents accidental confirmation)
|
|
1955
|
+
- Proper `aria-labelledby` and `aria-describedby` via Radix primitives
|
|
1956
|
+
|
|
1957
|
+
---
|
|
1958
|
+
|
|
1804
1959
|
## HazoUiDialog
|
|
1805
1960
|
|
|
1806
1961
|
A flexible, standardized dialog component with customizable animations, sizes, and theming. Built on Radix UI Dialog primitives with a consistent header/body/footer layout.
|
|
@@ -1832,7 +1987,7 @@ HazoUiDialog offers two approaches depending on your needs:
|
|
|
1832
1987
|
- **9 Animation Presets**: Zoom, slide (bottom/top/left/right), fade, bounce, scale-up, and flip animations
|
|
1833
1988
|
- **Header Bar Option**: Full-width colored header bar for modern modal designs
|
|
1834
1989
|
- **Color Customization**: Override header, body, footer, border, and accent colors via props
|
|
1835
|
-
- **Themed Variants**: Pre-built themes for success, warning,
|
|
1990
|
+
- **Themed Variants**: Pre-built themes for success, warning, destructive, and info states
|
|
1836
1991
|
- **Responsive Design**: Viewport-relative sizing with maximum constraints
|
|
1837
1992
|
- **Controlled Component**: Fully controlled open/close state
|
|
1838
1993
|
- **Callback Support**: Separate callbacks for confirm and cancel actions
|
|
@@ -1905,7 +2060,7 @@ interface HazoUiDialogProps {
|
|
|
1905
2060
|
showCloseButton?: boolean; // default: true
|
|
1906
2061
|
}
|
|
1907
2062
|
|
|
1908
|
-
type DialogVariant = 'default' | 'info' | 'success' | 'warning' | '
|
|
2063
|
+
type DialogVariant = 'default' | 'info' | 'success' | 'warning' | 'destructive';
|
|
1909
2064
|
type AnimationPreset = 'zoom' | 'slide' | 'fade' | 'bounce' | 'scale-up' | 'flip' | 'slide-left' | 'slide-right' | 'slide-top' | 'none';
|
|
1910
2065
|
type ButtonVariant = "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
|
|
1911
2066
|
```
|
|
@@ -2447,9 +2602,9 @@ function ProgressDialog() {
|
|
|
2447
2602
|
|
|
2448
2603
|
#### Themed Dialogs (Variant Prop)
|
|
2449
2604
|
|
|
2450
|
-
Use the `variant` prop to apply preset color themes with a single prop instead of specifying individual colors. Available variants: `info`, `success`, `warning`, `
|
|
2605
|
+
Use the `variant` prop to apply preset color themes with a single prop instead of specifying individual colors. Available variants: `info`, `success`, `warning`, `destructive`.
|
|
2451
2606
|
|
|
2452
|
-
Each variant auto-applies: header background tint, header text color, border color, accent color, tinted overlay, and (for `
|
|
2607
|
+
Each variant auto-applies: header background tint, header text color, border color, accent color, tinted overlay, and (for `destructive`) destructive button variant.
|
|
2453
2608
|
|
|
2454
2609
|
**Override chain:** Individual prop > Variant preset > Global config. You can use a variant and still override specific colors via props.
|
|
2455
2610
|
|
|
@@ -2465,7 +2620,7 @@ Each variant auto-applies: header background tint, header text color, border col
|
|
|
2465
2620
|
</HazoUiDialog>
|
|
2466
2621
|
|
|
2467
2622
|
// Danger variant (auto-sets destructive button)
|
|
2468
|
-
<HazoUiDialog variant="
|
|
2623
|
+
<HazoUiDialog variant="destructive" title="⛔ Delete" actionButtonText="Delete Permanently" {...props}>
|
|
2469
2624
|
<p>All data will be permanently deleted.</p>
|
|
2470
2625
|
</HazoUiDialog>
|
|
2471
2626
|
|
|
@@ -2486,7 +2641,7 @@ By default (`splitHeader={true}`), variant dialogs render the title and descript
|
|
|
2486
2641
|
</HazoUiDialog>
|
|
2487
2642
|
|
|
2488
2643
|
// Merged header - single background, italic description
|
|
2489
|
-
<HazoUiDialog variant="
|
|
2644
|
+
<HazoUiDialog variant="destructive" splitHeader={false} title="Delete" description="This is permanent." {...props}>
|
|
2490
2645
|
<p>One red header background with italic description text.</p>
|
|
2491
2646
|
</HazoUiDialog>
|
|
2492
2647
|
```
|
|
@@ -2506,7 +2661,7 @@ By default (`splitHeader={true}`), variant dialogs render the title and descript
|
|
|
2506
2661
|
</HazoUiDialog>
|
|
2507
2662
|
|
|
2508
2663
|
// Danger variant with non-destructive button override
|
|
2509
|
-
<HazoUiDialog variant="
|
|
2664
|
+
<HazoUiDialog variant="destructive" actionButtonVariant="default" title="Acknowledge" {...props}>
|
|
2510
2665
|
<p>Red colors from variant, default button from prop override.</p>
|
|
2511
2666
|
</HazoUiDialog>
|
|
2512
2667
|
```
|