hazo_ui 2.9.0 → 2.16.0

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.
@@ -0,0 +1,418 @@
1
+ # hazo_ui Setup Checklist
2
+
3
+ This checklist will guide you through installing and setting up hazo_ui in your project.
4
+
5
+ ## Prerequisites
6
+
7
+ - [ ] Node.js (v18 or higher recommended)
8
+ - [ ] npm or yarn package manager
9
+ - [ ] A React project (Next.js, Create React App, Vite, etc.)
10
+ - [ ] Tailwind CSS v4 (recommended) **or** v3 configured in your project
11
+
12
+ ## Quick Setup (Recommended)
13
+
14
+ ### 1. Install the Package
15
+
16
+ ```bash
17
+ npm install hazo_ui
18
+ ```
19
+
20
+ ### 2. Import CSS Variables
21
+
22
+ Add to your app's entry point (e.g., `layout.tsx`, `_app.tsx`, or `main.tsx`):
23
+
24
+ ```tsx
25
+ import 'hazo_ui/styles.css';
26
+ ```
27
+
28
+ ### 3. Configure Tailwind
29
+
30
+ Update your `tailwind.config.ts`:
31
+
32
+ ```ts
33
+ import hazoUiPreset from 'hazo_ui/tailwind-preset';
34
+
35
+ export default {
36
+ presets: [hazoUiPreset],
37
+ content: [
38
+ './src/**/*.{js,ts,jsx,tsx}',
39
+ './node_modules/hazo_ui/dist/**/*.js',
40
+ ],
41
+ };
42
+ ```
43
+
44
+ ### 4. Tailwind v4 — Add the `@source` directive
45
+
46
+ If your app uses **Tailwind CSS v4**, edit your global CSS to scan hazo_ui's compiled output and load the animation utilities:
47
+
48
+ ```css
49
+ @import "tailwindcss";
50
+ @import "tw-animate-css";
51
+
52
+ /* REQUIRED: enable scanning of hazo_ui components */
53
+ @source "../node_modules/hazo_ui/dist";
54
+ ```
55
+
56
+ For PostCSS, use the v4 plugin:
57
+
58
+ ```js
59
+ // postcss.config.js
60
+ module.exports = {
61
+ plugins: {
62
+ "@tailwindcss/postcss": {},
63
+ },
64
+ };
65
+ ```
66
+
67
+ Tailwind v3 users skip this section — `@tailwind base/components/utilities` and `tailwindcss-animate` continue to work.
68
+
69
+ **Done!** You can now use the components.
70
+
71
+ ---
72
+
73
+ ## Manual Setup (Alternative)
74
+
75
+ If you prefer not to use the preset, or need custom configuration:
76
+
77
+ ### 1. Install the Package
78
+
79
+ ```bash
80
+ npm install hazo_ui
81
+ ```
82
+
83
+ or
84
+
85
+ ```bash
86
+ yarn add hazo_ui
87
+ ```
88
+
89
+ or
90
+
91
+ ```bash
92
+ pnpm add hazo_ui
93
+ ```
94
+
95
+ ### 2. Install Peer Dependencies
96
+
97
+ The following peer dependencies are required:
98
+
99
+ - [ ] React (^18.0.0 or ^19.0.0)
100
+ - [ ] React DOM (^18.0.0 or ^19.0.0)
101
+
102
+ If not already installed:
103
+
104
+ ```bash
105
+ npm install react react-dom
106
+ ```
107
+
108
+ ### 3. Install Required Dependencies
109
+
110
+ hazo_ui requires the following dependencies. Install them if not already present:
111
+
112
+ ```bash
113
+ npm install @radix-ui/react-dialog @radix-ui/react-popover @radix-ui/react-select @radix-ui/react-slot @radix-ui/react-switch @radix-ui/react-tooltip @radix-ui/react-radio-group @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities class-variance-authority clsx date-fns lucide-react react-day-picker react-icons sonner tailwind-merge tw-animate-css vaul
114
+ ```
115
+
116
+ > Tailwind v3 users: replace `tw-animate-css` above with `tailwindcss-animate@^1.0.7`.
117
+
118
+ **Note**: If you're using specific components, you may not need all dependencies. Here's a breakdown:
119
+
120
+ - **All components require**: `clsx`, `tailwind-merge`, and the animation utility for your Tailwind version (`tw-animate-css` for v4, `tailwindcss-animate` for v3)
121
+ - **HazoUiMultiFilterDialog requires**: `@radix-ui/react-dialog`, `@radix-ui/react-popover`, `@radix-ui/react-select`, `@radix-ui/react-tooltip`, `date-fns`, `lucide-react`, `react-day-picker`
122
+ - **HazoUiMultiSortDialog requires**: `@radix-ui/react-dialog`, `@radix-ui/react-popover`, `@radix-ui/react-select`, `@radix-ui/react-tooltip`, `@dnd-kit/core`, `@dnd-kit/sortable`, `@dnd-kit/utilities`, `lucide-react`
123
+ - **HazoUiFlexRadio requires**: `@radix-ui/react-radio-group`, `@radix-ui/react-tooltip`, `react-icons`, `lucide-react`
124
+ - **HazoUiPillRadio requires**: `@radix-ui/react-tooltip`, `react-icons`
125
+ - **HazoUiFlexInput requires**: No additional dependencies (uses base shadcn/ui Input component)
126
+ - **HazoUiRte requires**: `@tiptap/react`, `@tiptap/extension-*` (multiple Tiptap extensions), `lucide-react`
127
+ - **HazoUiTextbox requires**: `@tiptap/react`, `@tiptap/extension-document`, `@tiptap/extension-paragraph`, `@tiptap/extension-text`, `@tiptap/extension-placeholder`
128
+ - **HazoUiTextarea requires**: Same as HazoUiTextbox plus `@tiptap/extension-hard-break`
129
+ - **Drawer requires**: `vaul`
130
+ - **State primitives (v2.10.0)**:
131
+ - **Skeleton, SkeletonCircle, SkeletonBar, SkeletonRect, SkeletonGroup**: No additional dependencies — uses the `.hazo-shimmer` utility shipped in `hazo_ui/styles.css`
132
+ - **EmptyState**: No additional dependencies (consumers typically pass `lucide-react` icons)
133
+ - **ErrorBanner, ErrorPage**: `lucide-react` (for `AlertTriangle`, `OctagonAlert`, `X` icons)
134
+ - **LoadingTimeout**: `lucide-react` (uses `ErrorBanner` internally)
135
+ - **ProgressiveImage**: No additional dependencies
136
+ - **HazoUiToaster, successToast, errorToast, rawToast**: `sonner`, `lucide-react`
137
+ - **useLoadingState, useErrorDisplay** hooks: No additional dependencies
138
+
139
+ ### 4. Configure Tailwind CSS
140
+
141
+ [ ] Ensure Tailwind CSS is installed and configured in your project
142
+
143
+ [ ] Add the following CSS variables to your global CSS file (usually `globals.css` or `index.css`):
144
+
145
+ **Tailwind v4 (recommended):**
146
+
147
+ ```css
148
+ @import "tailwindcss";
149
+ @import "tw-animate-css";
150
+
151
+ /* REQUIRED for Tailwind v4: scan hazo_ui's compiled output */
152
+ @source "../node_modules/hazo_ui/dist";
153
+
154
+ @layer base {
155
+ :root {
156
+ --background: 0 0% 100%;
157
+ --foreground: 222.2 84% 4.9%;
158
+ --card: 0 0% 100%;
159
+ --card-foreground: 222.2 84% 4.9%;
160
+ --popover: 0 0% 100%;
161
+ --popover-foreground: 222.2 84% 4.9%;
162
+ --primary: 222.2 47.4% 11.2%;
163
+ --primary-foreground: 210 40% 98%;
164
+ --secondary: 210 40% 96.1%;
165
+ --secondary-foreground: 222.2 47.4% 11.2%;
166
+ --muted: 210 40% 96.1%;
167
+ --muted-foreground: 215.4 16.3% 46.9%;
168
+ --accent: 210 40% 96.1%;
169
+ --accent-foreground: 222.2 47.4% 11.2%;
170
+ --destructive: 0 84.2% 60.2%;
171
+ --destructive-foreground: 210 40% 98%;
172
+ --border: 214.3 31.8% 91.4%;
173
+ --input: 214.3 31.8% 91.4%;
174
+ --ring: 222.2 84% 4.9%;
175
+ --radius: 0.5rem;
176
+ }
177
+
178
+ .dark {
179
+ --background: 222.2 84% 4.9%;
180
+ --foreground: 210 40% 98%;
181
+ --card: 222.2 84% 4.9%;
182
+ --card-foreground: 210 40% 98%;
183
+ --popover: 222.2 84% 4.9%;
184
+ --popover-foreground: 210 40% 98%;
185
+ --primary: 210 40% 98%;
186
+ --primary-foreground: 222.2 47.4% 11.2%;
187
+ --secondary: 217.2 32.6% 17.5%;
188
+ --secondary-foreground: 210 40% 98%;
189
+ --muted: 217.2 32.6% 17.5%;
190
+ --muted-foreground: 215 20.2% 65.1%;
191
+ --accent: 217.2 32.6% 17.5%;
192
+ --accent-foreground: 210 40% 98%;
193
+ --destructive: 0 62.8% 30.6%;
194
+ --destructive-foreground: 210 40% 98%;
195
+ --border: 217.2 32.6% 17.5%;
196
+ --input: 217.2 32.6% 17.5%;
197
+ --ring: 212.7 26.8% 83.9%;
198
+ }
199
+ }
200
+
201
+ @layer base {
202
+ * {
203
+ @apply border-border;
204
+ }
205
+ body {
206
+ @apply bg-background text-foreground;
207
+ }
208
+ }
209
+ ```
210
+
211
+ **Tailwind v3 (legacy):**
212
+
213
+ ```css
214
+ @tailwind base;
215
+ @tailwind components;
216
+ @tailwind utilities;
217
+
218
+ /* CSS variable blocks above remain identical */
219
+ ```
220
+
221
+ [ ] Ensure your `tailwind.config.js` or `tailwind.config.ts` includes the content paths:
222
+
223
+ ```js
224
+ module.exports = {
225
+ content: [
226
+ "./src/**/*.{js,ts,jsx,tsx}",
227
+ "./node_modules/hazo_ui/dist/**/*.{js,ts,jsx,tsx}", // Add this line
228
+ // ... other paths
229
+ ],
230
+ // ... rest of config
231
+ }
232
+ ```
233
+
234
+ ### 5. Import and Use Components
235
+
236
+ [ ] Import the component(s) you need:
237
+
238
+ ```tsx
239
+ // Import a component
240
+ import { HazoUiMultiFilterDialog } from 'hazo_ui';
241
+
242
+ // Import with types
243
+ import { HazoUiMultiFilterDialog, type FilterField, type FilterConfig } from 'hazo_ui';
244
+
245
+ // Import multiple components
246
+ import { HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiFlexRadio, HazoUiPillRadio, HazoUiFlexInput } from 'hazo_ui';
247
+
248
+ // Import state primitives (v2.10.0) — exported flat & unprefixed
249
+ import {
250
+ Skeleton, SkeletonCircle, SkeletonBar, SkeletonRect, SkeletonGroup,
251
+ EmptyState, ErrorBanner, ErrorPage, LoadingTimeout, ProgressiveImage,
252
+ HazoUiToaster, successToast, errorToast,
253
+ useLoadingState, useErrorDisplay,
254
+ } from 'hazo_ui';
255
+ ```
256
+
257
+ **Toaster setup**: Mount `<HazoUiToaster />` once at the root of your app (e.g., in `layout.tsx`) so `successToast()` / `errorToast()` calls have somewhere to render.
258
+
259
+ [ ] Use the component in your code (see README.md for detailed usage examples)
260
+
261
+ ### 6. Verify Installation
262
+
263
+ [ ] Check that the component renders correctly
264
+
265
+ [ ] Verify TypeScript types are working (if using TypeScript)
266
+
267
+ [ ] Test component functionality
268
+
269
+ [ ] Check browser console for any errors
270
+
271
+ ## Troubleshooting
272
+
273
+ ### Common Issues
274
+
275
+ **Issue**: Dialog appears without backdrop/overlay or looks unstyled
276
+ - **Solution**: Ensure the CSS variables are defined in your globals.css (see Step 4 above). The backdrop uses `bg-black/80` which requires proper Tailwind configuration.
277
+
278
+ **Issue**: Dropdowns/Selects appear as unstyled inputs
279
+ - **Solution**:
280
+ 1. Tailwind v4: add `@source "../node_modules/hazo_ui/dist";` to your globals.css. Tailwind v3: add `./node_modules/hazo_ui/dist/**/*.{js,ts,jsx,tsx}` to your `content` array
281
+ 2. Verify CSS variables like `--popover`, `--border`, `--input` are defined
282
+ 3. Make sure the animation utility is installed: `tw-animate-css` (Tailwind v4) or `tailwindcss-animate` (Tailwind v3)
283
+
284
+ **Issue**: Components not styling correctly
285
+ - **Solution**: Ensure Tailwind CSS is properly configured and CSS variables are set up
286
+
287
+ **Issue**: TypeScript errors
288
+ - **Solution**: Make sure you have `@types/react` and `@types/react-dom` installed
289
+
290
+ **Issue**: Icons not showing (for HazoUiFlexRadio)
291
+ - **Solution**: Ensure `react-icons` is installed and you're using the correct icon set name
292
+
293
+ **Issue**: Drag and drop not working (for HazoUiMultiSortDialog)
294
+ - **Solution**: Ensure `@dnd-kit/core`, `@dnd-kit/sortable`, and `@dnd-kit/utilities` are installed
295
+
296
+ **Issue**: Date picker not working (for HazoUiMultiFilterDialog)
297
+ - **Solution**: Ensure `react-day-picker` and `date-fns` are installed
298
+
299
+ **Issue**: Input validation not working (for HazoUiFlexInput)
300
+ - **Solution**: Ensure the component is properly controlled with `value` and `onChange` props, and validation occurs on blur
301
+
302
+ **Issue**: Command pills not appearing (for HazoUiTextbox/HazoUiTextarea)
303
+ - **Solution**:
304
+ 1. Ensure `prefixes` prop is properly configured with `char` and `commands` arrays
305
+ 2. Verify you're typing the correct prefix character (e.g., @, #, /)
306
+ 3. Check that `@tiptap/react` and related extensions are installed
307
+
308
+ **Issue**: Edit popover not opening when clicking pills (for HazoUiTextbox/HazoUiTextarea)
309
+ - **Solution**:
310
+ 1. Ensure pills are rendered (check if commands are inserted)
311
+ 2. Verify the `prefixes` array includes commands for the clicked pill's prefix
312
+ 3. Check browser console for JavaScript errors
313
+
314
+ **Issue**: Command dropdown not showing suggestions (for HazoUiTextbox/HazoUiTextarea)
315
+ - **Solution**:
316
+ 1. Type the prefix character (e.g., @, #, /) to trigger the dropdown
317
+ 2. Ensure the `prefixes` prop includes a matching prefix configuration
318
+ 3. Verify `commands` array is not empty for that prefix
319
+
320
+ **Issue**: "Adding different instances of a keyed plugin (suggestion$)" error (for HazoUiTextbox/HazoUiTextarea)
321
+ - **Solution**:
322
+ 1. This occurs when multiple editor instances coexist (e.g., in lists during React transitions)
323
+ 2. Provide a unique `instance_id` prop to each component instance
324
+ 3. If not provided, the component auto-generates one using React.useId()
325
+
326
+ ## Next Steps
327
+
328
+ - [ ] Read the [README.md](./README.md) for detailed component documentation
329
+ - [ ] Check out the component examples in the README
330
+ - [ ] Customize the styling to match your design system
331
+ - [ ] Test all components in your application
332
+
333
+ ## Development Workflow
334
+
335
+ ### Build the Library
336
+
337
+ ```bash
338
+ npm run build
339
+ ```
340
+
341
+ ### Watch Mode
342
+
343
+ ```bash
344
+ npm run dev
345
+ ```
346
+
347
+ ### Testing Components
348
+
349
+ #### Using Storybook
350
+
351
+ ```bash
352
+ npm run storybook
353
+ ```
354
+
355
+ Storybook will start at `http://localhost:6006`.
356
+
357
+ #### Using the Dev App
358
+
359
+ ```bash
360
+ npm run dev:app
361
+ ```
362
+
363
+ The accompanying Next.js dev app will run at `http://localhost:3000`.
364
+
365
+ ### Before Publishing
366
+
367
+ ```bash
368
+ npm run test:build
369
+ npm run type-check
370
+ npm run build-storybook
371
+ ```
372
+
373
+ ## Adding New Components
374
+
375
+ 1. Create a new directory in `src/components/your_component_name/`.
376
+ 2. Add `index.tsx` with your component implementation.
377
+ 3. Create `your_component_name.stories.tsx` for Storybook coverage.
378
+ 4. Export the component from `src/index.ts`:
379
+ ```ts
380
+ export { YourComponent } from "./components/your_component_name";
381
+ ```
382
+
383
+ ## Tree-Shaking Guidance
384
+
385
+ The library is optimized for tree-shaking. Always import components individually:
386
+
387
+ ```tsx
388
+ // ✅ Recommended
389
+ import { HazoUiFlexRadio } from "hazo_ui";
390
+
391
+ // ❌ Avoid
392
+ import * as HazoUI from "hazo_ui";
393
+ ```
394
+
395
+ ## Publishing Checklist
396
+
397
+ 1. Update the version in `package.json`.
398
+ 2. Run `npm run prepublishOnly` (this runs `build` and `type-check` automatically).
399
+ 3. Publish:
400
+ ```bash
401
+ npm publish
402
+ ```
403
+
404
+ ## Support
405
+
406
+ If you encounter any issues:
407
+
408
+ 1. Check the [README.md](./README.md) for detailed documentation
409
+ 2. Review the troubleshooting section above
410
+ 3. Check that all dependencies are installed correctly
411
+ 4. Verify your Tailwind CSS configuration
412
+
413
+ ## Additional Resources
414
+
415
+ - [Tailwind CSS Documentation](https://tailwindcss.com/docs)
416
+ - [Radix UI Documentation](https://www.radix-ui.com/)
417
+ - [React Icons Documentation](https://react-icons.github.io/react-icons/)
418
+