cleanplate 0.3.31 → 0.3.33

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 (45) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/components/accordion/Accordion.d.ts.map +1 -1
  3. package/dist/components/form-controls/Checkbox.d.ts +3 -0
  4. package/dist/components/form-controls/Checkbox.d.ts.map +1 -1
  5. package/dist/components/form-controls/Date.d.ts +3 -0
  6. package/dist/components/form-controls/Date.d.ts.map +1 -1
  7. package/dist/components/form-controls/File.d.ts +3 -0
  8. package/dist/components/form-controls/File.d.ts.map +1 -1
  9. package/dist/components/form-controls/Input.d.ts +3 -0
  10. package/dist/components/form-controls/Input.d.ts.map +1 -1
  11. package/dist/components/form-controls/Radio.d.ts +3 -0
  12. package/dist/components/form-controls/Radio.d.ts.map +1 -1
  13. package/dist/components/form-controls/Select.d.ts +3 -0
  14. package/dist/components/form-controls/Select.d.ts.map +1 -1
  15. package/dist/components/form-controls/Stepper.d.ts +3 -0
  16. package/dist/components/form-controls/Stepper.d.ts.map +1 -1
  17. package/dist/components/form-controls/TextArea.d.ts +3 -0
  18. package/dist/components/form-controls/TextArea.d.ts.map +1 -1
  19. package/dist/components/form-controls/Toggle.d.ts +3 -0
  20. package/dist/components/form-controls/Toggle.d.ts.map +1 -1
  21. package/dist/components/form-controls/form-field-margin.d.ts +6 -0
  22. package/dist/components/form-controls/form-field-margin.d.ts.map +1 -0
  23. package/dist/components/form-controls/index.d.ts +1 -0
  24. package/dist/components/form-controls/index.d.ts.map +1 -1
  25. package/dist/components/icon/material-icon-names.d.ts +2 -2
  26. package/dist/components/icon/material-icon-names.d.ts.map +1 -1
  27. package/dist/components/statistic/Statistic.d.ts +43 -0
  28. package/dist/components/statistic/Statistic.d.ts.map +1 -0
  29. package/dist/components/statistic/format-value.d.ts +7 -0
  30. package/dist/components/statistic/format-value.d.ts.map +1 -0
  31. package/dist/components/statistic/index.d.ts +4 -0
  32. package/dist/components/statistic/index.d.ts.map +1 -0
  33. package/dist/components/statistic/tone-defaults.d.ts +7 -0
  34. package/dist/components/statistic/tone-defaults.d.ts.map +1 -0
  35. package/dist/index.css +1 -1
  36. package/dist/index.d.ts +2 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.es.css +1 -1
  39. package/dist/index.es.js +4 -4
  40. package/dist/index.js +4 -4
  41. package/docs/FeedbackState.md +3 -3
  42. package/docs/FormControls.md +1 -1
  43. package/docs/Statistic.md +317 -0
  44. package/llms.txt +10 -1
  45. package/package.json +1 -1
@@ -167,9 +167,9 @@ export const ProjectsEmpty = ({ onCreate }) => (
167
167
  ### Stable slot classes (for CSS overrides)
168
168
 
169
169
  - `cp-feedback-state` — root
170
- - `cp-feedback-state__media`, `cp-feedback-state__media-img`
171
- - `cp-feedback-state__content`, `cp-feedback-state__title`, `cp-feedback-state__description`
172
- - `cp-feedback-state__error-code`, `cp-feedback-state__actions`, `cp-feedback-state__details`
170
+ - `cp-feedback-state-media`, `cp-feedback-state-media-img`
171
+ - `cp-feedback-state-content`, `cp-feedback-state-title`, `cp-feedback-state-description`
172
+ - `cp-feedback-state-error-code`, `cp-feedback-state-actions`, `cp-feedback-state-details`
173
173
 
174
174
  ## Related Components / Links
175
175
 
@@ -1,6 +1,6 @@
1
1
  # FormControls
2
2
 
3
- FormControls is a set of form primitives exported as a namespace: `FormControls.Input`, `FormControls.Select`, `FormControls.TextArea`, `FormControls.Date`, `FormControls.Checkbox`, `FormControls.Radio`, `FormControls.File`, `FormControls.Toggle`, `FormControls.Stepper`. Use them to build forms with consistent styling, labels, validation messages, and optional fluid layout. Common props across controls: label, isDisabled, isRequired, isFluid, className, error.
3
+ FormControls is a set of form primitives exported as a namespace: `FormControls.Input`, `FormControls.Select`, `FormControls.TextArea`, `FormControls.Date`, `FormControls.Checkbox`, `FormControls.Radio`, `FormControls.File`, `FormControls.Toggle`, `FormControls.Stepper`. Use them to build forms with consistent styling, labels, validation messages, and optional fluid layout. Common props across controls: label, isDisabled, isRequired, isFluid, margin, className, error.
4
4
 
5
5
  ## Controls overview
6
6
 
@@ -0,0 +1,317 @@
1
+ # Statistic Component
2
+
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
+
5
+ **Note:** `Statistic.Timer` (countdown/countup) is planned for a future release — not in v1.
6
+
7
+ ## Props / Inputs
8
+
9
+ | Prop | Type | Required | Default | Description |
10
+ | --- | --- | --- | --- | --- |
11
+ | title | ReactNode | no | — | Label above the value row (or in the header row when `icon` or `variant="card"`). |
12
+ | value | string \| number | no | — | Metric value; see formatting rules below. |
13
+ | precision | number | no | — | Fixed decimal places when `value` is a number. |
14
+ | groupSeparator | string | no | `","` | Thousands separator for numeric values. |
15
+ | decimalSeparator | string | no | `"."` | Decimal separator for numeric values. |
16
+ | prefix | ReactNode | no | — | Node before value; hidden when `loading`. |
17
+ | suffix | ReactNode | no | — | Node after value; hidden when `loading`. |
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. |
24
+ | size | `"small"` \| `"medium"` \| `"large"` | no | `"medium"` | Title and value typographic scale. |
25
+ | loading | boolean | no | `false` | Show `Spinner` in value row; title stays visible. |
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). |
27
+ | className | string | no | `""` | Additional class names on the root element. |
28
+ | dataTestId | string | no | — | `data-testid` on the root element. |
29
+
30
+ ## Types
31
+
32
+ ### StatisticSize
33
+ ```typescript
34
+ type StatisticSize = "small" | "medium" | "large";
35
+ ```
36
+
37
+ ### StatisticTone
38
+ ```typescript
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
+ }
82
+ ```
83
+
84
+ ### SpacingOption
85
+ ```typescript
86
+ type SpacingOption = (typeof SPACING_OPTIONS)[number];
87
+ ```
88
+
89
+ ### StatisticMargin
90
+ ```typescript
91
+ type StatisticMargin = string | SpacingOption[];
92
+ ```
93
+
94
+ ### StatisticProps
95
+ ```typescript
96
+ interface StatisticProps {
97
+ title?: React.ReactNode;
98
+ value?: string | number;
99
+ precision?: number;
100
+ groupSeparator?: string;
101
+ decimalSeparator?: string;
102
+ prefix?: React.ReactNode;
103
+ suffix?: React.ReactNode;
104
+ icon?: React.ReactNode;
105
+ description?: React.ReactNode;
106
+ progress?: StatisticProgress;
107
+ footer?: StatisticFooter;
108
+ variant?: StatisticVariant;
109
+ tone?: StatisticTone;
110
+ size?: StatisticSize;
111
+ loading?: boolean;
112
+ margin?: StatisticMargin;
113
+ className?: string;
114
+ dataTestId?: string;
115
+ }
116
+ ```
117
+
118
+ ## Value formatting
119
+
120
+ 1. **`value` is `string`:** rendered verbatim; `precision` and separators are ignored.
121
+ 2. **`value` is `number`:** non-finite values (`NaN`, `±Infinity`) render as `—`. Otherwise apply `precision` (if set), group the integer part with `groupSeparator`, and join fractional part with `decimalSeparator`.
122
+ 3. **`value` omitted:** no value text is rendered (title still shows if set).
123
+
124
+ ## Usage Examples
125
+
126
+ ### Basic
127
+
128
+ ```jsx
129
+ import { Statistic } from "cleanplate";
130
+
131
+ export const Example = () => (
132
+ <Statistic title="Active Users" value={112893} />
133
+ );
134
+ ```
135
+
136
+ ### Precision
137
+
138
+ ```jsx
139
+ <Statistic title="Account Balance (CNY)" value={112893} precision={2} />
140
+ ```
141
+
142
+ ### Prefix and suffix
143
+
144
+ ```jsx
145
+ import { Statistic, Icon } from "cleanplate";
146
+
147
+ <Statistic
148
+ title="Feedback"
149
+ value={1128}
150
+ prefix={<Icon name="thumb_up" size="small" />}
151
+ />
152
+ <Statistic title="Unmerged" value={93} suffix="/ 100" />
153
+ ```
154
+
155
+ ### Loading
156
+
157
+ ```jsx
158
+ <Statistic title="Active Users" value={112893} loading />
159
+ ```
160
+
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)
172
+
173
+ ```jsx
174
+ import { Statistic, Icon } from "cleanplate";
175
+
176
+ <Statistic
177
+ variant="card"
178
+ tone="success"
179
+ title="Active"
180
+ value={11.28}
181
+ precision={2}
182
+ prefix={<Icon name="arrow_upward" size="small" />}
183
+ suffix="%"
184
+ />
185
+ <Statistic variant="card" tone="danger" title="Overdue" value={0} prefix="₹" />
186
+ ```
187
+
188
+ ### Pre-formatted string value
189
+
190
+ ```jsx
191
+ <Statistic title="Revenue" value="¥1.2M" />
192
+ ```
193
+
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)
224
+
225
+ Use `Container` for multi-card layouts — no built-in grid component:
226
+
227
+ ```jsx
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>
261
+ </Container>
262
+ ```
263
+
264
+ ### Sizes
265
+
266
+ ```jsx
267
+ <Statistic title="Small" value={112893} size="small" />
268
+ <Statistic title="Medium" value={112893} size="medium" />
269
+ <Statistic title="Large" value={112893} size="large" />
270
+ ```
271
+
272
+ ## Behavior Notes
273
+
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.
279
+ - **Accessibility:** Title renders in a `div` (not a heading) — parent owns page heading hierarchy. Value formatting is skipped while `loading`.
280
+ - **Customization:** Override via root `className` or target documented `cp-` slot classes in CSS (no per-slot `className` or `style` props).
281
+
282
+ ### Documented slot classes
283
+
284
+ - `cp-statistic` — root
285
+ - `cp-statistic-card`
286
+ - `cp-statistic-small` | `cp-statistic-medium` | `cp-statistic-large`
287
+ - `cp-statistic-header`
288
+ - `cp-statistic-icon`
289
+ - `cp-statistic-title`
290
+ - `cp-statistic-content`
291
+ - `cp-statistic-prefix`
292
+ - `cp-statistic-value`
293
+ - `cp-statistic-tone-neutral` | `cp-statistic-tone-success` | `cp-statistic-tone-warning` | `cp-statistic-tone-danger` | `cp-statistic-tone-muted`
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`
300
+
301
+ Example override:
302
+
303
+ ```css
304
+ .dashboard-card .cp-statistic {
305
+ padding: var(--space-4);
306
+ }
307
+ ```
308
+
309
+ ## Related Components / Links
310
+
311
+ - Spinner (loading state inside value row)
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)
317
+ - Table (tabular data; Statistic for dashboard tiles)
package/llms.txt CHANGED
@@ -115,6 +115,14 @@ All component documentation is located in the `docs/` folder. The following docu
115
115
  - Types: SpinnerProps, SpinnerSize, SpinnerVariant, SpinnerIcon, SpinnerMargin, SpacingOption
116
116
  - Related Components: Container, Icon (used internally)
117
117
 
118
+ ### Statistic Component
119
+ - File: `docs/Statistic.md`
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
+ - **Not** in v1: `Statistic.Timer` (countdown/countup), `formatter` prop, per-slot `className`/`style` — planned or use string `value` / slot class overrides instead
125
+
118
126
  ### Stepper Component
119
127
  - File: `docs/Stepper.md`
120
128
  - Purpose: Displays a sequence of steps for wizards or multi-step flows. Each step has label, key, and optional active/completed state; steps can be clickable.
@@ -275,6 +283,7 @@ All documentation files follow a consistent format:
275
283
  | Alert | `docs/Alert.md` | Inline feedback and notices |
276
284
  | FeedbackState | `docs/FeedbackState.md` | Empty/error content regions |
277
285
  | Spinner | `docs/Spinner.md` | Loading and activity indicator |
286
+ | Statistic | `docs/Statistic.md` | Dashboard KPI metrics with formatting and loading |
278
287
  | Stepper | `docs/Stepper.md` | Wizard / checkout **step progress** (not numeric +/−; that is **FormControls.Stepper** in FormControls) |
279
288
  | BreadCrumb | `docs/BreadCrumb.md` | Navigation trail and page hierarchy |
280
289
  | Accordion | `docs/Accordion.md` | Collapsible panels and FAQ sections |
@@ -312,5 +321,5 @@ npm install cleanplate
312
321
  ## Usage
313
322
 
314
323
  ```jsx
315
- import { Button, Typography, Icon, MediaObject, Avatar, Container, Dropdown, Alert, FeedbackState, Spinner, Stepper, BreadCrumb, Accordion, ConfirmDialog, Modal, Drawer, Pagination, Table, Badge, Pills, Animated, FormControls, Toast, MenuList, Header, PageHeader, BottomSheet, Footer, AppShell } from "cleanplate";
324
+ import { Button, Typography, Icon, MediaObject, Avatar, Container, Dropdown, Alert, FeedbackState, Spinner, Statistic, Stepper, BreadCrumb, Accordion, ConfirmDialog, Modal, Drawer, Pagination, Table, Badge, Pills, Animated, FormControls, Toast, MenuList, Header, PageHeader, BottomSheet, Footer, AppShell } from "cleanplate";
316
325
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cleanplate",
3
- "version": "0.3.31",
3
+ "version": "0.3.33",
4
4
  "description": "CleanPlate - A Headless React UI Framework",
5
5
  "files": [
6
6
  "dist",