@alfadocs/ui-kit-debug 1.106.0 → 1.107.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/dist/_chunks/stat-group-CC4-O-Fj.js +97 -0
- package/dist/_chunks/stat-group-CC4-O-Fj.js.map +1 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/stat-group/index.js +1 -1
- package/dist/components/stat-group/stat-group.d.ts.map +1 -1
- package/dist/core.css +1 -1
- package/dist/index.js +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/stat-group-DSNnzkbW.js +0 -107
- package/dist/_chunks/stat-group-DSNnzkbW.js.map +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as S, Children as j } from "react";
|
|
3
|
+
import { c as x } from "./index-D2ZczOXr.js";
|
|
4
|
+
const d = 6;
|
|
5
|
+
function N(a, t) {
|
|
6
|
+
const p = Math.max(1, Math.min(t, d));
|
|
7
|
+
if (a <= p) return Math.max(1, a);
|
|
8
|
+
const m = Math.ceil(a / p), l = Math.ceil(a / m);
|
|
9
|
+
for (let r = l; r >= 2; r -= 1)
|
|
10
|
+
if (a % r !== 1) return r;
|
|
11
|
+
return l;
|
|
12
|
+
}
|
|
13
|
+
function _(a, t) {
|
|
14
|
+
return t > 1 && a > t && a % t === 1;
|
|
15
|
+
}
|
|
16
|
+
const b = {
|
|
17
|
+
2: "ds:@[400px]:grid-cols-[repeat(var(--sg-t2),minmax(0,1fr))]",
|
|
18
|
+
3: "ds:@[608px]:grid-cols-[repeat(var(--sg-t3),minmax(0,1fr))]",
|
|
19
|
+
4: "ds:@[816px]:grid-cols-[repeat(var(--sg-t4),minmax(0,1fr))]",
|
|
20
|
+
5: "ds:@[1024px]:grid-cols-[repeat(var(--sg-t5),minmax(0,1fr))]",
|
|
21
|
+
6: "ds:@[1232px]:grid-cols-[repeat(var(--sg-t6),minmax(0,1fr))]"
|
|
22
|
+
}, G = {
|
|
23
|
+
2: {
|
|
24
|
+
normal: "ds:@[400px]:col-span-[var(--sg-s2)]",
|
|
25
|
+
last: "ds:@[400px]:col-span-[var(--sg-l2)]"
|
|
26
|
+
},
|
|
27
|
+
3: {
|
|
28
|
+
normal: "ds:@[608px]:col-span-[var(--sg-s3)]",
|
|
29
|
+
last: "ds:@[608px]:col-span-[var(--sg-l3)]"
|
|
30
|
+
},
|
|
31
|
+
4: {
|
|
32
|
+
normal: "ds:@[816px]:col-span-[var(--sg-s4)]",
|
|
33
|
+
last: "ds:@[816px]:col-span-[var(--sg-l4)]"
|
|
34
|
+
},
|
|
35
|
+
5: {
|
|
36
|
+
normal: "ds:@[1024px]:col-span-[var(--sg-s5)]",
|
|
37
|
+
last: "ds:@[1024px]:col-span-[var(--sg-l5)]"
|
|
38
|
+
},
|
|
39
|
+
6: {
|
|
40
|
+
normal: "ds:@[1232px]:col-span-[var(--sg-s6)]",
|
|
41
|
+
last: "ds:@[1232px]:col-span-[var(--sg-l6)]"
|
|
42
|
+
}
|
|
43
|
+
}, A = x("ds:@container ds:block ds:w-full ds:min-w-0"), C = x(
|
|
44
|
+
[
|
|
45
|
+
"ds:grid ds:list-none ds:m-0 ds:p-0 ds:grid-cols-1",
|
|
46
|
+
"ds:gap-[var(--spacing-md)] ds:items-stretch"
|
|
47
|
+
].join(" ")
|
|
48
|
+
), O = x("ds:flex ds:min-w-0 ds:[&>*]:w-full ds:[&>*]:min-w-0"), V = S(
|
|
49
|
+
function({ children: t, maxColumns: p = d, className: m, ...l }, r) {
|
|
50
|
+
const f = j.toArray(t), i = f.length, w = Math.min(p, d), u = [], e = {}, v = {};
|
|
51
|
+
for (let s = 2; s <= d; s += 1) {
|
|
52
|
+
const n = N(i, Math.min(s, w)), o = i > 0 ? i % n : 0, c = o === 0 ? 1 : o;
|
|
53
|
+
u.push(b[s]), e[`--sg-t${s}`] = n * c, e[`--sg-s${s}`] = c, e[`--sg-l${s}`] = o === 0 ? c : n, v[s] = o;
|
|
54
|
+
}
|
|
55
|
+
return /* @__PURE__ */ g(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
ref: r,
|
|
59
|
+
"data-component": "stat-group",
|
|
60
|
+
"data-count": i,
|
|
61
|
+
role: l["aria-label"] ? "group" : void 0,
|
|
62
|
+
className: [A(), m].filter(Boolean).join(" "),
|
|
63
|
+
...l,
|
|
64
|
+
children: /* @__PURE__ */ g(
|
|
65
|
+
"ul",
|
|
66
|
+
{
|
|
67
|
+
className: [C(), ...u].join(" "),
|
|
68
|
+
style: e,
|
|
69
|
+
children: f.map((s, n) => {
|
|
70
|
+
const o = Object.entries(G).map(([c, h]) => {
|
|
71
|
+
const M = v[Number(c)];
|
|
72
|
+
return M > 0 && n >= i - M ? h.last : h.normal;
|
|
73
|
+
}).join(" ");
|
|
74
|
+
return /* @__PURE__ */ g(
|
|
75
|
+
"li",
|
|
76
|
+
{
|
|
77
|
+
"data-stat-group-item": "",
|
|
78
|
+
className: [O(), o].join(" "),
|
|
79
|
+
children: s
|
|
80
|
+
},
|
|
81
|
+
n
|
|
82
|
+
);
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
V.displayName = "StatGroup";
|
|
91
|
+
export {
|
|
92
|
+
d as S,
|
|
93
|
+
V as a,
|
|
94
|
+
_ as b,
|
|
95
|
+
N as s
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=stat-group-CC4-O-Fj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stat-group-CC4-O-Fj.js","sources":["../../src/components/stat-group/stat-group.tsx"],"sourcesContent":["import {\n Children,\n forwardRef,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cva } from 'class-variance-authority';\n\n/* ------------------------------------------------------------------ */\n/* Layout maths (pure, no measuring) */\n/* ------------------------------------------------------------------ */\n\n// Min tile width is 192px (4 x --spacing-2xl) and the gap is --spacing-md\n// (16px). Container queries cannot read var(), and rem in a container query\n// resolves against the host root font size (10px on the platform), so the\n// breakpoints below are literal px: n columns need n * 192 + (n - 1) * 16 px.\nexport const STAT_GROUP_MAX_COLUMNS = 6;\nexport type StatGroupColumns = 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * Columns for `count` tiles when `available` columns fit: one row if they\n * all fit, otherwise balanced rows, preferring a split with no lone tile.\n */\nexport function statGroupColumns(\n count: number,\n available: number,\n): StatGroupColumns {\n const fit = Math.max(1, Math.min(available, STAT_GROUP_MAX_COLUMNS));\n if (count <= fit) return Math.max(1, count) as StatGroupColumns;\n const rows = Math.ceil(count / fit);\n const balanced = Math.ceil(count / rows);\n for (let cols = balanced; cols >= 2; cols -= 1) {\n if (count % cols !== 1) return cols as StatGroupColumns;\n }\n return balanced as StatGroupColumns;\n}\n\n/** True when the last row would hold a single tile at this column count. */\nexport function statGroupHasOrphan(count: number, cols: number): boolean {\n return cols > 1 && count > cols && count % cols === 1;\n}\n\n/* ------------------------------------------------------------------ */\n/* Static class tables (Tailwind needs literal class names) */\n/* ------------------------------------------------------------------ */\n\n// Keys are the number of columns that fit (container width in the value).\n// Each breakpoint uses a grid of equal tracks (--sg-t<fit>). A normal tile\n// spans --sg-s<fit> tracks and a tile on a short last row spans --sg-l<fit>,\n// so the short row shares the full width. See the component for the maths.\nconst LIST: Record<number, string> = {\n 2: 'ds:@[400px]:grid-cols-[repeat(var(--sg-t2),minmax(0,1fr))]',\n 3: 'ds:@[608px]:grid-cols-[repeat(var(--sg-t3),minmax(0,1fr))]',\n 4: 'ds:@[816px]:grid-cols-[repeat(var(--sg-t4),minmax(0,1fr))]',\n 5: 'ds:@[1024px]:grid-cols-[repeat(var(--sg-t5),minmax(0,1fr))]',\n 6: 'ds:@[1232px]:grid-cols-[repeat(var(--sg-t6),minmax(0,1fr))]',\n};\n\nconst SPAN: Record<number, { normal: string; last: string }> = {\n 2: {\n normal: 'ds:@[400px]:col-span-[var(--sg-s2)]',\n last: 'ds:@[400px]:col-span-[var(--sg-l2)]',\n },\n 3: {\n normal: 'ds:@[608px]:col-span-[var(--sg-s3)]',\n last: 'ds:@[608px]:col-span-[var(--sg-l3)]',\n },\n 4: {\n normal: 'ds:@[816px]:col-span-[var(--sg-s4)]',\n last: 'ds:@[816px]:col-span-[var(--sg-l4)]',\n },\n 5: {\n normal: 'ds:@[1024px]:col-span-[var(--sg-s5)]',\n last: 'ds:@[1024px]:col-span-[var(--sg-l5)]',\n },\n 6: {\n normal: 'ds:@[1232px]:col-span-[var(--sg-s6)]',\n last: 'ds:@[1232px]:col-span-[var(--sg-l6)]',\n },\n};\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\n// The wrapper is the size container; the list inside is the grid.\nconst rootVariants = cva('ds:@container ds:block ds:w-full ds:min-w-0');\n\nconst listVariants = cva(\n [\n 'ds:grid ds:list-none ds:m-0 ds:p-0 ds:grid-cols-1',\n 'ds:gap-[var(--spacing-md)] ds:items-stretch',\n ].join(' '),\n);\n\nconst itemVariants = cva('ds:flex ds:min-w-0 ds:[&>*]:w-full ds:[&>*]:min-w-0');\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport interface StatGroupProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'children'\n> {\n /** The tiles, usually `Stat`. Each child becomes one grid cell. */\n children: ReactNode;\n /**\n * Most columns allowed, 1 to 6. Default 6. Lower it to keep tiles wider,\n * for example 4 on a dense dashboard.\n */\n maxColumns?: StatGroupColumns;\n /** Accessible name for the group of figures. */\n 'aria-label'?: string;\n}\n\n/* ------------------------------------------------------------------ */\n/* Component */\n/* ------------------------------------------------------------------ */\n\nexport const StatGroup = forwardRef<HTMLDivElement, StatGroupProps>(\n function StatGroup(\n { children, maxColumns = STAT_GROUP_MAX_COLUMNS, className, ...rest },\n ref,\n ) {\n const items = Children.toArray(children);\n const count = items.length;\n const cap = Math.min(maxColumns, STAT_GROUP_MAX_COLUMNS);\n\n // At each breakpoint with n columns and k tiles on a short last row, the\n // grid has n * k equal tracks: normal tiles span k, last-row tiles span n.\n // A span of k tracks is (W - (n - 1) * gap) / n, so full rows are unchanged.\n const listClasses: string[] = [];\n const listVars: Record<string, number> = {};\n const lastRowAt: Record<number, number> = {};\n for (let fit = 2; fit <= STAT_GROUP_MAX_COLUMNS; fit += 1) {\n const cols = statGroupColumns(count, Math.min(fit, cap));\n const short = count > 0 ? count % cols : 0;\n const k = short === 0 ? 1 : short;\n listClasses.push(LIST[fit]!);\n listVars[`--sg-t${fit}`] = cols * k;\n listVars[`--sg-s${fit}`] = k;\n listVars[`--sg-l${fit}`] = short === 0 ? k : cols;\n lastRowAt[fit] = short;\n }\n\n return (\n <div\n ref={ref}\n data-component=\"stat-group\"\n data-count={count}\n role={rest['aria-label'] ? 'group' : undefined}\n className={[rootVariants(), className].filter(Boolean).join(' ')}\n {...rest}\n >\n <ul\n className={[listVariants(), ...listClasses].join(' ')}\n // Inline style: permitted per 23-constraints §Runtime-computed dimensions\n // (CSS custom property setter; the track rules live in classes).\n // eslint-disable-next-line react/forbid-dom-props -- per-breakpoint track counts as CSS variables\n style={listVars as CSSProperties}\n >\n {items.map((child, index) => {\n const spans = Object.entries(SPAN)\n .map(([fit, s]) => {\n const short = lastRowAt[Number(fit)]!;\n return short > 0 && index >= count - short ? s.last : s.normal;\n })\n .join(' ');\n return (\n <li\n key={index}\n data-stat-group-item=\"\"\n className={[itemVariants(), spans].join(' ')}\n >\n {child}\n </li>\n );\n })}\n </ul>\n </div>\n );\n },\n);\n\nStatGroup.displayName = 'StatGroup';\n"],"names":["STAT_GROUP_MAX_COLUMNS","statGroupColumns","count","available","fit","rows","balanced","cols","statGroupHasOrphan","LIST","SPAN","rootVariants","cva","listVariants","itemVariants","StatGroup","forwardRef","children","maxColumns","className","rest","ref","items","Children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AAQ0B,IAAQM,EAAE,OAAOA,EAAE;AAAA,cAC1D,CAAC,EACA,KAAK,GAAG;AACX,qBACE,gBAAAJ;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBAEC,wBAAqB;AAAA,kBACrB,WAAW,CAAChB,EAAA,GAAgBmB,CAAK,EAAE,KAAK,GAAG;AAAA,kBAE1C,UAAAF;AAAA,gBAAA;AAAA,gBAJIC;AAAA,cAAA;AAAA,YAOX,CAAC;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAGN;AACF;AAEAjB,EAAU,cAAc;"}
|
package/dist/agent-catalog.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat-group.d.ts","sourceRoot":"","sources":["../../../src/components/stat-group/stat-group.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"stat-group.d.ts","sourceRoot":"","sources":["../../../src/components/stat-group/stat-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAWf,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAErD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,gBAAgB,CASlB;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvE;AA6DD,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,cAAc,CAAC,cAAc,CAAC,EAC9B,UAAU,CACX;IACC,mEAAmE;IACnE,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD,eAAO,MAAM,SAAS,2GA+DrB,CAAC"}
|