@cascivo/react 0.5.0 → 0.5.1
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/context-menu/context-menu.js +42 -13
- package/dist/index.d.ts +4 -1
- package/dist/stat/stat.css +1 -1
- package/dist/stat/stat.js +7 -3
- package/dist/stat/stat.module.js +7 -6
- package/dist/styles.css +1 -1
- package/package.json +3 -3
|
@@ -7,13 +7,36 @@ import { useRef as o } from "react";
|
|
|
7
7
|
//#region ../components/src/context-menu/context-menu.tsx
|
|
8
8
|
function s({ children: s }) {
|
|
9
9
|
r();
|
|
10
|
-
let c = o(null), l = o(null), u = t(!1)
|
|
10
|
+
let c = o(null), l = o(null), u = t(!1), d = () => {
|
|
11
|
+
let e = c.current;
|
|
12
|
+
return e ? Array.from(e.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])")) : [];
|
|
13
|
+
}, f = (e) => {
|
|
14
|
+
let t = d();
|
|
15
|
+
t.length !== 0 && t[e(t, t.indexOf(document.activeElement))]?.focus();
|
|
16
|
+
}, p = (e) => {
|
|
17
|
+
switch (e.key) {
|
|
18
|
+
case "ArrowDown":
|
|
19
|
+
e.preventDefault(), f((e, t) => t < 0 ? 0 : (t + 1) % e.length);
|
|
20
|
+
break;
|
|
21
|
+
case "ArrowUp":
|
|
22
|
+
e.preventDefault(), f((e, t) => t < 0 ? e.length - 1 : (t - 1 + e.length) % e.length);
|
|
23
|
+
break;
|
|
24
|
+
case "Home":
|
|
25
|
+
e.preventDefault(), f(() => 0);
|
|
26
|
+
break;
|
|
27
|
+
case "End":
|
|
28
|
+
e.preventDefault(), f((e) => e.length - 1);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
11
32
|
n(() => {
|
|
12
33
|
let e = c.current;
|
|
13
|
-
if (e) if (u.value)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
34
|
+
if (e) if (u.value) {
|
|
35
|
+
try {
|
|
36
|
+
e.showPopover();
|
|
37
|
+
} catch {}
|
|
38
|
+
d()[0]?.focus();
|
|
39
|
+
} else try {
|
|
17
40
|
e.hidePopover();
|
|
18
41
|
} catch {}
|
|
19
42
|
}), n(() => {
|
|
@@ -24,34 +47,40 @@ function s({ children: s }) {
|
|
|
24
47
|
};
|
|
25
48
|
return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
|
|
26
49
|
});
|
|
27
|
-
function
|
|
50
|
+
function m(e) {
|
|
28
51
|
e.preventDefault();
|
|
29
52
|
let t = l.current;
|
|
30
53
|
t && (t.style.setProperty("--cascivo-context-x", `${e.clientX}px`), t.style.setProperty("--cascivo-context-y", `${e.clientY}px`), u.value = !0);
|
|
31
54
|
}
|
|
32
|
-
let [
|
|
55
|
+
let [h, ...g] = Array.isArray(s) ? s : [s];
|
|
33
56
|
return /* @__PURE__ */ a("div", {
|
|
34
57
|
ref: l,
|
|
35
|
-
onContextMenu:
|
|
58
|
+
onContextMenu: m,
|
|
36
59
|
className: e.wrapper,
|
|
37
|
-
children: [
|
|
60
|
+
children: [h, /* @__PURE__ */ i("div", {
|
|
38
61
|
ref: c,
|
|
39
62
|
popover: "auto",
|
|
40
63
|
role: "menu",
|
|
41
64
|
"data-state": u.value ? "open" : "closed",
|
|
42
65
|
className: e.menu,
|
|
43
|
-
|
|
66
|
+
onKeyDown: p,
|
|
67
|
+
children: g
|
|
44
68
|
})]
|
|
45
69
|
});
|
|
46
70
|
}
|
|
47
71
|
function c({ children: t, onSelect: n, disabled: r }) {
|
|
72
|
+
function a() {
|
|
73
|
+
r || n();
|
|
74
|
+
}
|
|
75
|
+
function o(e) {
|
|
76
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), a());
|
|
77
|
+
}
|
|
48
78
|
return /* @__PURE__ */ i("div", {
|
|
49
79
|
role: "menuitem",
|
|
50
80
|
tabIndex: r ? -1 : 0,
|
|
51
81
|
"aria-disabled": r,
|
|
52
|
-
onClick:
|
|
53
|
-
|
|
54
|
-
},
|
|
82
|
+
onClick: a,
|
|
83
|
+
onKeyDown: o,
|
|
55
84
|
className: e.item,
|
|
56
85
|
children: t
|
|
57
86
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1866,12 +1866,14 @@ declare function CopyButton({
|
|
|
1866
1866
|
className,
|
|
1867
1867
|
...props
|
|
1868
1868
|
}: CopyButtonProps): import("react").JSX.Element;
|
|
1869
|
-
interface StatProps extends HTMLAttributes<HTMLDivElement> {
|
|
1869
|
+
interface StatProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
1870
1870
|
label: string;
|
|
1871
1871
|
value: string | number;
|
|
1872
1872
|
delta?: string;
|
|
1873
1873
|
trend?: 'up' | 'down' | 'flat';
|
|
1874
1874
|
helpText?: string;
|
|
1875
|
+
/** Trailing visual, e.g. a `Sparkline` from `@cascivo/charts`. Purely decorative — mark it `aria-hidden` yourself if it duplicates the value/delta already announced. */
|
|
1876
|
+
visual?: ReactNode;
|
|
1875
1877
|
}
|
|
1876
1878
|
declare function Stat({
|
|
1877
1879
|
label,
|
|
@@ -1879,6 +1881,7 @@ declare function Stat({
|
|
|
1879
1881
|
delta,
|
|
1880
1882
|
trend,
|
|
1881
1883
|
helpText,
|
|
1884
|
+
visual,
|
|
1882
1885
|
className,
|
|
1883
1886
|
...props
|
|
1884
1887
|
}: StatProps): import("react").JSX.Element;
|
package/dist/stat/stat.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer cascivo.component{.
|
|
1
|
+
@layer cascivo.component{._stat_r3v5x_2{gap:var(--cascivo-space-1);font-family:var(--cascivo-font-sans);flex-direction:column;display:flex}._label_r3v5x_9{font-size:var(--cascivo-text-sm);color:var(--cascivo-color-text-subtle);line-height:var(--cascivo-leading-tight)}._value_r3v5x_15{font-size:var(--cascivo-text-2xl);font-weight:var(--cascivo-font-semibold);color:var(--cascivo-color-text);line-height:var(--cascivo-leading-tight);font-variant-numeric:tabular-nums}._delta_r3v5x_23{align-items:center;gap:var(--cascivo-space-1);font-size:var(--cascivo-text-sm);font-weight:var(--cascivo-font-medium);font-variant-numeric:tabular-nums;display:inline-flex}._delta_r3v5x_23[data-trend=up]{color:var(--cascivo-color-success-foreground)}._delta_r3v5x_23[data-trend=down]{color:var(--cascivo-color-destructive-foreground)}._delta_r3v5x_23[data-trend=flat]{color:var(--cascivo-color-text-subtle)}._arrow_r3v5x_44{font-size:var(--cascivo-text-xs);line-height:1}._help_r3v5x_49{font-size:var(--cascivo-text-xs);color:var(--cascivo-color-text-subtle);line-height:var(--cascivo-leading-tight)}._visual_r3v5x_55{margin-block-start:var(--cascivo-space-1)}}
|
package/dist/stat/stat.js
CHANGED
|
@@ -4,10 +4,10 @@ import e from "./stat.module.js";
|
|
|
4
4
|
import { cn as t } from "@cascivo/core";
|
|
5
5
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
6
6
|
//#region ../components/src/stat/stat.tsx
|
|
7
|
-
function i({ label: i, value: a, delta: o, trend: s = "flat", helpText: c,
|
|
7
|
+
function i({ label: i, value: a, delta: o, trend: s = "flat", helpText: c, visual: l, className: u, ...d }) {
|
|
8
8
|
return /* @__PURE__ */ r("div", {
|
|
9
|
-
className: t(e.stat,
|
|
10
|
-
...
|
|
9
|
+
className: t(e.stat, u),
|
|
10
|
+
...d,
|
|
11
11
|
children: [
|
|
12
12
|
/* @__PURE__ */ n("span", {
|
|
13
13
|
className: e.label,
|
|
@@ -29,6 +29,10 @@ function i({ label: i, value: a, delta: o, trend: s = "flat", helpText: c, class
|
|
|
29
29
|
c && /* @__PURE__ */ n("span", {
|
|
30
30
|
className: e.help,
|
|
31
31
|
children: c
|
|
32
|
+
}),
|
|
33
|
+
l && /* @__PURE__ */ n("span", {
|
|
34
|
+
className: e.visual,
|
|
35
|
+
children: l
|
|
32
36
|
})
|
|
33
37
|
]
|
|
34
38
|
});
|
package/dist/stat/stat.module.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import './stat.css';
|
|
4
4
|
var e = {
|
|
5
|
-
stat: "
|
|
6
|
-
label: "
|
|
7
|
-
value: "
|
|
8
|
-
delta: "
|
|
9
|
-
arrow: "
|
|
10
|
-
help: "
|
|
5
|
+
stat: "_stat_r3v5x_2",
|
|
6
|
+
label: "_label_r3v5x_9",
|
|
7
|
+
value: "_value_r3v5x_15",
|
|
8
|
+
delta: "_delta_r3v5x_23",
|
|
9
|
+
arrow: "_arrow_r3v5x_44",
|
|
10
|
+
help: "_help_r3v5x_49",
|
|
11
|
+
visual: "_visual_r3v5x_55"
|
|
11
12
|
};
|
|
12
13
|
//#endregion
|
|
13
14
|
export { e as default };
|
package/dist/styles.css
CHANGED
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
/*$vite$:1*/
|
|
230
230
|
@layer cascivo.component{._stack_2ay4v_2{isolation:isolate;grid-template-areas:"stack";display:grid}._layer_2ay4v_8{transform:translate(calc(var(--cascivo-stack-index,0) * var(--cascivo-stack-offset,4px)), calc(var(--cascivo-stack-index,0) * var(--cascivo-stack-offset,4px)));z-index:calc(10 - var(--cascivo-stack-index,0));grid-area:stack}}
|
|
231
231
|
/*$vite$:1*/
|
|
232
|
-
@layer cascivo.component{.
|
|
232
|
+
@layer cascivo.component{._stat_r3v5x_2{gap:var(--cascivo-space-1);font-family:var(--cascivo-font-sans);flex-direction:column;display:flex}._label_r3v5x_9{font-size:var(--cascivo-text-sm);color:var(--cascivo-color-text-subtle);line-height:var(--cascivo-leading-tight)}._value_r3v5x_15{font-size:var(--cascivo-text-2xl);font-weight:var(--cascivo-font-semibold);color:var(--cascivo-color-text);line-height:var(--cascivo-leading-tight);font-variant-numeric:tabular-nums}._delta_r3v5x_23{align-items:center;gap:var(--cascivo-space-1);font-size:var(--cascivo-text-sm);font-weight:var(--cascivo-font-medium);font-variant-numeric:tabular-nums;display:inline-flex}._delta_r3v5x_23[data-trend=up]{color:var(--cascivo-color-success-foreground)}._delta_r3v5x_23[data-trend=down]{color:var(--cascivo-color-destructive-foreground)}._delta_r3v5x_23[data-trend=flat]{color:var(--cascivo-color-text-subtle)}._arrow_r3v5x_44{font-size:var(--cascivo-text-xs);line-height:1}._help_r3v5x_49{font-size:var(--cascivo-text-xs);color:var(--cascivo-color-text-subtle);line-height:var(--cascivo-leading-tight)}._visual_r3v5x_55{margin-block-start:var(--cascivo-space-1)}}
|
|
233
233
|
/*$vite$:1*/
|
|
234
234
|
@layer cascivo.component{._status_u4gep_2{align-items:center;gap:var(--cascivo-space-2);font-family:var(--cascivo-font-sans);font-size:var(--cascivo-text-sm);color:var(--cascivo-color-text);line-height:var(--cascivo-leading-tight);display:inline-flex}._status_u4gep_2[data-status=success] ._dot_u4gep_11{background-color:var(--cascivo-color-success)}._status_u4gep_2[data-status=warning] ._dot_u4gep_11{background-color:var(--cascivo-color-warning)}._status_u4gep_2[data-status=error] ._dot_u4gep_11{background-color:var(--cascivo-color-error)}._status_u4gep_2[data-status=info] ._dot_u4gep_11{background-color:var(--cascivo-color-info)}._status_u4gep_2[data-status=neutral] ._dot_u4gep_11{background-color:var(--cascivo-color-text-muted)}._dot_u4gep_11{border-radius:var(--cascivo-radius-full);flex-shrink:0;block-size:.5rem;inline-size:.5rem}@media (prefers-reduced-motion:no-preference){._status_u4gep_2[data-pulse] ._dot_u4gep_11{animation:_cascade-status-pulse_u4gep_1 2s var(--cascivo-ease-in-out) infinite}}@keyframes _cascade-status-pulse_u4gep_1{0%,to{opacity:1}50%{opacity:.4}}}
|
|
235
235
|
/*$vite$:1*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cascivo/react",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Prebuilt cascivo design system components — use without copying source",
|
|
6
6
|
"keywords": [
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"provenance": true
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@cascivo/core": "^0.3.
|
|
48
|
-
"@cascivo/i18n": "^0.2.
|
|
47
|
+
"@cascivo/core": "^0.3.1",
|
|
48
|
+
"@cascivo/i18n": "^0.2.5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@testing-library/jest-dom": "^6.9.1",
|