@ksojecki/purpose-ui 0.2.1 → 0.3.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/data/Avatar.d.ts +15 -0
- package/dist/data/index.d.ts +2 -1
- package/dist/data/index.js +90 -41
- package/dist/internal/initials.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
2
|
+
export interface AvatarProps {
|
|
3
|
+
/** The person's name, used for both initials and the accessible name. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** An optional image URL. Missing or failed images fall back to initials or a person icon. */
|
|
6
|
+
src?: string;
|
|
7
|
+
/** Frame size, from 24px (xs) to 96px (xl). Defaults to md (40px). */
|
|
8
|
+
size?: AvatarSize;
|
|
9
|
+
/** Hide the avatar from assistive technology when nearby text already names the person. */
|
|
10
|
+
decorative?: boolean;
|
|
11
|
+
/** Additional classes for the avatar frame. */
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** A round image of a person, with initials or a person icon when no image is available. */
|
|
15
|
+
export declare const Avatar: ({ name, src, size, decorative, className }: AvatarProps) => import("react").JSX.Element;
|
package/dist/data/index.d.ts
CHANGED
package/dist/data/index.js
CHANGED
|
@@ -1,85 +1,134 @@
|
|
|
1
1
|
import { t as e } from "../classNames-x6JVYA2t.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { useCallback as t, useState as n } from "react";
|
|
3
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
|
+
import { TbUser as o } from "react-icons/tb";
|
|
5
|
+
// src/internal/initials.ts
|
|
6
|
+
function s(e) {
|
|
7
|
+
let t = e.split(/\s+/u).flatMap((e) => e.match(/\p{L}/u) ?? []);
|
|
8
|
+
return [t[0], t.length > 1 ? t.at(-1) : void 0].map((e) => {
|
|
9
|
+
if (!e) return "";
|
|
10
|
+
let t = e.toLocaleUpperCase();
|
|
11
|
+
return [...t].length === 1 ? t : e;
|
|
12
|
+
}).join("");
|
|
13
|
+
}
|
|
14
|
+
// src/data/Avatar.tsx
|
|
15
|
+
var c = {
|
|
16
|
+
xs: "size-6 text-xs",
|
|
17
|
+
sm: "size-8 text-sm",
|
|
18
|
+
md: "size-10 text-base",
|
|
19
|
+
lg: "size-16 text-2xl",
|
|
20
|
+
xl: "size-24 text-4xl"
|
|
21
|
+
};
|
|
22
|
+
function l({ name: e, src: c }) {
|
|
23
|
+
let [l, u] = n("pending"), d = t((e) => {
|
|
24
|
+
e?.complete && u(e.naturalWidth > 0 ? "loaded" : "failed");
|
|
25
|
+
}, []), f = l === "loaded" ? "" : s(e);
|
|
26
|
+
return /* @__PURE__ */ a(r, { children: [c && l !== "failed" ? /* @__PURE__ */ i("img", {
|
|
27
|
+
alt: "",
|
|
28
|
+
className: "size-full object-cover",
|
|
29
|
+
hidden: l !== "loaded",
|
|
30
|
+
onError: () => u("failed"),
|
|
31
|
+
onLoad: () => u("loaded"),
|
|
32
|
+
ref: d,
|
|
33
|
+
src: c
|
|
34
|
+
}) : null, l === "loaded" ? null : /* @__PURE__ */ i("span", {
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
className: "flex size-full items-center justify-center bg-neutral font-semibold text-neutral-content",
|
|
37
|
+
children: f || /* @__PURE__ */ i(o, { className: "size-3/5" })
|
|
38
|
+
})] });
|
|
39
|
+
}
|
|
40
|
+
var u = ({ name: t, src: n, size: r = "md", decorative: a = !1, className: o }) => {
|
|
41
|
+
let s = a || !t.trim() ? { "aria-hidden": !0 } : {
|
|
42
|
+
role: "img",
|
|
43
|
+
"aria-label": t
|
|
44
|
+
};
|
|
45
|
+
return /* @__PURE__ */ i("span", {
|
|
46
|
+
...s,
|
|
47
|
+
className: e("avatar shrink-0 overflow-hidden rounded-full", c[r], o),
|
|
48
|
+
children: /* @__PURE__ */ i(l, {
|
|
49
|
+
name: t,
|
|
50
|
+
src: n
|
|
51
|
+
}, n)
|
|
52
|
+
});
|
|
53
|
+
}, d = {
|
|
5
54
|
xs: "table-xs",
|
|
6
55
|
sm: "table-sm",
|
|
7
56
|
md: "",
|
|
8
57
|
lg: "table-lg"
|
|
9
58
|
};
|
|
10
|
-
function
|
|
11
|
-
return /* @__PURE__ */
|
|
12
|
-
"aria-label":
|
|
13
|
-
className: e("overflow-x-auto",
|
|
14
|
-
role:
|
|
15
|
-
tabIndex:
|
|
16
|
-
children: /* @__PURE__ */
|
|
17
|
-
...
|
|
18
|
-
className: e("table",
|
|
19
|
-
children:
|
|
59
|
+
function f({ tableSize: t = "sm", zebra: n = !1, wrapperClassName: r, className: a, children: o, label: s, ...c }) {
|
|
60
|
+
return /* @__PURE__ */ i("div", {
|
|
61
|
+
"aria-label": s,
|
|
62
|
+
className: e("overflow-x-auto", r),
|
|
63
|
+
role: s ? "region" : void 0,
|
|
64
|
+
tabIndex: s ? 0 : void 0,
|
|
65
|
+
children: /* @__PURE__ */ i("table", {
|
|
66
|
+
...c,
|
|
67
|
+
className: e("table", d[t], n ? "table-zebra" : void 0, "w-full", a),
|
|
68
|
+
children: o
|
|
20
69
|
})
|
|
21
70
|
});
|
|
22
71
|
}
|
|
23
72
|
// src/data/DataTable.tsx
|
|
24
|
-
var
|
|
25
|
-
function
|
|
73
|
+
var p = "whitespace-nowrap text-right tabular-nums", m = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase().replace(/^./, (e) => e.toUpperCase()), h = (e, t) => e.id ?? e.key ?? String(t);
|
|
74
|
+
function g(e) {
|
|
26
75
|
return e[0] ? Object.keys(e[0]).map((e) => ({ key: e })) : [];
|
|
27
76
|
}
|
|
28
|
-
function
|
|
77
|
+
function _(e, t) {
|
|
29
78
|
if (e.render) return e.render(t);
|
|
30
79
|
if (!e.key) return null;
|
|
31
80
|
let n = t[e.key];
|
|
32
81
|
return e.format ? e.format(n, t) : n == null ? "" : String(n);
|
|
33
82
|
}
|
|
34
|
-
function
|
|
35
|
-
if (
|
|
36
|
-
let
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
-
...
|
|
39
|
-
children: [/* @__PURE__ */
|
|
83
|
+
function v({ rows: t, columns: n, getRowKey: o = (e, t) => e.id ?? t, empty: s, ...c }) {
|
|
84
|
+
if (t.length === 0 && s !== void 0) return /* @__PURE__ */ i(r, { children: s });
|
|
85
|
+
let l = (n ?? g(t)).filter((e) => !e.hidden);
|
|
86
|
+
return /* @__PURE__ */ a(f, {
|
|
87
|
+
...c,
|
|
88
|
+
children: [/* @__PURE__ */ i("thead", { children: /* @__PURE__ */ i("tr", { children: l.map((t, n) => /* @__PURE__ */ i("th", {
|
|
40
89
|
className: e(t.kind === "number" ? "text-right" : void 0, t.className),
|
|
41
|
-
children: t.srOnlyHeader ? /* @__PURE__ */
|
|
90
|
+
children: t.srOnlyHeader ? /* @__PURE__ */ i("span", {
|
|
42
91
|
className: "sr-only",
|
|
43
92
|
children: t.header
|
|
44
|
-
}) : t.header ?? (t.key ?
|
|
45
|
-
},
|
|
46
|
-
className: e(
|
|
47
|
-
children:
|
|
48
|
-
},
|
|
93
|
+
}) : t.header ?? (t.key ? m(t.key) : null)
|
|
94
|
+
}, h(t, n))) }) }), /* @__PURE__ */ i("tbody", { children: t.map((t, n) => /* @__PURE__ */ i("tr", { children: l.map((n, r) => /* @__PURE__ */ i("td", {
|
|
95
|
+
className: e(n.kind === "number" ? p : void 0, n.className),
|
|
96
|
+
children: _(n, t)
|
|
97
|
+
}, h(n, r))) }, o(t, n))) })]
|
|
49
98
|
});
|
|
50
99
|
}
|
|
51
100
|
// src/data/Metric.tsx
|
|
52
|
-
var
|
|
101
|
+
var y = {
|
|
53
102
|
default: void 0,
|
|
54
103
|
boxed: "rounded-box border border-base-300 bg-base-100"
|
|
55
|
-
},
|
|
104
|
+
}, b = {
|
|
56
105
|
info: "text-info",
|
|
57
106
|
success: "text-success",
|
|
58
107
|
warning: "text-warning",
|
|
59
108
|
error: "text-error"
|
|
60
|
-
},
|
|
61
|
-
className: e("stats",
|
|
109
|
+
}, x = ({ children: t, className: n, responsive: r = !1, vertical: a = !1 }) => /* @__PURE__ */ i("div", {
|
|
110
|
+
className: e("stats", r ? "stats-vertical sm:stats-horizontal" : a ? "stats-vertical" : void 0, n),
|
|
62
111
|
children: t
|
|
63
|
-
}),
|
|
112
|
+
}), S = ({ appearance: t = "default", className: n, description: r, figure: o, label: s, tone: c, value: l, valueClassName: u, ...d }) => /* @__PURE__ */ a("div", {
|
|
64
113
|
...d,
|
|
65
|
-
className: e("stat",
|
|
114
|
+
className: e("stat", y[t], n),
|
|
66
115
|
children: [
|
|
67
|
-
o ? /* @__PURE__ */
|
|
116
|
+
o ? /* @__PURE__ */ i("div", {
|
|
68
117
|
className: "stat-figure",
|
|
69
118
|
children: o
|
|
70
119
|
}) : null,
|
|
71
|
-
/* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ i("div", {
|
|
72
121
|
className: "stat-title",
|
|
73
122
|
children: s
|
|
74
123
|
}),
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
className: e("stat-value", c ?
|
|
124
|
+
/* @__PURE__ */ i("div", {
|
|
125
|
+
className: e("stat-value", c ? b[c] : void 0, u),
|
|
77
126
|
children: l
|
|
78
127
|
}),
|
|
79
|
-
|
|
128
|
+
r ? /* @__PURE__ */ i("div", {
|
|
80
129
|
className: "stat-desc",
|
|
81
|
-
children:
|
|
130
|
+
children: r
|
|
82
131
|
}) : null
|
|
83
132
|
]
|
|
84
133
|
});
|
|
85
|
-
export {
|
|
134
|
+
export { u as Avatar, v as DataTable, S as Metric, x as MetricGroup, f as Table };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initials(name: string): string;
|