hazo_ui 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +258 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -8,18 +8,271 @@ A set of UI components for common interaction elements in a SaaS app.
8
8
  npm install hazo_ui
9
9
  ```
10
10
 
11
- ## Usage
11
+ ## Components
12
12
 
13
- Import components individually for optimal tree-shaking:
13
+ ### MultiFilterDialog
14
+
15
+ A powerful, flexible dialog component for multi-field filtering with support for various input types. Perfect for table headers, grid views, or any interface where users need to apply multiple filters simultaneously.
16
+
17
+ ![MultiFilterDialog - Dialog with Multiple Filters](https://github.com/pub12/hazo_ui/raw/main/docs/Screenshot%202025-11-06%20at%202.51.24%E2%80%AFPM.png)
18
+
19
+ ![MultiFilterDialog - Filter Button with Active Filters Tooltip](https://github.com/pub12/hazo_ui/raw/main/docs/Screenshot%202025-11-06%20at%202.51.34%E2%80%AFPM.png)
20
+
21
+ ![MultiFilterDialog - Calendar Date Picker](https://github.com/pub12/hazo_ui/raw/main/docs/Screenshot%202025-11-06%20at%202.51.37%E2%80%AFPM.png)
22
+
23
+ ![MultiFilterDialog - Filter Output Example](https://github.com/pub12/hazo_ui/raw/main/docs/Screenshot%202025-11-06%20at%202.51.53%E2%80%AFPM.png)
24
+
25
+ #### Features
26
+
27
+ - **Multiple Field Types**: Supports text, number, combobox (select), boolean, and date fields
28
+ - **Operator Support**: Number and date fields support comparison operators (equals, greater than, less than, etc.)
29
+ - **Dynamic Field Addition**: Users can add and remove filter fields dynamically
30
+ - **Field Validation**: Built-in validation for text length, number ranges, and decimal precision
31
+ - **Visual Feedback**: Tooltip shows active filters when hovering over the filter button
32
+ - **Responsive Design**: Works seamlessly on mobile and desktop devices
33
+ - **TypeScript Support**: Fully typed with TypeScript interfaces
34
+ - **Accessible**: Built with accessibility in mind using Radix UI primitives
35
+
36
+ #### Field Types
37
+
38
+ 1. **Text Fields**
39
+ - Configurable min/max length
40
+ - Real-time validation
41
+
42
+ 2. **Number Fields**
43
+ - Min/max value constraints
44
+ - Optional decimal support with precision control
45
+ - Comparison operators: equals, not equals, greater than, less than, greater or equal, less or equal
46
+
47
+ 3. **Combobox Fields**
48
+ - Dropdown selection from predefined options
49
+ - Searchable field selection
50
+
51
+ 4. **Boolean Fields**
52
+ - Custom true/false labels
53
+ - Simple toggle selection
54
+
55
+ 5. **Date Fields**
56
+ - Calendar picker interface
57
+ - Comparison operators for date ranges
58
+ - Formatted display (e.g., "Nov 6, 2025")
59
+
60
+ #### Usage
14
61
 
15
62
  ```tsx
16
- import { ExampleComponent } from 'hazo_ui';
63
+ import { MultiFilterDialog, type FilterField, type FilterConfig } from 'hazo_ui';
64
+ import { useState } from 'react';
65
+
66
+ function DataTable() {
67
+ const [filters, setFilters] = useState<FilterConfig[]>([]);
17
68
 
18
- function App() {
19
- return <ExampleComponent>Hello World</ExampleComponent>;
69
+ // Define available filter fields
70
+ const availableFields: FilterField[] = [
71
+ {
72
+ value: "name",
73
+ label: "Name",
74
+ type: "text",
75
+ textConfig: {
76
+ minLength: 2,
77
+ maxLength: 50,
78
+ },
79
+ },
80
+ {
81
+ value: "age",
82
+ label: "Age",
83
+ type: "number",
84
+ numberConfig: {
85
+ min: 0,
86
+ max: 120,
87
+ allowDecimal: false,
88
+ },
89
+ },
90
+ {
91
+ value: "price",
92
+ label: "Price",
93
+ type: "number",
94
+ numberConfig: {
95
+ min: 0,
96
+ max: 10000,
97
+ allowDecimal: true,
98
+ decimalLength: 2,
99
+ },
100
+ },
101
+ {
102
+ value: "status",
103
+ label: "Status",
104
+ type: "combobox",
105
+ comboboxOptions: [
106
+ { label: "Active", value: "active" },
107
+ { label: "Inactive", value: "inactive" },
108
+ { label: "Pending", value: "pending" },
109
+ { label: "Completed", value: "completed" },
110
+ ],
111
+ },
112
+ {
113
+ value: "is_verified",
114
+ label: "Verified",
115
+ type: "boolean",
116
+ booleanLabels: {
117
+ trueLabel: "Yes",
118
+ falseLabel: "No",
119
+ },
120
+ },
121
+ {
122
+ value: "created_date",
123
+ label: "Created Date",
124
+ type: "date",
125
+ },
126
+ ];
127
+
128
+ // Handle filter changes
129
+ const handleFilterChange = (filterConfig: FilterConfig[]) => {
130
+ setFilters(filterConfig);
131
+ // Apply filters to your data
132
+ console.log('Applied filters:', filterConfig);
133
+ };
134
+
135
+ return (
136
+ <div>
137
+ <MultiFilterDialog
138
+ availableFields={availableFields}
139
+ onFilterChange={handleFilterChange}
140
+ initialFilters={filters}
141
+ />
142
+ {/* Your table/grid component */}
143
+ </div>
144
+ );
20
145
  }
21
146
  ```
22
147
 
148
+ #### Example Input
149
+
150
+ ```tsx
151
+ // Available fields configuration
152
+ const availableFields: FilterField[] = [
153
+ {
154
+ value: "name",
155
+ label: "Name",
156
+ type: "text",
157
+ textConfig: {
158
+ minLength: 2,
159
+ maxLength: 50,
160
+ },
161
+ },
162
+ {
163
+ value: "age",
164
+ label: "Age",
165
+ type: "number",
166
+ numberConfig: {
167
+ min: 0,
168
+ max: 120,
169
+ allowDecimal: false,
170
+ },
171
+ },
172
+ {
173
+ value: "status",
174
+ label: "Status",
175
+ type: "combobox",
176
+ comboboxOptions: [
177
+ { label: "Active", value: "active" },
178
+ { label: "Inactive", value: "inactive" },
179
+ ],
180
+ },
181
+ ];
182
+
183
+ // Initial filters (optional)
184
+ const initialFilters: FilterConfig[] = [
185
+ {
186
+ field: "name",
187
+ value: "John",
188
+ },
189
+ {
190
+ field: "age",
191
+ operator: "greater_than",
192
+ value: 25,
193
+ },
194
+ ];
195
+ ```
196
+
197
+ #### Expected Output
198
+
199
+ When users apply filters, the `onFilterChange` callback receives an array of `FilterConfig` objects:
200
+
201
+ ```typescript
202
+ // Example output when user applies filters:
203
+ [
204
+ {
205
+ field: "name",
206
+ value: "John"
207
+ },
208
+ {
209
+ field: "age",
210
+ operator: "greater_than",
211
+ value: 25
212
+ },
213
+ {
214
+ field: "status",
215
+ value: "active"
216
+ },
217
+ {
218
+ field: "is_verified",
219
+ value: true
220
+ },
221
+ {
222
+ field: "created_date",
223
+ operator: "greater_equal",
224
+ value: Date // JavaScript Date object
225
+ }
226
+ ]
227
+ ```
228
+
229
+ #### TypeScript Interfaces
230
+
231
+ ```typescript
232
+ interface FilterField {
233
+ value: string; // Unique identifier for the field
234
+ label: string; // Display label
235
+ type: 'text' | 'number' | 'combobox' | 'boolean' | 'date';
236
+ textConfig?: {
237
+ minLength?: number;
238
+ maxLength?: number;
239
+ };
240
+ numberConfig?: {
241
+ min?: number;
242
+ max?: number;
243
+ allowDecimal?: boolean;
244
+ decimalLength?: number;
245
+ };
246
+ comboboxOptions?: Array<{ label: string; value: string }>;
247
+ booleanLabels?: {
248
+ trueLabel?: string;
249
+ falseLabel?: string;
250
+ };
251
+ }
252
+
253
+ interface FilterConfig {
254
+ field: string; // Field identifier
255
+ operator?: string; // For number/date: 'equals', 'not_equals', 'greater_than', 'less_than', 'greater_equal', 'less_equal'
256
+ value: any; // Filter value (string, number, boolean, or Date)
257
+ }
258
+ ```
259
+
260
+ #### Styling
261
+
262
+ The component uses Tailwind CSS and follows shadcn/ui design patterns. Make sure your project has Tailwind CSS configured with the following CSS variables:
263
+
264
+ ```css
265
+ :root {
266
+ --background: 0 0% 100%;
267
+ --foreground: 222.2 84% 4.9%;
268
+ --primary: 222.2 47.4% 11.2%;
269
+ --primary-foreground: 210 40% 98%;
270
+ /* ... other CSS variables */
271
+ }
272
+ ```
273
+
274
+ See the component library's Tailwind config for the complete set of CSS variables.
275
+
23
276
  ## Development
24
277
 
25
278
  ### Build the library
@@ -50,4 +303,3 @@ npm run test:dev
50
303
  ## License
51
304
 
52
305
  MIT
53
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Set of UI components for common interaction elements in a SaaS app",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",