anarock-widgets 1.0.385 → 1.0.386

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/package.json +1 -1
  2. package/readme.md +1 -465
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anarock-widgets",
3
- "version": "1.0.385",
3
+ "version": "1.0.386",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -1,468 +1,4 @@
1
- # CLAUDE.md
2
-
3
- ## Project Overview
4
-
5
- - This repository is a reusable React widget library for ANAROCK dashboards.
6
- - It contains residential and commercial dashboard widgets packaged for reuse in other applications.
7
- - Widgets are primarily presentational cards, charts, and section wrappers.
8
- - The repo also includes a local playground for visual development and manual verification.
9
-
10
- ## Tech Stack
11
-
12
- - React 18
13
- - JavaScript / JSX
14
- - Vite
15
- - Tailwind CSS utilities
16
- - Recharts
17
- - MUI (`@mui/material`, `@mui/icons-material`)
18
- - Emotion (`@emotion/react`, `@emotion/styled`)
19
- - `react-icons`
20
- - `lucide-react`
21
- - `react-datepicker`
22
-
23
- Not present in this repo:
24
-
25
- - TypeScript source files
26
- - Redux
27
- - React Context as a formal app-level state layer
28
- - Socket.IO / websockets
29
- - React Hook Form
30
- - Dedicated API client layer
31
-
32
- ## Project Structure
33
-
34
- ```text
35
- src/
36
- index.js
37
- index.css
38
- playground/
39
- App.jsx
40
- main.jsx
41
- index.css
42
- index.html
43
- widgets/
44
- components/
45
- utils/
46
- overview/
47
- community/
48
- financials/
49
- facilities/
50
- gate-and-security/
51
- helpdesk/
52
- engagement/
53
- commercial-dashboard/
54
- commercial-smart-access/
55
- commercial-helpdesk/
56
- commercial-visitors/
57
- commercial-amenities/
58
- commercial-asset-management/
59
- commercial-guard-petrol/
60
- commercial-food-and-order/
61
- commercial-table/
62
- ```
63
-
64
- ### Folder Responsibilities
65
-
66
- - `src/index.js`
67
- - Public export surface for the package.
68
- - Any widget intended for external consumption must be exported here.
69
-
70
- - `src/playground/`
71
- - Local development harness.
72
- - Used to render widgets in isolation and check layout/visual behavior.
73
-
74
- - `src/widgets/components/`
75
- - Shared UI building blocks used across multiple widget sections.
76
- - Examples:
77
- - `Card.jsx`
78
- - `CardNoLogo.jsx`
79
- - `Header.jsx`
80
- - `CommercialHeader.jsx`
81
- - `ActionButtons.jsx`
82
-
83
- - `src/widgets/utils/`
84
- - Cross-widget helpers and common fallback UI.
85
- - Examples:
86
- - `EmptyState.jsx`
87
- - `formatAmount`
88
- - `updateSession`
89
-
90
- - `src/widgets/<section>/`
91
- - Section-level wrapper components.
92
- - Each folder usually has:
93
- - `index.jsx` for section composition
94
- - `component/` or `components/` for actual widget cards/charts
95
-
96
- ### Section Examples
97
-
98
- - Residential:
99
- - `src/widgets/community/`
100
- - `src/widgets/financials/`
101
- - `src/widgets/helpdesk/`
102
-
103
- - Commercial:
104
- - `src/widgets/commercial-amenities/`
105
- - `src/widgets/commercial-visitors/`
106
- - `src/widgets/commercial-asset-management/`
107
-
108
- ## Component Architecture
109
-
110
- ### Component Types
111
-
112
- - Section wrappers
113
- - Compose multiple child widgets into a page/grid.
114
- - Usually live at `src/widgets/<section>/index.jsx`.
115
-
116
- - Presentational widgets
117
- - Cards, charts, summary panels.
118
- - Usually accept `data` or similarly named props.
119
-
120
- - Shared UI primitives
121
- - Card shells, headers, tooltips, chips, empty states.
122
- - Reused across multiple sections.
123
-
124
- ### Smart vs Dumb Components
125
-
126
- - Mostly dumb/presentational:
127
- - Most widgets receive props and render UI.
128
- - Data transformation is local and lightweight.
129
-
130
- - Light smart behavior inside components:
131
- - Some widgets normalize API-shaped data before rendering.
132
- - Some widgets manage local UI state:
133
- - date pickers
134
- - legend toggles
135
- - local pagination
136
-
137
- - No dedicated container layer exists.
138
- - If adding one, keep business/data orchestration above presentational widgets.
139
-
140
- ### Reusable Component Patterns
141
-
142
- - Use `Card.jsx` for standard dashboard cards.
143
- - Use `CardNoLogo.jsx` for commercial cards and date-navigation variants.
144
- - Use `Header.jsx` for residential section-level date/export controls.
145
- - Use `CommercialHeader.jsx` for commercial section headers.
146
- - Use `EmptyState.jsx` for explicit no-data rendering.
147
-
148
- ## State Management
149
-
150
- ### Current State Model
151
-
152
- - Local component state with `useState` is the primary state mechanism.
153
- - Derived view data is often computed inline or with `useMemo`.
154
- - There is no Redux store and no centralized global app state inside this package.
155
-
156
- ### Where State Lives
157
-
158
- - Widget-local state:
159
- - chart legend visibility
160
- - local date picker state
161
- - pagination state
162
- - dropdown open/close state
163
-
164
- - Browser storage state:
165
- - `sessionStorage` is used in `ActionButtons.jsx` and `utils/index.jsx`
166
- - keys used:
167
- - `community_id`
168
- - `widget_id`
169
- - `export`
170
-
171
- ### When To Use Local State
172
-
173
- - Use local state for:
174
- - temporary UI interactions
175
- - date controls local to a widget
176
- - table pagination
177
- - visual toggles
178
-
179
- ### When To Use Global State
180
-
181
- - There is no in-repo global state layer today.
182
- - If cross-widget coordination is needed, current code uses:
183
- - `sessionStorage`
184
- - custom browser events such as `dashboard-update`
185
-
186
- - Do not introduce Redux or Context unless the change requires true cross-section orchestration.
187
-
188
- ## API Layer
189
-
190
- ### Current Reality
191
-
192
- - There is no dedicated `services/` or API client layer in this repository.
193
- - Most widgets are data-agnostic UI components and expect props from a host application.
194
- - Some components include local normalization for backend-shaped data.
195
-
196
- ### Existing Data Pattern
197
-
198
- - Components often accept raw API-like payloads and normalize internally.
199
- - Example normalization pattern:
200
- - convert snake_case fields into render-friendly values
201
- - coerce numbers with `Number(...) || 0`
202
- - guard missing labels with `"Unknown"` or `"-"`
203
-
204
- ### Recommended API Integration Pattern
205
-
206
- If adding real API integration later:
207
-
208
- - Keep fetch logic outside widget components.
209
- - Add data fetching in the host application or a future `services/` layer.
210
- - Pass normalized props into widgets when possible.
211
- - If a widget must normalize, do it once near the top of the component.
212
-
213
- ## Socket Architecture
214
-
215
- - Not applicable in the current repository.
216
- - No socket initialization, event bus, or reconnection logic exists.
217
- - Do not add socket logic directly into presentational widgets.
218
-
219
- ## UI Guidelines
220
-
221
- ### Naming Conventions
222
-
223
- - Component names: PascalCase
224
- - Hook names: `useXxx` if custom hooks are added later
225
- - Utility function names: camelCase
226
- - Section wrappers should ideally be descriptively named, even though some existing files still use `function index()`
227
-
228
- ### Layout Structure
229
-
230
- - Section wrapper:
231
- - header first
232
- - grid layout second
233
- - cards inside grid cells
234
-
235
- - Widgets:
236
- - top bar with title/icon/period
237
- - main content area
238
- - optional footer
239
-
240
- ### Styling Approach
241
-
242
- - Tailwind utility classes are the primary styling method.
243
- - MUI is used selectively for controls/icons.
244
- - Avoid introducing a second styling system unless necessary.
245
-
246
- ### Responsive Design Approach
247
-
248
- - Most layouts use Tailwind grid classes and responsive column changes.
249
- - Prefer existing patterns such as:
250
- - `grid-cols-1 sm:grid-cols-2 lg:grid-cols-3`
251
- - `lg:grid-cols-[minmax(0,1fr)_minmax(0,4fr)]`
252
-
253
- - New widgets should:
254
- - degrade cleanly on smaller widths
255
- - avoid fixed widths unless the design already requires them
256
- - handle long labels without breaking charts or layouts
257
-
258
- ## Forms Handling
259
-
260
- - No formal forms layer exists.
261
- - Small input interactions are handled with local state.
262
- - Current examples include:
263
- - `react-datepicker`
264
- - MUI `Select`
265
- - local search/filter state
266
-
267
- Rules:
268
-
269
- - Keep form state local unless multiple widgets must share it.
270
- - Validate defensively at the component boundary.
271
- - Prefer simple controlled inputs over adding heavy form abstractions.
272
-
273
- ## Performance Rules
274
-
275
- - Keep widgets presentational and cheap to render.
276
- - Use `useMemo` only when:
277
- - data normalization is non-trivial
278
- - chart transformations are repeated
279
- - derived arrays/objects are expensive enough to justify memoization
280
-
281
- - Avoid:
282
- - recreating large transformed arrays multiple times in JSX
283
- - unnecessary state for purely derived values
284
- - deep prop drilling for temporary UI-only state
285
-
286
- - Prefer:
287
- - one normalization block near the top of the component
288
- - stable empty checks before rendering charts
289
- - safe `ResponsiveContainer` usage for Recharts
290
-
291
- - Lazy loading is not currently set up in this package.
292
- - If introduced later, apply it at section/playground level, not inside small leaf components.
293
-
294
- ## Code Conventions
295
-
296
- ### Naming
297
-
298
- - Components: PascalCase
299
- - Functions: camelCase
300
- - Constants: UPPER_SNAKE_CASE for true constants, otherwise camelCase
301
- - Props:
302
- - prefer descriptive names like `data`, `rows`, `totalAssets`, `onDateChange`
303
-
304
- ### File Naming
305
-
306
- - Existing code uses `.jsx`.
307
- - Component files are mostly PascalCase or descriptive kebab-lowercase variants already present in the repo.
308
- - Follow the local folder convention before introducing a new naming style.
309
-
310
- ### Hooks Naming
311
-
312
- - If custom hooks are added, name them `useXxx`.
313
- - Keep hooks pure and UI-agnostic when possible.
314
-
315
- ### Component File Structure
316
-
317
- Recommended order:
318
-
319
- 1. imports
320
- 2. constants / dummy data
321
- 3. helper functions
322
- 4. component definition
323
- 5. data normalization
324
- 6. early empty-state return
325
- 7. JSX
326
- 8. export default
327
-
328
- ## Common Patterns
329
-
330
- ### 1. Dummy Data Fallback
331
-
332
- Common pattern in commercial widgets:
333
-
334
- - `undefined` or `null` prop:
335
- - use internal dummy/demo data
336
- - explicit empty array:
337
- - show `EmptyState`
338
-
339
- This keeps the playground populated while still supporting real no-data rendering.
340
-
341
- ### 2. Empty State Pattern
342
-
343
- - Use `src/widgets/utils/EmptyState.jsx`.
344
- - Prefer explicit titles per widget, for example:
345
- - `No Booking Found`
346
- - `No Assets Found`
347
- - `No Visitors Found`
348
-
349
- ### 3. Local Data Normalization
350
-
351
- Typical rules:
352
-
353
- - `Array.isArray(data)` before `.map`
354
- - `Number(value) || 0` for numeric fields
355
- - `item?.name || "Unknown"` for labels
356
- - `??` for safe defaults
357
-
358
- ### 4. Section Composition
359
-
360
- - Section `index.jsx` files compose widgets into grids.
361
- - Add new widgets there if they belong to an existing dashboard section.
362
-
363
- ### 5. Browser Event Coordination
364
-
365
- - `updateSession` writes to `sessionStorage` and dispatches `dashboard-update`.
366
- - This is the current pattern for lightweight external coordination.
367
-
368
- ## Environment Variables
369
-
370
- - No environment variable convention is defined in the current repo.
371
- - No `.env` usage is visible in the widget source.
372
-
373
- If environment variables are added later:
374
-
375
- - use Vite conventions (`import.meta.env`)
376
- - keep secrets out of the package source
377
- - do not hardcode host-specific URLs in widget components
378
-
379
- ## How to Run the Project
380
-
381
- ```bash
382
- npm install
383
- npm run dev
384
- npm run build
385
- ```
386
-
387
- Notes:
388
-
389
- - `npm run dev` starts the Vite dev environment.
390
- - `src/playground/App.jsx` is the main place for visual verification.
391
- - `npm run build` produces the package output in `dist/`.
392
-
393
- ## Important Notes for AI Agents
394
-
395
- ### Where To Add New Features
396
-
397
- - New shared UI primitives:
398
- - `src/widgets/components/`
399
-
400
- - New utility helpers:
401
- - `src/widgets/utils/`
402
-
403
- - New widget cards inside an existing section:
404
- - `src/widgets/<section>/component/`
405
- - or `src/widgets/<section>/components/`
406
-
407
- - New section wrappers:
408
- - `src/widgets/<section>/index.jsx`
409
-
410
- ### Where To Add Public Exports
411
-
412
- - Always update `src/index.js`.
413
- - If it is not exported there, external consumers cannot import it.
414
-
415
- ### Where To Add Playground Examples
416
-
417
- - `src/playground/App.jsx`
418
-
419
- Add:
420
-
421
- - a normal data example
422
- - an empty-data example if the widget has important empty-state behavior
423
-
424
- ### Null / Empty Handling Rules
425
-
426
- Preserve this contract unless explicitly changing the section standard:
427
-
428
- - `undefined` / `null`
429
- - usually show internal demo fallback
430
- - `[]`
431
- - usually show `EmptyState`
432
- - all-zero datasets
433
- - often should also be treated as empty for charts where zero bars/areas add no value
434
-
435
- ### Things Agents Should Not Modify Without Reason
436
-
437
- - `src/index.js` export names unless intentionally changing public API
438
- - shared card/header components unless the change is meant to affect multiple widgets
439
- - browser storage keys:
440
- - `community_id`
441
- - `widget_id`
442
- - `export`
443
- - existing layout patterns in unrelated sections
444
- - package output settings in `package.json`, `vite.config.js`, or build config unless required
445
-
446
- ### Known Caveats
447
-
448
- - Some files use `function index()` instead of descriptive names.
449
- - Some export names in `src/index.js` are inconsistent with implementation names.
450
- - Some widgets are more demo-driven than data-driven.
451
- - `CommercialHeader.jsx` is mostly visual and not a full interaction layer.
452
- - `ActionButtons.jsx` contains commented filter UI; export behavior is the active part.
453
-
454
- ### Safe Workflow For New Widget Integration
455
-
456
- 1. Add the widget file in the correct section folder.
457
- 2. Reuse `Card.jsx` or `CardNoLogo.jsx`.
458
- 3. Normalize incoming data near the top of the component.
459
- 4. Handle `undefined`, `null`, empty array, and all-zero states.
460
- 5. Use `EmptyState` for explicit no-data rendering.
461
- 6. Add the widget to the relevant section `index.jsx`.
462
- 7. Export it from `src/index.js`.
463
- 8. Render it in `src/playground/App.jsx`.
464
- 9. Run `npm run build` if the task includes functional code changes.
465
-
1
+ # readme.md
466
2
 
467
3
  #Important To push the code for the npm package use
468
4