@ai-matrx/design-system 0.49.54 → 0.49.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/data-table/copy-helpers.d.cts +2 -2
- package/dist/data-table/copy-helpers.d.ts +2 -2
- package/dist/data-table/drill-chart.cjs +44 -6
- package/dist/data-table/drill-chart.cjs.map +1 -1
- package/dist/data-table/drill-chart.d.cts +8 -3
- package/dist/data-table/drill-chart.d.ts +8 -3
- package/dist/data-table/drill-chart.js +44 -6
- package/dist/data-table/drill-chart.js.map +1 -1
- package/dist/data-table/filter-engine.d.cts +2 -2
- package/dist/data-table/filter-engine.d.ts +2 -2
- package/dist/data-table/host.d.cts +2 -2
- package/dist/data-table/host.d.ts +2 -2
- package/dist/data-table/index.cjs +116 -40
- package/dist/data-table/index.cjs.map +1 -1
- package/dist/data-table/index.d.cts +28 -6
- package/dist/data-table/index.d.ts +28 -6
- package/dist/data-table/index.js +116 -40
- package/dist/data-table/index.js.map +1 -1
- package/dist/data-table/infer-filter.d.cts +2 -2
- package/dist/data-table/infer-filter.d.ts +2 -2
- package/dist/data-table/layered-filters.d.cts +2 -2
- package/dist/data-table/layered-filters.d.ts +2 -2
- package/dist/data-table/query-control.d.cts +2 -2
- package/dist/data-table/query-control.d.ts +2 -2
- package/dist/data-table/types.d.cts +2 -2
- package/dist/data-table/types.d.ts +2 -2
- package/dist/data-table/url-state.d.cts +2 -2
- package/dist/data-table/url-state.d.ts +2 -2
- package/dist/data-table/xlsx.d.cts +2 -2
- package/dist/data-table/xlsx.d.ts +2 -2
- package/dist/{drill-cISpem5b.d.cts → drill-qJ5gHL2F.d.cts} +11 -0
- package/dist/{drill-cISpem5b.d.ts → drill-qJ5gHL2F.d.ts} +11 -0
- package/dist/{layered-filters-ma_P0GDG.d.ts → layered-filters-CTdPPgxf.d.ts} +1 -1
- package/dist/{layered-filters-RHe2Kzrs.d.cts → layered-filters-HFquDviC.d.cts} +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { M as MatrxDrillDimension, a as MatrxDrillMeasure, b as MatrxDrillQuestion, c as MatrxDrillChartAnswers } from '../drill-
|
|
4
|
-
export { d as MATRX_DRILL_CHART_CEILING, e as MATRX_DRILL_CHART_OTHER, f as MATRX_DRILL_CHART_SERIES_LIMIT, g as MatrxDrillChartContext, h as MatrxDrillChartData, i as MatrxDrillChartPeriod, j as MatrxDrillChartPlan, k as MatrxDrillChartRequest, l as MatrxDrillChartRequestKey, m as MatrxDrillChartRow, n as MatrxDrillChartSeries, o as drillChartCellsQuestion, p as drillChartData, q as drillChartDrill, r as drillChartNarrowToPeriod, s as drillChartQuestions, t as drillChartSeriesKey } from '../drill-
|
|
3
|
+
import { M as MatrxDrillDimension, a as MatrxDrillMeasure, b as MatrxDrillQuestion, c as MatrxDrillChartAnswers } from '../drill-qJ5gHL2F.cjs';
|
|
4
|
+
export { d as MATRX_DRILL_CHART_CEILING, e as MATRX_DRILL_CHART_OTHER, f as MATRX_DRILL_CHART_SERIES_LIMIT, g as MatrxDrillChartContext, h as MatrxDrillChartData, i as MatrxDrillChartPeriod, j as MatrxDrillChartPlan, k as MatrxDrillChartRequest, l as MatrxDrillChartRequestKey, m as MatrxDrillChartRow, n as MatrxDrillChartSeries, o as drillChartCellsQuestion, p as drillChartData, q as drillChartDrill, r as drillChartNarrowToPeriod, s as drillChartQuestions, t as drillChartSeriesKey } from '../drill-qJ5gHL2F.cjs';
|
|
5
5
|
|
|
6
6
|
interface MatrxDrillChartProps {
|
|
7
7
|
dimensions: readonly MatrxDrillDimension[];
|
|
@@ -15,6 +15,11 @@ interface MatrxDrillChartProps {
|
|
|
15
15
|
seriesLimit?: number | undefined;
|
|
16
16
|
/** The Measure stacked. Default: the question's first shown Measure. */
|
|
17
17
|
measure?: string | null | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* STACK THESE MEASURES instead (two or more that add up, e.g. input and output tokens): one series
|
|
20
|
+
* each, no split; a segment click narrows to its period (lane DRILL-FLIP-FIXES L3).
|
|
21
|
+
*/
|
|
22
|
+
stack?: readonly string[] | null | undefined;
|
|
18
23
|
/** The time reference when the question does not group by time. */
|
|
19
24
|
time?: string | null | undefined;
|
|
20
25
|
/** The store's page ceiling, when the host knows it is not 1000. */
|
|
@@ -39,6 +44,6 @@ interface MatrxDrillChartProps {
|
|
|
39
44
|
* A long formatted value ("28,000,000 points") was clipped to ",000,000 points" (lane DRILL-ADOPT walk).
|
|
40
45
|
*/
|
|
41
46
|
declare function drillChartAxisNumber(measure: MatrxDrillMeasure | undefined, value: number): string;
|
|
42
|
-
declare function MatrxDrillChart({ dimensions, measures, question, onQuestionChange, answers, seriesLimit, measure: measureKey, time, ceiling, paths, error, emptyLabel, height, width, note, className, }: MatrxDrillChartProps): React.JSX.Element;
|
|
47
|
+
declare function MatrxDrillChart({ dimensions, measures, question, onQuestionChange, answers, seriesLimit, measure: measureKey, stack, time, ceiling, paths, error, emptyLabel, height, width, note, className, }: MatrxDrillChartProps): React.JSX.Element;
|
|
43
48
|
|
|
44
49
|
export { MatrxDrillChart, MatrxDrillChartAnswers, type MatrxDrillChartProps, drillChartAxisNumber };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { M as MatrxDrillDimension, a as MatrxDrillMeasure, b as MatrxDrillQuestion, c as MatrxDrillChartAnswers } from '../drill-
|
|
4
|
-
export { d as MATRX_DRILL_CHART_CEILING, e as MATRX_DRILL_CHART_OTHER, f as MATRX_DRILL_CHART_SERIES_LIMIT, g as MatrxDrillChartContext, h as MatrxDrillChartData, i as MatrxDrillChartPeriod, j as MatrxDrillChartPlan, k as MatrxDrillChartRequest, l as MatrxDrillChartRequestKey, m as MatrxDrillChartRow, n as MatrxDrillChartSeries, o as drillChartCellsQuestion, p as drillChartData, q as drillChartDrill, r as drillChartNarrowToPeriod, s as drillChartQuestions, t as drillChartSeriesKey } from '../drill-
|
|
3
|
+
import { M as MatrxDrillDimension, a as MatrxDrillMeasure, b as MatrxDrillQuestion, c as MatrxDrillChartAnswers } from '../drill-qJ5gHL2F.js';
|
|
4
|
+
export { d as MATRX_DRILL_CHART_CEILING, e as MATRX_DRILL_CHART_OTHER, f as MATRX_DRILL_CHART_SERIES_LIMIT, g as MatrxDrillChartContext, h as MatrxDrillChartData, i as MatrxDrillChartPeriod, j as MatrxDrillChartPlan, k as MatrxDrillChartRequest, l as MatrxDrillChartRequestKey, m as MatrxDrillChartRow, n as MatrxDrillChartSeries, o as drillChartCellsQuestion, p as drillChartData, q as drillChartDrill, r as drillChartNarrowToPeriod, s as drillChartQuestions, t as drillChartSeriesKey } from '../drill-qJ5gHL2F.js';
|
|
5
5
|
|
|
6
6
|
interface MatrxDrillChartProps {
|
|
7
7
|
dimensions: readonly MatrxDrillDimension[];
|
|
@@ -15,6 +15,11 @@ interface MatrxDrillChartProps {
|
|
|
15
15
|
seriesLimit?: number | undefined;
|
|
16
16
|
/** The Measure stacked. Default: the question's first shown Measure. */
|
|
17
17
|
measure?: string | null | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* STACK THESE MEASURES instead (two or more that add up, e.g. input and output tokens): one series
|
|
20
|
+
* each, no split; a segment click narrows to its period (lane DRILL-FLIP-FIXES L3).
|
|
21
|
+
*/
|
|
22
|
+
stack?: readonly string[] | null | undefined;
|
|
18
23
|
/** The time reference when the question does not group by time. */
|
|
19
24
|
time?: string | null | undefined;
|
|
20
25
|
/** The store's page ceiling, when the host knows it is not 1000. */
|
|
@@ -39,6 +44,6 @@ interface MatrxDrillChartProps {
|
|
|
39
44
|
* A long formatted value ("28,000,000 points") was clipped to ",000,000 points" (lane DRILL-ADOPT walk).
|
|
40
45
|
*/
|
|
41
46
|
declare function drillChartAxisNumber(measure: MatrxDrillMeasure | undefined, value: number): string;
|
|
42
|
-
declare function MatrxDrillChart({ dimensions, measures, question, onQuestionChange, answers, seriesLimit, measure: measureKey, time, ceiling, paths, error, emptyLabel, height, width, note, className, }: MatrxDrillChartProps): React.JSX.Element;
|
|
47
|
+
declare function MatrxDrillChart({ dimensions, measures, question, onQuestionChange, answers, seriesLimit, measure: measureKey, stack, time, ceiling, paths, error, emptyLabel, height, width, note, className, }: MatrxDrillChartProps): React.JSX.Element;
|
|
43
48
|
|
|
44
49
|
export { MatrxDrillChart, MatrxDrillChartAnswers, type MatrxDrillChartProps, drillChartAxisNumber };
|
|
@@ -267,9 +267,16 @@ function drillChartQuestions(question, seriesLimit = MATRX_DRILL_CHART_SERIES_LI
|
|
|
267
267
|
const timeInBy = question.by.find((ref) => parseDimensionRef(ref).grain !== null);
|
|
268
268
|
const firstTime = context.dimensions.find((d) => d.kind === "time");
|
|
269
269
|
const time = timeInBy ?? context.time ?? (firstTime ? `${firstTime.key}:${drillAutoGrain(question.window ?? null, context.now, firstTime.grains ?? MATRX_DRILL_DEFAULT_GRAINS)}` : null);
|
|
270
|
-
const
|
|
270
|
+
const stack = context.stack && context.stack.length >= 2 ? [...context.stack] : null;
|
|
271
|
+
const split = stack ? null : question.by.find((ref) => parseDimensionRef(ref).grain === null && dimensionFor(context.dimensions, ref)?.kind !== "time") ?? null;
|
|
271
272
|
const refuse = (sentence) => ({ ...base, time, split, refused: sentence, first: [], periodsHint: null });
|
|
272
273
|
if (!time) return refuse("This answer has no time to chart it over.");
|
|
274
|
+
if (stack) {
|
|
275
|
+
const missing = stack.find((k) => !context.measures.some((m) => m.key === k));
|
|
276
|
+
if (missing) return refuse(`There is no Measure "${missing}" to chart.`);
|
|
277
|
+
const loose = stack.map((k) => context.measures.find((m) => m.key === k)).find((m) => !m.additive || m.moment);
|
|
278
|
+
if (loose) return refuse(`${loose.label} does not add up, so it cannot be stacked.`);
|
|
279
|
+
}
|
|
273
280
|
if (!measure) return refuse(`There is no Measure "${measureKey}" to chart.`);
|
|
274
281
|
if (split && !measure.additive) {
|
|
275
282
|
return refuse(
|
|
@@ -282,13 +289,13 @@ function drillChartQuestions(question, seriesLimit = MATRX_DRILL_CHART_SERIES_LI
|
|
|
282
289
|
const periodsHint = Number.isFinite(days) && days > 0 ? Math.ceil(days / GRAIN_DAYS[grain]) + 1 : null;
|
|
283
290
|
const where = trailWhere(question);
|
|
284
291
|
const window = question.window ?? null;
|
|
285
|
-
const show = [measureKey];
|
|
292
|
+
const show = stack ?? [measureKey];
|
|
286
293
|
const first = [];
|
|
287
294
|
if (split) {
|
|
288
295
|
first.push({ key: "series", by: [split], where, show, sort: { key: measureKey, direction: "desc" }, limit, window });
|
|
289
296
|
}
|
|
290
297
|
first.push({ key: "periods", by: [time], where, show, sort: null, limit: periodsHint ? clampLimit(periodsHint, ceiling) : null, window });
|
|
291
|
-
return { ...base, time, split, refused: null, first, periodsHint };
|
|
298
|
+
return { ...base, ...stack ? { measure: stack[0], stack } : {}, time, split, refused: null, first, periodsHint };
|
|
292
299
|
}
|
|
293
300
|
function drillChartCellsQuestion(plan, question, series) {
|
|
294
301
|
if (plan.refused || !plan.split || !plan.time) return null;
|
|
@@ -362,6 +369,35 @@ function drillChartData(plan, answers, dimensions, measures, emptyLabel = "No va
|
|
|
362
369
|
values: {}
|
|
363
370
|
};
|
|
364
371
|
});
|
|
372
|
+
if (plan.stack) {
|
|
373
|
+
const keys = plan.stack;
|
|
374
|
+
const readOf = (row, k) => {
|
|
375
|
+
const v = row?.measures[k];
|
|
376
|
+
return v === null || v === void 0 ? null : v;
|
|
377
|
+
};
|
|
378
|
+
const totalRow = periodRows.find((r) => rowKind(r) === "total");
|
|
379
|
+
for (const [i, p] of periodBase.entries()) {
|
|
380
|
+
const row = groups[i];
|
|
381
|
+
let sum = null;
|
|
382
|
+
for (const k of keys) {
|
|
383
|
+
const v = readOf(row, k);
|
|
384
|
+
p.values[`m:${k}`] = v;
|
|
385
|
+
if (v !== null) sum = (sum ?? 0) + v;
|
|
386
|
+
}
|
|
387
|
+
p.total = sum;
|
|
388
|
+
}
|
|
389
|
+
const totals = keys.map((k) => readOf(totalRow, k));
|
|
390
|
+
const total = totals.every((t) => t === null) ? null : totals.reduce((a, t) => a + (t ?? 0), 0);
|
|
391
|
+
return {
|
|
392
|
+
time,
|
|
393
|
+
split: null,
|
|
394
|
+
measure: m,
|
|
395
|
+
series: keys.map((k, i) => ({ key: `m:${k}`, value: null, label: measures.find((x) => x.key === k)?.label ?? k, other: false, total: totals[i] ?? null })),
|
|
396
|
+
periods: periodBase,
|
|
397
|
+
total,
|
|
398
|
+
says
|
|
399
|
+
};
|
|
400
|
+
}
|
|
365
401
|
if (!split) {
|
|
366
402
|
const key = "all";
|
|
367
403
|
for (const p of periodBase) p.values[key] = p.total;
|
|
@@ -488,6 +524,7 @@ function MatrxDrillChart({
|
|
|
488
524
|
answers,
|
|
489
525
|
seriesLimit = MATRX_DRILL_CHART_SERIES_LIMIT,
|
|
490
526
|
measure: measureKey,
|
|
527
|
+
stack,
|
|
491
528
|
time,
|
|
492
529
|
ceiling,
|
|
493
530
|
paths = NO_PATHS,
|
|
@@ -499,8 +536,8 @@ function MatrxDrillChart({
|
|
|
499
536
|
className
|
|
500
537
|
}) {
|
|
501
538
|
const plan = useMemo(
|
|
502
|
-
() => drillChartQuestions(question, seriesLimit, { dimensions, measures, measure: measureKey, time, ceiling }),
|
|
503
|
-
[question, seriesLimit, dimensions, measures, measureKey, time, ceiling]
|
|
539
|
+
() => drillChartQuestions(question, seriesLimit, { dimensions, measures, measure: measureKey, stack, time, ceiling }),
|
|
540
|
+
[question, seriesLimit, dimensions, measures, measureKey, stack, time, ceiling]
|
|
504
541
|
);
|
|
505
542
|
const data = useMemo(() => drillChartData(plan, answers, dimensions, measures, emptyLabel), [plan, answers, dimensions, measures, emptyLabel]);
|
|
506
543
|
const measure = measures.find((m) => m.key === plan.measure);
|
|
@@ -508,7 +545,8 @@ function MatrxDrillChart({
|
|
|
508
545
|
const [hover, setHover] = useState(null);
|
|
509
546
|
const segmentClicked = useRef(false);
|
|
510
547
|
const plotRef = useRef(null);
|
|
511
|
-
const
|
|
548
|
+
const measureWords = plan.stack ? plan.stack.map((k) => measures.find((m) => m.key === k)?.label ?? k).join(" and ") : measure?.label ?? plan.measure;
|
|
549
|
+
const title = plan.time ? `${measureWords} by ${dimensionRefLabel(dimensions, plan.time).replace(/^.* by /, "")}${plan.split ? `, split by ${dimensionRefLabel(dimensions, plan.split)}` : ""}` : measureWords;
|
|
512
550
|
const frame = (body) => /* @__PURE__ */ jsxs2("section", { "data-matrx-drill-chart": true, "aria-label": title, className: cn("flex min-w-0 flex-col gap-1.5 px-2 py-2", className), children: [
|
|
513
551
|
note ? /* @__PURE__ */ jsx3("div", { "data-matrx-drill-chart-note": true, className: "text-xs text-muted-foreground", children: note }) : null,
|
|
514
552
|
body
|