@synerise/ds-estimation 1.4.26 → 1.4.28
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 +8 -0
- package/CLAUDE.md +117 -0
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.4.28](https://github.com/Synerise/synerise-design/compare/@synerise/ds-estimation@1.4.27...@synerise/ds-estimation@1.4.28) (2026-08-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-estimation
|
|
9
|
+
|
|
10
|
+
## [1.4.27](https://github.com/Synerise/synerise-design/compare/@synerise/ds-estimation@1.4.26...@synerise/ds-estimation@1.4.27) (2026-07-23)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-estimation
|
|
13
|
+
|
|
6
14
|
## [1.4.26](https://github.com/Synerise/synerise-design/compare/@synerise/ds-estimation@1.4.25...@synerise/ds-estimation@1.4.26) (2026-06-27)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-estimation
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Estimation (`@synerise/ds-estimation`)
|
|
2
|
+
|
|
3
|
+
> A card-style component for displaying a numeric estimation/metric value with optional progress bar, granular skeleton loading states, a calculated-date footer, and inline error alerts.
|
|
4
|
+
|
|
5
|
+
## Package structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
src/
|
|
9
|
+
Estimation.tsx — main component
|
|
10
|
+
Estimation.types.ts — EstimationProps and supporting types
|
|
11
|
+
Estimation.styles.ts — styled-components (shared with sub-components)
|
|
12
|
+
Estimation.spec.tsx — Vitest tests
|
|
13
|
+
index.ts — public exports
|
|
14
|
+
components/
|
|
15
|
+
EstimationCalculated.tsx — renders label + relative/custom date
|
|
16
|
+
EstimationProgressBar.tsx — Multivalue bar with colour-dot legend
|
|
17
|
+
EstimationProgressBar.styles.ts — styles for progress bar and legend
|
|
18
|
+
EstimationProgressBarSkeleton.tsx — skeleton placeholder for progress bar
|
|
19
|
+
hooks/
|
|
20
|
+
useDefaultTexts.tsx — merges i18n defaults with user overrides
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Public exports
|
|
24
|
+
|
|
25
|
+
### `Estimation` (default export)
|
|
26
|
+
|
|
27
|
+
All native `HTMLDivElement` attributes are accepted via `WithHTMLAttributes` from `@synerise/ds-utils`.
|
|
28
|
+
|
|
29
|
+
| Prop | Type | Default | Description |
|
|
30
|
+
|------|------|---------|-------------|
|
|
31
|
+
| `value` | `ReactNode` | — | Main estimation value displayed prominently |
|
|
32
|
+
| `label` | `ReactNode` | — | Label above the card (from `BaseLabelProps`) |
|
|
33
|
+
| `tooltip` | `ReactNode` | — | Tooltip content for the label (from `BaseLabelProps`) |
|
|
34
|
+
| `tooltipConfig` | `TooltipConfig` | — | Tooltip configuration object (from `BaseLabelProps`) |
|
|
35
|
+
| `total` | `ReactNode` | — | Top-right corner value (preformatted content) |
|
|
36
|
+
| `isLoading` | `boolean \| { total?: boolean; progressBar?: boolean }` | — | `true` = full skeleton; object = granular control (see notes) |
|
|
37
|
+
| `errorMessage` | `ReactNode` | — | Renders an `InlineAlert` in the footer |
|
|
38
|
+
| `footerButtons` | `ReactNode` | — | Buttons rendered on the right side of the footer |
|
|
39
|
+
| `texts` | `Partial<EstimationTexts>` | — | Overrides i18n strings for `calculated` and `loading` labels |
|
|
40
|
+
| `calculatedDate` | `Date \| ReactNode` | — | `Date` → rendered as relative time via `FormattedRelativeDateTimeTo`; any other `ReactNode` → rendered as-is |
|
|
41
|
+
| `progressBarValues` | `EstimationProgressValue[]` | — | Multivalue progress bar data; if any entry has `label`, a colour-dot legend is rendered below the bar |
|
|
42
|
+
|
|
43
|
+
No `forwardRef`.
|
|
44
|
+
|
|
45
|
+
### `EstimationProps`
|
|
46
|
+
|
|
47
|
+
TypeScript type re-exported for consumers.
|
|
48
|
+
|
|
49
|
+
## Usage patterns
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import Estimation from '@synerise/ds-estimation';
|
|
53
|
+
|
|
54
|
+
// Minimal
|
|
55
|
+
<Estimation value="1,234" />
|
|
56
|
+
|
|
57
|
+
// Full example
|
|
58
|
+
<Estimation
|
|
59
|
+
label="Estimated reach"
|
|
60
|
+
value="1,234"
|
|
61
|
+
total={<>of <strong>5,000</strong></>}
|
|
62
|
+
calculatedDate={new Date()}
|
|
63
|
+
progressBarValues={[
|
|
64
|
+
{ percent: 30, color: '#f00', label: 'Active' },
|
|
65
|
+
{ percent: 70, color: '#00f', label: 'Inactive' },
|
|
66
|
+
]}
|
|
67
|
+
footerButtons={<Button>Refresh</Button>}
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
// Loading — skeleton for everything
|
|
71
|
+
<Estimation value="1,234" isLoading />
|
|
72
|
+
|
|
73
|
+
// Loading — skeleton only for total and progress bar
|
|
74
|
+
<Estimation
|
|
75
|
+
value="1,234"
|
|
76
|
+
total={5000}
|
|
77
|
+
isLoading={{ total: true, progressBar: true }}
|
|
78
|
+
progressBarValues={[..]}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
// Error state
|
|
82
|
+
<Estimation value="1,234" errorMessage="Failed to load data" />
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Styling
|
|
86
|
+
|
|
87
|
+
All styles are in `Estimation.styles.ts`. The card body uses `Panel` from `@synerise/ds-panel` as the container. The dashed divider between content and footer is `Divider` from `@synerise/ds-divider`. Uses `@synerise/ds-core` theme palette tokens; no hardcoded colour values.
|
|
88
|
+
|
|
89
|
+
## Custom hooks
|
|
90
|
+
|
|
91
|
+
### `useDefaultTexts`
|
|
92
|
+
|
|
93
|
+
Merges user-provided `texts` with react-intl defaults:
|
|
94
|
+
- `loading` → `<FormattedMessage id="DS.ESTIMATION.LOADING" defaultMessage="Loading.." />`
|
|
95
|
+
- `calculated` → `<FormattedMessage id="DS.ESTIMATION.CALCULATED" defaultMessage="Calculated:" />`
|
|
96
|
+
|
|
97
|
+
Returns a complete `EstimationTexts` object. Requires an `IntlProvider` in the tree.
|
|
98
|
+
|
|
99
|
+
## Key dependencies
|
|
100
|
+
|
|
101
|
+
- `@synerise/ds-form-field` — `FormFieldLabel` and `BaseLabelProps` for the label/tooltip
|
|
102
|
+
- `@synerise/ds-progress-bar` — `Multivalue` component and `ProgressValue` type
|
|
103
|
+
- `@synerise/ds-panel` — card container
|
|
104
|
+
- `@synerise/ds-inline-alert` — error state display
|
|
105
|
+
- `@synerise/ds-skeleton` — loading placeholders
|
|
106
|
+
- `@synerise/ds-core` — `FormattedRelativeDateTimeTo` for relative date, `useTheme` in skeleton
|
|
107
|
+
- `react-intl` — i18n for default button labels
|
|
108
|
+
|
|
109
|
+
## Implementation notes
|
|
110
|
+
|
|
111
|
+
- **`isLoading` granular mode**: When `isLoading` is an object (e.g. `{ progressBar: true }`), only the flagged parts show skeletons. The main `value` is always skeletonized when `isLoading` is truthy in any form. The progress bar only renders at all when `isLoading` is falsy — `showProgressBarSkeleton` is only shown when `isLoading` is the object variant.
|
|
112
|
+
- **`total` hidden when `isLoading=true`**: When `isLoading` is a plain `true` boolean, `total` is not rendered (not skeletonized). The skeleton variant `{ total: true }` replaces it with a skeleton.
|
|
113
|
+
- **Footer is conditional**: The footer (divider + footer row) only renders when `footerButtons` is provided OR at least one of `isLoading`, `errorMessage`, or `calculatedDate` is truthy.
|
|
114
|
+
- **`calculatedDate` type discrimination**: `calculatedDate instanceof Date` check determines whether to wrap with `FormattedRelativeDateTimeTo`. Any non-Date `ReactNode` is rendered verbatim.
|
|
115
|
+
- **`EstimationProgressValue` and `EstimationTexts` types are not exported** from `index.ts` — consumers must import them from the deep path or declare locally.
|
|
116
|
+
- **Uses Vitest** for testing.
|
|
117
|
+
- **`react-intl` is a peer dependency** — component will throw at runtime without an `IntlProvider` ancestor.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-estimation",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.28",
|
|
4
4
|
"description": "Estimation UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"/dist",
|
|
19
19
|
"CHANGELOG.md",
|
|
20
|
+
"CLAUDE.md",
|
|
20
21
|
"README.md",
|
|
21
22
|
"package.json",
|
|
22
23
|
"LICENSE.md"
|
|
@@ -41,14 +42,14 @@
|
|
|
41
42
|
],
|
|
42
43
|
"types": "dist/index.d.ts",
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@synerise/ds-divider": "^1.3.
|
|
45
|
-
"@synerise/ds-form-field": "^1.3.
|
|
46
|
-
"@synerise/ds-inline-alert": "^1.1.
|
|
47
|
-
"@synerise/ds-panel": "^1.2.
|
|
48
|
-
"@synerise/ds-progress-bar": "^1.3.
|
|
49
|
-
"@synerise/ds-skeleton": "^1.0.
|
|
50
|
-
"@synerise/ds-typography": "^1.1.
|
|
51
|
-
"@synerise/ds-utils": "^1.10.
|
|
45
|
+
"@synerise/ds-divider": "^1.3.17",
|
|
46
|
+
"@synerise/ds-form-field": "^1.3.25",
|
|
47
|
+
"@synerise/ds-inline-alert": "^1.1.28",
|
|
48
|
+
"@synerise/ds-panel": "^1.2.18",
|
|
49
|
+
"@synerise/ds-progress-bar": "^1.3.14",
|
|
50
|
+
"@synerise/ds-skeleton": "^1.0.61",
|
|
51
|
+
"@synerise/ds-typography": "^1.1.28",
|
|
52
|
+
"@synerise/ds-utils": "^1.10.2"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
55
|
"@synerise/ds-core": "*",
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"styled-components": "^5.3.3",
|
|
58
59
|
"vitest": "4"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "6df24ed12cd5f276d8eccde730591807982e3385"
|
|
61
62
|
}
|