dishui 0.0.78 → 0.0.80
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/components/Avatar/index.d.ts +6 -4
- package/dist/components/Avatar/index.js +39 -28
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/Card/index.d.ts +16 -8
- package/dist/components/Card/index.js +81 -99
- package/dist/components/Card/index.js.map +1 -1
- package/dist/components/DateTimeInput/index.js +3 -2
- package/dist/components/DateTimeInput/index.js.map +1 -1
- package/dist/components/GroupedTable/index.d.ts +2 -1
- package/dist/components/GroupedTable/index.js +96 -37
- package/dist/components/GroupedTable/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +2 -2
- package/dist/components/Input/index.js +129 -111
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Label/index.js +1 -1
- package/dist/components/Label/index.js.map +1 -1
- package/dist/components/NavigationList/index.js +55 -24
- package/dist/components/NavigationList/index.js.map +1 -1
- package/dist/components/Resizable/index.d.ts +28 -0
- package/dist/components/Resizable/index.js +128 -0
- package/dist/components/Resizable/index.js.map +1 -0
- package/dist/components/Resizable/useResize.d.ts +21 -0
- package/dist/components/Resizable/useResize.js +60 -0
- package/dist/components/Resizable/useResize.js.map +1 -0
- package/dist/components/SidebarToggleButton/index.js +51 -43
- package/dist/components/SidebarToggleButton/index.js.map +1 -1
- package/dist/components/Slider/index.d.ts +17 -3
- package/dist/components/Slider/index.js +131 -28
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/pro/RichTextEditor/RichTextEditor.js +62 -62
- package/dist/components/pro/RichTextEditor/RichTextEditor.js.map +1 -1
- package/dist/components/pro/RichTextEditor/extensions/ResizableImage.d.ts +2 -0
- package/dist/components/pro/RichTextEditor/extensions/ResizableImage.js +94 -0
- package/dist/components/pro/RichTextEditor/extensions/ResizableImage.js.map +1 -0
- package/dist/components/pro/RichTextEditor/index.d.ts +1 -0
- package/dist/dishui.css +1 -1
- package/dist/index-nostyled.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +123 -121
- package/dist/layouts/Sidebar.js +34 -45
- package/dist/layouts/Sidebar.js.map +1 -1
- package/dist/lite.d.ts +2 -0
- package/dist/lite.js +20 -18
- package/dist/utils/i18n.js +145 -75
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/menu.js +85 -8
- package/dist/utils/menu.js.map +1 -1
- package/package.json +1 -1
|
@@ -15,15 +15,17 @@ export type AvatarProps = {
|
|
|
15
15
|
shape?: AvatarShape;
|
|
16
16
|
/** shape="square" 时的自定义圆角(数字按 px)。 */
|
|
17
17
|
radius?: number | string;
|
|
18
|
-
/** 边框宽度(数字按 px
|
|
18
|
+
/** 边框宽度(数字按 px);默认 0,旧 maskBorder 模式默认 2。不改变 maskSrc 图片。 */
|
|
19
19
|
borderWidth?: number | string;
|
|
20
20
|
/** 边框颜色。 */
|
|
21
21
|
borderColor?: string;
|
|
22
22
|
/** 边框线型:solid(默认)/ dashed / dotted。 */
|
|
23
23
|
borderStyle?: AvatarBorderStyle;
|
|
24
|
-
/**
|
|
24
|
+
/** 装饰图片 URL(SVG / PNG / WebP 等,需自带透明中心),按 contain 覆盖头像;不受 shape 裁剪。优先于 maskBorder,失败时隐藏装饰。 */
|
|
25
|
+
maskSrc?: string;
|
|
26
|
+
/** @deprecated 仅兼容旧 CSS 颜色 / 渐变环,并非图片 mask。图片覆盖请使用 maskSrc;两者同时传入时忽略 maskBorder。 */
|
|
25
27
|
maskBorder?: string;
|
|
26
|
-
/**
|
|
28
|
+
/** 头像图片 / 字母内容透明度 0–1,默认 1;不影响装饰图片或通知角标。 */
|
|
27
29
|
centerOpacity?: number;
|
|
28
30
|
/** 角标通知位置,默认 top-right。 */
|
|
29
31
|
notificationPosition?: AvatarNotificationPosition;
|
|
@@ -41,7 +43,7 @@ export type AvatarProps = {
|
|
|
41
43
|
/**
|
|
42
44
|
* Avatar —— 头像组件。
|
|
43
45
|
* 展示图片头像;未配置(或加载失败)时回退为 `name` 的关键字母。
|
|
44
|
-
* 支持自定义边框形态 / 颜色 /
|
|
46
|
+
* 支持自定义边框形态 / 颜色 / 线型、透明中心装饰图片 overlay(maskSrc)
|
|
45
47
|
* 以及四角 notification 短描述(计数 / 文本 / 圆点)。
|
|
46
48
|
*/
|
|
47
49
|
declare const Avatar: React.FC<AvatarProps>;
|
|
@@ -14,56 +14,67 @@ var i = (e) => {
|
|
|
14
14
|
"top-right": "top-0 right-0 translate-x-1/3 -translate-y-1/3",
|
|
15
15
|
"bottom-left": "bottom-0 left-0 -translate-x-1/3 translate-y-1/3",
|
|
16
16
|
"bottom-right": "bottom-0 right-0 translate-x-1/3 translate-y-1/3"
|
|
17
|
-
}, s = ({ src: s, alt:
|
|
18
|
-
let
|
|
19
|
-
t.useEffect(() =>
|
|
20
|
-
let
|
|
17
|
+
}, s = ({ src: s, alt: l, name: u, size: d = 40, shape: f = "circle", radius: p, borderWidth: m, borderColor: h, borderStyle: g = "solid", maskBorder: _, maskSrc: v, centerOpacity: y = 1, notificationPosition: b = "top-right", notification: x, notificationColor: S = "var(--color-error)", className: C = "", style: w, onClick: T }) => {
|
|
18
|
+
let E = typeof d == "number" ? `${d}px` : d, [D, O] = t.useState(!1);
|
|
19
|
+
t.useEffect(() => O(!1), [s]);
|
|
20
|
+
let k = !!s && !D, A = u ? i(u) : "", j = `calc(${E} * 0.36)`, M = f === "square" ? { borderRadius: p ?? "0.5rem" } : {}, N = v ? void 0 : _, P = m === void 0 ? N ? "2px" : "0px" : typeof m == "number" ? `${m}px` : m, F = x != null && x !== !1;
|
|
21
21
|
return /* @__PURE__ */ r("span", {
|
|
22
|
-
className: e("relative inline-flex shrink-0 leading-none",
|
|
22
|
+
className: e("relative inline-flex shrink-0 leading-none", T && "cursor-pointer", C),
|
|
23
23
|
style: {
|
|
24
|
-
width:
|
|
25
|
-
height:
|
|
26
|
-
...
|
|
24
|
+
width: E,
|
|
25
|
+
height: E,
|
|
26
|
+
...w
|
|
27
27
|
},
|
|
28
|
-
onClick:
|
|
28
|
+
onClick: T,
|
|
29
29
|
children: [
|
|
30
|
-
|
|
30
|
+
N && /* @__PURE__ */ n("span", {
|
|
31
31
|
"aria-hidden": "true",
|
|
32
32
|
className: "pointer-events-none absolute inset-0 z-10",
|
|
33
33
|
style: {
|
|
34
|
-
padding:
|
|
35
|
-
background:
|
|
34
|
+
padding: P,
|
|
35
|
+
background: N,
|
|
36
36
|
WebkitMask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
|
|
37
37
|
WebkitMaskComposite: "xor",
|
|
38
38
|
mask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
|
|
39
39
|
maskComposite: "exclude",
|
|
40
|
-
...
|
|
40
|
+
...M
|
|
41
41
|
}
|
|
42
42
|
}),
|
|
43
43
|
/* @__PURE__ */ n("span", {
|
|
44
|
-
className: e("relative flex h-full w-full select-none items-center justify-center overflow-hidden bg-base-200 text-center font-semibold text-base-content/70", a[
|
|
44
|
+
className: e("relative flex h-full w-full select-none items-center justify-center overflow-hidden bg-base-200 text-center font-semibold text-base-content/70", a[f]),
|
|
45
45
|
style: {
|
|
46
|
-
fontSize:
|
|
47
|
-
opacity:
|
|
48
|
-
borderWidth:
|
|
49
|
-
borderStyle:
|
|
50
|
-
borderColor:
|
|
51
|
-
...
|
|
46
|
+
fontSize: j,
|
|
47
|
+
opacity: y,
|
|
48
|
+
borderWidth: N ? 0 : P,
|
|
49
|
+
borderStyle: N ? void 0 : g,
|
|
50
|
+
borderColor: N ? void 0 : h,
|
|
51
|
+
...M
|
|
52
52
|
},
|
|
53
|
-
children:
|
|
53
|
+
children: k ? /* @__PURE__ */ n("img", {
|
|
54
54
|
src: s,
|
|
55
|
-
alt:
|
|
55
|
+
alt: l ?? u ?? "",
|
|
56
56
|
className: "h-full w-full object-cover",
|
|
57
|
-
onError: () =>
|
|
58
|
-
}) :
|
|
57
|
+
onError: () => O(!0)
|
|
58
|
+
}) : A
|
|
59
59
|
}),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
v && /* @__PURE__ */ n(c, { src: v }, v),
|
|
61
|
+
F && /* @__PURE__ */ n("span", {
|
|
62
|
+
className: e("absolute z-20 flex items-center justify-center rounded-full border-2 border-base-100 font-bold leading-none text-white", o[b], x === !0 ? "h-3 w-3 p-0" : "h-[18px] min-w-[18px] px-1 text-[10px]"),
|
|
63
|
+
style: { backgroundColor: S },
|
|
64
|
+
children: x === !0 ? "" : x
|
|
64
65
|
})
|
|
65
66
|
]
|
|
66
67
|
});
|
|
68
|
+
}, c = ({ src: e }) => {
|
|
69
|
+
let [r, i] = t.useState(!1);
|
|
70
|
+
return r ? null : /* @__PURE__ */ n("img", {
|
|
71
|
+
src: e,
|
|
72
|
+
alt: "",
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
draggable: !1,
|
|
75
|
+
className: "pointer-events-none absolute inset-0 z-10 h-full w-full select-none object-contain",
|
|
76
|
+
onError: () => i(!0)
|
|
77
|
+
});
|
|
67
78
|
};
|
|
68
79
|
//#endregion
|
|
69
80
|
export { s as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Avatar/index.tsx"],"sourcesContent":["import React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type AvatarShape = 'circle' | 'square' | 'squircle';\nexport type AvatarBorderStyle = 'solid' | 'dashed' | 'dotted';\nexport type AvatarNotificationPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport type AvatarProps = {\n /** 头像图片地址;缺省或加载失败时回退为 `name` 的关键字母。 */\n src?: string;\n /** 图片 alt 描述。 */\n alt?: string;\n /** 名称 / 描述:未配置头像时取其关键字母(两个单词取首字母,否则取前两个字符)作为回退展示。 */\n name?: string;\n /** 方形尺寸;数字按 px 处理。默认 40。 */\n size?: number | string;\n /** 边框(整体)形态:circle 圆形(默认)/ square 方形 / squircle 超椭圆圆角方。 */\n shape?: AvatarShape;\n /** shape=\"square\" 时的自定义圆角(数字按 px)。 */\n radius?: number | string;\n /** 边框宽度(数字按 px
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Avatar/index.tsx"],"sourcesContent":["import React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type AvatarShape = 'circle' | 'square' | 'squircle';\nexport type AvatarBorderStyle = 'solid' | 'dashed' | 'dotted';\nexport type AvatarNotificationPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport type AvatarProps = {\n /** 头像图片地址;缺省或加载失败时回退为 `name` 的关键字母。 */\n src?: string;\n /** 图片 alt 描述。 */\n alt?: string;\n /** 名称 / 描述:未配置头像时取其关键字母(两个单词取首字母,否则取前两个字符)作为回退展示。 */\n name?: string;\n /** 方形尺寸;数字按 px 处理。默认 40。 */\n size?: number | string;\n /** 边框(整体)形态:circle 圆形(默认)/ square 方形 / squircle 超椭圆圆角方。 */\n shape?: AvatarShape;\n /** shape=\"square\" 时的自定义圆角(数字按 px)。 */\n radius?: number | string;\n /** 边框宽度(数字按 px);默认 0,旧 maskBorder 模式默认 2。不改变 maskSrc 图片。 */\n borderWidth?: number | string;\n /** 边框颜色。 */\n borderColor?: string;\n /** 边框线型:solid(默认)/ dashed / dotted。 */\n borderStyle?: AvatarBorderStyle;\n /** 装饰图片 URL(SVG / PNG / WebP 等,需自带透明中心),按 contain 覆盖头像;不受 shape 裁剪。优先于 maskBorder,失败时隐藏装饰。 */\n maskSrc?: string;\n /** @deprecated 仅兼容旧 CSS 颜色 / 渐变环,并非图片 mask。图片覆盖请使用 maskSrc;两者同时传入时忽略 maskBorder。 */\n maskBorder?: string;\n /** 头像图片 / 字母内容透明度 0–1,默认 1;不影响装饰图片或通知角标。 */\n centerOpacity?: number;\n /** 角标通知位置,默认 top-right。 */\n notificationPosition?: AvatarNotificationPosition;\n /** 角标通知内容(如计数数值 / 短文本);传 `true` 显示小圆点,不传则不渲染角标。 */\n notification?: React.ReactNode;\n /** 角标背景色,默认 var(--color-error)。 */\n notificationColor?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n /** Inline styles on the wrapper. */\n style?: React.CSSProperties;\n /** Click handler. */\n onClick?: (e: React.MouseEvent<HTMLSpanElement>) => void;\n};\n\n/** 从名称/描述中提取关键字母:两个单词取首字母,否则取前两个字符(统一大写)。 */\nconst initialsOf = (name: string): string => {\n const parts = name.trim().split(/\\s+/).filter(Boolean);\n if (parts.length >= 2) return (parts[0][0] + parts[1][0]).toUpperCase();\n return name.trim().slice(0, 2).toUpperCase();\n};\n\nconst SHAPE_CLASS: Record<AvatarShape, string> = {\n circle: 'rounded-full',\n square: '',\n squircle: 'mask mask-squircle',\n};\n\nconst NOTIFICATION_POSITION_CLASS: Record<AvatarNotificationPosition, string> = {\n 'top-left': 'top-0 left-0 -translate-x-1/3 -translate-y-1/3',\n 'top-right': 'top-0 right-0 translate-x-1/3 -translate-y-1/3',\n 'bottom-left': 'bottom-0 left-0 -translate-x-1/3 translate-y-1/3',\n 'bottom-right': 'bottom-0 right-0 translate-x-1/3 translate-y-1/3',\n};\n\n/**\n * Avatar —— 头像组件。\n * 展示图片头像;未配置(或加载失败)时回退为 `name` 的关键字母。\n * 支持自定义边框形态 / 颜色 / 线型、透明中心装饰图片 overlay(maskSrc)\n * 以及四角 notification 短描述(计数 / 文本 / 圆点)。\n */\nconst Avatar: React.FC<AvatarProps> = ({\n src,\n alt,\n name,\n size = 40,\n shape = 'circle',\n radius,\n borderWidth,\n borderColor,\n borderStyle = 'solid',\n maskBorder,\n maskSrc,\n centerOpacity = 1,\n notificationPosition = 'top-right',\n notification,\n notificationColor = 'var(--color-error)',\n className = '',\n style,\n onClick,\n}) => {\n const px = typeof size === 'number' ? `${size}px` : size;\n const [imgFailed, setImgFailed] = React.useState(false);\n React.useEffect(() => setImgFailed(false), [src]);\n\n const showImage = Boolean(src) && !imgFailed;\n const initials = name ? initialsOf(name) : '';\n const fontSize = `calc(${px} * 0.36)`;\n\n const shapeStyle: React.CSSProperties = shape === 'square' ? { borderRadius: radius ?? '0.5rem' } : {};\n const legacyMaskBorder = maskSrc ? undefined : maskBorder;\n const ringWidth = borderWidth === undefined ? (legacyMaskBorder ? '2px' : '0px') : typeof borderWidth === 'number' ? `${borderWidth}px` : borderWidth;\n\n const showNotification = notification !== undefined && notification !== null && notification !== false;\n\n return (\n <span\n className={cn('relative inline-flex shrink-0 leading-none', onClick && 'cursor-pointer', className)}\n style={{ width: px, height: px, ...style }}\n onClick={onClick}\n >\n {/* 仅保留旧版 CSS 环兼容;图片 overlay 不使用 CSS mask。 */}\n {legacyMaskBorder && (\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-0 z-10\"\n style={{\n padding: ringWidth,\n background: legacyMaskBorder,\n WebkitMask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',\n WebkitMaskComposite: 'xor',\n mask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',\n maskComposite: 'exclude',\n ...shapeStyle,\n } as React.CSSProperties}\n />\n )}\n <span\n className={cn(\n 'relative flex h-full w-full select-none items-center justify-center overflow-hidden bg-base-200 text-center font-semibold text-base-content/70',\n SHAPE_CLASS[shape],\n )}\n style={{\n fontSize,\n opacity: centerOpacity,\n borderWidth: legacyMaskBorder ? 0 : ringWidth,\n borderStyle: legacyMaskBorder ? undefined : borderStyle,\n borderColor: legacyMaskBorder ? undefined : borderColor,\n ...shapeStyle,\n }}\n >\n {showImage ? (\n <img\n src={src}\n alt={alt ?? name ?? ''}\n className=\"h-full w-full object-cover\"\n onError={() => setImgFailed(true)}\n />\n ) : (\n initials\n )}\n </span>\n {maskSrc && <AvatarMaskImage key={maskSrc} src={maskSrc} />}\n {showNotification && (\n <span\n className={cn(\n 'absolute z-20 flex items-center justify-center rounded-full border-2 border-base-100 font-bold leading-none text-white',\n NOTIFICATION_POSITION_CLASS[notificationPosition],\n notification === true ? 'h-3 w-3 p-0' : 'h-[18px] min-w-[18px] px-1 text-[10px]',\n )}\n style={{ backgroundColor: notificationColor }}\n >\n {notification === true ? '' : notification}\n </span>\n )}\n </span>\n );\n};\n\n// A new URL remounts this layer so a failed decoration can recover independently.\nconst AvatarMaskImage: React.FC<{ src: string }> = ({ src }) => {\n const [failed, setFailed] = React.useState(false);\n if (failed) return null;\n return (\n <img\n src={src}\n alt=\"\"\n aria-hidden=\"true\"\n draggable={false}\n className=\"pointer-events-none absolute inset-0 z-10 h-full w-full select-none object-contain\"\n onError={() => setFailed(true)}\n />\n );\n};\n\nexport default Avatar;\n"],"mappings":";;;;AA+CA,IAAM,KAAc,MAAyB;CAC3C,IAAM,IAAQ,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;CAErD,OADI,EAAM,UAAU,KAAW,EAAM,EAAE,CAAC,KAAK,EAAM,EAAE,CAAC,GAAA,CAAI,YAAY,IAC/D,EAAK,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY;AAC7C,GAEM,IAA2C;CAC/C,QAAQ;CACR,QAAQ;CACR,UAAU;AACZ,GAEM,IAA0E;CAC9E,YAAY;CACZ,aAAa;CACb,eAAe;CACf,gBAAgB;AAClB,GAQM,KAAiC,EACrC,QACA,QACA,SACA,UAAO,IACP,WAAQ,UACR,WACA,gBACA,gBACA,iBAAc,SACd,eACA,YACA,mBAAgB,GAChB,0BAAuB,aACvB,iBACA,uBAAoB,sBACpB,eAAY,IACZ,UACA,iBACI;CACJ,IAAM,IAAK,OAAO,KAAS,WAAW,GAAG,EAAK,MAAM,GAC9C,CAAC,GAAW,KAAgB,EAAM,SAAS,EAAK;CACtD,EAAM,gBAAgB,EAAa,EAAK,GAAG,CAAC,CAAG,CAAC;CAEhD,IAAM,IAAY,EAAQ,KAAQ,CAAC,GAC7B,IAAW,IAAO,EAAW,CAAI,IAAI,IACrC,IAAW,QAAQ,EAAG,WAEtB,IAAkC,MAAU,WAAW,EAAE,cAAc,KAAU,SAAS,IAAI,CAAC,GAC/F,IAAmB,IAAU,KAAA,IAAY,GACzC,IAAY,MAAgB,KAAA,IAAa,IAAmB,QAAQ,QAAS,OAAO,KAAgB,WAAW,GAAG,EAAY,MAAM,GAEpI,IAAmB,KAA+C,QAAQ,MAAiB;CAEjG,OACE,kBAAC,QAAD;EACE,WAAW,EAAG,8CAA8C,KAAW,kBAAkB,CAAS;EAClG,OAAO;GAAE,OAAO;GAAI,QAAQ;GAAI,GAAG;EAAM;EAChC;EAHX,UAAA;GAMG,KACC,kBAAC,QAAD;IACE,eAAY;IACZ,WAAU;IACV,OAAO;KACL,SAAS;KACT,YAAY;KACZ,YAAY;KACZ,qBAAqB;KACrB,MAAM;KACN,eAAe;KACf,GAAG;IACL;GACD,CAAA;GAEH,kBAAC,QAAD;IACE,WAAW,EACT,kJACA,EAAY,EACd;IACA,OAAO;KACL;KACA,SAAS;KACT,aAAa,IAAmB,IAAI;KACpC,aAAa,IAAmB,KAAA,IAAY;KAC5C,aAAa,IAAmB,KAAA,IAAY;KAC5C,GAAG;IACL;IAEC,UAAA,IACC,kBAAC,OAAD;KACO;KACL,KAAK,KAAO,KAAQ;KACpB,WAAU;KACV,eAAe,EAAa,EAAI;IACjC,CAAA,IAED;GAEE,CAAA;GACL,KAAW,kBAAC,GAAD,EAA+B,KAAK,EAAU,GAAxB,CAAwB;GACzD,KACC,kBAAC,QAAD;IACE,WAAW,EACT,0HACA,EAA4B,IAC5B,MAAiB,KAAO,gBAAgB,wCAC1C;IACA,OAAO,EAAE,iBAAiB,EAAkB;IAE3C,UAAA,MAAiB,KAAO,KAAK;GAC1B,CAAA;EAEJ;;AAEV,GAGM,KAA8C,EAAE,aAAU;CAC9D,IAAM,CAAC,GAAQ,KAAa,EAAM,SAAS,EAAK;CAEhD,OADI,IAAe,OAEjB,kBAAC,OAAD;EACO;EACL,KAAI;EACJ,eAAY;EACZ,WAAW;EACX,WAAU;EACV,eAAe,EAAU,EAAI;CAC9B,CAAA;AAEL"}
|
|
@@ -114,19 +114,27 @@ export type CardMetaProps = {
|
|
|
114
114
|
};
|
|
115
115
|
export type CardInfoTone = 'primary' | 'success' | 'warning' | 'info' | 'error' | 'neutral';
|
|
116
116
|
export type CardInfoProps = {
|
|
117
|
-
/** Metric name
|
|
117
|
+
/** Metric name. */
|
|
118
118
|
label: React.ReactNode;
|
|
119
119
|
/** Metric value (number or short text). */
|
|
120
120
|
value: React.ReactNode;
|
|
121
|
-
/** Icon
|
|
121
|
+
/** Icon slot. Use Icon to control its size, color and background independently. */
|
|
122
122
|
icon?: React.ReactNode;
|
|
123
|
-
/** `top`
|
|
124
|
-
iconPosition?: 'top' | 'left';
|
|
125
|
-
/**
|
|
123
|
+
/** `top` keeps the icon beside the label; `left` / `right` flank the content. */
|
|
124
|
+
iconPosition?: 'top' | 'left' | 'right';
|
|
125
|
+
/** Stacked content (default), compact horizontal row, or two-column summary. */
|
|
126
|
+
layout?: 'stacked' | 'horizontal' | 'split';
|
|
127
|
+
/** Content alignment (default left). */
|
|
128
|
+
align?: 'left' | 'center' | 'right';
|
|
129
|
+
/** Additional multi-line content below the summary. */
|
|
130
|
+
children?: React.ReactNode;
|
|
131
|
+
/** Footer slot separated by a subtle divider. */
|
|
132
|
+
footer?: React.ReactNode;
|
|
133
|
+
/** @deprecated Use Icon styles instead. Shape of the optional neutral compatibility box. */
|
|
126
134
|
iconShape?: 'square' | 'circle';
|
|
127
|
-
/**
|
|
135
|
+
/** @deprecated Use Icon styles instead. Optional neutral icon box (default false). */
|
|
128
136
|
iconBoxed?: boolean;
|
|
129
|
-
/**
|
|
137
|
+
/** Card surface and border tone (default neutral). Does not style the icon. */
|
|
130
138
|
tone?: CardInfoTone;
|
|
131
139
|
/** Small hint text below the value (e.g. deltas, update time). */
|
|
132
140
|
hint?: React.ReactNode;
|
|
@@ -136,7 +144,7 @@ export type CardInfoProps = {
|
|
|
136
144
|
variant?: CardProps['variant'];
|
|
137
145
|
/** Show a border (default true). */
|
|
138
146
|
bordered?: boolean;
|
|
139
|
-
/** Enable the glass background (default
|
|
147
|
+
/** Enable the glass background (default true, matching Card). */
|
|
140
148
|
glass?: boolean;
|
|
141
149
|
/** Extra class names on the card. */
|
|
142
150
|
className?: string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { cn as e } from "../../utils/cn.js";
|
|
2
2
|
import { CardMetric as t } from "./Metric2.js";
|
|
3
|
+
/* empty css */
|
|
3
4
|
import "react";
|
|
4
5
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
6
|
//#region src/components/Card/index.tsx
|
|
6
7
|
var i = ({ children: t, variant: r, bordered: i = !1, dash: a = !1, side: o = !1, imageFull: s = !1, compact: c = !1, hover: l = !0, glass: u = !0, size: d = "sm", className: f = "" }) => {
|
|
7
|
-
let p = u && !r ? "glass shadow-lg" : "", m = r ? `bg-${r} text-${r}-content shadow-md` : "", h = i ? "card-bordered" : "", g = a ? "card-dash" : "", _ = o ? "card-side" : "", v = s ? "image-full" : "", y = c ? "card-compact" : "", b = l ? "hover:shadow-xl transition-shadow duration-300" : "", x = d ? `card-${d}` : "";
|
|
8
|
+
let p = u && !r ? "glass dishui-card-glass shadow-lg" : "", m = r ? `bg-${r} text-${r}-content shadow-md` : "", h = i ? "card-bordered" : "", g = a ? "card-dash" : "", _ = o ? "card-side" : "", v = s ? "image-full" : "", y = c ? "card-compact" : "", b = l ? "hover:shadow-xl transition-shadow duration-300" : "", x = d ? `card-${d}` : "";
|
|
8
9
|
f.includes("w-") || f.match(/max-w-|min-w-/);
|
|
9
10
|
let S = e("card", "", p, m, h, g, _, v, y, b, x, f);
|
|
10
11
|
return /* @__PURE__ */ n("div", {
|
|
@@ -41,7 +42,7 @@ var i = ({ children: t, variant: r, bordered: i = !1, dash: a = !1, side: o = !1
|
|
|
41
42
|
children: t
|
|
42
43
|
});
|
|
43
44
|
}, d = ({ variant: t, bordered: n = !1, glass: r = !0, className: i = "" }) => {
|
|
44
|
-
let a = r && !t ? "glass shadow-lg" : "", o = t ? `bg-${t} text-${t}-content shadow-md` : "";
|
|
45
|
+
let a = r && !t ? "glass dishui-card-glass shadow-lg" : "", o = t ? `bg-${t} text-${t}-content shadow-md` : "";
|
|
45
46
|
return e("card", a, o, n && "card-bordered", i);
|
|
46
47
|
}, f = ({ className: t }) => /* @__PURE__ */ r("svg", {
|
|
47
48
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -118,10 +119,10 @@ var i = ({ children: t, variant: r, bordered: i = !1, dash: a = !1, side: o = !1
|
|
|
118
119
|
}), /* @__PURE__ */ r("div", {
|
|
119
120
|
className: "card-body gap-0 p-6",
|
|
120
121
|
children: [/* @__PURE__ */ n("div", {
|
|
121
|
-
className: "relative z-10 text-lg text-base-content",
|
|
122
|
+
className: e("relative z-10 min-w-0 wrap-anywhere text-lg text-base-content", s && "pe-10"),
|
|
122
123
|
children: t
|
|
123
124
|
}), /* @__PURE__ */ r("div", {
|
|
124
|
-
className: e("mt-4 flex items-center justify-between gap-3", c && "border-t border-base-300 pt-3.5"),
|
|
125
|
+
className: e("mt-4 flex flex-wrap items-center justify-between gap-3", c && "border-t border-base-300 pt-3.5"),
|
|
125
126
|
children: [/* @__PURE__ */ r("div", {
|
|
126
127
|
className: "flex min-w-0 items-center gap-2.5",
|
|
127
128
|
children: [a && /* @__PURE__ */ n("span", {
|
|
@@ -174,108 +175,89 @@ var i = ({ children: t, variant: r, bordered: i = !1, dash: a = !1, side: o = !1
|
|
|
174
175
|
})
|
|
175
176
|
]
|
|
176
177
|
})
|
|
177
|
-
}), g = {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
},
|
|
186
|
-
warning: {
|
|
187
|
-
text: "text-warning",
|
|
188
|
-
bg: "bg-warning/10"
|
|
189
|
-
},
|
|
190
|
-
info: {
|
|
191
|
-
text: "text-info",
|
|
192
|
-
bg: "bg-info/10"
|
|
193
|
-
},
|
|
194
|
-
error: {
|
|
195
|
-
text: "text-error",
|
|
196
|
-
bg: "bg-error/10"
|
|
197
|
-
},
|
|
198
|
-
neutral: {
|
|
199
|
-
text: "text-base-content/70",
|
|
200
|
-
bg: "bg-base-content/5"
|
|
201
|
-
}
|
|
202
|
-
}, _ = ({ label: t, value: i, icon: a, iconPosition: o = "top", iconShape: s = "square", iconBoxed: c = !0, tone: l = "primary", hint: u, loading: f = !1, variant: p, bordered: m = !0, glass: h = !1, className: _ = "", onClick: v }) => {
|
|
203
|
-
let y = g[l], b = d({
|
|
204
|
-
variant: p,
|
|
205
|
-
bordered: m,
|
|
206
|
-
glass: h,
|
|
207
|
-
className: e("bg-base-200 p-4", _)
|
|
208
|
-
}), x = a && /* @__PURE__ */ n("span", {
|
|
209
|
-
className: e(o === "left" ? "flex shrink-0 items-center justify-center p-2.5 [&>svg]:h-5 [&>svg]:w-5" : "p-1.5 [&>svg]:h-4 [&>svg]:w-4", s === "circle" ? "rounded-full" : o === "left" ? "rounded-lg" : "rounded-md", y.bg, y.text),
|
|
210
|
-
children: a
|
|
211
|
-
}), S = a && /* @__PURE__ */ n("span", {
|
|
212
|
-
className: e(o === "left" ? "flex shrink-0" : "inline-flex", "[&>svg]:h-6 [&>svg]:w-6", y.text),
|
|
178
|
+
}), g = ({ label: t, value: i, icon: a, iconPosition: o = "top", iconShape: s = "square", iconBoxed: c = !1, tone: l = "neutral", layout: u = "stacked", align: f = "left", children: p, footer: m, hint: h, loading: g = !1, variant: _, bordered: v = !0, glass: y = !0, className: b = "", onClick: x }) => {
|
|
179
|
+
let S = d({
|
|
180
|
+
variant: _,
|
|
181
|
+
bordered: v,
|
|
182
|
+
glass: y,
|
|
183
|
+
className: e("blade-card-info", "p-4", b)
|
|
184
|
+
}), C = a != null && /* @__PURE__ */ n("span", {
|
|
185
|
+
className: e("blade-card-info__icon", c && (s === "circle" ? "rounded-full" : "rounded-lg"), c && "bg-base-content/5"),
|
|
213
186
|
children: a
|
|
214
187
|
});
|
|
215
|
-
return
|
|
216
|
-
className:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
188
|
+
return /* @__PURE__ */ r("div", {
|
|
189
|
+
className: S,
|
|
190
|
+
"data-layout": u,
|
|
191
|
+
"data-align": f,
|
|
192
|
+
"data-tone": _ ? void 0 : l,
|
|
193
|
+
"data-bordered": v,
|
|
194
|
+
"data-glass": y,
|
|
195
|
+
role: x ? "button" : void 0,
|
|
196
|
+
tabIndex: x ? 0 : void 0,
|
|
197
|
+
"aria-busy": g || void 0,
|
|
198
|
+
onClick: x,
|
|
199
|
+
onKeyDown: x ? (e) => {
|
|
200
|
+
e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.repeat || e.currentTarget.click());
|
|
201
|
+
} : void 0,
|
|
202
|
+
children: [/* @__PURE__ */ r("div", {
|
|
203
|
+
className: "blade-card-info__body",
|
|
204
|
+
children: [
|
|
205
|
+
o === "left" && C,
|
|
206
|
+
/* @__PURE__ */ r("div", {
|
|
207
|
+
className: "blade-card-info__content",
|
|
208
|
+
children: [/* @__PURE__ */ r("div", {
|
|
209
|
+
className: "blade-card-info__summary",
|
|
210
|
+
children: [/* @__PURE__ */ r("div", {
|
|
211
|
+
className: "blade-card-info__header",
|
|
212
|
+
children: [/* @__PURE__ */ n("div", {
|
|
213
|
+
className: "blade-card-info__label",
|
|
214
|
+
children: t
|
|
215
|
+
}), o === "top" && C]
|
|
216
|
+
}), /* @__PURE__ */ r("div", {
|
|
217
|
+
className: "blade-card-info__reading",
|
|
218
|
+
children: [/* @__PURE__ */ n("div", {
|
|
219
|
+
className: "blade-card-info__value",
|
|
220
|
+
children: g ? /* @__PURE__ */ n("span", {
|
|
221
|
+
className: "blade-card-info__skeleton",
|
|
222
|
+
"aria-hidden": "true"
|
|
223
|
+
}) : i
|
|
224
|
+
}), h != null && /* @__PURE__ */ n("div", {
|
|
225
|
+
className: "blade-card-info__hint",
|
|
226
|
+
children: h
|
|
227
|
+
})]
|
|
228
|
+
})]
|
|
229
|
+
}), p != null && /* @__PURE__ */ n("div", {
|
|
230
|
+
className: "blade-card-info__details",
|
|
231
|
+
children: p
|
|
232
|
+
})]
|
|
233
|
+
}),
|
|
234
|
+
o === "right" && C
|
|
235
|
+
]
|
|
236
|
+
}), m != null && /* @__PURE__ */ n("div", {
|
|
237
|
+
className: "blade-card-info__footer",
|
|
238
|
+
children: m
|
|
239
|
+
})]
|
|
258
240
|
});
|
|
259
|
-
},
|
|
241
|
+
}, _ = {
|
|
260
242
|
primary: "text-primary",
|
|
261
243
|
success: "text-success",
|
|
262
244
|
warning: "text-warning",
|
|
263
245
|
info: "text-info",
|
|
264
246
|
error: "text-error",
|
|
265
247
|
neutral: "text-base-content/70"
|
|
266
|
-
},
|
|
248
|
+
}, v = {
|
|
267
249
|
primary: "bg-primary text-primary-content",
|
|
268
250
|
success: "bg-success text-success-content",
|
|
269
251
|
warning: "bg-warning text-warning-content",
|
|
270
252
|
info: "bg-info text-info-content",
|
|
271
253
|
error: "bg-error text-error-content",
|
|
272
254
|
neutral: "bg-neutral text-neutral-content"
|
|
273
|
-
},
|
|
255
|
+
}, y = {
|
|
274
256
|
md: "text-2xl",
|
|
275
257
|
lg: "text-4xl",
|
|
276
258
|
xl: "text-5xl",
|
|
277
259
|
"2xl": "text-6xl"
|
|
278
|
-
},
|
|
260
|
+
}, b = (e) => e === "neutral" ? "var(--color-base-content)" : `var(--color-${e})`, x = ({ data: e, type: t, height: i }) => {
|
|
279
261
|
if (!e || e.length < 2) return null;
|
|
280
262
|
let a = Math.min(...e), o = Math.max(...e) - a || 1, s = (t) => t / (e.length - 1) * 100, c = (e) => i - 3 - (e - a) / o * (i - 6), l = e.map((e, t) => `${s(t).toFixed(2)},${c(e).toFixed(2)}`);
|
|
281
263
|
if (t === "bar") {
|
|
@@ -326,21 +308,21 @@ var i = ({ children: t, variant: r, bordered: i = !1, dash: a = !1, side: o = !1
|
|
|
326
308
|
vectorEffect: "non-scaling-stroke"
|
|
327
309
|
})
|
|
328
310
|
});
|
|
329
|
-
},
|
|
330
|
-
let
|
|
311
|
+
}, S = ({ label: e, value: t, tone: i = "primary", loading: a = !1, className: o = "", unit: s, valueSize: c = "xl", align: l = "left", sparkline: u, sparklineData: d, sparklineType: f = "line", sparklineHeight: p = 36, indicator: m = !1, filled: h = !1, onClick: g }) => {
|
|
312
|
+
let S = u ?? (d && d.length >= 2 ? /* @__PURE__ */ n(x, {
|
|
331
313
|
data: d,
|
|
332
314
|
type: f,
|
|
333
315
|
height: p
|
|
334
|
-
}) : null), C = h ? "" :
|
|
316
|
+
}) : null), C = h ? "" : _[i], w = h ? "opacity-80" : "text-base-content/60";
|
|
335
317
|
return /* @__PURE__ */ r("div", {
|
|
336
318
|
onClick: g,
|
|
337
|
-
className: `relative flex flex-col overflow-hidden rounded-lg p-3 ${h ?
|
|
319
|
+
className: `relative flex flex-col overflow-hidden rounded-lg p-3 ${h ? v[i] : "border border-base-300/60 bg-base-200"} ${g ? "cursor-pointer transition-colors hover:border-primary/40" : ""} ${o}`.trim(),
|
|
338
320
|
children: [
|
|
339
321
|
m && !h && /* @__PURE__ */ n("span", {
|
|
340
322
|
"aria-hidden": "true",
|
|
341
323
|
className: "absolute right-0 top-0 h-0 w-0",
|
|
342
324
|
style: {
|
|
343
|
-
borderTop: "14px solid " +
|
|
325
|
+
borderTop: "14px solid " + b(i),
|
|
344
326
|
borderLeft: "14px solid transparent"
|
|
345
327
|
}
|
|
346
328
|
}),
|
|
@@ -351,22 +333,22 @@ var i = ({ children: t, variant: r, bordered: i = !1, dash: a = !1, side: o = !1
|
|
|
351
333
|
/* @__PURE__ */ n("div", {
|
|
352
334
|
className: `flex min-h-[3rem] flex-1 items-center py-1 ${l === "center" ? "justify-center" : "justify-start"}`,
|
|
353
335
|
children: a ? /* @__PURE__ */ n("span", { className: `inline-block h-8 w-16 animate-pulse rounded ${h ? "bg-white/25" : "bg-base-content/10"}` }) : /* @__PURE__ */ r("span", {
|
|
354
|
-
className: `leading-none tracking-tight ${
|
|
336
|
+
className: `leading-none tracking-tight ${y[c]} font-semibold ${h ? "" : C}`.trim(),
|
|
355
337
|
children: [t, s != null && s !== "" && /* @__PURE__ */ n("span", {
|
|
356
338
|
className: "ml-0.5 text-[0.45em] font-semibold",
|
|
357
339
|
children: s
|
|
358
340
|
})]
|
|
359
341
|
})
|
|
360
342
|
}),
|
|
361
|
-
|
|
362
|
-
className: `-mx-3 -mb-3 mt-1 ${h ? "text-white" :
|
|
363
|
-
children:
|
|
343
|
+
S && /* @__PURE__ */ n("div", {
|
|
344
|
+
className: `-mx-3 -mb-3 mt-1 ${h ? "text-white" : _[i]}`,
|
|
345
|
+
children: S
|
|
364
346
|
})
|
|
365
347
|
]
|
|
366
348
|
});
|
|
367
|
-
},
|
|
368
|
-
|
|
349
|
+
}, C = i;
|
|
350
|
+
C.Title = a, C.Body = o, C.Actions = s, C.Figure = u, C.Feature = p, C.Quote = m, C.Meta = h, C.Info = g, C.Stat = S, C.Metric = t;
|
|
369
351
|
//#endregion
|
|
370
|
-
export {
|
|
352
|
+
export { C as default };
|
|
371
353
|
|
|
372
354
|
//# sourceMappingURL=index.js.map
|