cleanplate 0.3.31 → 0.3.32
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/CHANGELOG.md +1 -0
- package/dist/components/accordion/Accordion.d.ts.map +1 -1
- package/dist/components/form-controls/Checkbox.d.ts +3 -0
- package/dist/components/form-controls/Checkbox.d.ts.map +1 -1
- package/dist/components/form-controls/Date.d.ts +3 -0
- package/dist/components/form-controls/Date.d.ts.map +1 -1
- package/dist/components/form-controls/File.d.ts +3 -0
- package/dist/components/form-controls/File.d.ts.map +1 -1
- package/dist/components/form-controls/Input.d.ts +3 -0
- package/dist/components/form-controls/Input.d.ts.map +1 -1
- package/dist/components/form-controls/Radio.d.ts +3 -0
- package/dist/components/form-controls/Radio.d.ts.map +1 -1
- package/dist/components/form-controls/Select.d.ts +3 -0
- package/dist/components/form-controls/Select.d.ts.map +1 -1
- package/dist/components/form-controls/Stepper.d.ts +3 -0
- package/dist/components/form-controls/Stepper.d.ts.map +1 -1
- package/dist/components/form-controls/TextArea.d.ts +3 -0
- package/dist/components/form-controls/TextArea.d.ts.map +1 -1
- package/dist/components/form-controls/Toggle.d.ts +3 -0
- package/dist/components/form-controls/Toggle.d.ts.map +1 -1
- package/dist/components/form-controls/form-field-margin.d.ts +6 -0
- package/dist/components/form-controls/form-field-margin.d.ts.map +1 -0
- package/dist/components/form-controls/index.d.ts +1 -0
- package/dist/components/form-controls/index.d.ts.map +1 -1
- package/dist/components/icon/material-icon-names.d.ts +2 -2
- package/dist/components/icon/material-icon-names.d.ts.map +1 -1
- package/dist/components/statistic/Statistic.d.ts +24 -0
- package/dist/components/statistic/Statistic.d.ts.map +1 -0
- package/dist/components/statistic/format-value.d.ts +7 -0
- package/dist/components/statistic/format-value.d.ts.map +1 -0
- package/dist/components/statistic/index.d.ts +4 -0
- package/dist/components/statistic/index.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.css +1 -1
- package/dist/index.es.js +4 -4
- package/dist/index.js +4 -4
- package/docs/FeedbackState.md +3 -3
- package/docs/FormControls.md +1 -1
- package/docs/Statistic.md +197 -0
- package/llms.txt +10 -1
- package/package.json +1 -1
package/docs/FeedbackState.md
CHANGED
|
@@ -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-
|
|
171
|
-
- `cp-feedback-
|
|
172
|
-
- `cp-feedback-
|
|
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
|
|
package/docs/FormControls.md
CHANGED
|
@@ -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,197 @@
|
|
|
1
|
+
# Statistic Component
|
|
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`.
|
|
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. |
|
|
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
|
+
| valueTone | `"default"` \| `"positive"` \| `"negative"` | no | `"default"` | Semantic color on the value text only. |
|
|
19
|
+
| size | `"small"` \| `"medium"` \| `"large"` | no | `"medium"` | Title and value typographic scale. |
|
|
20
|
+
| loading | boolean | no | `false` | Show `Spinner` in value row; title stays visible. |
|
|
21
|
+
| 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). |
|
|
22
|
+
| className | string | no | `""` | Additional class names on the root element. |
|
|
23
|
+
| dataTestId | string | no | — | `data-testid` on the root element. |
|
|
24
|
+
|
|
25
|
+
## Types
|
|
26
|
+
|
|
27
|
+
### StatisticSize
|
|
28
|
+
```typescript
|
|
29
|
+
type StatisticSize = "small" | "medium" | "large";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### StatisticValueTone
|
|
33
|
+
```typescript
|
|
34
|
+
type StatisticValueTone = "default" | "positive" | "negative";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### SpacingOption
|
|
38
|
+
```typescript
|
|
39
|
+
type SpacingOption = (typeof SPACING_OPTIONS)[number];
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### StatisticMargin
|
|
43
|
+
```typescript
|
|
44
|
+
type StatisticMargin = string | SpacingOption[];
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### StatisticProps
|
|
48
|
+
```typescript
|
|
49
|
+
interface StatisticProps {
|
|
50
|
+
title?: React.ReactNode;
|
|
51
|
+
value?: string | number;
|
|
52
|
+
precision?: number;
|
|
53
|
+
groupSeparator?: string;
|
|
54
|
+
decimalSeparator?: string;
|
|
55
|
+
prefix?: React.ReactNode;
|
|
56
|
+
suffix?: React.ReactNode;
|
|
57
|
+
valueTone?: StatisticValueTone;
|
|
58
|
+
size?: StatisticSize;
|
|
59
|
+
loading?: boolean;
|
|
60
|
+
margin?: StatisticMargin;
|
|
61
|
+
className?: string;
|
|
62
|
+
dataTestId?: string;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Value formatting
|
|
67
|
+
|
|
68
|
+
1. **`value` is `string`:** rendered verbatim; `precision` and separators are ignored.
|
|
69
|
+
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`.
|
|
70
|
+
3. **`value` omitted:** no value text is rendered (title still shows if set).
|
|
71
|
+
|
|
72
|
+
## Usage Examples
|
|
73
|
+
|
|
74
|
+
### Basic
|
|
75
|
+
|
|
76
|
+
```jsx
|
|
77
|
+
import { Statistic } from "cleanplate";
|
|
78
|
+
|
|
79
|
+
export const Example = () => (
|
|
80
|
+
<Statistic title="Active Users" value={112893} />
|
|
81
|
+
);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Precision
|
|
85
|
+
|
|
86
|
+
```jsx
|
|
87
|
+
<Statistic title="Account Balance (CNY)" value={112893} precision={2} />
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Prefix and suffix
|
|
91
|
+
|
|
92
|
+
```jsx
|
|
93
|
+
import { Statistic, Icon } from "cleanplate";
|
|
94
|
+
|
|
95
|
+
<Statistic
|
|
96
|
+
title="Feedback"
|
|
97
|
+
value={1128}
|
|
98
|
+
prefix={<Icon name="thumb_up" size="small" />}
|
|
99
|
+
/>
|
|
100
|
+
<Statistic title="Unmerged" value={93} suffix="/ 100" />
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Loading
|
|
104
|
+
|
|
105
|
+
```jsx
|
|
106
|
+
<Statistic title="Active Users" value={112893} loading />
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Value tones
|
|
110
|
+
|
|
111
|
+
```jsx
|
|
112
|
+
import { Statistic, Icon } from "cleanplate";
|
|
113
|
+
|
|
114
|
+
<Statistic
|
|
115
|
+
title="Active"
|
|
116
|
+
value={11.28}
|
|
117
|
+
precision={2}
|
|
118
|
+
valueTone="positive"
|
|
119
|
+
prefix={<Icon name="arrow_upward" size="small" />}
|
|
120
|
+
suffix="%"
|
|
121
|
+
/>
|
|
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
|
+
/>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Pre-formatted string value
|
|
133
|
+
|
|
134
|
+
```jsx
|
|
135
|
+
<Statistic title="Revenue" value="¥1.2M" />
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### In a card (composition)
|
|
139
|
+
|
|
140
|
+
CleanPlate has no `Card` component — wrap with `Container` or app markup:
|
|
141
|
+
|
|
142
|
+
```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
|
+
/>
|
|
154
|
+
</Container>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Sizes
|
|
158
|
+
|
|
159
|
+
```jsx
|
|
160
|
+
<Statistic title="Small" value={112893} size="small" />
|
|
161
|
+
<Statistic title="Medium" value={112893} size="medium" />
|
|
162
|
+
<Statistic title="Large" value={112893} size="large" />
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Behavior Notes
|
|
166
|
+
|
|
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).
|
|
169
|
+
- **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).
|
|
171
|
+
|
|
172
|
+
### Documented slot classes
|
|
173
|
+
|
|
174
|
+
- `cp-statistic` — root
|
|
175
|
+
- `cp-statistic-small` | `cp-statistic-medium` | `cp-statistic-large`
|
|
176
|
+
- `cp-statistic-title`
|
|
177
|
+
- `cp-statistic-content`
|
|
178
|
+
- `cp-statistic-prefix`
|
|
179
|
+
- `cp-statistic-value`
|
|
180
|
+
- `cp-statistic-value-positive` | `cp-statistic-value-negative`
|
|
181
|
+
- `cp-statistic-suffix`
|
|
182
|
+
|
|
183
|
+
Example override:
|
|
184
|
+
|
|
185
|
+
```css
|
|
186
|
+
.dashboard-card .cp-statistic {
|
|
187
|
+
padding: var(--space-4);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Related Components / Links
|
|
192
|
+
|
|
193
|
+
- 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)
|
|
197
|
+
- 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, 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)
|
|
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
|
```
|