rte-utils 1.2.3 → 1.2.4
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/README.md +128 -41
- package/dist/components/Chip.d.ts +9 -0
- package/dist/components/Histogramme.d.ts +16 -16
- package/dist/components/index.d.ts +2 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -15,16 +15,16 @@ npm install rte-utils
|
|
|
15
15
|
You need to import both the component and its CSS styles:
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
18
|
+
import { Histogram, Chip } from "rte-utils";
|
|
19
|
+
import "rte-utils/dist/index.css"; // Import the CSS styles
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
### Basic Example
|
|
23
23
|
|
|
24
24
|
```tsx
|
|
25
|
-
import React from
|
|
26
|
-
import { Histogram } from
|
|
27
|
-
import
|
|
25
|
+
import React from "react";
|
|
26
|
+
import { Histogram } from "rte-utils";
|
|
27
|
+
import "rte-utils/dist/index.css";
|
|
28
28
|
|
|
29
29
|
function App() {
|
|
30
30
|
return (
|
|
@@ -52,15 +52,15 @@ export default App;
|
|
|
52
52
|
### Advanced Example with Animation
|
|
53
53
|
|
|
54
54
|
```tsx
|
|
55
|
-
import React, { useState } from
|
|
56
|
-
import { Histogram } from
|
|
57
|
-
import
|
|
55
|
+
import React, { useState } from "react";
|
|
56
|
+
import { Histogram } from "rte-utils";
|
|
57
|
+
import "rte-utils/dist/index.css";
|
|
58
58
|
|
|
59
59
|
function EnergyDashboard() {
|
|
60
60
|
const [currentValue, setCurrentValue] = useState(45);
|
|
61
61
|
|
|
62
62
|
return (
|
|
63
|
-
<div style={{ display:
|
|
63
|
+
<div style={{ display: "flex", gap: "1rem" }}>
|
|
64
64
|
<Histogram
|
|
65
65
|
max={{ value: 100, color: "#D3D64E" }}
|
|
66
66
|
relative={{ value: currentValue, color: "#C0C402" }}
|
|
@@ -75,8 +75,8 @@ function EnergyDashboard() {
|
|
|
75
75
|
<p className="histogram-label">Consommation</p>
|
|
76
76
|
</div>
|
|
77
77
|
</Histogram>
|
|
78
|
-
|
|
79
|
-
<button onClick={() => setCurrentValue(prev => prev + 10)}>
|
|
78
|
+
|
|
79
|
+
<button onClick={() => setCurrentValue((prev) => prev + 10)}>
|
|
80
80
|
Increase (+10)
|
|
81
81
|
</button>
|
|
82
82
|
</div>
|
|
@@ -87,18 +87,18 @@ function EnergyDashboard() {
|
|
|
87
87
|
### Horizontal Orientation Example
|
|
88
88
|
|
|
89
89
|
```tsx
|
|
90
|
-
import React from
|
|
91
|
-
import { Histogram } from
|
|
92
|
-
import
|
|
90
|
+
import React from "react";
|
|
91
|
+
import { Histogram } from "rte-utils";
|
|
92
|
+
import "rte-utils/dist/index.css";
|
|
93
93
|
|
|
94
94
|
function HorizontalChart() {
|
|
95
95
|
return (
|
|
96
|
-
<div style={{ display:
|
|
96
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
97
97
|
<Histogram
|
|
98
98
|
max={{ value: 100, color: "#D3D64E" }}
|
|
99
99
|
relative={{ value: 75, color: "#C0C402" }}
|
|
100
|
-
barWidth={200}
|
|
101
|
-
barHeight={24}
|
|
100
|
+
barWidth={200} // This becomes height in horizontal mode
|
|
101
|
+
barHeight={24} // This becomes width in horizontal mode
|
|
102
102
|
orientation="horizontal"
|
|
103
103
|
>
|
|
104
104
|
<div className="histogram-value-container">
|
|
@@ -117,38 +117,53 @@ function HorizontalChart() {
|
|
|
117
117
|
### Custom Corner Radius Example
|
|
118
118
|
|
|
119
119
|
```tsx
|
|
120
|
-
import React from
|
|
121
|
-
import { Histogram } from
|
|
122
|
-
import
|
|
120
|
+
import React from "react";
|
|
121
|
+
import { Histogram } from "rte-utils";
|
|
122
|
+
import "rte-utils/dist/index.css";
|
|
123
123
|
|
|
124
124
|
function CustomCornerChart() {
|
|
125
125
|
return (
|
|
126
|
-
<div style={{ display:
|
|
126
|
+
<div style={{ display: "flex", gap: "1rem" }}>
|
|
127
127
|
{/* Rounded top corners only */}
|
|
128
128
|
<Histogram
|
|
129
129
|
max={{ value: 100, color: "#E0E0E0" }}
|
|
130
130
|
relative={{ value: 60, color: "#4CAF50" }}
|
|
131
131
|
barWidth={32}
|
|
132
132
|
barHeight={120}
|
|
133
|
-
cornerRadius={{
|
|
133
|
+
cornerRadius={{
|
|
134
|
+
topLeft: 16,
|
|
135
|
+
topRight: 16,
|
|
136
|
+
bottomLeft: 0,
|
|
137
|
+
bottomRight: 0,
|
|
138
|
+
}}
|
|
134
139
|
/>
|
|
135
|
-
|
|
140
|
+
|
|
136
141
|
{/* Fully rounded corners */}
|
|
137
142
|
<Histogram
|
|
138
143
|
max={{ value: 100, color: "#F0F0F0", opacity: 0.5 }}
|
|
139
144
|
relative={{ value: 80, color: "#2196F3" }}
|
|
140
145
|
barWidth={32}
|
|
141
146
|
barHeight={120}
|
|
142
|
-
cornerRadius={{
|
|
147
|
+
cornerRadius={{
|
|
148
|
+
topLeft: 16,
|
|
149
|
+
topRight: 16,
|
|
150
|
+
bottomLeft: 16,
|
|
151
|
+
bottomRight: 16,
|
|
152
|
+
}}
|
|
143
153
|
/>
|
|
144
|
-
|
|
154
|
+
|
|
145
155
|
{/* Asymmetric corners */}
|
|
146
156
|
<Histogram
|
|
147
157
|
max={{ value: 100, color: "#FFECB3" }}
|
|
148
158
|
relative={{ value: 45, color: "#FF9800" }}
|
|
149
159
|
barWidth={32}
|
|
150
160
|
barHeight={120}
|
|
151
|
-
cornerRadius={{
|
|
161
|
+
cornerRadius={{
|
|
162
|
+
topLeft: 20,
|
|
163
|
+
topRight: 4,
|
|
164
|
+
bottomLeft: 4,
|
|
165
|
+
bottomRight: 20,
|
|
166
|
+
}}
|
|
152
167
|
/>
|
|
153
168
|
</div>
|
|
154
169
|
);
|
|
@@ -158,9 +173,9 @@ function CustomCornerChart() {
|
|
|
158
173
|
### Opacity and Advanced Styling Example
|
|
159
174
|
|
|
160
175
|
```tsx
|
|
161
|
-
import React from
|
|
162
|
-
import { Histogram } from
|
|
163
|
-
import
|
|
176
|
+
import React from "react";
|
|
177
|
+
import { Histogram } from "rte-utils";
|
|
178
|
+
import "rte-utils/dist/index.css";
|
|
164
179
|
|
|
165
180
|
function AdvancedStylingChart() {
|
|
166
181
|
return (
|
|
@@ -192,22 +207,22 @@ A histogram component with smooth animations for energy data visualization.
|
|
|
192
207
|
|
|
193
208
|
#### Props
|
|
194
209
|
|
|
195
|
-
| Prop
|
|
196
|
-
|
|
197
|
-
| `max`
|
|
198
|
-
| `relative`
|
|
199
|
-
| `barHeight`
|
|
200
|
-
| `barWidth`
|
|
201
|
-
| `orientation`
|
|
202
|
-
| `cornerRadius` | `{ topLeft?: number; topRight?: number; bottomLeft?: number; bottomRight?: number }` | ❌
|
|
203
|
-
| `children`
|
|
210
|
+
| Prop | Type | Required | Default | Description |
|
|
211
|
+
| -------------- | ------------------------------------------------------------------------------------ | -------- | ------------------------------------------------------------ | ------------------------------------------------------------------- |
|
|
212
|
+
| `max` | `{ value: number; color: string; opacity?: number }` | ✅ | - | Maximum value configuration with value, color, and optional opacity |
|
|
213
|
+
| `relative` | `{ value: number; color: string }` | ✅ | - | Relative/current value configuration with value and color |
|
|
214
|
+
| `barHeight` | `number` | ❌ | `103` | Height of the histogram bar in pixels |
|
|
215
|
+
| `barWidth` | `number` | ❌ | `32` | Width of the histogram bar in pixels |
|
|
216
|
+
| `orientation` | `'vertical' \| 'horizontal'` | ❌ | `'vertical'` | Orientation of the histogram bars |
|
|
217
|
+
| `cornerRadius` | `{ topLeft?: number; topRight?: number; bottomLeft?: number; bottomRight?: number }` | ❌ | `{ topLeft: 2, topRight: 2, bottomLeft: 2, bottomRight: 2 }` | Individual corner radius configuration |
|
|
218
|
+
| `children` | `React.ReactNode` | ❌ | - | Child components (typically text content) |
|
|
204
219
|
|
|
205
220
|
#### Features
|
|
206
221
|
|
|
207
222
|
- **Smooth animations**: 1-second Chart.js-style transitions with easeOutQuart easing
|
|
208
223
|
- **Multiple orientations**: Support for both vertical and horizontal layouts
|
|
209
224
|
- **Individual corner control**: Customize each corner radius independently
|
|
210
|
-
- **Dynamic two-color visualization**:
|
|
225
|
+
- **Dynamic two-color visualization**:
|
|
211
226
|
- Background bar color defined by `max.color` represents the maximum value
|
|
212
227
|
- Foreground bar color defined by `relative.color` represents the relative value
|
|
213
228
|
- **Opacity control**: Optional opacity setting for background bars
|
|
@@ -220,7 +235,7 @@ A histogram component with smooth animations for energy data visualization.
|
|
|
220
235
|
The component uses external CSS classes for styling. Make sure to import the CSS file:
|
|
221
236
|
|
|
222
237
|
```tsx
|
|
223
|
-
import
|
|
238
|
+
import "rte-utils/dist/index.css";
|
|
224
239
|
```
|
|
225
240
|
|
|
226
241
|
You can override the default styles by targeting the CSS classes:
|
|
@@ -238,6 +253,78 @@ You can override the default styles by targeting the CSS classes:
|
|
|
238
253
|
- `.histogram-unit` - Unit text
|
|
239
254
|
- `.histogram-label` - Label text
|
|
240
255
|
|
|
256
|
+
### Chip
|
|
257
|
+
|
|
258
|
+
A customizable chip component for displaying labels, tags, or status indicators.
|
|
259
|
+
|
|
260
|
+
#### Props
|
|
261
|
+
|
|
262
|
+
| Prop | Type | Required | Default | Description |
|
|
263
|
+
| ----------- | -------- | -------- | ------- | ---------------------------------------------- |
|
|
264
|
+
| `label` | `string` | ❌ | - | Text content to display inside the chip |
|
|
265
|
+
| `bgColor` | `string` | ❌ | - | Background color of the chip (CSS color value) |
|
|
266
|
+
| `textColor` | `string` | ❌ | - | Text color of the chip (CSS color value) |
|
|
267
|
+
|
|
268
|
+
#### Example Usage
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
import React from "react";
|
|
272
|
+
import { Chip } from "rte-utils";
|
|
273
|
+
import "rte-utils/dist/index.css";
|
|
274
|
+
|
|
275
|
+
function ChipExample() {
|
|
276
|
+
return (
|
|
277
|
+
<div style={{ display: "flex", gap: "0.5rem" }}>
|
|
278
|
+
{/* Default chip */}
|
|
279
|
+
<Chip label="Default" />
|
|
280
|
+
|
|
281
|
+
{/* Success status chip */}
|
|
282
|
+
<Chip label="Success" bgColor="#d4edda" textColor="#155724" />
|
|
283
|
+
|
|
284
|
+
{/* Warning status chip */}
|
|
285
|
+
<Chip label="Warning" bgColor="#fff3cd" textColor="#856404" />
|
|
286
|
+
|
|
287
|
+
{/* Error status chip */}
|
|
288
|
+
<Chip label="Error" bgColor="#f8d7da" textColor="#721c24" />
|
|
289
|
+
|
|
290
|
+
{/* Custom branded chip */}
|
|
291
|
+
<Chip label="Custom" bgColor="#007bff" textColor="#ffffff" />
|
|
292
|
+
</div>
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
#### Features
|
|
298
|
+
|
|
299
|
+
- **Flexible styling**: Customize background and text colors
|
|
300
|
+
- **Simple API**: Minimal props for easy integration
|
|
301
|
+
- **TypeScript support**: Full type definitions included
|
|
302
|
+
- **CSS classes**: Uses external CSS for consistent styling
|
|
303
|
+
|
|
304
|
+
#### CSS Classes
|
|
305
|
+
|
|
306
|
+
The Chip component uses the following CSS classes:
|
|
307
|
+
|
|
308
|
+
- `.chip-container` - Main chip container
|
|
309
|
+
- `.chip-content` - Content wrapper
|
|
310
|
+
- `.chip-label` - Label text styling
|
|
311
|
+
|
|
312
|
+
## Demo Application
|
|
313
|
+
|
|
314
|
+
This package includes a demo application that showcases all available components with interactive examples. The demo is located in the `/demo` folder and includes:
|
|
315
|
+
|
|
316
|
+
- **Interactive Histogram examples** with dynamic value controls
|
|
317
|
+
- **Chip component variations** with different colors and styles
|
|
318
|
+
- **Live examples** of all component features
|
|
319
|
+
|
|
320
|
+
To run the demo application:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
cd demo
|
|
324
|
+
npm install
|
|
325
|
+
npm run dev
|
|
326
|
+
```
|
|
327
|
+
|
|
241
328
|
## License
|
|
242
329
|
|
|
243
|
-
MIT
|
|
330
|
+
MIT
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./Histogramme.css";
|
|
3
|
-
interface
|
|
4
|
-
/** Maximum value
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
interface HistogrammeProps {
|
|
4
|
+
/** Maximum value for the bar chart */
|
|
5
|
+
maxValue: number;
|
|
6
|
+
/** Relative/current value to compare against max */
|
|
7
|
+
relativeValue: number;
|
|
8
|
+
/** Value to display in text */
|
|
9
|
+
value: number;
|
|
10
|
+
/** Unit label (e.g., "MWh") */
|
|
11
|
+
unit: string;
|
|
12
|
+
/** Description label (e.g., "Soutirage") */
|
|
13
|
+
label: string;
|
|
14
|
+
/** Background color of the container */
|
|
15
|
+
backgroundColor?: string;
|
|
14
16
|
/** Height of the histogram bar in pixels */
|
|
15
17
|
barHeight?: number;
|
|
16
|
-
/** Width of the
|
|
17
|
-
|
|
18
|
-
/** Child components (typically text content) */
|
|
19
|
-
children?: React.ReactNode;
|
|
18
|
+
/** Width of the component in pixels */
|
|
19
|
+
width?: number;
|
|
20
20
|
}
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const Histogramme: React.FC<HistogrammeProps>;
|
|
22
22
|
export {};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { Histogram } from
|
|
1
|
+
export { Histogram } from "./Histogram";
|
|
2
|
+
export { Chip } from "./Chip";
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap");*{font-family:Open Sans,sans-serif}.histogram-container{height:auto;max-width:54px;position:relative}.histogram-container--horizontal{max-width:none;width:auto}.histogram-content{align-items:center;display:flex;flex-direction:column;gap:8px;width:100%}.histogram-content--horizontal{align-items:center;flex-direction:row;height:100%}.histogram-bar{position:relative}.histogram-svg{display:block}.histogram-text-container{align-items:center;display:flex;flex-direction:column;gap:0;width:100%}.histogram-text-container--horizontal{align-items:flex-start;margin-left:8px}.histogram-value-container{text-align:center;width:40px}.histogram-value{font-size:16px;line-height:14px}.histogram-unit,.histogram-value{color:#000;display:block;font-weight:600;margin:0}.histogram-unit{font-size:12px}.histogram-label{color:#6f6f6f;font-size:12px;font-style:normal;font-weight:400;line-height:18px;margin:0;text-align:left;white-space:nowrap}
|
|
1
|
+
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap");*{font-family:Open Sans,sans-serif}.histogram-container{height:auto;max-width:54px;position:relative}.histogram-container--horizontal{max-width:none;width:auto}.histogram-content{align-items:center;display:flex;flex-direction:column;gap:8px;width:100%}.histogram-content--horizontal{align-items:center;flex-direction:row;height:100%}.histogram-bar{position:relative}.histogram-svg{display:block}.histogram-text-container{align-items:center;display:flex;flex-direction:column;gap:0;width:100%}.histogram-text-container--horizontal{align-items:flex-start;margin-left:8px}.histogram-value-container{text-align:center;width:40px}.histogram-value{font-size:16px;line-height:14px}.histogram-unit,.histogram-value{color:#000;display:block;font-weight:600;margin:0}.histogram-unit{font-size:12px}.histogram-label{color:#6f6f6f;font-size:12px;font-style:normal;font-weight:400;line-height:18px;margin:0;text-align:left;white-space:nowrap}.chip-container{align-items:center;background-color:var(--chip-bg-color,#e0e0e0);border-radius:60px;color:var(--chip-text-color,#000);display:inline-flex;min-width:84px;padding:8px}.chip-content{align-items:center;display:flex;flex-grow:1;gap:.5rem;justify-content:center}.chip-label{font-size:14px;font-weight:600;margin:0}
|
package/dist/index.esm.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap");*{font-family:Open Sans,sans-serif}.histogram-container{height:auto;max-width:54px;position:relative}.histogram-container--horizontal{max-width:none;width:auto}.histogram-content{align-items:center;display:flex;flex-direction:column;gap:8px;width:100%}.histogram-content--horizontal{align-items:center;flex-direction:row;height:100%}.histogram-bar{position:relative}.histogram-svg{display:block}.histogram-text-container{align-items:center;display:flex;flex-direction:column;gap:0;width:100%}.histogram-text-container--horizontal{align-items:flex-start;margin-left:8px}.histogram-value-container{text-align:center;width:40px}.histogram-value{font-size:16px;line-height:14px}.histogram-unit,.histogram-value{color:#000;display:block;font-weight:600;margin:0}.histogram-unit{font-size:12px}.histogram-label{color:#6f6f6f;font-size:12px;font-style:normal;font-weight:400;line-height:18px;margin:0;text-align:left;white-space:nowrap}
|
|
1
|
+
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap");*{font-family:Open Sans,sans-serif}.histogram-container{height:auto;max-width:54px;position:relative}.histogram-container--horizontal{max-width:none;width:auto}.histogram-content{align-items:center;display:flex;flex-direction:column;gap:8px;width:100%}.histogram-content--horizontal{align-items:center;flex-direction:row;height:100%}.histogram-bar{position:relative}.histogram-svg{display:block}.histogram-text-container{align-items:center;display:flex;flex-direction:column;gap:0;width:100%}.histogram-text-container--horizontal{align-items:flex-start;margin-left:8px}.histogram-value-container{text-align:center;width:40px}.histogram-value{font-size:16px;line-height:14px}.histogram-unit,.histogram-value{color:#000;display:block;font-weight:600;margin:0}.histogram-unit{font-size:12px}.histogram-label{color:#6f6f6f;font-size:12px;font-style:normal;font-weight:400;line-height:18px;margin:0;text-align:left;white-space:nowrap}.chip-container{align-items:center;background-color:var(--chip-bg-color,#e0e0e0);border-radius:60px;color:var(--chip-text-color,#000);display:inline-flex;min-width:84px;padding:8px}.chip-content{align-items:center;display:flex;flex-grow:1;gap:.5rem;justify-content:center}.chip-label{font-size:14px;font-weight:600;margin:0}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as t,jsxs as o}from"react/jsx-runtime";import{useState as a,useEffect as
|
|
1
|
+
import{jsx as t,jsxs as o}from"react/jsx-runtime";import{useState as a,useEffect as c}from"react";var n=function(n){var i,e,r,l,h=n.max,m=n.relative,g=n.barHeight,s=void 0===g?103:g,p=n.barWidth,d=void 0===p?32:p,v=n.orientation,f=void 0===v?"vertical":v,b=n.cornerRadius,L=n.children,u=a(0),R=u[0],z=u[1],x=a(0),N=x[0],w=x[1],y=Math.min(m.value/h.value*100,100)/100*s,M=Math.min(m.value/h.value*100,100)/100*d;c(function(){z(0),w(0);var t=Date.now(),o=function(){var a=Date.now()-t,c=Math.min(a/1e3,1),n=1-Math.pow(1-c,4);z(y*n),w(M*n),c<1&&requestAnimationFrame(o)};requestAnimationFrame(o)},[y,M]);var Q="horizontal"===f?s:d,C="horizontal"===f?d:s,q="horizontal"===f?s:d,A="horizontal"===f?d:s,D=function(t,o,a,c,n){var i=n.topLeft,e=n.topRight,r=n.bottomLeft,l=n.bottomRight;return"\n M ".concat(t+i," ").concat(o,"\n L ").concat(t+a-e," ").concat(o,"\n Q ").concat(t+a," ").concat(o," ").concat(t+a," ").concat(o+e,"\n L ").concat(t+a," ").concat(o+c-l,"\n Q ").concat(t+a," ").concat(o+c," ").concat(t+a-l," ").concat(o+c,"\n L ").concat(t+r," ").concat(o+c,"\n Q ").concat(t," ").concat(o+c," ").concat(t," ").concat(o+c-r,"\n L ").concat(t," ").concat(o+i,"\n Q ").concat(t," ").concat(o," ").concat(t+i," ").concat(o,"\n Z\n ").trim().replace(/\s+/g," ")},F={topLeft:2,topRight:2,bottomLeft:2,bottomRight:2},j=b?{topLeft:null!==(i=b.topLeft)&&void 0!==i?i:F.topLeft,topRight:null!==(e=b.topRight)&&void 0!==e?e:F.topRight,bottomLeft:null!==(r=b.bottomLeft)&&void 0!==r?r:F.bottomLeft,bottomRight:null!==(l=b.bottomRight)&&void 0!==l?l:F.bottomRight}:F;return t("div",{className:"histogram-container ".concat("horizontal"===f?"histogram-container--horizontal":""),children:o("div",{className:"histogram-content ".concat("horizontal"===f?"histogram-content--horizontal":""),children:[t("div",{className:"histogram-bar",style:{height:"".concat(C,"px"),width:"".concat(Q,"px")},children:o("svg",{width:q,height:A,viewBox:"0 0 ".concat(q," ").concat(A),className:"histogram-svg",children:[t("path",{d:D(0,0,q,A,j),fill:h.color,fillOpacity:h.opacity||1}),t("path","vertical"===f?{d:D(0,A-R,q,R,{topLeft:R>=A?j.topLeft:0,topRight:R>=A?j.topRight:0,bottomLeft:j.bottomLeft,bottomRight:j.bottomRight}),fill:m.color}:{d:D(0,0,N,A,{topLeft:j.topLeft,topRight:N>=q?j.topRight:0,bottomLeft:j.bottomLeft,bottomRight:N>=q?j.bottomRight:0}),fill:m.color})]})}),L&&t("div",{className:"histogram-text-container ".concat("horizontal"===f?"histogram-text-container--horizontal":""),children:L})]})})},i=function(o){var a=o.label,c=o.bgColor,n=o.textColor;return t("div",{className:"chip-container",style:{backgroundColor:c},children:t("div",{className:"chip-content",children:t("p",{className:"chip-label",style:{color:n},children:a})})})};export{i as Chip,n as Histogram};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/components/Histogram.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport \"./Histogram.css\";\n\ninterface HistogramProps {\n /** Maximum value configuration with value and color */\n max: {\n value: number;\n color: string;\n opacity?: number;\n };\n /** Relative/current value configuration with value and color */\n relative: {\n value: number;\n color: string;\n };\n /** Height of the histogram bar in pixels */\n barHeight?: number;\n /** Width of the histogram bar in pixels */\n barWidth?: number;\n /** Orientation of the histogram - 'vertical' or 'horizontal' */\n orientation?: 'vertical' | 'horizontal';\n /** Corner radius configuration for individual corners */\n cornerRadius?: {\n topLeft?: number;\n topRight?: number;\n bottomLeft?: number;\n bottomRight?: number;\n };\n /** Child components (typically text content) */\n children?: React.ReactNode;\n}\n\nexport const Histogram: React.FC<HistogramProps> = ({\n max,\n relative,\n barHeight = 103,\n barWidth = 32,\n orientation = 'vertical',\n cornerRadius,\n children,\n}) => {\n const [animatedHeight, setAnimatedHeight] = useState(0);\n const [animatedWidth, setAnimatedWidth] = useState(0);\n\n // Calculate target dimensions based on orientation\n const targetHeight = (Math.min((relative.value / max.value) * 100, 100) / 100) * barHeight;\n const targetWidth = (Math.min((relative.value / max.value) * 100, 100) / 100) * barWidth;\n\n // Simple Chart.js-like animation: always animate from 0 to target\n useEffect(() => {\n setAnimatedHeight(0);\n setAnimatedWidth(0);\n \n const startTime = Date.now();\n const duration = 1000;\n\n const animate = () => {\n const elapsed = Date.now() - startTime;\n const progress = Math.min(elapsed / duration, 1);\n\n // Chart.js-like easing (easeOutQuart)\n const easeOutQuart = 1 - Math.pow(1 - progress, 4);\n \n setAnimatedHeight(targetHeight * easeOutQuart);\n setAnimatedWidth(targetWidth * easeOutQuart);\n\n if (progress < 1) {\n requestAnimationFrame(animate);\n }\n };\n\n requestAnimationFrame(animate);\n }, [targetHeight, targetWidth]);\n\n const displayWidth = orientation === 'horizontal' ? barHeight : barWidth;\n const displayHeight = orientation === 'horizontal' ? barWidth : barHeight;\n const svgWidth = orientation === 'horizontal' ? barHeight : barWidth;\n const svgHeight = orientation === 'horizontal' ? barWidth : barHeight;\n\n // Helper function to create rounded rectangle path\n const createRoundedRectPath = (\n x: number,\n y: number,\n width: number,\n height: number,\n radii: { topLeft: number; topRight: number; bottomLeft: number; bottomRight: number }\n ) => {\n const { topLeft, topRight, bottomLeft, bottomRight } = radii;\n \n return `\n M ${x + topLeft} ${y}\n L ${x + width - topRight} ${y}\n Q ${x + width} ${y} ${x + width} ${y + topRight}\n L ${x + width} ${y + height - bottomRight}\n Q ${x + width} ${y + height} ${x + width - bottomRight} ${y + height}\n L ${x + bottomLeft} ${y + height}\n Q ${x} ${y + height} ${x} ${y + height - bottomLeft}\n L ${x} ${y + topLeft}\n Q ${x} ${y} ${x + topLeft} ${y}\n Z\n `.trim().replace(/\\s+/g, ' ');\n };\n\n // Default corner radius values\n const defaultCornerRadius = { topLeft: 2, topRight: 2, bottomLeft: 2, bottomRight: 2 };\n const corners = cornerRadius ? {\n topLeft: cornerRadius.topLeft ?? defaultCornerRadius.topLeft,\n topRight: cornerRadius.topRight ?? defaultCornerRadius.topRight,\n bottomLeft: cornerRadius.bottomLeft ?? defaultCornerRadius.bottomLeft,\n bottomRight: cornerRadius.bottomRight ?? defaultCornerRadius.bottomRight,\n } : defaultCornerRadius;\n\n return (\n <div className={`histogram-container ${orientation === 'horizontal' ? 'histogram-container--horizontal' : ''}`}>\n <div className={`histogram-content ${orientation === 'horizontal' ? 'histogram-content--horizontal' : ''}`}>\n <div \n className=\"histogram-bar\"\n style={{\n height: `${displayHeight}px`,\n width: `${displayWidth}px`\n }}\n >\n <svg\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${svgWidth} ${svgHeight}`}\n className=\"histogram-svg\"\n >\n {/* Background bar (max value) */}\n <path\n d={createRoundedRectPath(0, 0, svgWidth, svgHeight, corners)}\n fill={max.color}\n fillOpacity={max.opacity || 1}\n />\n {/* Foreground bar (relative value) with animation */}\n {orientation === 'vertical' ? (\n <path\n d={createRoundedRectPath(\n 0,\n svgHeight - animatedHeight,\n svgWidth,\n animatedHeight,\n {\n topLeft: animatedHeight >= svgHeight ? corners.topLeft : 0,\n topRight: animatedHeight >= svgHeight ? corners.topRight : 0,\n bottomLeft: corners.bottomLeft,\n bottomRight: corners.bottomRight,\n }\n )}\n fill={relative.color}\n />\n ) : (\n <path\n d={createRoundedRectPath(\n 0,\n 0,\n animatedWidth,\n svgHeight,\n {\n topLeft: corners.topLeft,\n topRight: animatedWidth >= svgWidth ? corners.topRight : 0,\n bottomLeft: corners.bottomLeft,\n bottomRight: animatedWidth >= svgWidth ? corners.bottomRight : 0,\n }\n )}\n fill={relative.color}\n />\n )}\n </svg>\n </div>\n {children && (\n <div className={`histogram-text-container ${orientation === 'horizontal' ? 'histogram-text-container--horizontal' : ''}`}>\n {children}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"names":["Histogram","_a","max","relative","_f","barHeight","_g","barWidth","_h","orientation","cornerRadius","children","_j","useState","animatedHeight","setAnimatedHeight","_k","animatedWidth","setAnimatedWidth","targetHeight","Math","min","value","targetWidth","useEffect","startTime","Date","now","animate","elapsed","progress","easeOutQuart","pow","requestAnimationFrame","displayWidth","displayHeight","svgWidth","svgHeight","createRoundedRectPath","x","y","width","height","radii","topLeft","topRight","bottomLeft","bottomRight","concat","trim","replace","defaultCornerRadius","corners","_b","_c","_d","_e","_jsx","className","_jsxs","style","viewBox","d","fill","color","fillOpacity","opacity"],"mappings":"kGAgCO,IAAMA,EAAsC,SAACC,eAClDC,EAAGD,EAAAC,IACHC,EAAQF,EAAAE,SACRC,EAAAH,EAAAI,UAAAA,OAAY,IAAAD,EAAA,IAAGA,EACfE,aAAAC,OAAW,IAAAD,EAAA,GAAEA,EACbE,EAAwBP,EAAAQ,YAAxBA,OAAW,IAAAD,EAAG,WAAUA,EACxBE,EAAYT,EAAAS,aACZC,EAAQV,EAAAU,SAEFC,EAAsCC,EAAS,GAA9CC,EAAcF,EAAA,GAAEG,EAAiBH,EAAA,GAClCI,EAAoCH,EAAS,GAA5CI,EAAaD,EAAA,GAAEE,EAAgBF,EAAA,GAGhCG,EAAgBC,KAAKC,IAAKlB,EAASmB,MAAQpB,EAAIoB,MAAS,IAAK,KAAO,IAAOjB,EAC3EkB,EAAeH,KAAKC,IAAKlB,EAASmB,MAAQpB,EAAIoB,MAAS,IAAK,KAAO,IAAOf,EAGhFiB,EAAU,WACRT,EAAkB,GAClBG,EAAiB,GAEjB,IAAMO,EAAYC,KAAKC,MAGjBC,EAAU,WACd,IAAMC,EAAUH,KAAKC,MAAQF,EACvBK,EAAWV,KAAKC,IAAIQ,EAJX,IAI+B,GAGxCE,EAAe,EAAIX,KAAKY,IAAI,EAAIF,EAAU,GAEhDf,EAAkBI,EAAeY,GACjCb,EAAiBK,EAAcQ,GAE3BD,EAAW,GACbG,sBAAsB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C,aACjHE,QAMb"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/Histogram.tsx","../src/components/Chip.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport \"./Histogram.css\";\n\ninterface HistogramProps {\n /** Maximum value configuration with value and color */\n max: {\n value: number;\n color: string;\n opacity?: number;\n };\n /** Relative/current value configuration with value and color */\n relative: {\n value: number;\n color: string;\n };\n /** Height of the histogram bar in pixels */\n barHeight?: number;\n /** Width of the histogram bar in pixels */\n barWidth?: number;\n /** Orientation of the histogram - 'vertical' or 'horizontal' */\n orientation?: 'vertical' | 'horizontal';\n /** Corner radius configuration for individual corners */\n cornerRadius?: {\n topLeft?: number;\n topRight?: number;\n bottomLeft?: number;\n bottomRight?: number;\n };\n /** Child components (typically text content) */\n children?: React.ReactNode;\n}\n\nexport const Histogram: React.FC<HistogramProps> = ({\n max,\n relative,\n barHeight = 103,\n barWidth = 32,\n orientation = 'vertical',\n cornerRadius,\n children,\n}) => {\n const [animatedHeight, setAnimatedHeight] = useState(0);\n const [animatedWidth, setAnimatedWidth] = useState(0);\n\n // Calculate target dimensions based on orientation\n const targetHeight = (Math.min((relative.value / max.value) * 100, 100) / 100) * barHeight;\n const targetWidth = (Math.min((relative.value / max.value) * 100, 100) / 100) * barWidth;\n\n // Simple Chart.js-like animation: always animate from 0 to target\n useEffect(() => {\n setAnimatedHeight(0);\n setAnimatedWidth(0);\n \n const startTime = Date.now();\n const duration = 1000;\n\n const animate = () => {\n const elapsed = Date.now() - startTime;\n const progress = Math.min(elapsed / duration, 1);\n\n // Chart.js-like easing (easeOutQuart)\n const easeOutQuart = 1 - Math.pow(1 - progress, 4);\n \n setAnimatedHeight(targetHeight * easeOutQuart);\n setAnimatedWidth(targetWidth * easeOutQuart);\n\n if (progress < 1) {\n requestAnimationFrame(animate);\n }\n };\n\n requestAnimationFrame(animate);\n }, [targetHeight, targetWidth]);\n\n const displayWidth = orientation === 'horizontal' ? barHeight : barWidth;\n const displayHeight = orientation === 'horizontal' ? barWidth : barHeight;\n const svgWidth = orientation === 'horizontal' ? barHeight : barWidth;\n const svgHeight = orientation === 'horizontal' ? barWidth : barHeight;\n\n // Helper function to create rounded rectangle path\n const createRoundedRectPath = (\n x: number,\n y: number,\n width: number,\n height: number,\n radii: { topLeft: number; topRight: number; bottomLeft: number; bottomRight: number }\n ) => {\n const { topLeft, topRight, bottomLeft, bottomRight } = radii;\n \n return `\n M ${x + topLeft} ${y}\n L ${x + width - topRight} ${y}\n Q ${x + width} ${y} ${x + width} ${y + topRight}\n L ${x + width} ${y + height - bottomRight}\n Q ${x + width} ${y + height} ${x + width - bottomRight} ${y + height}\n L ${x + bottomLeft} ${y + height}\n Q ${x} ${y + height} ${x} ${y + height - bottomLeft}\n L ${x} ${y + topLeft}\n Q ${x} ${y} ${x + topLeft} ${y}\n Z\n `.trim().replace(/\\s+/g, ' ');\n };\n\n // Default corner radius values\n const defaultCornerRadius = { topLeft: 2, topRight: 2, bottomLeft: 2, bottomRight: 2 };\n const corners = cornerRadius ? {\n topLeft: cornerRadius.topLeft ?? defaultCornerRadius.topLeft,\n topRight: cornerRadius.topRight ?? defaultCornerRadius.topRight,\n bottomLeft: cornerRadius.bottomLeft ?? defaultCornerRadius.bottomLeft,\n bottomRight: cornerRadius.bottomRight ?? defaultCornerRadius.bottomRight,\n } : defaultCornerRadius;\n\n return (\n <div className={`histogram-container ${orientation === 'horizontal' ? 'histogram-container--horizontal' : ''}`}>\n <div className={`histogram-content ${orientation === 'horizontal' ? 'histogram-content--horizontal' : ''}`}>\n <div \n className=\"histogram-bar\"\n style={{\n height: `${displayHeight}px`,\n width: `${displayWidth}px`\n }}\n >\n <svg\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${svgWidth} ${svgHeight}`}\n className=\"histogram-svg\"\n >\n {/* Background bar (max value) */}\n <path\n d={createRoundedRectPath(0, 0, svgWidth, svgHeight, corners)}\n fill={max.color}\n fillOpacity={max.opacity || 1}\n />\n {/* Foreground bar (relative value) with animation */}\n {orientation === 'vertical' ? (\n <path\n d={createRoundedRectPath(\n 0,\n svgHeight - animatedHeight,\n svgWidth,\n animatedHeight,\n {\n topLeft: animatedHeight >= svgHeight ? corners.topLeft : 0,\n topRight: animatedHeight >= svgHeight ? corners.topRight : 0,\n bottomLeft: corners.bottomLeft,\n bottomRight: corners.bottomRight,\n }\n )}\n fill={relative.color}\n />\n ) : (\n <path\n d={createRoundedRectPath(\n 0,\n 0,\n animatedWidth,\n svgHeight,\n {\n topLeft: corners.topLeft,\n topRight: animatedWidth >= svgWidth ? corners.topRight : 0,\n bottomLeft: corners.bottomLeft,\n bottomRight: animatedWidth >= svgWidth ? corners.bottomRight : 0,\n }\n )}\n fill={relative.color}\n />\n )}\n </svg>\n </div>\n {children && (\n <div className={`histogram-text-container ${orientation === 'horizontal' ? 'histogram-text-container--horizontal' : ''}`}>\n {children}\n </div>\n )}\n </div>\n </div>\n );\n};\n","import React from \"react\";\nimport \"./Chip.css\";\n\ninterface ChipProps {\n // Define any props you want to pass to the Chip component\n label?: string;\n bgColor?: string;\n textColor?: string;\n}\n\nexport const Chip: React.FC<ChipProps> = ({ label, bgColor, textColor }) => {\n return (\n <div className=\"chip-container\" style={{ backgroundColor: bgColor }}>\n <div className=\"chip-content\">\n <p className=\"chip-label\" style={{ color: textColor }}>\n {label}\n </p>\n </div>\n </div>\n );\n};\n"],"names":["Histogram","_a","max","relative","_f","barHeight","_g","barWidth","_h","orientation","cornerRadius","children","_j","useState","animatedHeight","setAnimatedHeight","_k","animatedWidth","setAnimatedWidth","targetHeight","Math","min","value","targetWidth","useEffect","startTime","Date","now","animate","elapsed","progress","easeOutQuart","pow","requestAnimationFrame","displayWidth","displayHeight","svgWidth","svgHeight","createRoundedRectPath","x","y","width","height","radii","topLeft","topRight","bottomLeft","bottomRight","concat","trim","replace","defaultCornerRadius","corners","_b","_c","_d","_e","_jsx","className","_jsxs","style","viewBox","d","fill","color","fillOpacity","opacity","Chip","label","bgColor","textColor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";var t=require("react/jsx-runtime"),o=require("react");exports.Histogram=function(a){var c,n,i,e,r=a.max,
|
|
1
|
+
"use strict";var t=require("react/jsx-runtime"),o=require("react");exports.Chip=function(o){var a=o.label,c=o.bgColor,n=o.textColor;return t.jsx("div",{className:"chip-container",style:{backgroundColor:c},children:t.jsx("div",{className:"chip-content",children:t.jsx("p",{className:"chip-label",style:{color:n},children:a})})})},exports.Histogram=function(a){var c,n,i,e,r=a.max,l=a.relative,h=a.barHeight,s=void 0===h?103:h,m=a.barWidth,g=void 0===m?32:m,p=a.orientation,d=void 0===p?"vertical":p,v=a.cornerRadius,f=a.children,u=o.useState(0),b=u[0],L=u[1],x=o.useState(0),R=x[0],j=x[1],z=Math.min(l.value/r.value*100,100)/100*s,N=Math.min(l.value/r.value*100,100)/100*g;o.useEffect(function(){L(0),j(0);var t=Date.now(),o=function(){var a=Date.now()-t,c=Math.min(a/1e3,1),n=1-Math.pow(1-c,4);L(z*n),j(N*n),c<1&&requestAnimationFrame(o)};requestAnimationFrame(o)},[z,N]);var w="horizontal"===d?s:g,y="horizontal"===d?g:s,M="horizontal"===d?s:g,q="horizontal"===d?g:s,C=function(t,o,a,c,n){var i=n.topLeft,e=n.topRight,r=n.bottomLeft,l=n.bottomRight;return"\n M ".concat(t+i," ").concat(o,"\n L ").concat(t+a-e," ").concat(o,"\n Q ").concat(t+a," ").concat(o," ").concat(t+a," ").concat(o+e,"\n L ").concat(t+a," ").concat(o+c-l,"\n Q ").concat(t+a," ").concat(o+c," ").concat(t+a-l," ").concat(o+c,"\n L ").concat(t+r," ").concat(o+c,"\n Q ").concat(t," ").concat(o+c," ").concat(t," ").concat(o+c-r,"\n L ").concat(t," ").concat(o+i,"\n Q ").concat(t," ").concat(o," ").concat(t+i," ").concat(o,"\n Z\n ").trim().replace(/\s+/g," ")},Q={topLeft:2,topRight:2,bottomLeft:2,bottomRight:2},A=v?{topLeft:null!==(c=v.topLeft)&&void 0!==c?c:Q.topLeft,topRight:null!==(n=v.topRight)&&void 0!==n?n:Q.topRight,bottomLeft:null!==(i=v.bottomLeft)&&void 0!==i?i:Q.bottomLeft,bottomRight:null!==(e=v.bottomRight)&&void 0!==e?e:Q.bottomRight}:Q;return t.jsx("div",{className:"histogram-container ".concat("horizontal"===d?"histogram-container--horizontal":""),children:t.jsxs("div",{className:"histogram-content ".concat("horizontal"===d?"histogram-content--horizontal":""),children:[t.jsx("div",{className:"histogram-bar",style:{height:"".concat(y,"px"),width:"".concat(w,"px")},children:t.jsxs("svg",{width:M,height:q,viewBox:"0 0 ".concat(M," ").concat(q),className:"histogram-svg",children:[t.jsx("path",{d:C(0,0,M,q,A),fill:r.color,fillOpacity:r.opacity||1}),"vertical"===d?t.jsx("path",{d:C(0,q-b,M,b,{topLeft:b>=q?A.topLeft:0,topRight:b>=q?A.topRight:0,bottomLeft:A.bottomLeft,bottomRight:A.bottomRight}),fill:l.color}):t.jsx("path",{d:C(0,0,R,q,{topLeft:A.topLeft,topRight:R>=M?A.topRight:0,bottomLeft:A.bottomLeft,bottomRight:R>=M?A.bottomRight:0}),fill:l.color})]})}),f&&t.jsx("div",{className:"histogram-text-container ".concat("horizontal"===d?"histogram-text-container--horizontal":""),children:f})]})})};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/components/Histogram.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport \"./Histogram.css\";\n\ninterface HistogramProps {\n /** Maximum value configuration with value and color */\n max: {\n value: number;\n color: string;\n opacity?: number;\n };\n /** Relative/current value configuration with value and color */\n relative: {\n value: number;\n color: string;\n };\n /** Height of the histogram bar in pixels */\n barHeight?: number;\n /** Width of the histogram bar in pixels */\n barWidth?: number;\n /** Orientation of the histogram - 'vertical' or 'horizontal' */\n orientation?: 'vertical' | 'horizontal';\n /** Corner radius configuration for individual corners */\n cornerRadius?: {\n topLeft?: number;\n topRight?: number;\n bottomLeft?: number;\n bottomRight?: number;\n };\n /** Child components (typically text content) */\n children?: React.ReactNode;\n}\n\nexport const Histogram: React.FC<HistogramProps> = ({\n max,\n relative,\n barHeight = 103,\n barWidth = 32,\n orientation = 'vertical',\n cornerRadius,\n children,\n}) => {\n const [animatedHeight, setAnimatedHeight] = useState(0);\n const [animatedWidth, setAnimatedWidth] = useState(0);\n\n // Calculate target dimensions based on orientation\n const targetHeight = (Math.min((relative.value / max.value) * 100, 100) / 100) * barHeight;\n const targetWidth = (Math.min((relative.value / max.value) * 100, 100) / 100) * barWidth;\n\n // Simple Chart.js-like animation: always animate from 0 to target\n useEffect(() => {\n setAnimatedHeight(0);\n setAnimatedWidth(0);\n \n const startTime = Date.now();\n const duration = 1000;\n\n const animate = () => {\n const elapsed = Date.now() - startTime;\n const progress = Math.min(elapsed / duration, 1);\n\n // Chart.js-like easing (easeOutQuart)\n const easeOutQuart = 1 - Math.pow(1 - progress, 4);\n \n setAnimatedHeight(targetHeight * easeOutQuart);\n setAnimatedWidth(targetWidth * easeOutQuart);\n\n if (progress < 1) {\n requestAnimationFrame(animate);\n }\n };\n\n requestAnimationFrame(animate);\n }, [targetHeight, targetWidth]);\n\n const displayWidth = orientation === 'horizontal' ? barHeight : barWidth;\n const displayHeight = orientation === 'horizontal' ? barWidth : barHeight;\n const svgWidth = orientation === 'horizontal' ? barHeight : barWidth;\n const svgHeight = orientation === 'horizontal' ? barWidth : barHeight;\n\n // Helper function to create rounded rectangle path\n const createRoundedRectPath = (\n x: number,\n y: number,\n width: number,\n height: number,\n radii: { topLeft: number; topRight: number; bottomLeft: number; bottomRight: number }\n ) => {\n const { topLeft, topRight, bottomLeft, bottomRight } = radii;\n \n return `\n M ${x + topLeft} ${y}\n L ${x + width - topRight} ${y}\n Q ${x + width} ${y} ${x + width} ${y + topRight}\n L ${x + width} ${y + height - bottomRight}\n Q ${x + width} ${y + height} ${x + width - bottomRight} ${y + height}\n L ${x + bottomLeft} ${y + height}\n Q ${x} ${y + height} ${x} ${y + height - bottomLeft}\n L ${x} ${y + topLeft}\n Q ${x} ${y} ${x + topLeft} ${y}\n Z\n `.trim().replace(/\\s+/g, ' ');\n };\n\n // Default corner radius values\n const defaultCornerRadius = { topLeft: 2, topRight: 2, bottomLeft: 2, bottomRight: 2 };\n const corners = cornerRadius ? {\n topLeft: cornerRadius.topLeft ?? defaultCornerRadius.topLeft,\n topRight: cornerRadius.topRight ?? defaultCornerRadius.topRight,\n bottomLeft: cornerRadius.bottomLeft ?? defaultCornerRadius.bottomLeft,\n bottomRight: cornerRadius.bottomRight ?? defaultCornerRadius.bottomRight,\n } : defaultCornerRadius;\n\n return (\n <div className={`histogram-container ${orientation === 'horizontal' ? 'histogram-container--horizontal' : ''}`}>\n <div className={`histogram-content ${orientation === 'horizontal' ? 'histogram-content--horizontal' : ''}`}>\n <div \n className=\"histogram-bar\"\n style={{\n height: `${displayHeight}px`,\n width: `${displayWidth}px`\n }}\n >\n <svg\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${svgWidth} ${svgHeight}`}\n className=\"histogram-svg\"\n >\n {/* Background bar (max value) */}\n <path\n d={createRoundedRectPath(0, 0, svgWidth, svgHeight, corners)}\n fill={max.color}\n fillOpacity={max.opacity || 1}\n />\n {/* Foreground bar (relative value) with animation */}\n {orientation === 'vertical' ? (\n <path\n d={createRoundedRectPath(\n 0,\n svgHeight - animatedHeight,\n svgWidth,\n animatedHeight,\n {\n topLeft: animatedHeight >= svgHeight ? corners.topLeft : 0,\n topRight: animatedHeight >= svgHeight ? corners.topRight : 0,\n bottomLeft: corners.bottomLeft,\n bottomRight: corners.bottomRight,\n }\n )}\n fill={relative.color}\n />\n ) : (\n <path\n d={createRoundedRectPath(\n 0,\n 0,\n animatedWidth,\n svgHeight,\n {\n topLeft: corners.topLeft,\n topRight: animatedWidth >= svgWidth ? corners.topRight : 0,\n bottomLeft: corners.bottomLeft,\n bottomRight: animatedWidth >= svgWidth ? corners.bottomRight : 0,\n }\n )}\n fill={relative.color}\n />\n )}\n </svg>\n </div>\n {children && (\n <div className={`histogram-text-container ${orientation === 'horizontal' ? 'histogram-text-container--horizontal' : ''}`}>\n {children}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"names":["_a","max","relative","_f","barHeight","_g","barWidth","_h","orientation","cornerRadius","children","_j","useState","animatedHeight","setAnimatedHeight","_k","animatedWidth","setAnimatedWidth","targetHeight","Math","min","value","targetWidth","useEffect","startTime","Date","now","animate","elapsed","progress","easeOutQuart","pow","requestAnimationFrame","displayWidth","displayHeight","svgWidth","svgHeight","createRoundedRectPath","x","y","width","height","radii","topLeft","topRight","bottomLeft","bottomRight","concat","trim","replace","defaultCornerRadius","corners","_b","_c","_d","_e","_jsx","jsx","className","_jsxs","style","viewBox","d","fill","color","fillOpacity","opacity"],"mappings":"qFAgCmD,SAACA,eAClDC,EAAGD,EAAAC,IACHC,EAAQF,EAAAE,SACRC,EAAAH,EAAAI,UAAAA,OAAY,IAAAD,EAAA,IAAGA,EACfE,aAAAC,OAAW,IAAAD,EAAA,GAAEA,EACbE,EAAwBP,EAAAQ,YAAxBA,OAAW,IAAAD,EAAG,WAAUA,EACxBE,EAAYT,EAAAS,aACZC,EAAQV,EAAAU,SAEFC,EAAsCC,EAAAA,SAAS,GAA9CC,EAAcF,EAAA,GAAEG,EAAiBH,EAAA,GAClCI,EAAoCH,EAAAA,SAAS,GAA5CI,EAAaD,EAAA,GAAEE,EAAgBF,EAAA,GAGhCG,EAAgBC,KAAKC,IAAKlB,EAASmB,MAAQpB,EAAIoB,MAAS,IAAK,KAAO,IAAOjB,EAC3EkB,EAAeH,KAAKC,IAAKlB,EAASmB,MAAQpB,EAAIoB,MAAS,IAAK,KAAO,IAAOf,EAGhFiB,EAAAA,UAAU,WACRT,EAAkB,GAClBG,EAAiB,GAEjB,IAAMO,EAAYC,KAAKC,MAGjBC,EAAU,WACd,IAAMC,EAAUH,KAAKC,MAAQF,EACvBK,EAAWV,KAAKC,IAAIQ,EAJX,IAI+B,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DC,WAAYM,EAAQN,WACpBC,YAAa9B,GAAiBmB,EAAWgB,EAAQL,YAAc,IAGnEiB,KAAM7D,EAAS8D,aAKtBtD,GACC8C,EAAAC,IAAA,MAAA,CAAKC,UAAW,4BAAAX,OAA4C,eAAhBvC,EAA+B,uCAAyC,aACjHE,QAMb"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/components/Chip.tsx","../src/components/Histogram.tsx"],"sourcesContent":["import React from \"react\";\nimport \"./Chip.css\";\n\ninterface ChipProps {\n // Define any props you want to pass to the Chip component\n label?: string;\n bgColor?: string;\n textColor?: string;\n}\n\nexport const Chip: React.FC<ChipProps> = ({ label, bgColor, textColor }) => {\n return (\n <div className=\"chip-container\" style={{ backgroundColor: bgColor }}>\n <div className=\"chip-content\">\n <p className=\"chip-label\" style={{ color: textColor }}>\n {label}\n </p>\n </div>\n </div>\n );\n};\n","import React, { useEffect, useState } from \"react\";\nimport \"./Histogram.css\";\n\ninterface HistogramProps {\n /** Maximum value configuration with value and color */\n max: {\n value: number;\n color: string;\n opacity?: number;\n };\n /** Relative/current value configuration with value and color */\n relative: {\n value: number;\n color: string;\n };\n /** Height of the histogram bar in pixels */\n barHeight?: number;\n /** Width of the histogram bar in pixels */\n barWidth?: number;\n /** Orientation of the histogram - 'vertical' or 'horizontal' */\n orientation?: 'vertical' | 'horizontal';\n /** Corner radius configuration for individual corners */\n cornerRadius?: {\n topLeft?: number;\n topRight?: number;\n bottomLeft?: number;\n bottomRight?: number;\n };\n /** Child components (typically text content) */\n children?: React.ReactNode;\n}\n\nexport const Histogram: React.FC<HistogramProps> = ({\n max,\n relative,\n barHeight = 103,\n barWidth = 32,\n orientation = 'vertical',\n cornerRadius,\n children,\n}) => {\n const [animatedHeight, setAnimatedHeight] = useState(0);\n const [animatedWidth, setAnimatedWidth] = useState(0);\n\n // Calculate target dimensions based on orientation\n const targetHeight = (Math.min((relative.value / max.value) * 100, 100) / 100) * barHeight;\n const targetWidth = (Math.min((relative.value / max.value) * 100, 100) / 100) * barWidth;\n\n // Simple Chart.js-like animation: always animate from 0 to target\n useEffect(() => {\n setAnimatedHeight(0);\n setAnimatedWidth(0);\n \n const startTime = Date.now();\n const duration = 1000;\n\n const animate = () => {\n const elapsed = Date.now() - startTime;\n const progress = Math.min(elapsed / duration, 1);\n\n // Chart.js-like easing (easeOutQuart)\n const easeOutQuart = 1 - Math.pow(1 - progress, 4);\n \n setAnimatedHeight(targetHeight * easeOutQuart);\n setAnimatedWidth(targetWidth * easeOutQuart);\n\n if (progress < 1) {\n requestAnimationFrame(animate);\n }\n };\n\n requestAnimationFrame(animate);\n }, [targetHeight, targetWidth]);\n\n const displayWidth = orientation === 'horizontal' ? barHeight : barWidth;\n const displayHeight = orientation === 'horizontal' ? barWidth : barHeight;\n const svgWidth = orientation === 'horizontal' ? barHeight : barWidth;\n const svgHeight = orientation === 'horizontal' ? barWidth : barHeight;\n\n // Helper function to create rounded rectangle path\n const createRoundedRectPath = (\n x: number,\n y: number,\n width: number,\n height: number,\n radii: { topLeft: number; topRight: number; bottomLeft: number; bottomRight: number }\n ) => {\n const { topLeft, topRight, bottomLeft, bottomRight } = radii;\n \n return `\n M ${x + topLeft} ${y}\n L ${x + width - topRight} ${y}\n Q ${x + width} ${y} ${x + width} ${y + topRight}\n L ${x + width} ${y + height - bottomRight}\n Q ${x + width} ${y + height} ${x + width - bottomRight} ${y + height}\n L ${x + bottomLeft} ${y + height}\n Q ${x} ${y + height} ${x} ${y + height - bottomLeft}\n L ${x} ${y + topLeft}\n Q ${x} ${y} ${x + topLeft} ${y}\n Z\n `.trim().replace(/\\s+/g, ' ');\n };\n\n // Default corner radius values\n const defaultCornerRadius = { topLeft: 2, topRight: 2, bottomLeft: 2, bottomRight: 2 };\n const corners = cornerRadius ? {\n topLeft: cornerRadius.topLeft ?? defaultCornerRadius.topLeft,\n topRight: cornerRadius.topRight ?? defaultCornerRadius.topRight,\n bottomLeft: cornerRadius.bottomLeft ?? defaultCornerRadius.bottomLeft,\n bottomRight: cornerRadius.bottomRight ?? defaultCornerRadius.bottomRight,\n } : defaultCornerRadius;\n\n return (\n <div className={`histogram-container ${orientation === 'horizontal' ? 'histogram-container--horizontal' : ''}`}>\n <div className={`histogram-content ${orientation === 'horizontal' ? 'histogram-content--horizontal' : ''}`}>\n <div \n className=\"histogram-bar\"\n style={{\n height: `${displayHeight}px`,\n width: `${displayWidth}px`\n }}\n >\n <svg\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${svgWidth} ${svgHeight}`}\n className=\"histogram-svg\"\n >\n {/* Background bar (max value) */}\n <path\n d={createRoundedRectPath(0, 0, svgWidth, svgHeight, corners)}\n fill={max.color}\n fillOpacity={max.opacity || 1}\n />\n {/* Foreground bar (relative value) with animation */}\n {orientation === 'vertical' ? (\n <path\n d={createRoundedRectPath(\n 0,\n svgHeight - animatedHeight,\n svgWidth,\n animatedHeight,\n {\n topLeft: animatedHeight >= svgHeight ? corners.topLeft : 0,\n topRight: animatedHeight >= svgHeight ? corners.topRight : 0,\n bottomLeft: corners.bottomLeft,\n bottomRight: corners.bottomRight,\n }\n )}\n fill={relative.color}\n />\n ) : (\n <path\n d={createRoundedRectPath(\n 0,\n 0,\n animatedWidth,\n svgHeight,\n {\n topLeft: corners.topLeft,\n topRight: animatedWidth >= svgWidth ? corners.topRight : 0,\n bottomLeft: corners.bottomLeft,\n bottomRight: animatedWidth >= svgWidth ? corners.bottomRight : 0,\n }\n )}\n fill={relative.color}\n />\n )}\n </svg>\n </div>\n {children && (\n <div className={`histogram-text-container ${orientation === 'horizontal' ? 'histogram-text-container--horizontal' : ''}`}>\n {children}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"names":["_a","label","bgColor","textColor","_jsx","jsx","className","style","backgroundColor","children","color","max","relative","_f","barHeight","_g","barWidth","_h","orientation","cornerRadius","_j","useState","animatedHeight","setAnimatedHeight","_k","animatedWidth","setAnimatedWidth","targetHeight","Math","min","value","targetWidth","useEffect","startTime","Date","now","animate","elapsed","progress","easeOutQuart","pow","requestAnimationFrame","displayWidth","displayHeight","svgWidth","svgHeight","createRoundedRectPath","x","y","width","height","radii","topLeft","topRight","bottomLeft","bottomRight","concat","trim","replace","defaultCornerRadius","corners","_b","_c","_d","_e","_jsxs","viewBox","d","fill","fillOpacity","opacity"],"mappings":"gFAUyC,SAACA,GAAE,IAAAC,UAAOC,EAAOF,EAAAE,QAAEC,EAASH,EAAAG,UACnE,OACEC,EAAKC,IAAA,MAAA,CAAAC,UAAU,iBAAiBC,MAAO,CAAEC,gBAAiBN,GACxDO,SAAAL,EAAAC,IAAA,MAAA,CAAKC,UAAU,eACbG,SAAAL,EAAAC,IAAA,IAAA,CAAGC,UAAU,aAAaC,MAAO,CAAEG,MAAOP,GACvCM,SAAAR,OAKX,oBCYmD,SAACD,eAClDW,EAAGX,EAAAW,IACHC,EAAQZ,EAAAY,SACRC,EAAAb,EAAAc,UAAAA,OAAY,IAAAD,EAAA,IAAGA,EACfE,aAAAC,OAAW,IAAAD,EAAA,GAAEA,EACbE,EAAwBjB,EAAAkB,YAAxBA,OAAW,IAAAD,EAAG,WAAUA,EACxBE,EAAYnB,EAAAmB,aACZV,EAAQT,EAAAS,SAEFW,EAAsCC,EAAAA,SAAS,GAA9CC,EAAcF,EAAA,GAAEG,EAAiBH,EAAA,GAClCI,EAAoCH,EAAAA,SAAS,GAA5CI,EAAaD,EAAA,GAAEE,EAAgBF,EAAA,GAGhCG,EAAgBC,KAAKC,IAAKjB,EAASkB,MAAQnB,EAAImB,MAAS,IAAK,KAAO,IAAOhB,EAC3EiB,EAAeH,KAAKC,IAAKjB,EAASkB,MAAQnB,EAAImB,MAAS,IAAK,KAAO,IAAOd,EAGhFgB,EAAAA,UAAU,WACRT,EAAkB,GAClBG,EAAiB,GAEjB,IAAMO,EAAYC,KAAKC,MAGjBC,EAAU,WACd,IAAMC,EAAUH,KAAKC,MAAQF,EACvBK,EAAWV,KAAKC,IAAIQ,EAJX,IAI+B,GAGxCE,EAAe,EAAIX,KA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BC,YAAa9B,GAAiBmB,EAAWgB,EAAQL,YAAc,IAGnEa,KAAMxD,EAASF,aAKtBD,GACCL,EAAAC,IAAA,MAAA,CAAKC,UAAW,4BAAAkD,OAA4C,eAAhBtC,EAA+B,uCAAyC,aACjHT,QAMb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rte-utils",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "React components library in TypeScript for agigox projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"tslib": "^2.8.1",
|
|
50
50
|
"typescript": "^5.1.0"
|
|
51
51
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
"optionalDependencies": {
|
|
53
|
+
"fsevents": "^2.3.3"
|
|
54
|
+
},
|
|
55
55
|
"repository": {
|
|
56
56
|
"type": "git",
|
|
57
57
|
"url": "git+https://github.com/agigox/rte-utils.git"
|