@knkcs/anker 1.10.1 → 1.10.3
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/atoms/index.d.ts +2 -0
- package/dist/atoms/index.js +2 -2
- package/dist/{chunk-ELQTHWXC.js → chunk-ETY43HAI.js} +10 -6
- package/dist/chunk-ETY43HAI.js.map +1 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.js +16 -5
- package/dist/components/index.js.map +1 -1
- package/package.json +4 -2
- package/dist/chunk-ELQTHWXC.js.map +0 -1
package/dist/atoms/index.d.ts
CHANGED
|
@@ -556,6 +556,8 @@ interface StatusBadgeProps {
|
|
|
556
556
|
label: string;
|
|
557
557
|
/** The background color for the badge (hex format, e.g. "#ff0000") */
|
|
558
558
|
color: string;
|
|
559
|
+
/** Optional icon rendered inline before the label inside the badge. */
|
|
560
|
+
icon?: React__default.ReactNode;
|
|
559
561
|
}
|
|
560
562
|
declare const StatusBadge: React__default.FC<StatusBadgeProps>;
|
|
561
563
|
|
package/dist/atoms/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Prose } from '../chunk-VOGT33LU.js';
|
|
2
|
-
import { formatRelativeToCurrentWeekDateTime, formatRelativeDateTime } from '../chunk-
|
|
3
|
-
export { StatusBadge, formatRelativeDateTime, formatRelativeToCurrentWeekDateTime } from '../chunk-
|
|
2
|
+
import { formatRelativeToCurrentWeekDateTime, formatRelativeDateTime } from '../chunk-ETY43HAI.js';
|
|
3
|
+
export { StatusBadge, formatRelativeDateTime, formatRelativeToCurrentWeekDateTime } from '../chunk-ETY43HAI.js';
|
|
4
4
|
import { Tooltip, Avatar, Table, MenuRoot, MenuTrigger, MenuContent, MenuItem, Badge } from '../chunk-2ZWZ2WAS.js';
|
|
5
5
|
export { SearchInput } from '../chunk-E7KRPPCQ.js';
|
|
6
6
|
import { Textarea } from '../chunk-NFZMG6ZL.js';
|
|
@@ -5,7 +5,7 @@ import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
|
5
5
|
import utcPlugin from 'dayjs/plugin/utc.js';
|
|
6
6
|
import { readableColor } from 'color2k';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { jsxs } from 'react/jsx-runtime';
|
|
9
9
|
|
|
10
10
|
dayjs.extend(utcPlugin);
|
|
11
11
|
dayjs.extend(relativeTime);
|
|
@@ -23,7 +23,7 @@ function formatRelativeToCurrentWeekDateTime(date, baseDate = /* @__PURE__ */ ne
|
|
|
23
23
|
return formatRelativeDateTime(date, baseDate);
|
|
24
24
|
}
|
|
25
25
|
var StatusBadge = (props) => {
|
|
26
|
-
const { label, color } = props;
|
|
26
|
+
const { label, color, icon } = props;
|
|
27
27
|
const textColor = useMemo(() => {
|
|
28
28
|
try {
|
|
29
29
|
return readableColor(color);
|
|
@@ -31,7 +31,7 @@ var StatusBadge = (props) => {
|
|
|
31
31
|
return "black";
|
|
32
32
|
}
|
|
33
33
|
}, [color]);
|
|
34
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ jsxs(
|
|
35
35
|
Badge,
|
|
36
36
|
{
|
|
37
37
|
bg: color,
|
|
@@ -39,12 +39,16 @@ var StatusBadge = (props) => {
|
|
|
39
39
|
rounded: "base",
|
|
40
40
|
px: 2,
|
|
41
41
|
marginInlineStart: 1,
|
|
42
|
-
|
|
42
|
+
gap: 1,
|
|
43
|
+
children: [
|
|
44
|
+
icon,
|
|
45
|
+
label
|
|
46
|
+
]
|
|
43
47
|
}
|
|
44
48
|
);
|
|
45
49
|
};
|
|
46
50
|
StatusBadge.displayName = "StatusBadge";
|
|
47
51
|
|
|
48
52
|
export { StatusBadge, formatRelativeDateTime, formatRelativeToCurrentWeekDateTime };
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-ETY43HAI.js.map
|
|
54
|
+
//# sourceMappingURL=chun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AA,EAAQ,MAAA;AAAA,MACR,EAAA,EAAI,CAAA;AAAA,MACJ,iBAAA,EAAmB,CAAA;AAAA,MACnB,GAAA,EAAK,CAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,QAAA,IAAA;AAAA,QACA;AAAA;AAAA;AAAA,GACF;AAEF;AAEA,WAAA,CAAY,WAAA,GAAc,aAAA","file":"chunk-ETY43HAI.js","sourcesContent":["import dayjs from \"dayjs\";\nimport calendarPlugin from \"dayjs/plugin/calendar.js\";\nimport relativeTime from \"dayjs/plugin/relativeTime.js\";\nimport utcPlugin from \"dayjs/plugin/utc.js\";\n\ndayjs.extend(utcPlugin);\ndayjs.extend(relativeTime);\ndayjs.extend(calendarPlugin);\n\nimport type { DateType } from \"../types\";\n\n/**\n * A function that will return a string with how far a given date is in the past or future,\n * using a baseDate as reference. If the baseDate is not passed, the function will use today as reference.\n *\n * @param date - the date to be formatted\n * @param baseDate - the date that should be used as a reference (default is \"today\")\n * @returns a relative date\n *\n * @example\n * // Considering today as 18.08.2021\n * formatRelativeDateTime('2021-08-17T15:45:00') // returns \"a day ago\"\n *\n * @example\n * formatRelativeDateTime('2021-08-17T15:45:00', '2021-08-16') // returns \"in a day\"\n */\nexport function formatRelativeDateTime(\n\tdate: DateType,\n\tbaseDate: DateType = new Date(),\n) {\n\treturn dayjs(date).from(baseDate);\n}\n\n/**\n * A function that formats a date relative to Today or to the `baseDate` if passed.\n * If the date is not today, it will return a string with \"Yesterday ...\", \"Tomorrow ...\", etc\n * If the date is not in the current week, it return a string with \"DD MMM YYYY\" format\n * If the date is today, it will return a string with \"... ago\" or \"in ...\"\n *\n * @param date - the date to be formatted\n * @param baseDate - the date that should be used as a reference (default is \"today\")\n * @returns a relative date\n *\n * @example\n * // Considering today as 18.08.2021\n * formatRelativeToCurrentWeekDateTime('2021-08-17T15:45:00') // returns \"Yesterday at 3:45 PM\"\n *\n * @example\n * formatRelativeToCurrentWeekDateTime('2021-08-17T15:45:00', '2021-08-16') // returns \"Tomorrow at 3:45 PM\"\n */\nexport function formatRelativeToCurrentWeekDateTime(\n\tdate: DateType,\n\tbaseDate: DateType = new Date(),\n) {\n\tconst isToday = dayjs(date).isSame(baseDate, \"day\");\n\n\tif (!isToday) {\n\t\t// if the date is not today, we display it with \"Yesterday\", \"Tomorrow\", etc.\n\t\t// and if the date is not in the current week then it will display \"17 Aug 2021\"\n\t\treturn dayjs(date).calendar(baseDate, {\n\t\t\tsameElse: \"DD MMM YYYY\",\n\t\t});\n\t}\n\n\t// returns \"... ago\"\n\treturn formatRelativeDateTime(date, baseDate);\n}\n","import { readableColor } from \"color2k\";\nimport type React from \"react\";\nimport { useMemo } from \"react\";\nimport { Badge } from \"../../primitives/badge\";\n\nexport interface StatusBadgeProps {\n\t/** The display label for the badge */\n\tlabel: string;\n\t/** The background color for the badge (hex format, e.g. \"#ff0000\") */\n\tcolor: string;\n\t/** Optional icon rendered inline before the label inside the badge. */\n\ticon?: React.ReactNode;\n}\n\nexport const StatusBadge: React.FC<StatusBadgeProps> = (props) => {\n\tconst { label, color, icon } = props;\n\n\tconst textColor = useMemo(() => {\n\t\ttry {\n\t\t\treturn readableColor(color);\n\t\t} catch {\n\t\t\treturn \"black\";\n\t\t}\n\t}, [color]);\n\n\treturn (\n\t\t<Badge\n\t\t\tbg={color}\n\t\t\tcolor={textColor}\n\t\t\trounded=\"base\"\n\t\t\tpx={2}\n\t\t\tmarginInlineStart={1}\n\t\t\tgap={1}\n\t\t>\n\t\t\t{icon}\n\t\t\t{label}\n\t\t</Badge>\n\t);\n};\n\nStatusBadge.displayName = \"StatusBadge\";\n"]}
|
|
@@ -263,6 +263,12 @@ interface IdentityCellProps {
|
|
|
263
263
|
avatarFallback?: string;
|
|
264
264
|
/** Avatar size; defaults to "sm" to match table density. */
|
|
265
265
|
size?: "sm" | "md";
|
|
266
|
+
/**
|
|
267
|
+
* Optional Chakra `colorPalette` forwarded to the underlying `Avatar`
|
|
268
|
+
* primitive (e.g. `"primary"`, `"secondary"`). Tints the fallback circle
|
|
269
|
+
* with the chosen palette. Omit for the default neutral-gray look.
|
|
270
|
+
*/
|
|
271
|
+
colorPalette?: string;
|
|
266
272
|
}
|
|
267
273
|
declare const IdentityCell: React__default.FC<IdentityCellProps>;
|
|
268
274
|
|
|
@@ -328,6 +334,11 @@ interface StatusBadgeCellProps {
|
|
|
328
334
|
* don't fit on the badge label.
|
|
329
335
|
*/
|
|
330
336
|
tooltip?: React__default.ReactNode;
|
|
337
|
+
/**
|
|
338
|
+
* Optional icon rendered inline before the label inside the badge (e.g.
|
|
339
|
+
* a `lucide-react` glyph). A small gap separates it from the label.
|
|
340
|
+
*/
|
|
341
|
+
icon?: React__default.ReactNode;
|
|
331
342
|
}
|
|
332
343
|
declare const StatusBadgeCell: React__default.FC<StatusBadgeCellProps>;
|
|
333
344
|
|
package/dist/components/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collapsible, Skeleton, Separator, Checkbox as Checkbox$1 } from '../chunk-TXGJ7BNX.js';
|
|
2
|
-
import { formatRelativeDateTime, StatusBadge } from '../chunk-
|
|
2
|
+
import { formatRelativeDateTime, StatusBadge } from '../chunk-ETY43HAI.js';
|
|
3
3
|
import { MenuItem, MenuRoot, MenuTrigger, MenuContent, Tooltip, Badge, Avatar, Table } from '../chunk-2ZWZ2WAS.js';
|
|
4
4
|
import { Popover, PopoverTrigger, PopoverContent, PopoverBody, Switch } from '../chunk-WQIEF5N3.js';
|
|
5
5
|
import { text_input_default } from '../chunk-OU6H3KU4.js';
|
|
@@ -746,12 +746,22 @@ var IdentityCell = ({
|
|
|
746
746
|
subText,
|
|
747
747
|
avatarSrc,
|
|
748
748
|
avatarFallback,
|
|
749
|
-
size = "sm"
|
|
749
|
+
size = "sm",
|
|
750
|
+
colorPalette
|
|
750
751
|
}) => {
|
|
751
752
|
if (name == null) return /* @__PURE__ */ jsx("span", { children: emptyCellValue });
|
|
752
753
|
const initials = avatarFallback ?? deriveInitials(name);
|
|
753
754
|
return /* @__PURE__ */ jsxs(HStack, { gap: 2, align: "center", children: [
|
|
754
|
-
/* @__PURE__ */ jsx(
|
|
755
|
+
/* @__PURE__ */ jsx(
|
|
756
|
+
Avatar,
|
|
757
|
+
{
|
|
758
|
+
size,
|
|
759
|
+
name,
|
|
760
|
+
src: avatarSrc,
|
|
761
|
+
fallback: initials,
|
|
762
|
+
colorPalette
|
|
763
|
+
}
|
|
764
|
+
),
|
|
755
765
|
/* @__PURE__ */ jsxs(VStack, { align: "start", gap: 0, children: [
|
|
756
766
|
/* @__PURE__ */ jsx(Text, { fontSize: "sm", fontWeight: "semibold", lineClamp: 1, children: name }),
|
|
757
767
|
subText != null && /* @__PURE__ */ jsx(Text, { fontSize: "xs", color: "fg.muted", lineClamp: 1, children: subText })
|
|
@@ -852,11 +862,12 @@ var StatusBadgeCell = ({
|
|
|
852
862
|
fallbackColor = "gray",
|
|
853
863
|
detail,
|
|
854
864
|
detailColor = "fg.error",
|
|
855
|
-
tooltip
|
|
865
|
+
tooltip,
|
|
866
|
+
icon
|
|
856
867
|
}) => {
|
|
857
868
|
if (value == null) return /* @__PURE__ */ jsx("span", { children: emptyCellValue });
|
|
858
869
|
const color = colorMap?.[value] ?? fallbackColor;
|
|
859
|
-
let badge = /* @__PURE__ */ jsx(StatusBadge, { label: value, color });
|
|
870
|
+
let badge = /* @__PURE__ */ jsx(StatusBadge, { label: value, color, icon });
|
|
860
871
|
if (tooltip != null) {
|
|
861
872
|
badge = /* @__PURE__ */ jsx(Tooltip, { content: tooltip, showArrow: true, children: /* @__PURE__ */ jsx("span", { children: badge }) });
|
|
862
873
|
}
|