cleanplate 0.3.32 → 0.3.34

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/docs/Statistic.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Statistic Component
2
2
 
3
- Purpose: Displays a labeled numeric metric for dashboards and summary tiles — optional title, formatted value, prefix/suffix, loading state, and semantic value coloring. Use it to highlight KPIs; not for inline tags (`Badge`) or general text (`Typography`). **Margin** uses the **framework-wide spacing suffix rule** (same for all components); see `llms.txt`.
3
+ Purpose: Displays a labeled numeric metric for dashboards and summary tiles — optional title, formatted value, prefix/suffix, loading state, semantic value coloring, and optional card-style layout with icon, progress, description, and footer badge. Use it to highlight KPIs; not for inline tags (`Badge`) or general text (`Typography`). **Margin** uses the **framework-wide spacing suffix rule** (same for all components); see `llms.txt`.
4
4
 
5
5
  **Note:** `Statistic.Timer` (countdown/countup) is planned for a future release — not in v1.
6
6
 
@@ -8,14 +8,19 @@ Purpose: Displays a labeled numeric metric for dashboards and summary tiles —
8
8
 
9
9
  | Prop | Type | Required | Default | Description |
10
10
  | --- | --- | --- | --- | --- |
11
- | title | ReactNode | no | — | Label above the value row. |
11
+ | title | ReactNode | no | — | Label above the value row (or in the header row when `icon` or `variant="card"`). |
12
12
  | value | string \| number | no | — | Metric value; see formatting rules below. |
13
13
  | precision | number | no | — | Fixed decimal places when `value` is a number. |
14
14
  | groupSeparator | string | no | `","` | Thousands separator for numeric values. |
15
15
  | decimalSeparator | string | no | `"."` | Decimal separator for numeric values. |
16
16
  | prefix | ReactNode | no | — | Node before value; hidden when `loading`. |
17
17
  | suffix | ReactNode | no | — | Node after value; hidden when `loading`. |
18
- | valueTone | `"default"` \| `"positive"` \| `"negative"` | no | `"default"` | Semantic color on the value text only. |
18
+ | icon | ReactNode | no | | Node in the header row beside `title` (often `<Icon />`). |
19
+ | description | ReactNode | no | — | Subtext below value/progress (e.g. "8 active members"); hidden when `loading`. |
20
+ | progress | `StatisticProgress` | no | — | Progress bar below value; composes `ProgressBar`. Hidden when `loading`. |
21
+ | footer | `StatisticFooter` | no | — | Bottom row with optional label and badge; hidden when `loading`. |
22
+ | variant | `"plain"` \| `"card"` | no | `"plain"` | `"card"` adds border, padding, and white background. |
23
+ | tone | `"neutral"` \| `"success"` \| `"warning"` \| `"danger"` \| `"muted"` | no | `"neutral"` | Semantic tone for icon accent, value color, card surface (when `variant="card"`), and default `progress` / `footer.badge` variants. |
19
24
  | size | `"small"` \| `"medium"` \| `"large"` | no | `"medium"` | Title and value typographic scale. |
20
25
  | loading | boolean | no | `false` | Show `Spinner` in value row; title stays visible. |
21
26
  | margin | string \| string[] | no | `"0"` | Spacing **suffix** for outer margin. The component adds the `m-` prefix (e.g. `"0"` → m-0, `"b-2"` → m-b-2). |
@@ -29,9 +34,51 @@ Purpose: Displays a labeled numeric metric for dashboards and summary tiles —
29
34
  type StatisticSize = "small" | "medium" | "large";
30
35
  ```
31
36
 
32
- ### StatisticValueTone
37
+ ### StatisticTone
33
38
  ```typescript
34
- type StatisticValueTone = "default" | "positive" | "negative";
39
+ type StatisticTone = "neutral" | "success" | "warning" | "danger" | "muted";
40
+ ```
41
+
42
+ | Tone | Use for | Card surface | Value color | Default progress | Default badge |
43
+ | --- | --- | --- | --- | --- | --- |
44
+ | `neutral` | Totals / informational | White | Default | `default` | `default` |
45
+ | `success` | Completed / positive | Green tint | Default | `success` | `success` |
46
+ | `warning` | Attention needed | Orange tint | Default | `warning` | `warning` |
47
+ | `danger` | Critical / overdue | Red tint | Red | `error` | `error` |
48
+ | `muted` | Zero-state / inactive | Gray tint | Muted | `info` | `info` |
49
+
50
+ Override progress or badge colors with `progress.variant` or `footer.badgeVariant` when needed.
51
+
52
+ ### StatisticVariant
53
+ ```typescript
54
+ type StatisticVariant = "plain" | "card";
55
+ ```
56
+
57
+ ### StatisticProgress
58
+ ```typescript
59
+ type StatisticProgressVariant =
60
+ | "default"
61
+ | "primary"
62
+ | "secondary"
63
+ | "success"
64
+ | "info"
65
+ | "error"
66
+ | "warning";
67
+
68
+ interface StatisticProgress {
69
+ value: number; // 0–100, passed to ProgressBar
70
+ variant?: StatisticProgressVariant;
71
+ size?: "small" | "medium" | "large";
72
+ }
73
+ ```
74
+
75
+ ### StatisticFooter
76
+ ```typescript
77
+ interface StatisticFooter {
78
+ label?: React.ReactNode;
79
+ badge?: React.ReactNode; // string renders Badge; ReactNode renders as-is
80
+ badgeVariant?: BadgeVariant;
81
+ }
35
82
  ```
36
83
 
37
84
  ### SpacingOption
@@ -54,7 +101,12 @@ interface StatisticProps {
54
101
  decimalSeparator?: string;
55
102
  prefix?: React.ReactNode;
56
103
  suffix?: React.ReactNode;
57
- valueTone?: StatisticValueTone;
104
+ icon?: React.ReactNode;
105
+ description?: React.ReactNode;
106
+ progress?: StatisticProgress;
107
+ footer?: StatisticFooter;
108
+ variant?: StatisticVariant;
109
+ tone?: StatisticTone;
58
110
  size?: StatisticSize;
59
111
  loading?: boolean;
60
112
  margin?: StatisticMargin;
@@ -106,27 +158,31 @@ import { Statistic, Icon } from "cleanplate";
106
158
  <Statistic title="Active Users" value={112893} loading />
107
159
  ```
108
160
 
109
- ### Value tones
161
+ ### Semantic tones
162
+
163
+ ```jsx
164
+ <Statistic variant="card" tone="neutral" title="Total billed" value={9000} prefix="₹" />
165
+ <Statistic variant="card" tone="success" title="Collected" value={3375} progress={{ value: 38 }} />
166
+ <Statistic variant="card" tone="warning" title="Outstanding" value={5625} prefix="₹" />
167
+ <Statistic variant="card" tone="danger" title="Overdue (>30d)" value={0} prefix="₹" />
168
+ <Statistic variant="card" tone="muted" title="Waived" value={0} progress={{ value: 0 }} />
169
+ ```
170
+
171
+ ### Value emphasis (plain)
110
172
 
111
173
  ```jsx
112
174
  import { Statistic, Icon } from "cleanplate";
113
175
 
114
176
  <Statistic
177
+ variant="card"
178
+ tone="success"
115
179
  title="Active"
116
180
  value={11.28}
117
181
  precision={2}
118
- valueTone="positive"
119
182
  prefix={<Icon name="arrow_upward" size="small" />}
120
183
  suffix="%"
121
184
  />
122
- <Statistic
123
- title="Idle"
124
- value={9.3}
125
- precision={2}
126
- valueTone="negative"
127
- prefix={<Icon name="arrow_downward" size="small" />}
128
- suffix="%"
129
- />
185
+ <Statistic variant="card" tone="danger" title="Overdue" value={0} prefix="₹" />
130
186
  ```
131
187
 
132
188
  ### Pre-formatted string value
@@ -135,22 +191,73 @@ import { Statistic, Icon } from "cleanplate";
135
191
  <Statistic title="Revenue" value="¥1.2M" />
136
192
  ```
137
193
 
138
- ### In a card (composition)
194
+ ### Card variant with icon and description
195
+
196
+ ```jsx
197
+ import { Statistic, Icon } from "cleanplate";
198
+
199
+ <Statistic
200
+ variant="card"
201
+ icon={<Icon name="group" size="small" />}
202
+ title="Total billed"
203
+ value={9000}
204
+ prefix="₹"
205
+ description="8 active members"
206
+ />
207
+ ```
208
+
209
+ ### Progress and footer badge
210
+
211
+ ```jsx
212
+ <Statistic
213
+ variant="card"
214
+ tone="success"
215
+ icon={<Icon name="check_circle" size="small" />}
216
+ title="Paid dues"
217
+ value={3}
218
+ progress={{ value: 38 }}
219
+ footer={{ label: "of 8 total", badge: "38%" }}
220
+ />
221
+ ```
222
+
223
+ ### Dashboard grid (composition)
139
224
 
140
- CleanPlate has no `Card` component wrap with `Container` or app markup:
225
+ Use `Container` for multi-card layouts no built-in grid component:
141
226
 
142
227
  ```jsx
143
- import { Statistic, Container, Icon } from "cleanplate";
144
-
145
- <Container padding="4" display="block">
146
- <Statistic
147
- title="Active"
148
- value={11.28}
149
- precision={2}
150
- valueTone="positive"
151
- prefix={<Icon name="arrow_upward" size="small" />}
152
- suffix="%"
153
- />
228
+ import { Statistic, Container, Icon, Typography } from "cleanplate";
229
+
230
+ <Container padding="4" display="block" gap="4">
231
+ <Container display="flex" gap="4" style={{ flexWrap: "wrap" }}>
232
+ <Container display="block" style={{ flex: "1 1 200px" }}>
233
+ <Statistic
234
+ variant="card"
235
+ icon={<Icon name="group" size="small" />}
236
+ title="Total billed"
237
+ value={9000}
238
+ prefix="₹"
239
+ description="8 active members"
240
+ />
241
+ </Container>
242
+ <Container display="block" style={{ flex: "1 1 200px" }}>
243
+ <Statistic
244
+ variant="card"
245
+ icon={<Icon name="check_circle" size="small" />}
246
+ title="Collected"
247
+ value={3375}
248
+ prefix="₹"
249
+ progress={{ value: 38, variant: "success", size: "small" }}
250
+ description="38% collection rate"
251
+ />
252
+ </Container>
253
+ </Container>
254
+
255
+ <Typography variant="h5" margin="b-2">
256
+ Due status breakdown
257
+ </Typography>
258
+ <Container display="flex" gap="4" style={{ flexWrap: "wrap" }}>
259
+ {/* more Statistic cards */}
260
+ </Container>
154
261
  </Container>
155
262
  ```
156
263
 
@@ -164,21 +271,32 @@ import { Statistic, Container, Icon } from "cleanplate";
164
271
 
165
272
  ## Behavior Notes
166
273
 
167
- - **Loading:** Title remains visible. The value row shows a `Spinner` sized to match `size`. `prefix` and `suffix` are not rendered while loading. The content row sets `aria-busy={true}` (no `--loading` CSS modifier on the root).
168
- - **Layout:** Title stacked above a horizontal row (`prefix` + value + `suffix`), baseline-aligned with tabular numerals (`font-variant-numeric: tabular-nums` on the content row).
274
+ - **Loading:** Title and icon remain visible. The value row shows a `Spinner` sized to match `size`. `prefix`, `suffix`, `progress`, `description`, and `footer` are not rendered while loading. The content row sets `aria-busy={true}`.
275
+ - **Header row:** When `variant="card"` or `icon` is set, `title` renders in a horizontal header row with the icon. Otherwise `title` stacks above the value row as before.
276
+ - **Layout:** Value row is horizontal (`prefix` + value + `suffix`), baseline-aligned with tabular numerals (`font-variant-numeric: tabular-nums` on the content row).
277
+ - **Progress:** Composes `ProgressBar` with `progress.value` (0–100). Default bar size is `small`; override via `progress.size`.
278
+ - **Footer badge:** When `footer.badge` is a string, renders `Badge` using `footer.badgeVariant` or the tone default. Pass a `ReactNode` for custom badge content.
169
279
  - **Accessibility:** Title renders in a `div` (not a heading) — parent owns page heading hierarchy. Value formatting is skipped while `loading`.
170
- - **Customization:** Override via root `className` or target documented `cp-` slot classes in CSS (no per-slot `className` or `style` props in v1).
280
+ - **Customization:** Override via root `className` or target documented `cp-` slot classes in CSS (no per-slot `className` or `style` props).
171
281
 
172
282
  ### Documented slot classes
173
283
 
174
284
  - `cp-statistic` — root
285
+ - `cp-statistic-card`
175
286
  - `cp-statistic-small` | `cp-statistic-medium` | `cp-statistic-large`
287
+ - `cp-statistic-header`
288
+ - `cp-statistic-icon`
176
289
  - `cp-statistic-title`
177
290
  - `cp-statistic-content`
178
291
  - `cp-statistic-prefix`
179
292
  - `cp-statistic-value`
180
- - `cp-statistic-value-positive` | `cp-statistic-value-negative`
293
+ - `cp-statistic-tone-neutral` | `cp-statistic-tone-success` | `cp-statistic-tone-warning` | `cp-statistic-tone-danger` | `cp-statistic-tone-muted`
181
294
  - `cp-statistic-suffix`
295
+ - `cp-statistic-progress`
296
+ - `cp-statistic-description`
297
+ - `cp-statistic-footer`
298
+ - `cp-statistic-footer-label`
299
+ - `cp-statistic-footer-badge`
182
300
 
183
301
  Example override:
184
302
 
@@ -191,7 +309,9 @@ Example override:
191
309
  ## Related Components / Links
192
310
 
193
311
  - Spinner (loading state inside value row)
194
- - Icon (often used in `prefix` / `suffix`)
195
- - Container (layout and card-style wrappers)
196
- - Badge (short status labels — not KPI metrics)
312
+ - Icon (header icon, or `prefix` / `suffix`)
313
+ - ProgressBar (composed when `progress` is set)
314
+ - Badge (composed for string `footer.badge`)
315
+ - Container (multi-card dashboard layouts)
316
+ - Typography (section headings above stat groups)
197
317
  - Table (tabular data; Statistic for dashboard tiles)
package/llms.txt CHANGED
@@ -117,10 +117,10 @@ All component documentation is located in the `docs/` folder. The following docu
117
117
 
118
118
  ### Statistic Component
119
119
  - File: `docs/Statistic.md`
120
- - Purpose: Displays a labeled numeric metric (title + formatted value) with optional prefix/suffix, loading state, and semantic value coloring. For dashboard KPIs and summary tiles.
121
- - Key Features: `value` string|number (grouping via `groupSeparator`/`decimalSeparator`, `precision`; non-finite numbers → `—`), prefix/suffix ReactNode (hidden when `loading`), `valueTone` default|positive|negative, sizes small|medium|large, `loading` (Spinner in value row; `aria-busy` on content), `margin` suffix API, `className`, `dataTestId`, documented `cp-` slot classes for CSS overrides
122
- - Types: StatisticProps, StatisticSize, StatisticValueTone, StatisticMargin, SpacingOption
123
- - Related Components: Spinner (loading), Icon (prefix/suffix), Container (card/grid layout), Badge (status labels not KPIs), Table (tabular data vs KPI tiles)
120
+ - Purpose: Displays a labeled numeric metric (title + formatted value) with optional prefix/suffix, loading state, semantic value coloring, and card-style dashboard tiles. For dashboard KPIs and summary tiles.
121
+ - Key Features: `value` string|number (grouping via `groupSeparator`/`decimalSeparator`, `precision`; non-finite numbers → `—`), prefix/suffix ReactNode (hidden when `loading`), `variant` plain|card, `tone` neutral|success|warning|danger|muted (icon, value, card surface, default progress/badge), `icon` header slot, `description` subtext, `progress` (composes ProgressBar), `footer` label+badge (composes Badge), sizes small|medium|large, `loading` (Spinner in value row; `aria-busy` on content), `margin` suffix API, `className`, `dataTestId`, documented `cp-` slot classes for CSS overrides
122
+ - Types: StatisticProps, StatisticSize, StatisticTone, StatisticVariant, StatisticProgress, StatisticProgressVariant, StatisticFooter, StatisticMargin, SpacingOption
123
+ - Related Components: Spinner (loading), Icon (header/prefix/suffix), ProgressBar (progress slot), Badge (footer badge), Container (multi-card grid layout), Typography (section headings), Table (tabular data vs KPI tiles)
124
124
  - **Not** in v1: `Statistic.Timer` (countdown/countup), `formatter` prop, per-slot `className`/`style` — planned or use string `value` / slot class overrides instead
125
125
 
126
126
  ### Stepper Component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cleanplate",
3
- "version": "0.3.32",
3
+ "version": "0.3.34",
4
4
  "description": "CleanPlate - A Headless React UI Framework",
5
5
  "files": [
6
6
  "dist",