@stackone/malachite 2.88.3 → 2.89.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/COMPONENTS.md +3 -1
- package/dist/components/Table/Table.js +557 -560
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Table/TablePagination.js +100 -181
- package/dist/components/Table/TablePagination.js.map +1 -1
- package/dist/components/Table/paginationPlacement.js +15 -0
- package/dist/components/Table/paginationPlacement.js.map +1 -0
- package/dist/components/Table/useFillHeight.js +53 -0
- package/dist/components/Table/useFillHeight.js.map +1 -0
- package/dist/components/TimeBarChart/TimeBarChartLegend.js +5 -16
- package/dist/components/TimeBarChart/TimeBarChartLegend.js.map +1 -1
- package/dist/components/TimeBarChart/TimeBarChartSwatch.js +21 -0
- package/dist/components/TimeBarChart/TimeBarChartSwatch.js.map +1 -0
- package/dist/components/UserIdentity.js +19 -0
- package/dist/components/UserIdentity.js.map +1 -0
- package/dist/index.d.ts +25 -1
- package/dist/index.js +482 -478
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,205 +1,124 @@
|
|
|
1
|
-
import { jsxs as d, jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
1
|
+
import { jsxs as d, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as O } from "react";
|
|
3
|
+
import { Button as f } from "../Button.js";
|
|
4
|
+
import S from "../CustomIcons/CaretDownIcon.js";
|
|
5
|
+
import T from "../CustomIcons/CaretLeftIcon.js";
|
|
4
6
|
import j from "../CustomIcons/CaretRightIcon.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
fontWeight: 500,
|
|
18
|
-
cursor: "pointer",
|
|
19
|
-
userSelect: "none",
|
|
20
|
-
transition: "background-color 120ms ease, border-color 120ms ease, color 120ms ease"
|
|
21
|
-
}, y = (r) => ({
|
|
22
|
-
...g,
|
|
23
|
-
width: 32,
|
|
24
|
-
minWidth: 32,
|
|
25
|
-
color: r ? "var(--malachite-text-placeholder, rgb(187, 187, 187))" : "var(--malachite-text-primary, rgb(10, 10, 10))",
|
|
26
|
-
opacity: r ? 0.4 : 1,
|
|
27
|
-
cursor: r ? "not-allowed" : "pointer"
|
|
28
|
-
}), L = (r) => ({
|
|
29
|
-
...g,
|
|
30
|
-
border: r ? "1px solid var(--malachite-accent-border, rgba(0, 175, 102, 0.2))" : "1px solid transparent",
|
|
31
|
-
color: r ? "var(--malachite-accent-foreground, rgb(2, 122, 66))" : "var(--malachite-text-primary, rgb(10, 10, 10))",
|
|
32
|
-
background: r ? "var(--malachite-card-background, rgb(255, 255, 255))" : "transparent"
|
|
33
|
-
}), R = {
|
|
34
|
-
...g,
|
|
35
|
-
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
36
|
-
cursor: "default",
|
|
37
|
-
letterSpacing: 1
|
|
38
|
-
}, A = {
|
|
39
|
-
height: 32,
|
|
40
|
-
padding: "0 8px",
|
|
41
|
-
border: "1px solid var(--malachite-card-border, rgb(232, 232, 232))",
|
|
42
|
-
borderRadius: 8,
|
|
43
|
-
background: "var(--malachite-card-background, rgb(255, 255, 255))",
|
|
44
|
-
color: "var(--malachite-text-primary, rgb(10, 10, 10))",
|
|
45
|
-
fontSize: 13,
|
|
46
|
-
fontWeight: 500,
|
|
47
|
-
cursor: "pointer",
|
|
48
|
-
appearance: "none",
|
|
49
|
-
WebkitAppearance: "none",
|
|
50
|
-
MozAppearance: "none",
|
|
51
|
-
backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%230a0a0a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")`,
|
|
52
|
-
backgroundRepeat: "no-repeat",
|
|
53
|
-
backgroundPosition: "right 8px center",
|
|
54
|
-
paddingRight: 28
|
|
55
|
-
}, W = {
|
|
56
|
-
width: 56,
|
|
57
|
-
height: 32,
|
|
58
|
-
padding: "0 8px",
|
|
59
|
-
border: "1px solid var(--malachite-card-border, rgb(232, 232, 232))",
|
|
60
|
-
borderRadius: 8,
|
|
61
|
-
background: "var(--malachite-card-background, rgb(255, 255, 255))",
|
|
62
|
-
color: "var(--malachite-text-primary, rgb(10, 10, 10))",
|
|
63
|
-
fontSize: 13,
|
|
64
|
-
textAlign: "center",
|
|
65
|
-
outline: "none"
|
|
66
|
-
}, B = ["10", "25", "50", "100"], T = (r, t) => {
|
|
67
|
-
if (t <= 7)
|
|
68
|
-
return Array.from({ length: t }, (b, m) => m + 1);
|
|
69
|
-
const i = [1];
|
|
70
|
-
return r <= 4 ? (i.push(2, 3, 4, 5, "ellipsis", t), i) : r >= t - 3 ? (i.push(
|
|
71
|
-
"ellipsis",
|
|
72
|
-
t - 4,
|
|
73
|
-
t - 3,
|
|
74
|
-
t - 2,
|
|
75
|
-
t - 1,
|
|
76
|
-
t
|
|
77
|
-
), i) : (i.push("ellipsis", r - 1, r, r + 1, "ellipsis", t), i);
|
|
78
|
-
}, z = ({
|
|
79
|
-
current: r,
|
|
80
|
-
pageSize: t,
|
|
81
|
-
total: i,
|
|
82
|
-
showSizeChanger: b = !0,
|
|
83
|
-
showQuickJumper: m = !1,
|
|
7
|
+
import b from "../Typography/SecondaryText.js";
|
|
8
|
+
import { FOCUS_RING as A } from "../focusRing.js";
|
|
9
|
+
const U = ["10", "25", "50", "100"], k = {
|
|
10
|
+
left: "justify-start",
|
|
11
|
+
center: "justify-center",
|
|
12
|
+
right: "justify-end"
|
|
13
|
+
}, N = { width: 32, height: 32 }, I = `h-8 rounded-lg border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)] text-[var(--malachite-text-primary)] text-[13px] hover:border-[var(--malachite-control-border-hover)] focus:border-[var(--malachite-control-border-hover)] ${A}`, D = (s, i) => i <= 7 ? Array.from({ length: i }, (l, o) => o + 1) : s <= 4 ? [1, 2, 3, 4, 5, "ellipsis", i] : s >= i - 3 ? [1, "ellipsis", ...Array.from({ length: 5 }, (l, o) => i - 4 + o)] : [1, "ellipsis", s - 1, s, s + 1, "ellipsis", i], Q = ({
|
|
14
|
+
current: s,
|
|
15
|
+
pageSize: i,
|
|
16
|
+
total: l,
|
|
17
|
+
showSizeChanger: o = !0,
|
|
18
|
+
showQuickJumper: y = !1,
|
|
84
19
|
showTotal: h,
|
|
85
|
-
pageSizeOptions:
|
|
86
|
-
onChange:
|
|
87
|
-
onShowSizeChange: u
|
|
20
|
+
pageSizeOptions: L = U,
|
|
21
|
+
onChange: n,
|
|
22
|
+
onShowSizeChange: u,
|
|
23
|
+
edge: _ = "bottom",
|
|
24
|
+
align: $ = "right"
|
|
88
25
|
}) => {
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
const e = parseInt(x, 10);
|
|
94
|
-
Number.isNaN(e) ||
|
|
95
|
-
},
|
|
26
|
+
const c = i > 0 ? i : 10, m = Math.max(1, Math.ceil(l / c)), r = Math.min(Math.max(1, s), m), [x, v] = O(""), p = (e) => {
|
|
27
|
+
const a = Math.min(Math.max(1, e), m);
|
|
28
|
+
a !== r && (n == null || n(a, c));
|
|
29
|
+
}, g = () => {
|
|
30
|
+
const e = Number.parseInt(x, 10);
|
|
31
|
+
Number.isNaN(e) || p(e), v("");
|
|
32
|
+
}, z = l === 0 ? 0 : (r - 1) * c + 1, E = Math.min(r * c, l), M = h ? h(l, [z, E]) : `Total ${l.toLocaleString("en-US")} items`;
|
|
96
33
|
return /* @__PURE__ */ d(
|
|
97
34
|
"div",
|
|
98
35
|
{
|
|
99
|
-
className: "mt-4 flex items-center
|
|
100
|
-
style: { color: "var(--malachite-text-primary, rgb(10, 10, 10))" },
|
|
36
|
+
className: `${_ === "top" ? "mb-4" : "mt-4"} flex items-center ${k[$]} gap-2 flex-wrap`,
|
|
101
37
|
children: [
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
|
|
38
|
+
/* @__PURE__ */ t(b, { size: "small", children: M }),
|
|
39
|
+
/* @__PURE__ */ t(
|
|
40
|
+
f,
|
|
104
41
|
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
42
|
+
variant: "ghost",
|
|
43
|
+
size: "medium",
|
|
44
|
+
iconOnly: !0,
|
|
45
|
+
style: N,
|
|
46
|
+
"aria-label": "Previous page",
|
|
47
|
+
icon: /* @__PURE__ */ t(T, { size: 12 }),
|
|
48
|
+
disabled: r <= 1,
|
|
49
|
+
onClick: () => p(r - 1)
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
D(r, m).map(
|
|
53
|
+
(e, a) => e === "ellipsis" ? /* @__PURE__ */ t(b, { size: "small", children: "…" }, `ellipsis-${a}`) : /* @__PURE__ */ t(
|
|
54
|
+
f,
|
|
55
|
+
{
|
|
56
|
+
variant: e === r ? "outline" : "ghost",
|
|
57
|
+
size: "medium",
|
|
58
|
+
"aria-label": `Page ${e}`,
|
|
59
|
+
"aria-current": e === r ? "page" : void 0,
|
|
60
|
+
onClick: () => p(e),
|
|
61
|
+
children: e.toLocaleString("en-US")
|
|
110
62
|
},
|
|
111
|
-
|
|
63
|
+
e
|
|
64
|
+
)
|
|
65
|
+
),
|
|
66
|
+
/* @__PURE__ */ t(
|
|
67
|
+
f,
|
|
68
|
+
{
|
|
69
|
+
variant: "ghost",
|
|
70
|
+
size: "medium",
|
|
71
|
+
iconOnly: !0,
|
|
72
|
+
style: N,
|
|
73
|
+
"aria-label": "Next page",
|
|
74
|
+
icon: /* @__PURE__ */ t(j, { size: 12 }),
|
|
75
|
+
disabled: r >= m,
|
|
76
|
+
onClick: () => p(r + 1)
|
|
112
77
|
}
|
|
113
78
|
),
|
|
114
|
-
/* @__PURE__ */ d("
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
"
|
|
79
|
+
o && /* @__PURE__ */ d("span", { className: "relative inline-flex items-center", children: [
|
|
80
|
+
/* @__PURE__ */ t(
|
|
81
|
+
"select",
|
|
117
82
|
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
children: /* @__PURE__ */ n(E, { size: 12 })
|
|
124
|
-
}
|
|
125
|
-
),
|
|
126
|
-
M.map(
|
|
127
|
-
(e, o) => e === "ellipsis" ? /* @__PURE__ */ n("span", { style: R, "aria-hidden": "true", children: "•••" }, `e-${o}`) : /* @__PURE__ */ n(
|
|
128
|
-
"button",
|
|
129
|
-
{
|
|
130
|
-
type: "button",
|
|
131
|
-
"aria-label": `Page ${e}`,
|
|
132
|
-
"aria-current": e === a ? "page" : void 0,
|
|
133
|
-
onClick: () => p(e),
|
|
134
|
-
style: L(e === a),
|
|
135
|
-
children: e.toLocaleString("en-US")
|
|
83
|
+
"aria-label": "Page size",
|
|
84
|
+
value: String(c),
|
|
85
|
+
onChange: (e) => {
|
|
86
|
+
const a = Number.parseInt(e.target.value, 10);
|
|
87
|
+
Number.isNaN(a) || (u == null || u(r, a), n == null || n(r, a));
|
|
136
88
|
},
|
|
137
|
-
|
|
138
|
-
|
|
89
|
+
className: `${I} appearance-none cursor-pointer pl-3 pr-8`,
|
|
90
|
+
children: L.map((e) => /* @__PURE__ */ d("option", { value: e, children: [
|
|
91
|
+
e,
|
|
92
|
+
" / page"
|
|
93
|
+
] }, e))
|
|
94
|
+
}
|
|
139
95
|
),
|
|
140
|
-
/* @__PURE__ */
|
|
141
|
-
|
|
96
|
+
/* @__PURE__ */ t("span", { className: "pointer-events-none absolute right-3 inline-flex text-[var(--malachite-text-secondary)]", children: /* @__PURE__ */ t(S, { size: 12 }) })
|
|
97
|
+
] }),
|
|
98
|
+
y && /* @__PURE__ */ d("span", { className: "inline-flex items-center gap-2", children: [
|
|
99
|
+
/* @__PURE__ */ t(b, { size: "small", children: "Go to" }),
|
|
100
|
+
/* @__PURE__ */ t(
|
|
101
|
+
"input",
|
|
142
102
|
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
103
|
+
"aria-label": "Go to page",
|
|
104
|
+
type: "number",
|
|
105
|
+
min: 1,
|
|
106
|
+
max: m,
|
|
107
|
+
value: x,
|
|
108
|
+
onChange: (e) => v(e.target.value),
|
|
109
|
+
onKeyDown: (e) => {
|
|
110
|
+
e.key === "Enter" && g();
|
|
111
|
+
},
|
|
112
|
+
onBlur: g,
|
|
113
|
+
className: `${I} w-[72px] px-2 text-center`
|
|
149
114
|
}
|
|
150
115
|
)
|
|
151
|
-
] })
|
|
152
|
-
b && /* @__PURE__ */ n(
|
|
153
|
-
"select",
|
|
154
|
-
{
|
|
155
|
-
"aria-label": "Page size",
|
|
156
|
-
value: String(t),
|
|
157
|
-
onChange: (e) => {
|
|
158
|
-
const o = parseInt(e.target.value, 10);
|
|
159
|
-
Number.isNaN(o) || (u == null || u(a, o), l == null || l(a, o));
|
|
160
|
-
},
|
|
161
|
-
style: A,
|
|
162
|
-
children: k.map((e) => /* @__PURE__ */ d("option", { value: e, children: [
|
|
163
|
-
e,
|
|
164
|
-
" / page"
|
|
165
|
-
] }, e))
|
|
166
|
-
}
|
|
167
|
-
),
|
|
168
|
-
m && /* @__PURE__ */ d(
|
|
169
|
-
"div",
|
|
170
|
-
{
|
|
171
|
-
className: "flex items-center gap-2",
|
|
172
|
-
style: {
|
|
173
|
-
fontSize: 13,
|
|
174
|
-
color: "var(--malachite-text-primary, rgb(10, 10, 10))"
|
|
175
|
-
},
|
|
176
|
-
children: [
|
|
177
|
-
/* @__PURE__ */ n("span", { children: "Go to" }),
|
|
178
|
-
/* @__PURE__ */ n(
|
|
179
|
-
"input",
|
|
180
|
-
{
|
|
181
|
-
"aria-label": "Go to page",
|
|
182
|
-
type: "number",
|
|
183
|
-
min: 1,
|
|
184
|
-
max: c,
|
|
185
|
-
value: x,
|
|
186
|
-
onChange: (e) => f(e.target.value),
|
|
187
|
-
onKeyDown: (e) => {
|
|
188
|
-
e.key === "Enter" && v();
|
|
189
|
-
},
|
|
190
|
-
onBlur: v,
|
|
191
|
-
style: W
|
|
192
|
-
}
|
|
193
|
-
),
|
|
194
|
-
/* @__PURE__ */ n("span", { children: "Page" })
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
)
|
|
116
|
+
] })
|
|
198
117
|
]
|
|
199
118
|
}
|
|
200
119
|
);
|
|
201
120
|
};
|
|
202
121
|
export {
|
|
203
|
-
|
|
122
|
+
Q as default
|
|
204
123
|
};
|
|
205
124
|
//# sourceMappingURL=TablePagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablePagination.js","sources":["../../../src/components/Table/TablePagination.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport CaretLeftIcon from '../CustomIcons/CaretLeftIcon';\nimport CaretRightIcon from '../CustomIcons/CaretRightIcon';\n\nexport type TablePaginationProps = {\n current: number;\n pageSize: number;\n total: number;\n showSizeChanger?: boolean;\n showQuickJumper?: boolean;\n showTotal?: (total: number, range: [number, number]) => React.ReactNode;\n pageSizeOptions?: string[];\n onChange?: (page: number, pageSize: number) => void;\n onShowSizeChange?: (current: number, size: number) => void;\n};\n\nconst baseButtonStyle: React.CSSProperties = {\n minWidth: 32,\n height: 32,\n padding: '0 8px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: 'transparent',\n border: '1px solid transparent',\n borderRadius: 8,\n color: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n fontSize: 13,\n fontWeight: 500,\n cursor: 'pointer',\n userSelect: 'none',\n transition: 'background-color 120ms ease, border-color 120ms ease, color 120ms ease',\n};\n\nconst arrowStyle = (disabled: boolean): React.CSSProperties => ({\n ...baseButtonStyle,\n width: 32,\n minWidth: 32,\n color: disabled\n ? 'var(--malachite-text-placeholder, rgb(187, 187, 187))'\n : 'var(--malachite-text-primary, rgb(10, 10, 10))',\n opacity: disabled ? 0.4 : 1,\n cursor: disabled ? 'not-allowed' : 'pointer',\n});\n\nconst pageButtonStyle = (active: boolean): React.CSSProperties => ({\n ...baseButtonStyle,\n border: active\n ? '1px solid var(--malachite-accent-border, rgba(0, 175, 102, 0.2))'\n : '1px solid transparent',\n color: active\n ? 'var(--malachite-accent-foreground, rgb(2, 122, 66))'\n : 'var(--malachite-text-primary, rgb(10, 10, 10))',\n background: active ? 'var(--malachite-card-background, rgb(255, 255, 255))' : 'transparent',\n});\n\nconst ellipsisStyle: React.CSSProperties = {\n ...baseButtonStyle,\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n cursor: 'default',\n letterSpacing: 1,\n};\n\nconst selectStyle: React.CSSProperties = {\n height: 32,\n padding: '0 8px',\n border: '1px solid var(--malachite-card-border, rgb(232, 232, 232))',\n borderRadius: 8,\n background: 'var(--malachite-card-background, rgb(255, 255, 255))',\n color: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n fontSize: 13,\n fontWeight: 500,\n cursor: 'pointer',\n appearance: 'none',\n WebkitAppearance: 'none',\n MozAppearance: 'none',\n backgroundImage:\n \"url(\\\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%230a0a0a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\\\")\",\n backgroundRepeat: 'no-repeat',\n backgroundPosition: 'right 8px center',\n paddingRight: 28,\n};\n\nconst jumperInputStyle: React.CSSProperties = {\n width: 56,\n height: 32,\n padding: '0 8px',\n border: '1px solid var(--malachite-card-border, rgb(232, 232, 232))',\n borderRadius: 8,\n background: 'var(--malachite-card-background, rgb(255, 255, 255))',\n color: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n fontSize: 13,\n textAlign: 'center',\n outline: 'none',\n};\n\nconst DEFAULT_PAGE_SIZE_OPTIONS = ['10', '25', '50', '100'];\n\n/**\n * Compute the page numbers to render. Uses an ellipsis-aware window similar\n * to Ant Design's pagination: show first, last, and a small window around the\n * current page, separated by '...' placeholders where there are gaps.\n *\n * Returns an array of either page numbers or the string 'ellipsis'.\n */\nconst computePageList = (current: number, totalPages: number): Array<number | 'ellipsis'> => {\n if (totalPages <= 7) {\n return Array.from({ length: totalPages }, (_, i) => i + 1);\n }\n\n const list: Array<number | 'ellipsis'> = [1];\n\n if (current <= 4) {\n list.push(2, 3, 4, 5, 'ellipsis', totalPages);\n return list;\n }\n\n if (current >= totalPages - 3) {\n list.push(\n 'ellipsis',\n totalPages - 4,\n totalPages - 3,\n totalPages - 2,\n totalPages - 1,\n totalPages,\n );\n return list;\n }\n\n list.push('ellipsis', current - 1, current, current + 1, 'ellipsis', totalPages);\n return list;\n};\n\nconst TablePagination: React.FC<TablePaginationProps> = ({\n current,\n pageSize,\n total,\n showSizeChanger = true,\n showQuickJumper = false,\n showTotal,\n pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,\n onChange,\n onShowSizeChange,\n}) => {\n // Guard pageSize <= 0: it would make totalPages Infinity/NaN and throw a\n // RangeError when building the page list. Fall back to a sane default.\n const safePageSize = pageSize > 0 ? pageSize : 10;\n const totalPages = Math.max(1, Math.ceil(total / safePageSize));\n const safeCurrent = Math.min(Math.max(1, current), totalPages);\n const [jumpValue, setJumpValue] = useState('');\n\n const goTo = (page: number) => {\n const next = Math.min(Math.max(1, page), totalPages);\n if (next !== safeCurrent) {\n onChange?.(next, safePageSize);\n }\n };\n\n const rangeStart = total === 0 ? 0 : (safeCurrent - 1) * safePageSize + 1;\n const rangeEnd = Math.min(safeCurrent * safePageSize, total);\n const totalLabel = showTotal\n ? showTotal(total, [rangeStart, rangeEnd])\n : `Total ${total.toLocaleString('en-US')} items`;\n\n const handleJump = () => {\n const n = parseInt(jumpValue, 10);\n if (!Number.isNaN(n)) {\n goTo(n);\n setJumpValue('');\n }\n };\n\n const pageList = computePageList(safeCurrent, totalPages);\n\n return (\n <div\n className=\"mt-4 flex items-center justify-end gap-3 flex-wrap\"\n style={{ color: 'var(--malachite-text-primary, rgb(10, 10, 10))' }}\n >\n <span\n style={{\n fontSize: 13,\n fontWeight: 500,\n color: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n marginRight: 4,\n }}\n >\n {totalLabel}\n </span>\n\n <div className=\"flex items-center gap-1\">\n <button\n type=\"button\"\n aria-label=\"Previous page\"\n onClick={() => goTo(safeCurrent - 1)}\n disabled={safeCurrent <= 1}\n style={arrowStyle(safeCurrent <= 1)}\n >\n <CaretLeftIcon size={12} />\n </button>\n {pageList.map((entry, idx) =>\n entry === 'ellipsis' ? (\n <span key={`e-${idx}`} style={ellipsisStyle} aria-hidden=\"true\">\n •••\n </span>\n ) : (\n <button\n key={entry}\n type=\"button\"\n aria-label={`Page ${entry}`}\n aria-current={entry === safeCurrent ? 'page' : undefined}\n onClick={() => goTo(entry)}\n style={pageButtonStyle(entry === safeCurrent)}\n >\n {entry.toLocaleString('en-US')}\n </button>\n ),\n )}\n <button\n type=\"button\"\n aria-label=\"Next page\"\n onClick={() => goTo(safeCurrent + 1)}\n disabled={safeCurrent >= totalPages}\n style={arrowStyle(safeCurrent >= totalPages)}\n >\n <CaretRightIcon size={12} />\n </button>\n </div>\n\n {showSizeChanger && (\n <select\n aria-label=\"Page size\"\n value={String(pageSize)}\n onChange={(e) => {\n const next = parseInt(e.target.value, 10);\n if (!Number.isNaN(next)) {\n onShowSizeChange?.(safeCurrent, next);\n onChange?.(safeCurrent, next);\n }\n }}\n style={selectStyle}\n >\n {pageSizeOptions.map((sz) => (\n <option key={sz} value={sz}>\n {sz} / page\n </option>\n ))}\n </select>\n )}\n\n {showQuickJumper && (\n <div\n className=\"flex items-center gap-2\"\n style={{\n fontSize: 13,\n color: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n }}\n >\n <span>Go to</span>\n <input\n aria-label=\"Go to page\"\n type=\"number\"\n min={1}\n max={totalPages}\n value={jumpValue}\n onChange={(e) => setJumpValue(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n handleJump();\n }\n }}\n onBlur={handleJump}\n style={jumperInputStyle}\n />\n <span>Page</span>\n </div>\n )}\n </div>\n );\n};\n\nexport default TablePagination;\n"],"names":["baseButtonStyle","arrowStyle","disabled","pageButtonStyle","active","ellipsisStyle","selectStyle","jumperInputStyle","DEFAULT_PAGE_SIZE_OPTIONS","computePageList","current","totalPages","_","i","list","TablePagination","pageSize","total","showSizeChanger","showQuickJumper","showTotal","pageSizeOptions","onChange","onShowSizeChange","safePageSize","safeCurrent","jumpValue","setJumpValue","useState","goTo","page","next","rangeStart","rangeEnd","totalLabel","handleJump","n","pageList","jsxs","jsx","CaretLeftIcon","entry","idx","CaretRightIcon","sz"],"mappings":";;;;AAgBA,MAAMA,IAAuC;AAAA,EACzC,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAChB,GAEMC,IAAa,CAACC,OAA4C;AAAA,EAC5D,GAAGF;AAAA,EACH,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAOE,IACD,0DACA;AAAA,EACN,SAASA,IAAW,MAAM;AAAA,EAC1B,QAAQA,IAAW,gBAAgB;AACvC,IAEMC,IAAkB,CAACC,OAA0C;AAAA,EAC/D,GAAGJ;AAAA,EACH,QAAQI,IACF,qEACA;AAAA,EACN,OAAOA,IACD,wDACA;AAAA,EACN,YAAYA,IAAS,yDAAyD;AAClF,IAEMC,IAAqC;AAAA,EACvC,GAAGL;AAAA,E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AmBE,GAAaM,IAChCT,KAAA,QAAAA,EAAWG,GAAaM;AAAA,YAEhC;AAAA,YACA,OAAOzB;AAAA,YAEN,YAAgB,IAAI,CAACsC,MAClB,gBAAAN,EAAC,UAAA,EAAgB,OAAOM,GACnB,UAAA;AAAA,cAAAA;AAAA,cAAG;AAAA,YAAA,EAAA,GADKA,CAEb,CACH;AAAA,UAAA;AAAA,QAAA;AAAA,QAIRzB,KACG,gBAAAmB;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,WAAU;AAAA,YACV,OAAO;AAAA,cACH,UAAU;AAAA,cACV,OAAO;AAAA,YAAA;AAAA,YAGX,UAAA;AAAA,cAAA,gBAAAC,EAAC,UAAK,UAAA,QAAA,CAAK;AAAA,cACX,gBAAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,cAAW;AAAA,kBACX,MAAK;AAAA,kBACL,KAAK;AAAA,kBACL,KAAK5B;AAAA,kBACL,OAAOe;AAAA,kBACP,UAAU,CAAC,MAAMC,EAAa,EAAE,OAAO,KAAK;AAAA,kBAC5C,WAAW,CAAC,MAAM;AACd,oBAAI,EAAE,QAAQ,WACVQ,EAAA;AAAA,kBAER;AAAA,kBACA,QAAQA;AAAA,kBACR,OAAO5B;AAAA,gBAAA;AAAA,cAAA;AAAA,cAEX,gBAAAgC,EAAC,UAAK,UAAA,OAAA,CAAI;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACd;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
1
|
+
{"version":3,"file":"TablePagination.js","sources":["../../../src/components/Table/TablePagination.tsx"],"sourcesContent":["import type React from 'react';\nimport { useState } from 'react';\nimport Button from '../Button';\nimport CaretDownIcon from '../CustomIcons/CaretDownIcon';\nimport CaretLeftIcon from '../CustomIcons/CaretLeftIcon';\nimport CaretRightIcon from '../CustomIcons/CaretRightIcon';\nimport SecondaryText from '../Typography/SecondaryText';\nimport { FOCUS_RING } from '../focusRing';\nimport type { TablePaginationAlign } from './paginationPlacement';\n\nexport type TablePaginationProps = {\n current: number;\n pageSize: number;\n total: number;\n showSizeChanger?: boolean;\n showQuickJumper?: boolean;\n showTotal?: (total: number, range: [number, number]) => React.ReactNode;\n pageSizeOptions?: string[];\n onChange?: (page: number, pageSize: number) => void;\n onShowSizeChange?: (current: number, size: number) => void;\n /** Which side of the rows it sits on, for the gap between them. */\n edge?: 'top' | 'bottom';\n align?: TablePaginationAlign;\n};\n\nconst DEFAULT_PAGE_SIZE_OPTIONS = ['10', '25', '50', '100'];\n\nconst JUSTIFY: Record<TablePaginationAlign, string> = {\n left: 'justify-start',\n center: 'justify-center',\n right: 'justify-end',\n};\n\n// `iconOnly` zeroes the padding, so an arrow collapses to its glyph unless given a box.\nconst SQUARE_CONTROL: React.CSSProperties = { width: 32, height: 32 };\n\n// Native controls rather than Dropdown and Input, which would more than double what every\n// Table costs a consumer whether it pages or not. Painted as Input is.\nconst FIELD_CLASS = `h-8 rounded-lg border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)] text-[var(--malachite-text-primary)] text-[13px] hover:border-[var(--malachite-control-border-hover)] focus:border-[var(--malachite-control-border-hover)] ${FOCUS_RING}`;\n\n/** First, last and a window around the current page, with an ellipsis over each gap. */\nconst computePageList = (current: number, totalPages: number): Array<number | 'ellipsis'> => {\n if (totalPages <= 7) {\n return Array.from({ length: totalPages }, (_, i) => i + 1);\n }\n if (current <= 4) {\n return [1, 2, 3, 4, 5, 'ellipsis', totalPages];\n }\n if (current >= totalPages - 3) {\n return [1, 'ellipsis', ...Array.from({ length: 5 }, (_, i) => totalPages - 4 + i)];\n }\n return [1, 'ellipsis', current - 1, current, current + 1, 'ellipsis', totalPages];\n};\n\nconst TablePagination: React.FC<TablePaginationProps> = ({\n current,\n pageSize,\n total,\n showSizeChanger = true,\n showQuickJumper = false,\n showTotal,\n pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,\n onChange,\n onShowSizeChange,\n edge = 'bottom',\n align = 'right',\n}) => {\n // Guard pageSize <= 0: it would make totalPages Infinity/NaN and throw a\n // RangeError when building the page list. Fall back to a sane default.\n const safePageSize = pageSize > 0 ? pageSize : 10;\n const totalPages = Math.max(1, Math.ceil(total / safePageSize));\n const safeCurrent = Math.min(Math.max(1, current), totalPages);\n const [jumpValue, setJumpValue] = useState('');\n\n const goTo = (page: number) => {\n const next = Math.min(Math.max(1, page), totalPages);\n if (next !== safeCurrent) {\n onChange?.(next, safePageSize);\n }\n };\n\n const handleJump = () => {\n const page = Number.parseInt(jumpValue, 10);\n if (!Number.isNaN(page)) {\n goTo(page);\n }\n setJumpValue('');\n };\n\n const rangeStart = total === 0 ? 0 : (safeCurrent - 1) * safePageSize + 1;\n const rangeEnd = Math.min(safeCurrent * safePageSize, total);\n const totalLabel = showTotal\n ? showTotal(total, [rangeStart, rangeEnd])\n : `Total ${total.toLocaleString('en-US')} items`;\n\n return (\n <div\n className={`${edge === 'top' ? 'mb-4' : 'mt-4'} flex items-center ${JUSTIFY[align]} gap-2 flex-wrap`}\n >\n <SecondaryText size=\"small\">{totalLabel}</SecondaryText>\n <Button\n variant=\"ghost\"\n size=\"medium\"\n iconOnly\n style={SQUARE_CONTROL}\n aria-label=\"Previous page\"\n icon={<CaretLeftIcon size={12} />}\n disabled={safeCurrent <= 1}\n onClick={() => goTo(safeCurrent - 1)}\n />\n {computePageList(safeCurrent, totalPages).map((entry, index) =>\n entry === 'ellipsis' ? (\n <SecondaryText key={`ellipsis-${index}`} size=\"small\">\n …\n </SecondaryText>\n ) : (\n <Button\n key={entry}\n variant={entry === safeCurrent ? 'outline' : 'ghost'}\n size=\"medium\"\n aria-label={`Page ${entry}`}\n aria-current={entry === safeCurrent ? 'page' : undefined}\n onClick={() => goTo(entry)}\n >\n {entry.toLocaleString('en-US')}\n </Button>\n ),\n )}\n <Button\n variant=\"ghost\"\n size=\"medium\"\n iconOnly\n style={SQUARE_CONTROL}\n aria-label=\"Next page\"\n icon={<CaretRightIcon size={12} />}\n disabled={safeCurrent >= totalPages}\n onClick={() => goTo(safeCurrent + 1)}\n />\n {showSizeChanger && (\n <span className=\"relative inline-flex items-center\">\n <select\n aria-label=\"Page size\"\n value={String(safePageSize)}\n onChange={(event) => {\n const size = Number.parseInt(event.target.value, 10);\n if (!Number.isNaN(size)) {\n onShowSizeChange?.(safeCurrent, size);\n onChange?.(safeCurrent, size);\n }\n }}\n className={`${FIELD_CLASS} appearance-none cursor-pointer pl-3 pr-8`}\n >\n {pageSizeOptions.map((option) => (\n <option key={option} value={option}>\n {option} / page\n </option>\n ))}\n </select>\n <span className=\"pointer-events-none absolute right-3 inline-flex text-[var(--malachite-text-secondary)]\">\n <CaretDownIcon size={12} />\n </span>\n </span>\n )}\n {showQuickJumper && (\n <span className=\"inline-flex items-center gap-2\">\n <SecondaryText size=\"small\">Go to</SecondaryText>\n <input\n aria-label=\"Go to page\"\n type=\"number\"\n min={1}\n max={totalPages}\n value={jumpValue}\n onChange={(event) => setJumpValue(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n handleJump();\n }\n }}\n onBlur={handleJump}\n className={`${FIELD_CLASS} w-[72px] px-2 text-center`}\n />\n </span>\n )}\n </div>\n );\n};\n\nexport default TablePagination;\n"],"names":["DEFAULT_PAGE_SIZE_OPTIONS","JUSTIFY","SQUARE_CONTROL","FIELD_CLASS","FOCUS_RING","computePageList","current","totalPages","_","i","TablePagination","pageSize","total","showSizeChanger","showQuickJumper","showTotal","pageSizeOptions","onChange","onShowSizeChange","edge","align","safePageSize","safeCurrent","jumpValue","setJumpValue","useState","goTo","page","next","handleJump","rangeStart","rangeEnd","totalLabel","jsxs","jsx","SecondaryText","Button","CaretLeftIcon","entry","index","CaretRightIcon","event","size","option","CaretDownIcon"],"mappings":";;;;;;;;AAyBA,MAAMA,IAA4B,CAAC,MAAM,MAAM,MAAM,KAAK,GAEpDC,IAAgD;AAAA,EAClD,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AACX,GAGMC,IAAsC,EAA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B,EAAM,OAAO,KAAK;AAAA,cACpD,WAAW,CAACA,MAAU;AAClB,gBAAIA,EAAM,QAAQ,WACdZ,EAAA;AAAA,cAER;AAAA,cACA,QAAQA;AAAA,cACR,WAAW,GAAG1B,CAAW;AAAA,YAAA;AAAA,UAAA;AAAA,QAC7B,EAAA,CACJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const c = {
|
|
2
|
+
Left: "left",
|
|
3
|
+
Center: "center",
|
|
4
|
+
Right: "right"
|
|
5
|
+
}, e = (t, o) => {
|
|
6
|
+
const n = t.find((i) => i.startsWith(o));
|
|
7
|
+
return n ? c[n.slice(o.length)] : void 0;
|
|
8
|
+
}, r = (t = ["bottomRight"]) => ({
|
|
9
|
+
top: e(t, "top"),
|
|
10
|
+
bottom: e(t, "bottom")
|
|
11
|
+
});
|
|
12
|
+
export {
|
|
13
|
+
r as paginationPlacement
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=paginationPlacement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginationPlacement.js","sources":["../../../src/components/Table/paginationPlacement.ts"],"sourcesContent":["import type { TablePaginationPosition } from './types';\n\nexport type TablePaginationAlign = 'left' | 'center' | 'right';\n\nconst ALIGN_OF: Record<string, TablePaginationAlign> = {\n Left: 'left',\n Center: 'center',\n Right: 'right',\n};\n\nconst alignAt = (\n positions: TablePaginationPosition[],\n edge: 'top' | 'bottom',\n): TablePaginationAlign | undefined => {\n const position = positions.find((candidate) => candidate.startsWith(edge));\n return position ? ALIGN_OF[position.slice(edge.length)] : undefined;\n};\n\n/** Where the pager goes for a `pagination.position` list, as antd reads it: one pager per edge\n * named, aligned as named. None given keeps the pager at the bottom right. */\nexport const paginationPlacement = (positions: TablePaginationPosition[] = ['bottomRight']) => ({\n top: alignAt(positions, 'top'),\n bottom: alignAt(positions, 'bottom'),\n});\n"],"names":["ALIGN_OF","alignAt","positions","edge","position","candidate","paginationPlacement"],"mappings":"AAIA,MAAMA,IAAiD;AAAA,EACnD,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,IAAU,CACZC,GACAC,MACmC;AACnC,QAAMC,IAAWF,EAAU,KAAK,CAACG,MAAcA,EAAU,WAAWF,CAAI,CAAC;AACzE,SAAOC,IAAWJ,EAASI,EAAS,MAAMD,EAAK,MAAM,CAAC,IAAI;AAC9D,GAIaG,IAAsB,CAACJ,IAAuC,CAAC,aAAa,OAAO;AAAA,EAC5F,KAAKD,EAAQC,GAAW,KAAK;AAAA,EAC7B,QAAQD,EAAQC,GAAW,QAAQ;AACvC;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useState as p, useLayoutEffect as g } from "react";
|
|
2
|
+
const f = 120, m = (t) => t.parentElement ?? t.getRootNode().host ?? null, w = (t) => {
|
|
3
|
+
const { overflowY: e } = getComputedStyle(t);
|
|
4
|
+
return e === "auto" || e === "scroll";
|
|
5
|
+
}, h = (t) => {
|
|
6
|
+
const e = [];
|
|
7
|
+
let o = m(t);
|
|
8
|
+
for (; o && o !== document.documentElement && o !== document.body; ) {
|
|
9
|
+
if (e.push(o), w(o))
|
|
10
|
+
return { ancestors: e, scroller: o };
|
|
11
|
+
o = m(o);
|
|
12
|
+
}
|
|
13
|
+
return { ancestors: e, scroller: null };
|
|
14
|
+
}, a = (t) => Number.parseFloat(t) || 0, y = (t) => {
|
|
15
|
+
const e = Array.from((t.parentElement ?? t.getRootNode()).children);
|
|
16
|
+
return e.slice(e.indexOf(t) + 1);
|
|
17
|
+
}, B = (t, e) => y(t).flatMap((o) => {
|
|
18
|
+
const { position: n, display: r, marginBottom: s } = getComputedStyle(o), c = o.getBoundingClientRect();
|
|
19
|
+
return n !== "fixed" && n !== "absolute" && r !== "none" && c.top >= e - 1 ? [c.bottom + a(s)] : [];
|
|
20
|
+
}), R = (t, e) => {
|
|
21
|
+
let o = 0, n = t, r = m(n);
|
|
22
|
+
for (; r && r !== document.documentElement; ) {
|
|
23
|
+
const s = n.getBoundingClientRect(), c = s.bottom + a(getComputedStyle(n).marginBottom), i = getComputedStyle(r);
|
|
24
|
+
if (o += Math.max(c, ...B(n, s.bottom)) - s.bottom + a(i.paddingBottom) + a(i.borderBottomWidth), r === e)
|
|
25
|
+
break;
|
|
26
|
+
n = r, r = m(n);
|
|
27
|
+
}
|
|
28
|
+
return o;
|
|
29
|
+
}, F = (t, e) => {
|
|
30
|
+
const o = t.getBoundingClientRect(), n = R(t, e);
|
|
31
|
+
return e ? e.getBoundingClientRect().top + e.clientTop + e.clientHeight - (o.top + e.scrollTop) - n : window.innerHeight - (o.top + window.scrollY) - n;
|
|
32
|
+
}, E = (t, e) => {
|
|
33
|
+
const [o, n] = p();
|
|
34
|
+
return g(() => {
|
|
35
|
+
if (!e || !t)
|
|
36
|
+
return;
|
|
37
|
+
const { ancestors: r, scroller: s } = h(t), c = () => n(Math.max(f, Math.floor(F(t, s))));
|
|
38
|
+
c();
|
|
39
|
+
let i = 0;
|
|
40
|
+
const u = () => {
|
|
41
|
+
cancelAnimationFrame(i), i = requestAnimationFrame(c);
|
|
42
|
+
}, l = typeof ResizeObserver > "u" ? null : new ResizeObserver(u);
|
|
43
|
+
for (const d of r)
|
|
44
|
+
l == null || l.observe(d);
|
|
45
|
+
return window.addEventListener("resize", u), () => {
|
|
46
|
+
cancelAnimationFrame(i), l == null || l.disconnect(), window.removeEventListener("resize", u);
|
|
47
|
+
};
|
|
48
|
+
}, [t, e]), e ? o : void 0;
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
E as useFillHeight
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=useFillHeight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFillHeight.js","sources":["../../../src/components/Table/useFillHeight.ts"],"sourcesContent":["import { useLayoutEffect, useState } from 'react';\n\n// A short window still shows a few rows rather than none.\nconst MIN_FILL_HEIGHT = 120;\n\n// The table renders inside a shadow root, so its page's layout continues at the host.\nconst parentAcrossShadow = (element: Element): Element | null =>\n element.parentElement ?? (element.getRootNode() as Partial<ShadowRoot>).host ?? null;\n\nconst scrollsVertically = (element: Element): boolean => {\n const { overflowY } = getComputedStyle(element);\n return overflowY === 'auto' || overflowY === 'scroll';\n};\n\n/** Every ancestor up to the nearest one that scrolls, and that scroller (none: the page). */\nconst ancestorsToScroller = (box: Element): { ancestors: Element[]; scroller: Element | null } => {\n const ancestors: Element[] = [];\n let node = parentAcrossShadow(box);\n while (node && node !== document.documentElement && node !== document.body) {\n ancestors.push(node);\n if (scrollsVertically(node)) {\n return { ancestors, scroller: node };\n }\n node = parentAcrossShadow(node);\n }\n return { ancestors, scroller: null };\n};\n\nconst px = (value: string): number => Number.parseFloat(value) || 0;\n\nconst siblingsAfter = (node: Element): Element[] => {\n const all = Array.from((node.parentElement ?? (node.getRootNode() as ParentNode)).children);\n return all.slice(all.indexOf(node) + 1);\n};\n\n/** Bottoms of the in-flow siblings laid out below `node`, not beside it as in a flex row. */\nconst bottomsBelow = (node: Element, nodeBottom: number): number[] =>\n siblingsAfter(node).flatMap((sibling) => {\n const { position, display, marginBottom } = getComputedStyle(sibling);\n const rect = sibling.getBoundingClientRect();\n const inFlow = position !== 'fixed' && position !== 'absolute' && display !== 'none';\n return inFlow && rect.top >= nodeBottom - 1 ? [rect.bottom + px(marginBottom)] : [];\n });\n\n/** Everything that has to fit after the box: at each level up to the scroller, what follows it\n * and the bottom padding and border around it. Summed rather than read off where the page ends,\n * as layouts stretched to the window's height end at its bottom whatever they hold. */\nconst spaceBelow = (box: Element, scroller: Element | null): number => {\n let below = 0;\n let node = box;\n let parent = parentAcrossShadow(node);\n while (parent && parent !== document.documentElement) {\n const nodeRect = node.getBoundingClientRect();\n const nodeBottom = nodeRect.bottom + px(getComputedStyle(node).marginBottom);\n const parentStyle = getComputedStyle(parent);\n below +=\n Math.max(nodeBottom, ...bottomsBelow(node, nodeRect.bottom)) -\n nodeRect.bottom +\n px(parentStyle.paddingBottom) +\n px(parentStyle.borderBottomWidth);\n if (parent === scroller) {\n break;\n }\n node = parent;\n parent = parentAcrossShadow(node);\n }\n return below;\n};\n\n/** From the box's top to the scroller's bottom, less everything laid out after the box. Taken as\n * if scrolled to the top, so a scrolled page settles back to fitting instead of keeping its overflow. */\nconst measureFill = (box: Element, scroller: Element | null): number => {\n const boxRect = box.getBoundingClientRect();\n const below = spaceBelow(box, scroller);\n if (!scroller) {\n return window.innerHeight - (boxRect.top + window.scrollY) - below;\n }\n const top = scroller.getBoundingClientRect().top + scroller.clientTop;\n return top + scroller.clientHeight - (boxRect.top + scroller.scrollTop) - below;\n};\n\n/** For `scrollHeight=\"fill\"`: the box's height, measured again whenever the page around it resizes. */\nexport const useFillHeight = (box: Element | null, enabled: boolean): number | undefined => {\n const [height, setHeight] = useState<number>();\n\n useLayoutEffect(() => {\n if (!enabled || !box) {\n return undefined;\n }\n const { ancestors, scroller } = ancestorsToScroller(box);\n const measure = () =>\n setHeight(Math.max(MIN_FILL_HEIGHT, Math.floor(measureFill(box, scroller))));\n measure();\n\n // A frame later, or the height set in response is reported back within the same frame.\n let frame = 0;\n const remeasure = () => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(measure);\n };\n const observer =\n typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(remeasure);\n for (const ancestor of ancestors) {\n observer?.observe(ancestor);\n }\n window.addEventListener('resize', remeasure);\n return () => {\n cancelAnimationFrame(frame);\n observer?.disconnect();\n window.removeEventListener('resize', remeasure);\n };\n }, [box, enabled]);\n\n return enabled ? height : undefined;\n};\n"],"names":["MIN_FILL_HEIGHT","parentAcrossShadow","element","scrollsVertically","overflowY","ancestorsToScroller","box","ancestors","node","px","value","siblingsAfter","all","bottomsBelow","nodeBottom","sibling","position","display","marginBottom","rect","spaceBelow","scroller","below","parent","nodeRect","parentStyle","measureFill","boxRect","useFillHeight","enabled","height","setHeight","useState","useLayoutEffect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AAU,QAAQC;AAEtB,kBAAO,iBAAiB,UAAUF,CAAS,GACpC,MAAM;AACT,2BAAqBD,CAAK,GAC1BE,KAAA,QAAAA,EAAU,cACV,OAAO,oBAAoB,UAAUD,CAAS;AAAA,IAClD;AAAA,EACJ,GAAG,CAAC9B,GAAKuB,CAAO,CAAC,GAEVA,IAAUC,IAAS;AAC9B;"}
|
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
1
|
+
import { jsx as a, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { TimeBarChartSwatch as i } from "./TimeBarChartSwatch.js";
|
|
3
|
+
const m = ({ series: t }) => /* @__PURE__ */ a("div", { style: { display: "flex", gap: 16, marginBottom: 8 }, children: t.map((e) => /* @__PURE__ */ l(
|
|
4
4
|
"span",
|
|
5
5
|
{
|
|
6
6
|
className: "text-[length:var(--malachite-font-size-xsmall,11px)] text-[var(--malachite-text-secondary,rgb(123,123,123))]",
|
|
7
7
|
style: { display: "inline-flex", alignItems: "center", gap: 6 },
|
|
8
8
|
children: [
|
|
9
|
-
/* @__PURE__ */ a(
|
|
10
|
-
"span",
|
|
11
|
-
{
|
|
12
|
-
"aria-hidden": !0,
|
|
13
|
-
style: {
|
|
14
|
-
width: 8,
|
|
15
|
-
height: 8,
|
|
16
|
-
borderRadius: 2,
|
|
17
|
-
background: l[e.tone]
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
),
|
|
9
|
+
/* @__PURE__ */ a(i, { tone: e.tone }),
|
|
21
10
|
e.label
|
|
22
11
|
]
|
|
23
12
|
},
|
|
24
13
|
e.key
|
|
25
14
|
)) });
|
|
26
15
|
export {
|
|
27
|
-
|
|
16
|
+
m as default
|
|
28
17
|
};
|
|
29
18
|
//# sourceMappingURL=TimeBarChartLegend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeBarChartLegend.js","sources":["../../../src/components/TimeBarChart/TimeBarChartLegend.tsx"],"sourcesContent":["import type React from 'react';\nimport type { TimeBarChartSeries } from './TimeBarChart';\nimport
|
|
1
|
+
{"version":3,"file":"TimeBarChartLegend.js","sources":["../../../src/components/TimeBarChart/TimeBarChartLegend.tsx"],"sourcesContent":["import type React from 'react';\nimport type { TimeBarChartSeries } from './TimeBarChart';\nimport TimeBarChartSwatch from './TimeBarChartSwatch';\n\nconst TimeBarChartLegend: React.FC<{ series: TimeBarChartSeries[] }> = ({ series }) => (\n <div style={{ display: 'flex', gap: 16, marginBottom: 8 }}>\n {series.map((entry) => (\n <span\n key={entry.key}\n className=\"text-[length:var(--malachite-font-size-xsmall,11px)] text-[var(--malachite-text-secondary,rgb(123,123,123))]\"\n style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}\n >\n <TimeBarChartSwatch tone={entry.tone} />\n {entry.label}\n </span>\n ))}\n </div>\n);\n\nexport default TimeBarChartLegend;\n"],"names":["TimeBarChartLegend","series","jsx","entry","jsxs","TimeBarChartSwatch"],"mappings":";;AAIA,MAAMA,IAAiE,CAAC,EAAE,QAAAC,QACtE,gBAAAC,EAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,KAAK,IAAI,cAAc,EAAA,GACjD,UAAAD,EAAO,IAAI,CAACE,MACT,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IAEG,WAAU;AAAA,IACV,OAAO,EAAE,SAAS,eAAe,YAAY,UAAU,KAAK,EAAA;AAAA,IAE5D,UAAA;AAAA,MAAA,gBAAAF,EAACG,GAAA,EAAmB,MAAMF,EAAM,KAAA,CAAM;AAAA,MACrCA,EAAM;AAAA,IAAA;AAAA,EAAA;AAAA,EALFA,EAAM;AAMf,CACH,EAAA,CACL;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { TONE_FILL as a } from "./tones.js";
|
|
3
|
+
const o = ({ tone: r }) => /* @__PURE__ */ i(
|
|
4
|
+
"span",
|
|
5
|
+
{
|
|
6
|
+
"aria-hidden": !0,
|
|
7
|
+
style: {
|
|
8
|
+
display: "inline-block",
|
|
9
|
+
width: 8,
|
|
10
|
+
height: 8,
|
|
11
|
+
borderRadius: 2,
|
|
12
|
+
flexShrink: 0,
|
|
13
|
+
background: a[r]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
export {
|
|
18
|
+
o as TimeBarChartSwatch,
|
|
19
|
+
o as default
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=TimeBarChartSwatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeBarChartSwatch.js","sources":["../../../src/components/TimeBarChart/TimeBarChartSwatch.tsx"],"sourcesContent":["import type React from 'react';\nimport type { TimeBarChartTone } from './TimeBarChart';\nimport { TONE_FILL } from './tones';\n\nexport interface TimeBarChartSwatchProps {\n tone: TimeBarChartTone;\n}\n\n/** The mark a series is drawn in, for naming it outside the chart: a stat beside the chart\n * that stands in for the legend, say. Decorative, so the label next to it does the naming. */\nconst TimeBarChartSwatch: React.FC<TimeBarChartSwatchProps> = ({ tone }) => (\n <span\n aria-hidden\n style={{\n display: 'inline-block',\n width: 8,\n height: 8,\n borderRadius: 2,\n flexShrink: 0,\n background: TONE_FILL[tone],\n }}\n />\n);\n\nexport default TimeBarChartSwatch;\nexport { TimeBarChartSwatch };\n"],"names":["TimeBarChartSwatch","tone","jsx","TONE_FILL"],"mappings":";;AAUA,MAAMA,IAAwD,CAAC,EAAE,MAAAC,EAAA,MAC7D,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,eAAW;AAAA,IACX,OAAO;AAAA,MACH,SAAS;AAAA,MACT,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,YAAYC,EAAUF,CAAI;AAAA,IAAA;AAAA,EAC9B;AACJ;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsxs as a, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar as c } from "./Avatar.js";
|
|
3
|
+
import d from "./Typography/SecondaryText.js";
|
|
4
|
+
import p from "./Typography/Text.js";
|
|
5
|
+
const f = { small: 24, medium: 32 }, o = { small: "small", medium: "medium" }, m = "block overflow-hidden text-ellipsis whitespace-nowrap", w = ({ name: e, email: l, src: n, size: i = "small" }) => {
|
|
6
|
+
const r = (e == null ? void 0 : e.trim()) || void 0, t = r ? l : void 0;
|
|
7
|
+
return /* @__PURE__ */ a("span", { className: "flex items-center gap-3 min-w-0", children: [
|
|
8
|
+
/* @__PURE__ */ s("span", { "aria-hidden": !0, className: "flex shrink-0", children: /* @__PURE__ */ s(c, { name: r ?? l, src: n, size: f[i] }) }),
|
|
9
|
+
/* @__PURE__ */ a("span", { className: "flex flex-col min-w-0", children: [
|
|
10
|
+
/* @__PURE__ */ s(p, { size: o[i], className: m, children: r ?? l ?? "-" }),
|
|
11
|
+
t && /* @__PURE__ */ s(d, { size: o[i], className: m, children: t })
|
|
12
|
+
] })
|
|
13
|
+
] });
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
w as UserIdentity,
|
|
17
|
+
w as default
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=UserIdentity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserIdentity.js","sources":["../../src/components/UserIdentity.tsx"],"sourcesContent":["import type React from 'react';\nimport Avatar from './Avatar';\nimport SecondaryText from './Typography/SecondaryText';\nimport Text from './Typography/Text';\nimport type { FontSize } from './Typography/textStyles';\n\nexport type UserIdentitySize = 'small' | 'medium';\n\nconst AVATAR_PX: Record<UserIdentitySize, number> = { small: 24, medium: 32 };\nconst TEXT_SIZE: Record<UserIdentitySize, FontSize> = { small: 'small', medium: 'medium' };\nconst ONE_LINE = 'block overflow-hidden text-ellipsis whitespace-nowrap';\n\nexport interface UserIdentityProps {\n /** The first line. Without one, the email takes its place and the second line is dropped. */\n name?: string;\n email?: string;\n /** Photo URL. Without one the avatar shows the initial of the name, else of the email. */\n src?: string;\n size?: UserIdentitySize;\n}\n\n/** A person as the dashboard lists them: avatar, name, and their email beneath. */\nconst UserIdentity: React.FC<UserIdentityProps> = ({ name, email, src, size = 'small' }) => {\n const shownName = name?.trim() || undefined;\n const detail = shownName ? email : undefined;\n return (\n <span className=\"flex items-center gap-3 min-w-0\">\n {/* The text beside it already names the person, so the avatar is not announced twice. */}\n <span aria-hidden className=\"flex shrink-0\">\n <Avatar name={shownName ?? email} src={src} size={AVATAR_PX[size]} />\n </span>\n <span className=\"flex flex-col min-w-0\">\n <Text size={TEXT_SIZE[size]} className={ONE_LINE}>\n {shownName ?? email ?? '-'}\n </Text>\n {detail && (\n <SecondaryText size={TEXT_SIZE[size]} className={ONE_LINE}>\n {detail}\n </SecondaryText>\n )}\n </span>\n </span>\n );\n};\n\nexport default UserIdentity;\nexport { UserIdentity };\n"],"names":["AVATAR_PX","TEXT_SIZE","ONE_LINE","UserIdentity","name","email","src","size","shownName","detail","jsxs","jsx","Avatar","Text","SecondaryText"],"mappings":";;;;AAQA,MAAMA,IAA8C,EAAE,OAAO,IAAI,QAAQ,GAAA,GACnEC,IAAgD,EAAE,OAAO,SAAS,QAAQ,SAAA,GAC1EC,IAAW,yDAYXC,IAA4C,CAAC,EAAE,MAAAC,GAAM,OAAAC,GAAO,KAAAC,GAAK,MAAAC,IAAO,cAAc;AACxF,QAAMC,KAAYJ,KAAA,gBAAAA,EAAM,WAAU,QAC5BK,IAASD,IAAYH,IAAQ;AACnC,SACI,gBAAAK,EAAC,QAAA,EAAK,WAAU,mCAEZ,UAAA;AAAA,IAAA,gBAAAC,EAAC,QAAA,EAAK,eAAW,IAAC,WAAU,iBACxB,UAAA,gBAAAA,EAACC,GAAA,EAAO,MAAMJ,KAAaH,GAAO,KAAAC,GAAU,MAAMN,EAAUO,CAAI,GAAG,GACvE;AAAA,IACA,gBAAAG,EAAC,QAAA,EAAK,WAAU,yBACZ,UAAA;AAAA,MAAA,gBAAAC,EAACE,GAAA,EAAK,MAAMZ,EAAUM,CAAI,GAAG,WAAWL,GACnC,UAAAM,KAAaH,KAAS,IAAA,CAC3B;AAAA,MACCI,uBACIK,GAAA,EAAc,MAAMb,EAAUM,CAAI,GAAG,WAAWL,GAC5C,UAAAO,EAAA,CACL;AAAA,IAAA,EAAA,CAER;AAAA,EAAA,GACJ;AAER;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5413,7 +5413,9 @@ declare type TableProps<T = Record<string, unknown>> = {
|
|
|
5413
5413
|
bordered?: boolean;
|
|
5414
5414
|
showHeader?: boolean;
|
|
5415
5415
|
rowKey?: string | ((record: T) => string);
|
|
5416
|
-
|
|
5416
|
+
/** Bounds the rows' scroll area. `'fill'` takes whatever height its scroller has left, below
|
|
5417
|
+
* the content above it and above whatever follows, so the page itself never scrolls. */
|
|
5418
|
+
scrollHeight?: string | number | 'fill';
|
|
5417
5419
|
type?: TableType;
|
|
5418
5420
|
size?: TableSize;
|
|
5419
5421
|
/** Vertical density of body rows. 'compact' takes the cell padding to 4px and lets a row
|
|
@@ -5762,6 +5764,14 @@ export declare interface TimeBarChartSeries {
|
|
|
5762
5764
|
|
|
5763
5765
|
export declare type TimeBarChartSize = 'small' | 'medium' | 'large';
|
|
5764
5766
|
|
|
5767
|
+
/** The mark a series is drawn in, for naming it outside the chart: a stat beside the chart
|
|
5768
|
+
* that stands in for the legend, say. Decorative, so the label next to it does the naming. */
|
|
5769
|
+
export declare const TimeBarChartSwatch: default_2.FC<TimeBarChartSwatchProps>;
|
|
5770
|
+
|
|
5771
|
+
export declare interface TimeBarChartSwatchProps {
|
|
5772
|
+
tone: TimeBarChartTone;
|
|
5773
|
+
}
|
|
5774
|
+
|
|
5765
5775
|
export declare type TimeBarChartTone = 'success' | 'error' | 'neutral';
|
|
5766
5776
|
|
|
5767
5777
|
export declare type TimeBarChartUnit = 'minute' | 'hour' | 'day' | 'week' | 'month';
|
|
@@ -5979,6 +5989,20 @@ export declare interface UsageCardProps {
|
|
|
5979
5989
|
*/
|
|
5980
5990
|
export declare const useHasOpenOverlay: () => boolean;
|
|
5981
5991
|
|
|
5992
|
+
/** A person as the dashboard lists them: avatar, name, and their email beneath. */
|
|
5993
|
+
export declare const UserIdentity: default_2.FC<UserIdentityProps>;
|
|
5994
|
+
|
|
5995
|
+
export declare interface UserIdentityProps {
|
|
5996
|
+
/** The first line. Without one, the email takes its place and the second line is dropped. */
|
|
5997
|
+
name?: string;
|
|
5998
|
+
email?: string;
|
|
5999
|
+
/** Photo URL. Without one the avatar shows the initial of the name, else of the email. */
|
|
6000
|
+
src?: string;
|
|
6001
|
+
size?: UserIdentitySize;
|
|
6002
|
+
}
|
|
6003
|
+
|
|
6004
|
+
export declare type UserIdentitySize = 'small' | 'medium';
|
|
6005
|
+
|
|
5982
6006
|
export declare const useSidebarCollapsed: () => boolean;
|
|
5983
6007
|
|
|
5984
6008
|
/** Shows a toast from anywhere under a `ToastProvider`. Throws outside one. */
|