@giddaa-housing/ui 1.1.0 → 1.2.0
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/css/generated/shared.css +1 -1
- package/css/giddaa.css +12 -2
- package/dist/bullet-chart.d.ts +8 -4
- package/dist/bullet-chart.js +10 -6
- package/dist/button.js +1 -1
- package/dist/card.js +1 -1
- package/dist/chart.d.ts +33 -5
- package/dist/chart.js +210 -13
- package/dist/checkbox.js +1 -1
- package/dist/data-table.d.ts +7 -3
- package/dist/data-table.js +8 -5
- package/dist/funnel-chart.d.ts +11 -7
- package/dist/funnel-chart.js +11 -8
- package/dist/input-group.js +1 -1
- package/dist/input.js +1 -1
- package/dist/line-chart.d.ts +113 -41
- package/dist/line-chart.js +217 -30
- package/dist/list-item.d.ts +22 -0
- package/dist/list-item.js +84 -0
- package/dist/number-input.js +20 -17
- package/dist/pie-chart.d.ts +83 -52
- package/dist/pie-chart.js +85 -43
- package/dist/purchase-option-card.d.ts +79 -0
- package/dist/purchase-option-card.js +176 -0
- package/dist/radio-group.js +1 -1
- package/dist/select.js +1 -1
- package/dist/sparkline.d.ts +28 -15
- package/dist/sparkline.js +131 -37
- package/dist/styles.css +529 -43
- package/dist/switch.js +1 -1
- package/dist/table.js +6 -2
- package/dist/tabs.d.ts +11 -1
- package/dist/tabs.js +43 -4
- package/dist/textarea.js +1 -1
- package/dist/tree-map.d.ts +14 -14
- package/dist/tree-map.js +14 -15
- package/package.json +9 -1
package/dist/sparkline.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ import { ChartContainer, ChartValueType } from "./chart.js";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
//#region src/sparkline.d.ts
|
|
5
5
|
/**
|
|
6
|
-
* Small inline trend
|
|
7
|
-
* gridlines.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Small inline trend marks for KPI cards and dense tables — no axes, no
|
|
7
|
+
* gridlines. Three render styles ship as separate components sharing one engine:
|
|
8
|
+
* `SparklineLine`, `SparklineArea`, and `SparklineBar`. All are composed from
|
|
9
|
+
* recharts plot primitives so they share the charting engine with
|
|
10
|
+
* `line-chart`/`bar-chart` and get hover tooltips for free via the shared
|
|
11
|
+
* `ChartTooltip`/`ChartTooltipContent`.
|
|
10
12
|
*
|
|
11
13
|
* Sizing follows the same convention as the other charts: `size` sets the height
|
|
12
14
|
* (plus stroke/dot scale) and the width is parent-driven — the component is
|
|
@@ -14,8 +16,8 @@ import * as React from "react";
|
|
|
14
16
|
* recommended container sizes) or let it fill a KPI card.
|
|
15
17
|
*
|
|
16
18
|
* Sentiment colour is driven by the data direction — `status-success` for an
|
|
17
|
-
* upward series, `status-danger` for downward, `
|
|
18
|
-
*
|
|
19
|
+
* upward series, `status-danger` for downward, `fg-secondary` for flat — and can
|
|
20
|
+
* be overridden with `trend`. The area fill reuses the line colour at 14%.
|
|
19
21
|
*
|
|
20
22
|
* Tokens:
|
|
21
23
|
* - Stroke / fill — up: `var(--color-status-success)`, down:
|
|
@@ -26,22 +28,20 @@ import * as React from "react";
|
|
|
26
28
|
*
|
|
27
29
|
* @example
|
|
28
30
|
* // KPI card trend — colour follows the metric's sentiment automatically
|
|
29
|
-
* <
|
|
31
|
+
* <SparklineArea data={[40, 44, 42, 55, 58, 62, 70]} />
|
|
30
32
|
*
|
|
31
33
|
* @example
|
|
32
34
|
* // Interactive — hover tooltip with currency formatting and month captions
|
|
33
|
-
* <
|
|
35
|
+
* <SparklineLine data={values} tooltip label="Revenue" valueType="currency" labels={months} />
|
|
34
36
|
*
|
|
35
37
|
* @example
|
|
36
38
|
* // Dense table cell — fixed-width wrapper, bar render, no marker
|
|
37
39
|
* <span className="inline-block w-[72px]">
|
|
38
|
-
* <
|
|
40
|
+
* <SparklineBar data={values} size="sm" showMarker={false} />
|
|
39
41
|
* </span>
|
|
40
42
|
*/
|
|
41
43
|
/** Sparkline sizes line up with the three shared `ComponentSize` values. */
|
|
42
44
|
type SparklineSize = ComponentSize;
|
|
43
|
-
/** Render style for the series. */
|
|
44
|
-
type SparklineType = "line" | "bar" | "area";
|
|
45
45
|
/** Sentiment of the series — drives the stroke/fill colour. */
|
|
46
46
|
type SparklineTrend = "up" | "down" | "flat";
|
|
47
47
|
type SparklineLayout = {
|
|
@@ -66,11 +66,10 @@ type SparklineLayout = {
|
|
|
66
66
|
maxBarSize: number;
|
|
67
67
|
};
|
|
68
68
|
declare const SPARKLINE_LAYOUT: Record<SparklineSize, SparklineLayout>;
|
|
69
|
+
/** Shared props for all three sparkline render styles. */
|
|
69
70
|
type SparklineProps = Omit<React.ComponentProps<typeof ChartContainer>, "config" | "children"> & {
|
|
70
71
|
/** The series to plot. Needs at least two points to draw a trend. */
|
|
71
72
|
data: number[];
|
|
72
|
-
/** Render style. Defaults to `line`. */
|
|
73
|
-
type?: SparklineType;
|
|
74
73
|
/** Explicit size; otherwise inherited from the nearest `SizeProvider`. */
|
|
75
74
|
size?: SparklineSize;
|
|
76
75
|
/** Override the auto-detected sentiment colour. */
|
|
@@ -86,6 +85,20 @@ type SparklineProps = Omit<React.ComponentProps<typeof ChartContainer>, "config"
|
|
|
86
85
|
/** Value formatting for the tooltip. Defaults to `number`. */
|
|
87
86
|
valueType?: ChartValueType;
|
|
88
87
|
};
|
|
89
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Inline line sparkline — a bare trend stroke with an optional end-point dot and
|
|
90
|
+
* hover tooltip. Sentiment colour is auto-detected from the series direction.
|
|
91
|
+
*/
|
|
92
|
+
declare function SparklineLine({ data, size, trend, showMarker, tooltip, label, labels, valueType, className, style, "aria-label": ariaLabelProp, ...rest }: SparklineProps): React.JSX.Element;
|
|
93
|
+
/**
|
|
94
|
+
* Inline area sparkline — the same trend stroke as `SparklineLine` with a 14%
|
|
95
|
+
* wash beneath it, for KPI cards where the filled shape reads at a glance.
|
|
96
|
+
*/
|
|
97
|
+
declare function SparklineArea({ data, size, trend, showMarker, tooltip, label, labels, valueType, className, style, "aria-label": ariaLabelProp, ...rest }: SparklineProps): React.JSX.Element;
|
|
98
|
+
/**
|
|
99
|
+
* Inline bar sparkline — one thin bar per point, for discrete series (counts,
|
|
100
|
+
* per-period totals). The end-point marker rides the latest bar.
|
|
101
|
+
*/
|
|
102
|
+
declare function SparklineBar({ data, size, trend, showMarker, tooltip, label, labels, valueType, className, style, "aria-label": ariaLabelProp, ...rest }: SparklineProps): React.JSX.Element;
|
|
90
103
|
//#endregion
|
|
91
|
-
export { SPARKLINE_LAYOUT,
|
|
104
|
+
export { SPARKLINE_LAYOUT, SparklineArea, SparklineBar, SparklineLine, type SparklineProps, type SparklineSize, type SparklineTrend };
|
package/dist/sparkline.js
CHANGED
|
@@ -108,7 +108,7 @@ function SparklineBarShape({ x, y, width, height, index, value, lastIndex, radiu
|
|
|
108
108
|
strokeWidth: 2
|
|
109
109
|
}) : null] });
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function useSparklineSetup({ data, size, trend, showMarker, tooltip, label, labels, valueType }, kind, ariaLabelProp) {
|
|
112
112
|
const layout = SPARKLINE_LAYOUT[useComponentSize(size)];
|
|
113
113
|
const resolvedTrend = trend ?? resolveTrend(data);
|
|
114
114
|
const color = TREND_COLOR[resolvedTrend];
|
|
@@ -116,21 +116,10 @@ function Sparkline({ data, type = "line", size, trend, showMarker = true, toolti
|
|
|
116
116
|
x: labels?.[i] ?? `${i + 1}`,
|
|
117
117
|
value
|
|
118
118
|
}));
|
|
119
|
-
const lastIndex = data.length - 1;
|
|
120
119
|
const config = { value: {
|
|
121
|
-
label,
|
|
120
|
+
label: label ?? "Value",
|
|
122
121
|
color
|
|
123
122
|
} };
|
|
124
|
-
const showDot = showMarker && data.length >= 2;
|
|
125
|
-
const endDot = showDot ? /* @__PURE__ */ jsx(SparklineEndDot, {
|
|
126
|
-
lastIndex,
|
|
127
|
-
radius: layout.dotRadius
|
|
128
|
-
}) : false;
|
|
129
|
-
const barShape = showDot ? /* @__PURE__ */ jsx(SparklineBarShape, {
|
|
130
|
-
lastIndex,
|
|
131
|
-
radius: layout.barRadius,
|
|
132
|
-
dotRadius: layout.dotRadius
|
|
133
|
-
}) : void 0;
|
|
134
123
|
const activeDot = tooltip ? {
|
|
135
124
|
r: layout.dotRadius + .5,
|
|
136
125
|
fill: "var(--color-value)",
|
|
@@ -141,11 +130,28 @@ function Sparkline({ data, type = "line", size, trend, showMarker = true, toolti
|
|
|
141
130
|
cursor: false,
|
|
142
131
|
content: /* @__PURE__ */ jsx(ChartTooltipContent, {
|
|
143
132
|
size: "xs",
|
|
144
|
-
valueType
|
|
133
|
+
valueType: valueType ?? "number"
|
|
145
134
|
})
|
|
146
135
|
}) : null;
|
|
147
|
-
|
|
148
|
-
|
|
136
|
+
return {
|
|
137
|
+
layout,
|
|
138
|
+
resolvedTrend,
|
|
139
|
+
chartData,
|
|
140
|
+
lastIndex: data.length - 1,
|
|
141
|
+
config,
|
|
142
|
+
showDot: (showMarker ?? true) && data.length >= 2,
|
|
143
|
+
activeDot,
|
|
144
|
+
tooltipNode,
|
|
145
|
+
ariaLabel: ariaLabelProp ?? `${label ?? "Value"} ${kind}, trend ${resolvedTrend}`
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Frame shared by every render style — the empty placeholder (fewer than two
|
|
150
|
+
* points) and the responsive `ChartContainer` with the sparkline's aria wiring.
|
|
151
|
+
*/
|
|
152
|
+
function SparklineFrame({ setup, empty, className, style, children, ...props }) {
|
|
153
|
+
const { layout, config, ariaLabel } = setup;
|
|
154
|
+
if (empty) return /* @__PURE__ */ jsx("div", {
|
|
149
155
|
...props,
|
|
150
156
|
"aria-label": ariaLabel,
|
|
151
157
|
role: "img",
|
|
@@ -165,59 +171,105 @@ function Sparkline({ data, type = "line", size, trend, showMarker = true, toolti
|
|
|
165
171
|
height: layout.height,
|
|
166
172
|
...style
|
|
167
173
|
},
|
|
168
|
-
children
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
174
|
+
children
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Inline line sparkline — a bare trend stroke with an optional end-point dot and
|
|
179
|
+
* hover tooltip. Sentiment colour is auto-detected from the series direction.
|
|
180
|
+
*/
|
|
181
|
+
function SparklineLine({ data, size, trend, showMarker, tooltip, label, labels, valueType, className, style, "aria-label": ariaLabelProp, ...rest }) {
|
|
182
|
+
const setup = useSparklineSetup({
|
|
183
|
+
data,
|
|
184
|
+
size,
|
|
185
|
+
trend,
|
|
186
|
+
showMarker,
|
|
187
|
+
tooltip,
|
|
188
|
+
label,
|
|
189
|
+
labels,
|
|
190
|
+
valueType
|
|
191
|
+
}, "sparkline", ariaLabelProp);
|
|
192
|
+
const { layout, chartData, lastIndex, showDot, activeDot, tooltipNode } = setup;
|
|
193
|
+
const endDot = showDot ? /* @__PURE__ */ jsx(SparklineEndDot, {
|
|
194
|
+
lastIndex,
|
|
195
|
+
radius: layout.dotRadius
|
|
196
|
+
}) : false;
|
|
197
|
+
return /* @__PURE__ */ jsx(SparklineFrame, {
|
|
198
|
+
setup,
|
|
199
|
+
empty: data.length < 2,
|
|
200
|
+
className,
|
|
201
|
+
style,
|
|
202
|
+
...rest,
|
|
203
|
+
children: /* @__PURE__ */ jsxs(LineChart, {
|
|
181
204
|
accessibilityLayer: true,
|
|
182
205
|
data: chartData,
|
|
183
206
|
margin: layout.margin,
|
|
184
207
|
children: [
|
|
185
|
-
|
|
208
|
+
tooltipNode ? /* @__PURE__ */ jsx(XAxis, {
|
|
186
209
|
dataKey: "x",
|
|
187
210
|
hide: true
|
|
188
211
|
}) : null,
|
|
189
212
|
tooltipNode,
|
|
190
|
-
/* @__PURE__ */ jsx(
|
|
213
|
+
/* @__PURE__ */ jsx(Line, {
|
|
191
214
|
type: "monotone",
|
|
192
215
|
dataKey: "value",
|
|
193
216
|
stroke: "var(--color-value)",
|
|
194
217
|
strokeWidth: layout.strokeWidth,
|
|
195
218
|
strokeLinejoin: "round",
|
|
196
219
|
strokeLinecap: "round",
|
|
197
|
-
fill: "var(--color-value)",
|
|
198
|
-
fillOpacity: .14,
|
|
199
220
|
dot: endDot,
|
|
200
221
|
activeDot,
|
|
201
222
|
isAnimationActive: false
|
|
202
223
|
})
|
|
203
224
|
]
|
|
204
|
-
})
|
|
225
|
+
})
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Inline area sparkline — the same trend stroke as `SparklineLine` with a 14%
|
|
230
|
+
* wash beneath it, for KPI cards where the filled shape reads at a glance.
|
|
231
|
+
*/
|
|
232
|
+
function SparklineArea({ data, size, trend, showMarker, tooltip, label, labels, valueType, className, style, "aria-label": ariaLabelProp, ...rest }) {
|
|
233
|
+
const setup = useSparklineSetup({
|
|
234
|
+
data,
|
|
235
|
+
size,
|
|
236
|
+
trend,
|
|
237
|
+
showMarker,
|
|
238
|
+
tooltip,
|
|
239
|
+
label,
|
|
240
|
+
labels,
|
|
241
|
+
valueType
|
|
242
|
+
}, "sparkline", ariaLabelProp);
|
|
243
|
+
const { layout, chartData, lastIndex, showDot, activeDot, tooltipNode } = setup;
|
|
244
|
+
const endDot = showDot ? /* @__PURE__ */ jsx(SparklineEndDot, {
|
|
245
|
+
lastIndex,
|
|
246
|
+
radius: layout.dotRadius
|
|
247
|
+
}) : false;
|
|
248
|
+
return /* @__PURE__ */ jsx(SparklineFrame, {
|
|
249
|
+
setup,
|
|
250
|
+
empty: data.length < 2,
|
|
251
|
+
className,
|
|
252
|
+
style,
|
|
253
|
+
...rest,
|
|
254
|
+
children: /* @__PURE__ */ jsxs(AreaChart, {
|
|
205
255
|
accessibilityLayer: true,
|
|
206
256
|
data: chartData,
|
|
207
257
|
margin: layout.margin,
|
|
208
258
|
children: [
|
|
209
|
-
|
|
259
|
+
tooltipNode ? /* @__PURE__ */ jsx(XAxis, {
|
|
210
260
|
dataKey: "x",
|
|
211
261
|
hide: true
|
|
212
262
|
}) : null,
|
|
213
263
|
tooltipNode,
|
|
214
|
-
/* @__PURE__ */ jsx(
|
|
264
|
+
/* @__PURE__ */ jsx(Area, {
|
|
215
265
|
type: "monotone",
|
|
216
266
|
dataKey: "value",
|
|
217
267
|
stroke: "var(--color-value)",
|
|
218
268
|
strokeWidth: layout.strokeWidth,
|
|
219
269
|
strokeLinejoin: "round",
|
|
220
270
|
strokeLinecap: "round",
|
|
271
|
+
fill: "var(--color-value)",
|
|
272
|
+
fillOpacity: .14,
|
|
221
273
|
dot: endDot,
|
|
222
274
|
activeDot,
|
|
223
275
|
isAnimationActive: false
|
|
@@ -226,5 +278,47 @@ function Sparkline({ data, type = "line", size, trend, showMarker = true, toolti
|
|
|
226
278
|
})
|
|
227
279
|
});
|
|
228
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Inline bar sparkline — one thin bar per point, for discrete series (counts,
|
|
283
|
+
* per-period totals). The end-point marker rides the latest bar.
|
|
284
|
+
*/
|
|
285
|
+
function SparklineBar({ data, size, trend, showMarker, tooltip, label, labels, valueType, className, style, "aria-label": ariaLabelProp, ...rest }) {
|
|
286
|
+
const setup = useSparklineSetup({
|
|
287
|
+
data,
|
|
288
|
+
size,
|
|
289
|
+
trend,
|
|
290
|
+
showMarker,
|
|
291
|
+
tooltip,
|
|
292
|
+
label,
|
|
293
|
+
labels,
|
|
294
|
+
valueType
|
|
295
|
+
}, "bar sparkline", ariaLabelProp);
|
|
296
|
+
const { layout, chartData, lastIndex, showDot, tooltipNode } = setup;
|
|
297
|
+
const barShape = showDot ? /* @__PURE__ */ jsx(SparklineBarShape, {
|
|
298
|
+
lastIndex,
|
|
299
|
+
radius: layout.barRadius,
|
|
300
|
+
dotRadius: layout.dotRadius
|
|
301
|
+
}) : void 0;
|
|
302
|
+
return /* @__PURE__ */ jsx(SparklineFrame, {
|
|
303
|
+
setup,
|
|
304
|
+
empty: data.length < 2,
|
|
305
|
+
className,
|
|
306
|
+
style,
|
|
307
|
+
...rest,
|
|
308
|
+
children: /* @__PURE__ */ jsxs(BarChart, {
|
|
309
|
+
accessibilityLayer: true,
|
|
310
|
+
data: chartData,
|
|
311
|
+
margin: layout.margin,
|
|
312
|
+
children: [tooltipNode, /* @__PURE__ */ jsx(Bar, {
|
|
313
|
+
dataKey: "value",
|
|
314
|
+
fill: "var(--color-value)",
|
|
315
|
+
radius: layout.barRadius,
|
|
316
|
+
maxBarSize: layout.maxBarSize,
|
|
317
|
+
shape: barShape,
|
|
318
|
+
isAnimationActive: false
|
|
319
|
+
})]
|
|
320
|
+
})
|
|
321
|
+
});
|
|
322
|
+
}
|
|
229
323
|
//#endregion
|
|
230
|
-
export { SPARKLINE_LAYOUT,
|
|
324
|
+
export { SPARKLINE_LAYOUT, SparklineArea, SparklineBar, SparklineLine };
|