@nanahoshi/mona-ui 0.41.0 → 0.42.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/docs/api/auto-complete.md +2 -0
- package/docs/api/combo-box.md +2 -0
- package/docs/api/dropdowns.md +3 -1
- package/docs/api/i18n.md +20 -0
- package/docs/api/locales.md +14 -14
- package/docs/api/sparkline.md +85 -0
- package/docs/auto-complete.md +64 -0
- package/docs/combo-box.md +65 -0
- package/docs/sparkline.md +303 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +95 -30
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +58 -5
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +64 -29
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +39 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +25 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +25 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +5 -0
- package/fesm2022/nanahoshi-mona-ui-sparkline.mjs +573 -0
- package/i18n/catalogs/en-US.messages.json +5 -0
- package/llms.txt +3 -1
- package/locales/ar-sa/ar-sa.messages.json +5 -0
- package/locales/de-de/de-de.messages.json +5 -0
- package/locales/es-es/es-es.messages.json +5 -0
- package/locales/fr-fr/fr-fr.messages.json +5 -0
- package/locales/id-id/id-id.messages.json +5 -0
- package/locales/it-it/it-it.messages.json +5 -0
- package/locales/ja-jp/ja-jp.messages.json +5 -0
- package/locales/ko-kr/ko-kr.messages.json +5 -0
- package/locales/pl-pl/pl-pl.messages.json +5 -0
- package/locales/pt-br/pt-br.messages.json +5 -0
- package/locales/ru-ru/ru-ru.messages.json +5 -0
- package/locales/tr-tr/tr-tr.messages.json +5 -0
- package/locales/zh-cn/zh-cn.messages.json +5 -0
- package/locales/zh-tw/zh-tw.messages.json +5 -0
- package/package.json +5 -1
- package/sparkline/package.json +4 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +42 -1
- package/types/nanahoshi-mona-ui-combo-box.d.ts +37 -1
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +54 -4
- package/types/nanahoshi-mona-ui-i18n.d.ts +12 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +5 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +5 -0
- package/types/nanahoshi-mona-ui-sparkline.d.ts +228 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Component, booleanAttribute, computed, inject, input } from "@angular/core";
|
|
3
|
+
import { MonaI18nService, formatNumber } from "@nanahoshi/mona-ui/i18n";
|
|
4
|
+
import { createElementControlId } from "@nanahoshi/mona-ui/internal";
|
|
5
|
+
import { twMerge } from "tailwind-merge";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { area, curveLinear, curveMonotoneX, curveNatural, curveStep, curveStepAfter, line } from "d3-shape";
|
|
8
|
+
function localizeNumber(value, options) {
|
|
9
|
+
return formatNumber(value, "en-US", options);
|
|
10
|
+
}
|
|
11
|
+
const SPARKLINE_DEFAULT_MESSAGES = {
|
|
12
|
+
noData: "No data",
|
|
13
|
+
summary: (count, first, last, min, max) => `${count === 1 ? `${localizeNumber(count)} value` : `${localizeNumber(count)} values`}, first ${first}, last ${last}, lowest ${min}, highest ${max}`,
|
|
14
|
+
winLossSummary: (wins, losses, draws) => `${wins === 1 ? `${localizeNumber(wins)} win` : `${localizeNumber(wins)} wins`}, ${losses === 1 ? `${localizeNumber(losses)} loss` : `${localizeNumber(losses)} losses`}, ${draws === 1 ? `${localizeNumber(draws)} draw` : `${localizeNumber(draws)} draws`}`
|
|
15
|
+
};
|
|
16
|
+
const sparklineBaseThemeVariants = cva(`
|
|
17
|
+
relative inline-block h-6 w-24 shrink-0 align-middle
|
|
18
|
+
[--mona-sparkline-color:var(--color-chart-1)] [--mona-sparkline-negative-color:var(--color-error)]
|
|
19
|
+
`, {
|
|
20
|
+
variants: { markers: {
|
|
21
|
+
true: "p-[3px]",
|
|
22
|
+
false: ""
|
|
23
|
+
} },
|
|
24
|
+
defaultVariants: { markers: false }
|
|
25
|
+
});
|
|
26
|
+
const SPARKLINE_SVG_CLASSES = `
|
|
27
|
+
block size-full overflow-visible forced-color-adjust-none
|
|
28
|
+
forced-colors:[--mona-sparkline-color:CanvasText] forced-colors:[--mona-sparkline-negative-color:CanvasText]
|
|
29
|
+
`;
|
|
30
|
+
const SPARKLINE_LINE_CLASSES = "fill-none stroke-(--mona-sparkline-color) [stroke-linecap:round] [stroke-linejoin:round] [stroke-width:1.5px]";
|
|
31
|
+
const SPARKLINE_AREA_CLASSES = "fill-(--mona-sparkline-color) stroke-none [fill-opacity:0.2]";
|
|
32
|
+
const SPARKLINE_DOT_CLASSES = "fill-none stroke-(--mona-sparkline-color) [stroke-linecap:round] [stroke-width:5px]";
|
|
33
|
+
const SPARKLINE_BAR_CLASSES = {
|
|
34
|
+
negative: "fill-(--mona-sparkline-negative-color)",
|
|
35
|
+
positive: "fill-(--mona-sparkline-color)",
|
|
36
|
+
zero: "fill-muted-foreground forced-colors:fill-[CanvasText]"
|
|
37
|
+
};
|
|
38
|
+
const SPARKLINE_REFERENCE_CLASSES = "fill-none stroke-muted-foreground [stroke-dasharray:3_2] [stroke-width:1px] forced-colors:stroke-[GrayText]";
|
|
39
|
+
const SPARKLINE_BASELINE_CLASSES = "fill-none stroke-border [stroke-width:1px] forced-colors:stroke-[GrayText]";
|
|
40
|
+
const BAR_WIDTH_RATIO = .7;
|
|
41
|
+
const CURVES = {
|
|
42
|
+
linear: curveLinear,
|
|
43
|
+
"monotone-x": curveMonotoneX,
|
|
44
|
+
natural: curveNatural,
|
|
45
|
+
step: curveStep,
|
|
46
|
+
"step-after": curveStepAfter
|
|
47
|
+
};
|
|
48
|
+
const WIN_LOSS_BAR_HEIGHT = 46;
|
|
49
|
+
const WIN_LOSS_TICK_HEIGHT = 8;
|
|
50
|
+
const EMPTY_GEOMETRY = {
|
|
51
|
+
areaPath: "",
|
|
52
|
+
bars: [],
|
|
53
|
+
baselineY: null,
|
|
54
|
+
dotsPath: "",
|
|
55
|
+
linePath: "",
|
|
56
|
+
markersPath: "",
|
|
57
|
+
referenceY: null
|
|
58
|
+
};
|
|
59
|
+
function readSparklineValues(data) {
|
|
60
|
+
return Array.from(data, (value) => typeof value === "number" && Number.isFinite(value) ? value : null);
|
|
61
|
+
}
|
|
62
|
+
function getSparklineStats(values) {
|
|
63
|
+
const finite = values.filter((value) => value !== null);
|
|
64
|
+
if (finite.length === 0) return null;
|
|
65
|
+
return {
|
|
66
|
+
count: finite.length,
|
|
67
|
+
draws: finite.filter((value) => value === 0).length,
|
|
68
|
+
first: finite[0],
|
|
69
|
+
last: finite[finite.length - 1],
|
|
70
|
+
losses: finite.filter((value) => value < 0).length,
|
|
71
|
+
max: Math.max(...finite),
|
|
72
|
+
min: Math.min(...finite),
|
|
73
|
+
wins: finite.filter((value) => value > 0).length
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function computeSparklineGeometry(values, options) {
|
|
77
|
+
const stats = getSparklineStats(values);
|
|
78
|
+
if (!stats) return EMPTY_GEOMETRY;
|
|
79
|
+
if (options.type === "win-loss") return {
|
|
80
|
+
...EMPTY_GEOMETRY,
|
|
81
|
+
bars: getWinLossBars(values)
|
|
82
|
+
};
|
|
83
|
+
const domain = getDomain(stats, options);
|
|
84
|
+
const toY = (value) => round(clamp((domain.high - value) / (domain.high - domain.low) * 100, 0, 100));
|
|
85
|
+
const zero = clamp(0, domain.low, domain.high);
|
|
86
|
+
const referenceY = options.referenceValue != null && Number.isFinite(options.referenceValue) ? toY(options.referenceValue) : null;
|
|
87
|
+
if (options.type === "column") {
|
|
88
|
+
const baselineY = toY(zero);
|
|
89
|
+
return {
|
|
90
|
+
...EMPTY_GEOMETRY,
|
|
91
|
+
bars: getColumnBars(values, toY, baselineY),
|
|
92
|
+
baselineY: domain.low < 0 && domain.high > 0 ? baselineY : null,
|
|
93
|
+
referenceY
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const toX = (index) => values.length === 1 ? 50 : round(index / (values.length - 1) * 100);
|
|
97
|
+
const runs = getRuns(values);
|
|
98
|
+
const point = (index) => `${toX(index)} ${toY(values[index])}`;
|
|
99
|
+
const lines = runs.filter((run) => run.length > 1).map((run) => run.map((index) => [toX(index), toY(values[index])]));
|
|
100
|
+
const curve = CURVES[options.curve] ?? curveLinear;
|
|
101
|
+
const drawLine = line().curve(curve).digits(2);
|
|
102
|
+
const linePath = lines.map((points) => drawLine(points) ?? "").join("");
|
|
103
|
+
const dotsPath = runs.filter((run) => run.length === 1).map((run) => dot(point(run[0]))).join("");
|
|
104
|
+
const drawArea = area().curve(curve).digits(2).y0(toY(zero));
|
|
105
|
+
return {
|
|
106
|
+
areaPath: options.type === "area" ? lines.map((points) => drawArea(points) ?? "").join("") : "",
|
|
107
|
+
bars: [],
|
|
108
|
+
baselineY: null,
|
|
109
|
+
dotsPath,
|
|
110
|
+
linePath,
|
|
111
|
+
markersPath: getMarkedIndices(values, stats, options.markers).map((index) => dot(point(index))).join(""),
|
|
112
|
+
referenceY
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function getDomain(stats, options) {
|
|
116
|
+
const reference = options.referenceValue != null && Number.isFinite(options.referenceValue) ? options.referenceValue : null;
|
|
117
|
+
const lows = [
|
|
118
|
+
stats.min,
|
|
119
|
+
...reference === null ? [] : [reference],
|
|
120
|
+
...options.type === "column" ? [0] : []
|
|
121
|
+
];
|
|
122
|
+
const highs = [
|
|
123
|
+
stats.max,
|
|
124
|
+
...reference === null ? [] : [reference],
|
|
125
|
+
...options.type === "column" ? [0] : []
|
|
126
|
+
];
|
|
127
|
+
let low = options.min != null && Number.isFinite(options.min) ? options.min : Math.min(...lows);
|
|
128
|
+
let high = options.max != null && Number.isFinite(options.max) ? options.max : Math.max(...highs);
|
|
129
|
+
if (low > high) [low, high] = [high, low];
|
|
130
|
+
if (low === high) return {
|
|
131
|
+
high: high + 1,
|
|
132
|
+
low: low - 1
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
high,
|
|
136
|
+
low
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function getColumnBars(values, toY, baselineY) {
|
|
140
|
+
const slot = 100 / values.length;
|
|
141
|
+
const width = round(slot * BAR_WIDTH_RATIO);
|
|
142
|
+
const bars = [];
|
|
143
|
+
values.forEach((value, index) => {
|
|
144
|
+
if (value === null) return;
|
|
145
|
+
const y = toY(value);
|
|
146
|
+
bars.push({
|
|
147
|
+
height: round(Math.abs(baselineY - y)),
|
|
148
|
+
kind: value < 0 ? "negative" : "positive",
|
|
149
|
+
width,
|
|
150
|
+
x: round(index * slot + (slot - width) / 2),
|
|
151
|
+
y: Math.min(y, baselineY)
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
return bars;
|
|
155
|
+
}
|
|
156
|
+
function getWinLossBars(values) {
|
|
157
|
+
const slot = 100 / values.length;
|
|
158
|
+
const width = round(slot * BAR_WIDTH_RATIO);
|
|
159
|
+
const middle = 50;
|
|
160
|
+
const bars = [];
|
|
161
|
+
values.forEach((value, index) => {
|
|
162
|
+
if (value === null) return;
|
|
163
|
+
const x = round(index * slot + (slot - width) / 2);
|
|
164
|
+
if (value > 0) bars.push({
|
|
165
|
+
height: WIN_LOSS_BAR_HEIGHT,
|
|
166
|
+
kind: "positive",
|
|
167
|
+
width,
|
|
168
|
+
x,
|
|
169
|
+
y: 0
|
|
170
|
+
});
|
|
171
|
+
else if (value < 0) bars.push({
|
|
172
|
+
height: WIN_LOSS_BAR_HEIGHT,
|
|
173
|
+
kind: "negative",
|
|
174
|
+
width,
|
|
175
|
+
x,
|
|
176
|
+
y: 54
|
|
177
|
+
});
|
|
178
|
+
else bars.push({
|
|
179
|
+
height: WIN_LOSS_TICK_HEIGHT,
|
|
180
|
+
kind: "zero",
|
|
181
|
+
width,
|
|
182
|
+
x,
|
|
183
|
+
y: middle - WIN_LOSS_TICK_HEIGHT / 2
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
return bars;
|
|
187
|
+
}
|
|
188
|
+
function getMarkedIndices(values, stats, markers) {
|
|
189
|
+
const indices = /* @__PURE__ */ new Set();
|
|
190
|
+
for (const marker of markers) switch (marker) {
|
|
191
|
+
case "first":
|
|
192
|
+
indices.add(values.findIndex((value) => value !== null));
|
|
193
|
+
break;
|
|
194
|
+
case "last": {
|
|
195
|
+
let index = values.length - 1;
|
|
196
|
+
while (values[index] === null) index--;
|
|
197
|
+
indices.add(index);
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case "max":
|
|
201
|
+
indices.add(values.indexOf(stats.max));
|
|
202
|
+
break;
|
|
203
|
+
case "min": indices.add(values.indexOf(stats.min));
|
|
204
|
+
}
|
|
205
|
+
return Array.from(indices).sort((a, b) => a - b);
|
|
206
|
+
}
|
|
207
|
+
function getRuns(values) {
|
|
208
|
+
const runs = [];
|
|
209
|
+
let run = [];
|
|
210
|
+
values.forEach((value, index) => {
|
|
211
|
+
if (value === null) {
|
|
212
|
+
if (run.length > 0) runs.push(run);
|
|
213
|
+
run = [];
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
run.push(index);
|
|
217
|
+
});
|
|
218
|
+
if (run.length > 0) runs.push(run);
|
|
219
|
+
return runs;
|
|
220
|
+
}
|
|
221
|
+
function dot(point) {
|
|
222
|
+
return `M${point}h0`;
|
|
223
|
+
}
|
|
224
|
+
function clamp(value, min, max) {
|
|
225
|
+
return Math.min(Math.max(value, min), max);
|
|
226
|
+
}
|
|
227
|
+
function round(value) {
|
|
228
|
+
return Math.round(value * 100) / 100;
|
|
229
|
+
}
|
|
230
|
+
var SparklineComponent = class SparklineComponent {
|
|
231
|
+
constructor() {
|
|
232
|
+
this.#i18n = inject(MonaI18nService);
|
|
233
|
+
this.#messages = this.#i18n.componentMessages("sparkline", SPARKLINE_DEFAULT_MESSAGES);
|
|
234
|
+
this.#values = computed(() => readSparklineValues(this.data()), ...ngDevMode ? [{ debugName: "#values" }] : /* istanbul ignore next */ []);
|
|
235
|
+
this.accessibleName = computed(() => {
|
|
236
|
+
if (this.decorative()) return null;
|
|
237
|
+
return this.ariaLabel().trim() || this.summary();
|
|
238
|
+
}, ...ngDevMode ? [{ debugName: "accessibleName" }] : /* istanbul ignore next */ []);
|
|
239
|
+
this.areaClass = SPARKLINE_AREA_CLASSES;
|
|
240
|
+
this.barClasses = SPARKLINE_BAR_CLASSES;
|
|
241
|
+
this.baseClass = computed(() => {
|
|
242
|
+
const markers = this.markers().length > 0 && this.type() !== "column" && this.type() !== "win-loss";
|
|
243
|
+
return twMerge(sparklineBaseThemeVariants({ markers }), this.userClass());
|
|
244
|
+
}, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
|
|
245
|
+
this.baselineClass = SPARKLINE_BASELINE_CLASSES;
|
|
246
|
+
this.describedBy = computed(() => {
|
|
247
|
+
if (this.decorative()) return null;
|
|
248
|
+
return [this.ariaDescribedBy().trim(), this.ariaLabel().trim() ? this.descriptionId : ""].filter((id) => id.length > 0).join(" ") || null;
|
|
249
|
+
}, ...ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []);
|
|
250
|
+
this.descriptionId = createElementControlId();
|
|
251
|
+
this.dotClass = SPARKLINE_DOT_CLASSES;
|
|
252
|
+
this.geometry = computed(() => computeSparklineGeometry(this.#values(), {
|
|
253
|
+
curve: this.curve(),
|
|
254
|
+
markers: this.markers(),
|
|
255
|
+
max: this.max(),
|
|
256
|
+
min: this.min(),
|
|
257
|
+
referenceValue: this.referenceValue(),
|
|
258
|
+
type: this.type()
|
|
259
|
+
}), ...ngDevMode ? [{ debugName: "geometry" }] : /* istanbul ignore next */ []);
|
|
260
|
+
this.lineClass = SPARKLINE_LINE_CLASSES;
|
|
261
|
+
this.referenceClass = SPARKLINE_REFERENCE_CLASSES;
|
|
262
|
+
this.showDescription = computed(() => !this.decorative() && this.ariaLabel().trim().length > 0, ...ngDevMode ? [{ debugName: "showDescription" }] : /* istanbul ignore next */ []);
|
|
263
|
+
this.summary = computed(() => {
|
|
264
|
+
const messages = this.#messages();
|
|
265
|
+
const stats = getSparklineStats(this.#values());
|
|
266
|
+
if (!stats) return messages.noData;
|
|
267
|
+
if (this.type() === "win-loss") return messages.winLossSummary(stats.wins, stats.losses, stats.draws);
|
|
268
|
+
const locale = this.#i18n.localeId();
|
|
269
|
+
const options = this.format() ?? void 0;
|
|
270
|
+
const format = (value) => formatNumber(value, locale, options);
|
|
271
|
+
return messages.summary(stats.count, format(stats.first), format(stats.last), format(stats.min), format(stats.max));
|
|
272
|
+
}, ...ngDevMode ? [{ debugName: "summary" }] : /* istanbul ignore next */ []);
|
|
273
|
+
this.svgClass = SPARKLINE_SVG_CLASSES;
|
|
274
|
+
this.ariaDescribedBy = input("", {
|
|
275
|
+
...ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {},
|
|
276
|
+
alias: "aria-describedby"
|
|
277
|
+
});
|
|
278
|
+
this.ariaLabel = input("", {
|
|
279
|
+
...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
|
|
280
|
+
alias: "aria-label"
|
|
281
|
+
});
|
|
282
|
+
this.color = input("", ...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
|
|
283
|
+
this.curve = input("linear", ...ngDevMode ? [{ debugName: "curve" }] : /* istanbul ignore next */ []);
|
|
284
|
+
this.data = input([], ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
285
|
+
this.decorative = input(false, {
|
|
286
|
+
...ngDevMode ? { debugName: "decorative" } : /* istanbul ignore next */ {},
|
|
287
|
+
transform: booleanAttribute
|
|
288
|
+
});
|
|
289
|
+
this.format = input(null, ...ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []);
|
|
290
|
+
this.markers = input([], ...ngDevMode ? [{ debugName: "markers" }] : /* istanbul ignore next */ []);
|
|
291
|
+
this.max = input(null, ...ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []);
|
|
292
|
+
this.min = input(null, ...ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []);
|
|
293
|
+
this.negativeColor = input("", ...ngDevMode ? [{ debugName: "negativeColor" }] : /* istanbul ignore next */ []);
|
|
294
|
+
this.referenceValue = input(null, ...ngDevMode ? [{ debugName: "referenceValue" }] : /* istanbul ignore next */ []);
|
|
295
|
+
this.type = input("line", ...ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []);
|
|
296
|
+
this.userClass = input("", {
|
|
297
|
+
...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
|
|
298
|
+
alias: "class"
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
#i18n;
|
|
302
|
+
#messages;
|
|
303
|
+
#values;
|
|
304
|
+
static {
|
|
305
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
306
|
+
minVersion: "12.0.0",
|
|
307
|
+
version: "22.2.6",
|
|
308
|
+
ngImport: i0,
|
|
309
|
+
type: SparklineComponent,
|
|
310
|
+
deps: [],
|
|
311
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
static {
|
|
315
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
316
|
+
minVersion: "17.0.0",
|
|
317
|
+
version: "22.2.6",
|
|
318
|
+
type: SparklineComponent,
|
|
319
|
+
isStandalone: true,
|
|
320
|
+
selector: "mona-sparkline",
|
|
321
|
+
inputs: {
|
|
322
|
+
ariaDescribedBy: {
|
|
323
|
+
classPropertyName: "ariaDescribedBy",
|
|
324
|
+
publicName: "aria-describedby",
|
|
325
|
+
isSignal: true,
|
|
326
|
+
isRequired: false,
|
|
327
|
+
transformFunction: null
|
|
328
|
+
},
|
|
329
|
+
ariaLabel: {
|
|
330
|
+
classPropertyName: "ariaLabel",
|
|
331
|
+
publicName: "aria-label",
|
|
332
|
+
isSignal: true,
|
|
333
|
+
isRequired: false,
|
|
334
|
+
transformFunction: null
|
|
335
|
+
},
|
|
336
|
+
color: {
|
|
337
|
+
classPropertyName: "color",
|
|
338
|
+
publicName: "color",
|
|
339
|
+
isSignal: true,
|
|
340
|
+
isRequired: false,
|
|
341
|
+
transformFunction: null
|
|
342
|
+
},
|
|
343
|
+
curve: {
|
|
344
|
+
classPropertyName: "curve",
|
|
345
|
+
publicName: "curve",
|
|
346
|
+
isSignal: true,
|
|
347
|
+
isRequired: false,
|
|
348
|
+
transformFunction: null
|
|
349
|
+
},
|
|
350
|
+
data: {
|
|
351
|
+
classPropertyName: "data",
|
|
352
|
+
publicName: "data",
|
|
353
|
+
isSignal: true,
|
|
354
|
+
isRequired: false,
|
|
355
|
+
transformFunction: null
|
|
356
|
+
},
|
|
357
|
+
decorative: {
|
|
358
|
+
classPropertyName: "decorative",
|
|
359
|
+
publicName: "decorative",
|
|
360
|
+
isSignal: true,
|
|
361
|
+
isRequired: false,
|
|
362
|
+
transformFunction: null
|
|
363
|
+
},
|
|
364
|
+
format: {
|
|
365
|
+
classPropertyName: "format",
|
|
366
|
+
publicName: "format",
|
|
367
|
+
isSignal: true,
|
|
368
|
+
isRequired: false,
|
|
369
|
+
transformFunction: null
|
|
370
|
+
},
|
|
371
|
+
markers: {
|
|
372
|
+
classPropertyName: "markers",
|
|
373
|
+
publicName: "markers",
|
|
374
|
+
isSignal: true,
|
|
375
|
+
isRequired: false,
|
|
376
|
+
transformFunction: null
|
|
377
|
+
},
|
|
378
|
+
max: {
|
|
379
|
+
classPropertyName: "max",
|
|
380
|
+
publicName: "max",
|
|
381
|
+
isSignal: true,
|
|
382
|
+
isRequired: false,
|
|
383
|
+
transformFunction: null
|
|
384
|
+
},
|
|
385
|
+
min: {
|
|
386
|
+
classPropertyName: "min",
|
|
387
|
+
publicName: "min",
|
|
388
|
+
isSignal: true,
|
|
389
|
+
isRequired: false,
|
|
390
|
+
transformFunction: null
|
|
391
|
+
},
|
|
392
|
+
negativeColor: {
|
|
393
|
+
classPropertyName: "negativeColor",
|
|
394
|
+
publicName: "negativeColor",
|
|
395
|
+
isSignal: true,
|
|
396
|
+
isRequired: false,
|
|
397
|
+
transformFunction: null
|
|
398
|
+
},
|
|
399
|
+
referenceValue: {
|
|
400
|
+
classPropertyName: "referenceValue",
|
|
401
|
+
publicName: "referenceValue",
|
|
402
|
+
isSignal: true,
|
|
403
|
+
isRequired: false,
|
|
404
|
+
transformFunction: null
|
|
405
|
+
},
|
|
406
|
+
type: {
|
|
407
|
+
classPropertyName: "type",
|
|
408
|
+
publicName: "type",
|
|
409
|
+
isSignal: true,
|
|
410
|
+
isRequired: false,
|
|
411
|
+
transformFunction: null
|
|
412
|
+
},
|
|
413
|
+
userClass: {
|
|
414
|
+
classPropertyName: "userClass",
|
|
415
|
+
publicName: "class",
|
|
416
|
+
isSignal: true,
|
|
417
|
+
isRequired: false,
|
|
418
|
+
transformFunction: null
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
host: { properties: {
|
|
422
|
+
"attr.aria-describedby": "describedBy()",
|
|
423
|
+
"attr.aria-hidden": "decorative() || null",
|
|
424
|
+
"attr.aria-label": "accessibleName()",
|
|
425
|
+
"attr.role": "decorative() ? null : 'img'",
|
|
426
|
+
"class": "baseClass()",
|
|
427
|
+
"style.--mona-sparkline-color": "color() || null",
|
|
428
|
+
"style.--mona-sparkline-negative-color": "negativeColor() || null"
|
|
429
|
+
} },
|
|
430
|
+
ngImport: i0,
|
|
431
|
+
template: "@let shape = geometry();\n<svg aria-hidden=\"true\" focusable=\"false\" preserveAspectRatio=\"none\" viewBox=\"0 0 100 100\" [class]=\"svgClass\">\n @if (shape.baselineY !== null) {\n <line\n vector-effect=\"non-scaling-stroke\"\n x1=\"0\"\n x2=\"100\"\n [attr.y1]=\"shape.baselineY\"\n [attr.y2]=\"shape.baselineY\"\n [class]=\"baselineClass\" />\n }\n @if (shape.referenceY !== null) {\n <line\n vector-effect=\"non-scaling-stroke\"\n x1=\"0\"\n x2=\"100\"\n [attr.y1]=\"shape.referenceY\"\n [attr.y2]=\"shape.referenceY\"\n [class]=\"referenceClass\" />\n }\n @for (bar of shape.bars; track $index) {\n <rect\n [attr.height]=\"bar.height\"\n [attr.width]=\"bar.width\"\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [class]=\"barClasses[bar.kind]\" />\n }\n @if (shape.areaPath) {\n <path [attr.d]=\"shape.areaPath\" [class]=\"areaClass\" />\n }\n @if (shape.linePath) {\n <path vector-effect=\"non-scaling-stroke\" [attr.d]=\"shape.linePath\" [class]=\"lineClass\" />\n }\n @if (shape.dotsPath) {\n <path vector-effect=\"non-scaling-stroke\" [attr.d]=\"shape.dotsPath\" [class]=\"dotClass\" />\n }\n @if (shape.markersPath) {\n <path vector-effect=\"non-scaling-stroke\" [attr.d]=\"shape.markersPath\" [class]=\"dotClass\" />\n }\n</svg>\n@if (showDescription()) {\n <span hidden [id]=\"descriptionId\">{{ summary() }}</span>\n}\n"
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
436
|
+
minVersion: "12.0.0",
|
|
437
|
+
version: "22.2.6",
|
|
438
|
+
ngImport: i0,
|
|
439
|
+
type: SparklineComponent,
|
|
440
|
+
decorators: [{
|
|
441
|
+
type: Component,
|
|
442
|
+
args: [{
|
|
443
|
+
selector: "mona-sparkline",
|
|
444
|
+
host: {
|
|
445
|
+
"[attr.aria-describedby]": "describedBy()",
|
|
446
|
+
"[attr.aria-hidden]": "decorative() || null",
|
|
447
|
+
"[attr.aria-label]": "accessibleName()",
|
|
448
|
+
"[attr.role]": "decorative() ? null : 'img'",
|
|
449
|
+
"[class]": "baseClass()",
|
|
450
|
+
"[style.--mona-sparkline-color]": "color() || null",
|
|
451
|
+
"[style.--mona-sparkline-negative-color]": "negativeColor() || null"
|
|
452
|
+
},
|
|
453
|
+
template: "@let shape = geometry();\n<svg aria-hidden=\"true\" focusable=\"false\" preserveAspectRatio=\"none\" viewBox=\"0 0 100 100\" [class]=\"svgClass\">\n @if (shape.baselineY !== null) {\n <line\n vector-effect=\"non-scaling-stroke\"\n x1=\"0\"\n x2=\"100\"\n [attr.y1]=\"shape.baselineY\"\n [attr.y2]=\"shape.baselineY\"\n [class]=\"baselineClass\" />\n }\n @if (shape.referenceY !== null) {\n <line\n vector-effect=\"non-scaling-stroke\"\n x1=\"0\"\n x2=\"100\"\n [attr.y1]=\"shape.referenceY\"\n [attr.y2]=\"shape.referenceY\"\n [class]=\"referenceClass\" />\n }\n @for (bar of shape.bars; track $index) {\n <rect\n [attr.height]=\"bar.height\"\n [attr.width]=\"bar.width\"\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [class]=\"barClasses[bar.kind]\" />\n }\n @if (shape.areaPath) {\n <path [attr.d]=\"shape.areaPath\" [class]=\"areaClass\" />\n }\n @if (shape.linePath) {\n <path vector-effect=\"non-scaling-stroke\" [attr.d]=\"shape.linePath\" [class]=\"lineClass\" />\n }\n @if (shape.dotsPath) {\n <path vector-effect=\"non-scaling-stroke\" [attr.d]=\"shape.dotsPath\" [class]=\"dotClass\" />\n }\n @if (shape.markersPath) {\n <path vector-effect=\"non-scaling-stroke\" [attr.d]=\"shape.markersPath\" [class]=\"dotClass\" />\n }\n</svg>\n@if (showDescription()) {\n <span hidden [id]=\"descriptionId\">{{ summary() }}</span>\n}\n"
|
|
454
|
+
}]
|
|
455
|
+
}],
|
|
456
|
+
propDecorators: {
|
|
457
|
+
ariaDescribedBy: [{
|
|
458
|
+
type: i0.Input,
|
|
459
|
+
args: [{
|
|
460
|
+
isSignal: true,
|
|
461
|
+
alias: "aria-describedby",
|
|
462
|
+
required: false
|
|
463
|
+
}]
|
|
464
|
+
}],
|
|
465
|
+
ariaLabel: [{
|
|
466
|
+
type: i0.Input,
|
|
467
|
+
args: [{
|
|
468
|
+
isSignal: true,
|
|
469
|
+
alias: "aria-label",
|
|
470
|
+
required: false
|
|
471
|
+
}]
|
|
472
|
+
}],
|
|
473
|
+
color: [{
|
|
474
|
+
type: i0.Input,
|
|
475
|
+
args: [{
|
|
476
|
+
isSignal: true,
|
|
477
|
+
alias: "color",
|
|
478
|
+
required: false
|
|
479
|
+
}]
|
|
480
|
+
}],
|
|
481
|
+
curve: [{
|
|
482
|
+
type: i0.Input,
|
|
483
|
+
args: [{
|
|
484
|
+
isSignal: true,
|
|
485
|
+
alias: "curve",
|
|
486
|
+
required: false
|
|
487
|
+
}]
|
|
488
|
+
}],
|
|
489
|
+
data: [{
|
|
490
|
+
type: i0.Input,
|
|
491
|
+
args: [{
|
|
492
|
+
isSignal: true,
|
|
493
|
+
alias: "data",
|
|
494
|
+
required: false
|
|
495
|
+
}]
|
|
496
|
+
}],
|
|
497
|
+
decorative: [{
|
|
498
|
+
type: i0.Input,
|
|
499
|
+
args: [{
|
|
500
|
+
isSignal: true,
|
|
501
|
+
alias: "decorative",
|
|
502
|
+
required: false
|
|
503
|
+
}]
|
|
504
|
+
}],
|
|
505
|
+
format: [{
|
|
506
|
+
type: i0.Input,
|
|
507
|
+
args: [{
|
|
508
|
+
isSignal: true,
|
|
509
|
+
alias: "format",
|
|
510
|
+
required: false
|
|
511
|
+
}]
|
|
512
|
+
}],
|
|
513
|
+
markers: [{
|
|
514
|
+
type: i0.Input,
|
|
515
|
+
args: [{
|
|
516
|
+
isSignal: true,
|
|
517
|
+
alias: "markers",
|
|
518
|
+
required: false
|
|
519
|
+
}]
|
|
520
|
+
}],
|
|
521
|
+
max: [{
|
|
522
|
+
type: i0.Input,
|
|
523
|
+
args: [{
|
|
524
|
+
isSignal: true,
|
|
525
|
+
alias: "max",
|
|
526
|
+
required: false
|
|
527
|
+
}]
|
|
528
|
+
}],
|
|
529
|
+
min: [{
|
|
530
|
+
type: i0.Input,
|
|
531
|
+
args: [{
|
|
532
|
+
isSignal: true,
|
|
533
|
+
alias: "min",
|
|
534
|
+
required: false
|
|
535
|
+
}]
|
|
536
|
+
}],
|
|
537
|
+
negativeColor: [{
|
|
538
|
+
type: i0.Input,
|
|
539
|
+
args: [{
|
|
540
|
+
isSignal: true,
|
|
541
|
+
alias: "negativeColor",
|
|
542
|
+
required: false
|
|
543
|
+
}]
|
|
544
|
+
}],
|
|
545
|
+
referenceValue: [{
|
|
546
|
+
type: i0.Input,
|
|
547
|
+
args: [{
|
|
548
|
+
isSignal: true,
|
|
549
|
+
alias: "referenceValue",
|
|
550
|
+
required: false
|
|
551
|
+
}]
|
|
552
|
+
}],
|
|
553
|
+
type: [{
|
|
554
|
+
type: i0.Input,
|
|
555
|
+
args: [{
|
|
556
|
+
isSignal: true,
|
|
557
|
+
alias: "type",
|
|
558
|
+
required: false
|
|
559
|
+
}]
|
|
560
|
+
}],
|
|
561
|
+
userClass: [{
|
|
562
|
+
type: i0.Input,
|
|
563
|
+
args: [{
|
|
564
|
+
isSignal: true,
|
|
565
|
+
alias: "class",
|
|
566
|
+
required: false
|
|
567
|
+
}]
|
|
568
|
+
}]
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
export { SPARKLINE_DEFAULT_MESSAGES, SparklineComponent };
|
|
572
|
+
|
|
573
|
+
//# sourceMappingURL=nanahoshi-mona-ui-sparkline.mjs.map
|
|
@@ -562,6 +562,11 @@
|
|
|
562
562
|
"itemMoved": "{item} moved to position {position} of {total}",
|
|
563
563
|
"itemMovedToList": "{item} moved to {list}, position {position} of {total}"
|
|
564
564
|
},
|
|
565
|
+
"sparkline": {
|
|
566
|
+
"noData": "No data",
|
|
567
|
+
"summary": "{count, plural, =1 {# value} other {# values}}, first {first}, last {last}, lowest {min}, highest {max}",
|
|
568
|
+
"winLossSummary": "{wins, plural, =1 {# win} other {# wins}}, {losses, plural, =1 {# loss} other {# losses}}, {draws, plural, =1 {# draw} other {# draws}}"
|
|
569
|
+
},
|
|
565
570
|
"spinner": {
|
|
566
571
|
"cancel": "Cancel",
|
|
567
572
|
"loading": "Loading"
|
package/llms.txt
CHANGED
|
@@ -120,6 +120,7 @@ Mona UI is an Angular component library styled with Tailwind CSS 4. Its componen
|
|
|
120
120
|
- [Treemap](docs/chart-treemap.md): A treemap series that tiles hierarchical data by value.
|
|
121
121
|
- [Radar & Polar](docs/chart-radar.md): Radar and polar series on angular and radial axes, for comparing metrics or directions.
|
|
122
122
|
- [Radial](docs/chart-radial.md): Radial bar, rose and gauge series that draw values as arcs around a center.
|
|
123
|
+
- [Sparkline](docs/sparkline.md): A word-sized line, area, column or win-loss chart, for a table cell or a line of text.
|
|
123
124
|
|
|
124
125
|
## Navigation
|
|
125
126
|
|
|
@@ -202,7 +203,7 @@ Mona UI is an Angular component library styled with Tailwind CSS 4. Its componen
|
|
|
202
203
|
- [`@nanahoshi/mona-ui/filter`](docs/api/filter.md): 7 exports, in full.
|
|
203
204
|
- [`@nanahoshi/mona-ui/form-field`](docs/api/form-field.md): 6 exports, in full.
|
|
204
205
|
- [`@nanahoshi/mona-ui/grid`](docs/api/grid.md): 97 exports, in full.
|
|
205
|
-
- [`@nanahoshi/mona-ui/i18n`](docs/api/i18n.md):
|
|
206
|
+
- [`@nanahoshi/mona-ui/i18n`](docs/api/i18n.md): 121 exports, in full.
|
|
206
207
|
- [`@nanahoshi/mona-ui/kanban`](docs/api/kanban.md): 10 exports, in full.
|
|
207
208
|
- [`@nanahoshi/mona-ui/label`](docs/api/label.md): 4 exports, in full.
|
|
208
209
|
- [`@nanahoshi/mona-ui/list`](docs/api/list.md): 10 exports, in full.
|
|
@@ -234,6 +235,7 @@ Mona UI is an Angular component library styled with Tailwind CSS 4. Its componen
|
|
|
234
235
|
- [`@nanahoshi/mona-ui/skeleton`](docs/api/skeleton.md): 1 export, in full.
|
|
235
236
|
- [`@nanahoshi/mona-ui/slider`](docs/api/slider.md): 8 exports, in full.
|
|
236
237
|
- [`@nanahoshi/mona-ui/sortable`](docs/api/sortable.md): 10 exports, in full.
|
|
238
|
+
- [`@nanahoshi/mona-ui/sparkline`](docs/api/sparkline.md): 5 exports, in full.
|
|
237
239
|
- [`@nanahoshi/mona-ui/spinner`](docs/api/spinner.md): 9 exports, in full.
|
|
238
240
|
- [`@nanahoshi/mona-ui/split-button`](docs/api/split-button.md): 14 exports, in full.
|
|
239
241
|
- [`@nanahoshi/mona-ui/splitter`](docs/api/splitter.md): 3 exports, in full.
|
|
@@ -562,6 +562,11 @@
|
|
|
562
562
|
"itemMoved": "تم نقل {item} إلى الموضع {position} من {total}",
|
|
563
563
|
"itemMovedToList": "تم نقل {item} إلى {list}، الموضع {position} من {total}"
|
|
564
564
|
},
|
|
565
|
+
"sparkline": {
|
|
566
|
+
"noData": "لا توجد بيانات",
|
|
567
|
+
"summary": "عدد القيم: {count}، الأولى {first}، الأخيرة {last}، الأدنى {min}، الأعلى {max}",
|
|
568
|
+
"winLossSummary": "الفوز: {wins}، الخسارة: {losses}، التعادل: {draws}"
|
|
569
|
+
},
|
|
565
570
|
"spinner": {
|
|
566
571
|
"cancel": "إلغاء",
|
|
567
572
|
"loading": "جارٍ التحميل"
|
|
@@ -562,6 +562,11 @@
|
|
|
562
562
|
"itemMoved": "{item} an Position {position} von {total} verschoben",
|
|
563
563
|
"itemMovedToList": "{item} nach {list} verschoben, Position {position} von {total}"
|
|
564
564
|
},
|
|
565
|
+
"sparkline": {
|
|
566
|
+
"noData": "Keine Daten",
|
|
567
|
+
"summary": "{count, plural, =1 {# Wert} other {# Werte}}, erster {first}, letzter {last}, niedrigster {min}, höchster {max}",
|
|
568
|
+
"winLossSummary": "{wins, plural, =1 {# Sieg} other {# Siege}}, {losses, plural, =1 {# Niederlage} other {# Niederlagen}}, {draws, plural, =1 {# Unentschieden} other {# Unentschieden}}"
|
|
569
|
+
},
|
|
565
570
|
"spinner": {
|
|
566
571
|
"cancel": "Abbrechen",
|
|
567
572
|
"loading": "Wird geladen"
|
|
@@ -562,6 +562,11 @@
|
|
|
562
562
|
"itemMoved": "{item} ahora está en la posición {position} de {total}",
|
|
563
563
|
"itemMovedToList": "{item} ahora está en {list}, posición {position} de {total}"
|
|
564
564
|
},
|
|
565
|
+
"sparkline": {
|
|
566
|
+
"noData": "No hay datos",
|
|
567
|
+
"summary": "{count, plural, =1 {# valor} other {# valores}}, primero {first}, último {last}, mínimo {min}, máximo {max}",
|
|
568
|
+
"winLossSummary": "{wins, plural, =1 {# victoria} other {# victorias}}, {losses, plural, =1 {# derrota} other {# derrotas}}, {draws, plural, =1 {# empate} other {# empates}}"
|
|
569
|
+
},
|
|
565
570
|
"spinner": {
|
|
566
571
|
"cancel": "Cancelar",
|
|
567
572
|
"loading": "Cargando"
|
|
@@ -562,6 +562,11 @@
|
|
|
562
562
|
"itemMoved": "{item} est maintenant en position {position} sur {total}",
|
|
563
563
|
"itemMovedToList": "{item} est maintenant dans {list}, à la position {position} sur {total}"
|
|
564
564
|
},
|
|
565
|
+
"sparkline": {
|
|
566
|
+
"noData": "Aucune donnée",
|
|
567
|
+
"summary": "{count, plural, =1 {# valeur} other {# valeurs}}, première {first}, dernière {last}, minimum {min}, maximum {max}",
|
|
568
|
+
"winLossSummary": "{wins, plural, =1 {# victoire} other {# victoires}}, {losses, plural, =1 {# défaite} other {# défaites}}, {draws, plural, =1 {# match nul} other {# matchs nuls}}"
|
|
569
|
+
},
|
|
565
570
|
"spinner": {
|
|
566
571
|
"cancel": "Annuler",
|
|
567
572
|
"loading": "Chargement"
|
|
@@ -562,6 +562,11 @@
|
|
|
562
562
|
"itemMoved": "{item} dipindahkan ke posisi {position} dari {total}",
|
|
563
563
|
"itemMovedToList": "{item} dipindahkan ke {list}, posisi {position} dari {total}"
|
|
564
564
|
},
|
|
565
|
+
"sparkline": {
|
|
566
|
+
"noData": "Tidak ada data",
|
|
567
|
+
"summary": "{count} nilai, pertama {first}, terakhir {last}, terendah {min}, tertinggi {max}",
|
|
568
|
+
"winLossSummary": "{wins} menang, {losses} kalah, {draws} seri"
|
|
569
|
+
},
|
|
565
570
|
"spinner": {
|
|
566
571
|
"cancel": "Batal",
|
|
567
572
|
"loading": "Memuat"
|