@ai-matrx/records-ui 0.116.34 → 0.116.36
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 +30 -1
- package/dist/{chunk-IL66BADF.js → chunk-HGPMJHRJ.js} +4 -1
- package/dist/{chunk-IL66BADF.js.map → chunk-HGPMJHRJ.js.map} +1 -1
- package/dist/index.cjs +39 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +111 -83
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +4 -0
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -17254,6 +17254,7 @@ var import_records28 = require("@ai-matrx/records");
|
|
|
17254
17254
|
var import_react82 = require("@ai-matrx/records/react");
|
|
17255
17255
|
init_Refusal();
|
|
17256
17256
|
init_names();
|
|
17257
|
+
init_refusals();
|
|
17257
17258
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
17258
17259
|
var PREVIEW_GROUPS = 1e3;
|
|
17259
17260
|
function ruleWords(rules) {
|
|
@@ -17292,6 +17293,9 @@ function FieldRulePreview({ field: field2, tableId, rules }) {
|
|
|
17292
17293
|
const numbers = holdsNumbers3(field2);
|
|
17293
17294
|
const groups = answer.data.map((row) => ({ value: groupValue(row.groups[field2.key] ?? null, numbers), count: row.row_count }));
|
|
17294
17295
|
setPreview((0, import_records28.previewRuleChange)(latest.current, groups, answer.data.length >= PREVIEW_GROUPS));
|
|
17296
|
+
}).catch((thrown) => {
|
|
17297
|
+
if (cancelled) return;
|
|
17298
|
+
setRefusal((0, refusals_exports.refusalFromThrown)(thrown, `${name}'s values could not be counted.`, "The check still applies when you save."));
|
|
17295
17299
|
});
|
|
17296
17300
|
}, 300);
|
|
17297
17301
|
return () => {
|
|
@@ -45187,6 +45191,20 @@ function planCategoryTicks(slotPx, charPx = TICK_CHAR_PX, minChars = TICK_MIN_CH
|
|
|
45187
45191
|
const step2 = Math.max(1, Math.ceil((minChars * charPx + 4) / slot));
|
|
45188
45192
|
return { step: step2, perLine: Math.max(3, Math.floor((slot * step2 - 4) / charPx)) };
|
|
45189
45193
|
}
|
|
45194
|
+
function ScatterName(props) {
|
|
45195
|
+
const { placed } = props;
|
|
45196
|
+
const text = String(props.value ?? "");
|
|
45197
|
+
const x = Number(props.x ?? 0);
|
|
45198
|
+
const y = Number(props.y ?? 0) - 8;
|
|
45199
|
+
const key = `${x}|${y}|${text}`;
|
|
45200
|
+
if (placed.current.keys.includes(key)) placed.current = { keys: [], boxes: [] };
|
|
45201
|
+
placed.current.keys.push(key);
|
|
45202
|
+
const w = text.length * 6.4;
|
|
45203
|
+
const box = { l: x - w / 2, r: x + w / 2, t: y - 7, b: y + 7 };
|
|
45204
|
+
if (placed.current.boxes.some((o) => box.l < o.r + 4 && o.l < box.r + 4 && box.t < o.b && o.t < box.b)) return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("g", {});
|
|
45205
|
+
placed.current.boxes.push(box);
|
|
45206
|
+
return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("text", { x, y, textAnchor: "middle", fontSize: 10, className: "fill-muted-foreground", "data-records-chart-label": "", children: text });
|
|
45207
|
+
}
|
|
45190
45208
|
function lineAxis(width, count) {
|
|
45191
45209
|
const plan = planCategoryTicks((width - 56) / Math.max(count, 1));
|
|
45192
45210
|
const pad4 = Math.min(30, Math.ceil(plan.perLine * TICK_CHAR_PX / 2));
|
|
@@ -45250,6 +45268,7 @@ function Drawing({
|
|
|
45250
45268
|
const pretty2 = usePrettyWith(prettyPlain);
|
|
45251
45269
|
const compactTick = useCompactWith(compactTickPlain);
|
|
45252
45270
|
const labelText = (v) => typeof v === "number" ? pretty2(v).length > 7 ? compactTick(v) : pretty2(v) : "";
|
|
45271
|
+
const scatterNames = (0, import_react262.useRef)({ keys: [], boxes: [] });
|
|
45253
45272
|
const compared = series.length > 1;
|
|
45254
45273
|
const drawOrder = compared ? [series[1], series[0]] : series;
|
|
45255
45274
|
const goalLine = (horizontal2) => goal && typeof goal.value === "number" ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
|
|
@@ -45292,7 +45311,7 @@ function Drawing({
|
|
|
45292
45311
|
nameKey: "label",
|
|
45293
45312
|
innerRadius: hole ? dataLabels ? DONUT_LABELLED.inner : 44 : 0,
|
|
45294
45313
|
outerRadius: dataLabels ? DONUT_LABELLED.outer : 66,
|
|
45295
|
-
...dataLabels ? donutLabelProps(points.map((p) => p.values[series[0]] ?? 0), dataLabels === "value" ? (v) => labelText(v) : null) : {},
|
|
45314
|
+
...dataLabels ? donutLabelProps(points.map((p) => p.values[series[0]] ?? 0), dataLabels === "value" ? (v) => labelText(v) : null, hole) : {},
|
|
45296
45315
|
paddingAngle: donutGap(points.length),
|
|
45297
45316
|
isAnimationActive: false,
|
|
45298
45317
|
...click ? { onClick: click, className: "cursor-pointer" } : {},
|
|
@@ -45417,7 +45436,7 @@ function Drawing({
|
|
|
45417
45436
|
}
|
|
45418
45437
|
}
|
|
45419
45438
|
),
|
|
45420
|
-
/* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.Scatter, { data: dots, fill: SERIES_COLORS[0], isAnimationActive: false, ...click ? { onClick: (_e, index) => click(null, index), className: "cursor-pointer" } : {}, children: dataLabels && dots.length <= 12 ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.LabelList, { dataKey: "label",
|
|
45439
|
+
/* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.Scatter, { data: dots, fill: SERIES_COLORS[0], isAnimationActive: false, ...click ? { onClick: (_e, index) => click(null, index), className: "cursor-pointer" } : {}, children: dataLabels && dots.length <= 12 ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_recharts.LabelList, { dataKey: "label", content: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(ScatterName, { placed: scatterNames }) }) : null })
|
|
45421
45440
|
] }) });
|
|
45422
45441
|
}
|
|
45423
45442
|
if (kind2 === "line") {
|
|
@@ -45532,16 +45551,28 @@ function SpacedLabel(props) {
|
|
|
45532
45551
|
return placement === "end" ? /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("text", { x: x + w + 4, y: y + h / 2, dominantBaseline: "central", fontSize: 10, className: "fill-muted-foreground tabular-nums", "data-records-chart-label": "", children: words2 }) : /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("text", { x: x + w / 2, y: y - 5, textAnchor: "middle", fontSize: 10, className: "fill-muted-foreground tabular-nums", "data-records-chart-label": "", children: words2 });
|
|
45533
45552
|
}
|
|
45534
45553
|
var DONUT_LABELLED = { inner: 30, outer: 46 };
|
|
45535
|
-
function
|
|
45554
|
+
function insideLabelRadius(inner2, outer2) {
|
|
45555
|
+
return inner2 <= 0 ? outer2 * 0.62 : (inner2 + outer2) / 2;
|
|
45556
|
+
}
|
|
45557
|
+
var INSIDE_LABEL_BOX = { w: 24, h: 11 };
|
|
45558
|
+
function donutLabelPlan(values, outer2 = DONUT_LABELLED.outer, inner2 = DONUT_LABELLED.inner) {
|
|
45536
45559
|
const total = values.reduce((a, b) => a + (b > 0 ? b : 0), 0);
|
|
45537
45560
|
if (total <= 0) return values.map(() => "none");
|
|
45538
45561
|
let acc = 0;
|
|
45539
45562
|
const lastY = { left: null, right: null };
|
|
45563
|
+
const insideBoxes = [];
|
|
45564
|
+
const rIn = insideLabelRadius(inner2, outer2);
|
|
45540
45565
|
return values.map((v) => {
|
|
45541
45566
|
const share = v > 0 ? v / total : 0;
|
|
45542
45567
|
const mid = (acc + share / 2) * 2 * Math.PI;
|
|
45543
45568
|
acc += share;
|
|
45544
|
-
if (share >= 0.09)
|
|
45569
|
+
if (share >= 0.09) {
|
|
45570
|
+
const at = { x: Math.cos(mid) * rIn, y: -Math.sin(mid) * rIn };
|
|
45571
|
+
if (!insideBoxes.some((b) => Math.abs(b.x - at.x) < INSIDE_LABEL_BOX.w && Math.abs(b.y - at.y) < INSIDE_LABEL_BOX.h)) {
|
|
45572
|
+
insideBoxes.push(at);
|
|
45573
|
+
return "inside";
|
|
45574
|
+
}
|
|
45575
|
+
}
|
|
45545
45576
|
if (share < 0.03) return "none";
|
|
45546
45577
|
const y = -Math.sin(mid) * (outer2 + 10);
|
|
45547
45578
|
const side = Math.cos(mid) >= 0 ? "right" : "left";
|
|
@@ -45551,8 +45582,9 @@ function donutLabelPlan(values, outer2 = DONUT_LABELLED.outer) {
|
|
|
45551
45582
|
return "outside";
|
|
45552
45583
|
});
|
|
45553
45584
|
}
|
|
45554
|
-
function donutLabelProps(values, asValue) {
|
|
45555
|
-
const
|
|
45585
|
+
function donutLabelProps(values, asValue, hole = true) {
|
|
45586
|
+
const innerR = hole ? DONUT_LABELLED.inner : 0;
|
|
45587
|
+
const plan = donutLabelPlan(values, DONUT_LABELLED.outer, innerR);
|
|
45556
45588
|
const total = values.reduce((a, b) => a + (b > 0 ? b : 0), 0);
|
|
45557
45589
|
const words2 = (i) => asValue ? asValue(values[i] ?? 0) : `${Math.round((values[i] ?? 0) / (total || 1) * 100)}%`;
|
|
45558
45590
|
return {
|
|
@@ -45569,7 +45601,7 @@ function donutLabelProps(values, asValue) {
|
|
|
45569
45601
|
const rad = Math.PI / 180;
|
|
45570
45602
|
const mid = p.midAngle ?? 0;
|
|
45571
45603
|
if (where === "inside") {
|
|
45572
|
-
const r = (
|
|
45604
|
+
const r = insideLabelRadius(p.innerRadius ?? 0, p.outerRadius ?? 0);
|
|
45573
45605
|
return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("text", { x: (p.cx ?? 0) + r * Math.cos(-mid * rad), y: (p.cy ?? 0) + r * Math.sin(-mid * rad), textAnchor: "middle", dominantBaseline: "central", fontSize: 9, className: "fill-background font-medium tabular-nums", "data-records-chart-label": "", children: words2(at) });
|
|
45574
45606
|
}
|
|
45575
45607
|
return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)("text", { x: p.x ?? 0, y: p.y ?? 0, textAnchor: Math.cos(-mid * rad) >= 0 ? "start" : "end", dominantBaseline: "central", fontSize: 9, className: "fill-muted-foreground tabular-nums", "data-records-chart-label": "", children: words2(at) });
|