@open-feishu-card/renderer 0.2.30 → 0.2.32
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/all.css +25 -3
- package/dist/index.cjs +31 -6
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +31 -6
- package/dist/styles.css +25 -3
- package/package.json +1 -1
package/dist/all.css
CHANGED
|
@@ -1067,16 +1067,38 @@
|
|
|
1067
1067
|
align-items: center;
|
|
1068
1068
|
gap: 8px;
|
|
1069
1069
|
max-width: 600px; /* 客户端 .ud__toast max-width:600px */
|
|
1070
|
-
padding:
|
|
1071
|
-
border-radius:
|
|
1070
|
+
padding: 9px 16px; /* 客户端 .ud__notice--filled padding:9px 0 9px 16px */
|
|
1071
|
+
border-radius: 6px; /* 客户端 .ud__notice border-radius:6px */
|
|
1072
1072
|
background: rgba(31, 35, 41, 0.92); /* N900 深色半透明,白字 */
|
|
1073
1073
|
color: #fff;
|
|
1074
1074
|
font-size: 14px;
|
|
1075
1075
|
line-height: 1.5;
|
|
1076
|
-
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
|
|
1076
|
+
box-shadow: var(--shadow-s4-down, 0 4px 16px rgba(0, 0, 0, 0.16));
|
|
1077
1077
|
margin-bottom: 16px; /* 客户端 .ud__toast margin-bottom:16px */
|
|
1078
1078
|
animation: universal-card-toast-in 0.3s cubic-bezier(0.2, 0, 0, 1);
|
|
1079
1079
|
}
|
|
1080
|
+
/* outlined 浅色变体:对齐客户端 .ud__notice--outlined.ud__notice-{type}
|
|
1081
|
+
浅底 + 同色描边 + 深色文字(真机第二张:浅橙底橙边 warning) */
|
|
1082
|
+
.universal-card-toast--outlined {
|
|
1083
|
+
background: #fff;
|
|
1084
|
+
color: #1f2329;
|
|
1085
|
+
}
|
|
1086
|
+
.universal-card-toast--outlined.universal-card-toast--warning {
|
|
1087
|
+
background: #fff7e6;
|
|
1088
|
+
border: 1px solid #ff9d4c;
|
|
1089
|
+
}
|
|
1090
|
+
.universal-card-toast--outlined.universal-card-toast--error {
|
|
1091
|
+
background: #fef1f1;
|
|
1092
|
+
border: 1px solid #f54a45;
|
|
1093
|
+
}
|
|
1094
|
+
.universal-card-toast--outlined.universal-card-toast--info {
|
|
1095
|
+
background: #e8f0ff;
|
|
1096
|
+
border: 1px solid #3370ff;
|
|
1097
|
+
}
|
|
1098
|
+
.universal-card-toast--outlined.universal-card-toast--success {
|
|
1099
|
+
background: #f0fbef;
|
|
1100
|
+
border: 1px solid #34c724;
|
|
1101
|
+
}
|
|
1080
1102
|
.universal-card-toast--leave {
|
|
1081
1103
|
animation: universal-card-toast-out 0.3s cubic-bezier(0.2, 0, 0, 1) forwards;
|
|
1082
1104
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -671,7 +671,8 @@ function resolveImageSrc(p, ctx) {
|
|
|
671
671
|
if (p.src) return p.src;
|
|
672
672
|
if (p.url) return resolveURL(p.url) || null;
|
|
673
673
|
if (p.img_url) return p.img_url;
|
|
674
|
-
|
|
674
|
+
const imageId = p.imageID || p.img_key;
|
|
675
|
+
if (imageId && ctx.options.imageBaseURL) return ctx.options.imageBaseURL + imageId;
|
|
675
676
|
return null;
|
|
676
677
|
}
|
|
677
678
|
function resolveMediaSrc(p, kind, ctx) {
|
|
@@ -701,6 +702,7 @@ function personAvatarSrc(person, ctx) {
|
|
|
701
702
|
const r = ctx.options.resolvePersonAvatar(person);
|
|
702
703
|
if (r) return r;
|
|
703
704
|
}
|
|
705
|
+
if (person.avatar_url) return person.avatar_url;
|
|
704
706
|
if (!person.avatar_key) return null;
|
|
705
707
|
const base = ctx.options.avatarBaseURL || PERSON_AVATAR_BASE;
|
|
706
708
|
const suffix = ctx.options.avatarURLSuffix ?? PERSON_AVATAR_SUFFIX;
|
|
@@ -2035,16 +2037,38 @@ var BASE_STYLES_CSS = `/**
|
|
|
2035
2037
|
align-items: center;
|
|
2036
2038
|
gap: 8px;
|
|
2037
2039
|
max-width: 600px; /* \u5BA2\u6237\u7AEF .ud__toast max-width:600px */
|
|
2038
|
-
padding:
|
|
2039
|
-
border-radius:
|
|
2040
|
+
padding: 9px 16px; /* \u5BA2\u6237\u7AEF .ud__notice--filled padding:9px 0 9px 16px */
|
|
2041
|
+
border-radius: 6px; /* \u5BA2\u6237\u7AEF .ud__notice border-radius:6px */
|
|
2040
2042
|
background: rgba(31, 35, 41, 0.92); /* N900 \u6DF1\u8272\u534A\u900F\u660E\uFF0C\u767D\u5B57 */
|
|
2041
2043
|
color: #fff;
|
|
2042
2044
|
font-size: 14px;
|
|
2043
2045
|
line-height: 1.5;
|
|
2044
|
-
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
|
|
2046
|
+
box-shadow: var(--shadow-s4-down, 0 4px 16px rgba(0, 0, 0, 0.16));
|
|
2045
2047
|
margin-bottom: 16px; /* \u5BA2\u6237\u7AEF .ud__toast margin-bottom:16px */
|
|
2046
2048
|
animation: universal-card-toast-in 0.3s cubic-bezier(0.2, 0, 0, 1);
|
|
2047
2049
|
}
|
|
2050
|
+
/* outlined \u6D45\u8272\u53D8\u4F53\uFF1A\u5BF9\u9F50\u5BA2\u6237\u7AEF .ud__notice--outlined.ud__notice-{type}
|
|
2051
|
+
\u6D45\u5E95 + \u540C\u8272\u63CF\u8FB9 + \u6DF1\u8272\u6587\u5B57\uFF08\u771F\u673A\u7B2C\u4E8C\u5F20\uFF1A\u6D45\u6A59\u5E95\u6A59\u8FB9 warning\uFF09 */
|
|
2052
|
+
.universal-card-toast--outlined {
|
|
2053
|
+
background: #fff;
|
|
2054
|
+
color: #1f2329;
|
|
2055
|
+
}
|
|
2056
|
+
.universal-card-toast--outlined.universal-card-toast--warning {
|
|
2057
|
+
background: #fff7e6;
|
|
2058
|
+
border: 1px solid #ff9d4c;
|
|
2059
|
+
}
|
|
2060
|
+
.universal-card-toast--outlined.universal-card-toast--error {
|
|
2061
|
+
background: #fef1f1;
|
|
2062
|
+
border: 1px solid #f54a45;
|
|
2063
|
+
}
|
|
2064
|
+
.universal-card-toast--outlined.universal-card-toast--info {
|
|
2065
|
+
background: #e8f0ff;
|
|
2066
|
+
border: 1px solid #3370ff;
|
|
2067
|
+
}
|
|
2068
|
+
.universal-card-toast--outlined.universal-card-toast--success {
|
|
2069
|
+
background: #f0fbef;
|
|
2070
|
+
border: 1px solid #34c724;
|
|
2071
|
+
}
|
|
2048
2072
|
.universal-card-toast--leave {
|
|
2049
2073
|
animation: universal-card-toast-out 0.3s cubic-bezier(0.2, 0, 0, 1) forwards;
|
|
2050
2074
|
}
|
|
@@ -6870,7 +6894,7 @@ var DEFAULT_SHOW_TIME = 2e3;
|
|
|
6870
6894
|
var TYPE_ICON = {
|
|
6871
6895
|
success: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#34c724"/><path d="M4.5 8.2l2.2 2.2 4.8-4.8" fill="none" stroke="#fff" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
6872
6896
|
info: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#3370ff"/><circle cx="8" cy="4.6" r="1" fill="#fff"/><rect x="7.2" y="7" width="1.6" height="4.2" rx="0.8" fill="#fff"/></svg>',
|
|
6873
|
-
warning: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#fad355"/><rect x="7.2" y="3.8" width="1.6" height="4.6" rx="0.8" fill="#
|
|
6897
|
+
warning: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#fad355"/><rect x="7.2" y="3.8" width="1.6" height="4.6" rx="0.8" fill="#fff"/><circle cx="8" cy="11.8" r="1" fill="#fff"/></svg>',
|
|
6874
6898
|
error: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#f54a45"/><path d="M5.6 5.6l4.8 4.8M10.4 5.6l-4.8 4.8" stroke="#fff" stroke-width="1.6" stroke-linecap="round"/></svg>'
|
|
6875
6899
|
};
|
|
6876
6900
|
function escapeHTML(s) {
|
|
@@ -6879,7 +6903,8 @@ function escapeHTML(s) {
|
|
|
6879
6903
|
function renderToastHTML(type, opts) {
|
|
6880
6904
|
const maxLines = opts.maxLines ?? 1;
|
|
6881
6905
|
const styleAttr = maxLines > 1 ? ` style="-webkit-line-clamp:${maxLines};"` : "";
|
|
6882
|
-
|
|
6906
|
+
const variantClass = opts.variant === "outlined" ? " universal-card-toast--outlined" : "";
|
|
6907
|
+
return `<div class="universal-card-toast universal-card-toast--${type}${variantClass}" role="status" aria-live="polite"><span class="universal-card-toast__icon">${TYPE_ICON[type]}</span><span class="universal-card-toast__text"${styleAttr}>${escapeHTML(opts.content)}</span></div>`;
|
|
6883
6908
|
}
|
|
6884
6909
|
function createToastHost(container) {
|
|
6885
6910
|
const hostEl = typeof document === "undefined" ? null : container ?? document.body;
|
package/dist/index.d.cts
CHANGED
|
@@ -81,6 +81,8 @@ interface ElementProperty {
|
|
|
81
81
|
hoverTips?: CardElement;
|
|
82
82
|
hasBorder?: boolean;
|
|
83
83
|
imageID?: string;
|
|
84
|
+
/** DSL 公开字段;dslToRaw 常原样留在 property(未改名为 imageID) */
|
|
85
|
+
img_key?: string;
|
|
84
86
|
origin_key?: string;
|
|
85
87
|
src?: string;
|
|
86
88
|
url?: string | LinkURL;
|
|
@@ -291,7 +293,7 @@ interface RenderOptions {
|
|
|
291
293
|
/** 音视频地址前缀:最终 src = mediaBaseURL + fileID */
|
|
292
294
|
mediaBaseURL?: string;
|
|
293
295
|
/**
|
|
294
|
-
* 人员表(open_id -> { content 姓名, avatar_key 头像 })。
|
|
296
|
+
* 人员表(open_id -> { content 姓名, avatar_key / avatar_url 头像 })。
|
|
295
297
|
* person_v1 / person_list 元素只带 ID,姓名/头像在此反查。
|
|
296
298
|
* 异步渲染(renderCardToStringAsync)会自动从 json_attachment.persons 填入;
|
|
297
299
|
* 同步渲染若想出名字/头像,需手动传入。缺省时人员降级为固定头像 +「赵天雄」。
|
|
@@ -326,7 +328,8 @@ interface RenderOptions {
|
|
|
326
328
|
* 人员信息:person_v1 / person_list / at 元素只带 ID,姓名与头像 key 在这里。
|
|
327
329
|
* 取自飞书消息 content 的 json_attachment.persons(按 open_id「ou_...」索引);
|
|
328
330
|
* fetchCardMessage 还会把信封 mentions 与 at_users 合并进来(含 @_user_N 别名键)。
|
|
329
|
-
* avatar_key 是公开可访问的头像图 key(无需鉴权,见 PERSON_AVATAR_BASE
|
|
331
|
+
* avatar_key 是公开可访问的头像图 key(无需鉴权,见 PERSON_AVATAR_BASE);
|
|
332
|
+
* 本地预览也可用 avatar_url(含 data URI)直接给头像地址。
|
|
330
333
|
*/
|
|
331
334
|
interface PersonInfo {
|
|
332
335
|
person_id?: string;
|
|
@@ -335,6 +338,11 @@ interface PersonInfo {
|
|
|
335
338
|
type?: number;
|
|
336
339
|
/** 头像图 key(形如 v3_00te_...),拼 avatarBaseURL 取图 */
|
|
337
340
|
avatar_key?: string;
|
|
341
|
+
/**
|
|
342
|
+
* 直接可用的头像 URL(含 data URI)。
|
|
343
|
+
* 本地预览虚拟用户没有飞书 avatar_key 时用这个;优先级低于 resolvePersonAvatar,高于 avatar_key。
|
|
344
|
+
*/
|
|
345
|
+
avatar_url?: string;
|
|
338
346
|
}
|
|
339
347
|
/**
|
|
340
348
|
* 消息信封上的 @ 提及(data.items[0].mentions),不在 body.content 内。
|
|
@@ -627,6 +635,8 @@ interface ToastOptions {
|
|
|
627
635
|
showTime?: number;
|
|
628
636
|
/** 最大行数,超出截断省略,默认 1(客户端 maxLines:1) */
|
|
629
637
|
maxLines?: number;
|
|
638
|
+
/** 视觉形态:'dark' 深色悬浮胶囊(默认);'outlined' 浅底彩边(对齐客户端 .ud__notice--outlined) */
|
|
639
|
+
variant?: 'dark' | 'outlined';
|
|
630
640
|
}
|
|
631
641
|
interface ToastAPI {
|
|
632
642
|
success: (opts: ToastOptions) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -81,6 +81,8 @@ interface ElementProperty {
|
|
|
81
81
|
hoverTips?: CardElement;
|
|
82
82
|
hasBorder?: boolean;
|
|
83
83
|
imageID?: string;
|
|
84
|
+
/** DSL 公开字段;dslToRaw 常原样留在 property(未改名为 imageID) */
|
|
85
|
+
img_key?: string;
|
|
84
86
|
origin_key?: string;
|
|
85
87
|
src?: string;
|
|
86
88
|
url?: string | LinkURL;
|
|
@@ -291,7 +293,7 @@ interface RenderOptions {
|
|
|
291
293
|
/** 音视频地址前缀:最终 src = mediaBaseURL + fileID */
|
|
292
294
|
mediaBaseURL?: string;
|
|
293
295
|
/**
|
|
294
|
-
* 人员表(open_id -> { content 姓名, avatar_key 头像 })。
|
|
296
|
+
* 人员表(open_id -> { content 姓名, avatar_key / avatar_url 头像 })。
|
|
295
297
|
* person_v1 / person_list 元素只带 ID,姓名/头像在此反查。
|
|
296
298
|
* 异步渲染(renderCardToStringAsync)会自动从 json_attachment.persons 填入;
|
|
297
299
|
* 同步渲染若想出名字/头像,需手动传入。缺省时人员降级为固定头像 +「赵天雄」。
|
|
@@ -326,7 +328,8 @@ interface RenderOptions {
|
|
|
326
328
|
* 人员信息:person_v1 / person_list / at 元素只带 ID,姓名与头像 key 在这里。
|
|
327
329
|
* 取自飞书消息 content 的 json_attachment.persons(按 open_id「ou_...」索引);
|
|
328
330
|
* fetchCardMessage 还会把信封 mentions 与 at_users 合并进来(含 @_user_N 别名键)。
|
|
329
|
-
* avatar_key 是公开可访问的头像图 key(无需鉴权,见 PERSON_AVATAR_BASE
|
|
331
|
+
* avatar_key 是公开可访问的头像图 key(无需鉴权,见 PERSON_AVATAR_BASE);
|
|
332
|
+
* 本地预览也可用 avatar_url(含 data URI)直接给头像地址。
|
|
330
333
|
*/
|
|
331
334
|
interface PersonInfo {
|
|
332
335
|
person_id?: string;
|
|
@@ -335,6 +338,11 @@ interface PersonInfo {
|
|
|
335
338
|
type?: number;
|
|
336
339
|
/** 头像图 key(形如 v3_00te_...),拼 avatarBaseURL 取图 */
|
|
337
340
|
avatar_key?: string;
|
|
341
|
+
/**
|
|
342
|
+
* 直接可用的头像 URL(含 data URI)。
|
|
343
|
+
* 本地预览虚拟用户没有飞书 avatar_key 时用这个;优先级低于 resolvePersonAvatar,高于 avatar_key。
|
|
344
|
+
*/
|
|
345
|
+
avatar_url?: string;
|
|
338
346
|
}
|
|
339
347
|
/**
|
|
340
348
|
* 消息信封上的 @ 提及(data.items[0].mentions),不在 body.content 内。
|
|
@@ -627,6 +635,8 @@ interface ToastOptions {
|
|
|
627
635
|
showTime?: number;
|
|
628
636
|
/** 最大行数,超出截断省略,默认 1(客户端 maxLines:1) */
|
|
629
637
|
maxLines?: number;
|
|
638
|
+
/** 视觉形态:'dark' 深色悬浮胶囊(默认);'outlined' 浅底彩边(对齐客户端 .ud__notice--outlined) */
|
|
639
|
+
variant?: 'dark' | 'outlined';
|
|
630
640
|
}
|
|
631
641
|
interface ToastAPI {
|
|
632
642
|
success: (opts: ToastOptions) => void;
|
package/dist/index.js
CHANGED
|
@@ -670,7 +670,8 @@ function resolveImageSrc(p, ctx) {
|
|
|
670
670
|
if (p.src) return p.src;
|
|
671
671
|
if (p.url) return resolveURL(p.url) || null;
|
|
672
672
|
if (p.img_url) return p.img_url;
|
|
673
|
-
|
|
673
|
+
const imageId = p.imageID || p.img_key;
|
|
674
|
+
if (imageId && ctx.options.imageBaseURL) return ctx.options.imageBaseURL + imageId;
|
|
674
675
|
return null;
|
|
675
676
|
}
|
|
676
677
|
function resolveMediaSrc(p, kind, ctx) {
|
|
@@ -700,6 +701,7 @@ function personAvatarSrc(person, ctx) {
|
|
|
700
701
|
const r = ctx.options.resolvePersonAvatar(person);
|
|
701
702
|
if (r) return r;
|
|
702
703
|
}
|
|
704
|
+
if (person.avatar_url) return person.avatar_url;
|
|
703
705
|
if (!person.avatar_key) return null;
|
|
704
706
|
const base = ctx.options.avatarBaseURL || PERSON_AVATAR_BASE;
|
|
705
707
|
const suffix = ctx.options.avatarURLSuffix ?? PERSON_AVATAR_SUFFIX;
|
|
@@ -2034,16 +2036,38 @@ var BASE_STYLES_CSS = `/**
|
|
|
2034
2036
|
align-items: center;
|
|
2035
2037
|
gap: 8px;
|
|
2036
2038
|
max-width: 600px; /* \u5BA2\u6237\u7AEF .ud__toast max-width:600px */
|
|
2037
|
-
padding:
|
|
2038
|
-
border-radius:
|
|
2039
|
+
padding: 9px 16px; /* \u5BA2\u6237\u7AEF .ud__notice--filled padding:9px 0 9px 16px */
|
|
2040
|
+
border-radius: 6px; /* \u5BA2\u6237\u7AEF .ud__notice border-radius:6px */
|
|
2039
2041
|
background: rgba(31, 35, 41, 0.92); /* N900 \u6DF1\u8272\u534A\u900F\u660E\uFF0C\u767D\u5B57 */
|
|
2040
2042
|
color: #fff;
|
|
2041
2043
|
font-size: 14px;
|
|
2042
2044
|
line-height: 1.5;
|
|
2043
|
-
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
|
|
2045
|
+
box-shadow: var(--shadow-s4-down, 0 4px 16px rgba(0, 0, 0, 0.16));
|
|
2044
2046
|
margin-bottom: 16px; /* \u5BA2\u6237\u7AEF .ud__toast margin-bottom:16px */
|
|
2045
2047
|
animation: universal-card-toast-in 0.3s cubic-bezier(0.2, 0, 0, 1);
|
|
2046
2048
|
}
|
|
2049
|
+
/* outlined \u6D45\u8272\u53D8\u4F53\uFF1A\u5BF9\u9F50\u5BA2\u6237\u7AEF .ud__notice--outlined.ud__notice-{type}
|
|
2050
|
+
\u6D45\u5E95 + \u540C\u8272\u63CF\u8FB9 + \u6DF1\u8272\u6587\u5B57\uFF08\u771F\u673A\u7B2C\u4E8C\u5F20\uFF1A\u6D45\u6A59\u5E95\u6A59\u8FB9 warning\uFF09 */
|
|
2051
|
+
.universal-card-toast--outlined {
|
|
2052
|
+
background: #fff;
|
|
2053
|
+
color: #1f2329;
|
|
2054
|
+
}
|
|
2055
|
+
.universal-card-toast--outlined.universal-card-toast--warning {
|
|
2056
|
+
background: #fff7e6;
|
|
2057
|
+
border: 1px solid #ff9d4c;
|
|
2058
|
+
}
|
|
2059
|
+
.universal-card-toast--outlined.universal-card-toast--error {
|
|
2060
|
+
background: #fef1f1;
|
|
2061
|
+
border: 1px solid #f54a45;
|
|
2062
|
+
}
|
|
2063
|
+
.universal-card-toast--outlined.universal-card-toast--info {
|
|
2064
|
+
background: #e8f0ff;
|
|
2065
|
+
border: 1px solid #3370ff;
|
|
2066
|
+
}
|
|
2067
|
+
.universal-card-toast--outlined.universal-card-toast--success {
|
|
2068
|
+
background: #f0fbef;
|
|
2069
|
+
border: 1px solid #34c724;
|
|
2070
|
+
}
|
|
2047
2071
|
.universal-card-toast--leave {
|
|
2048
2072
|
animation: universal-card-toast-out 0.3s cubic-bezier(0.2, 0, 0, 1) forwards;
|
|
2049
2073
|
}
|
|
@@ -6869,7 +6893,7 @@ var DEFAULT_SHOW_TIME = 2e3;
|
|
|
6869
6893
|
var TYPE_ICON = {
|
|
6870
6894
|
success: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#34c724"/><path d="M4.5 8.2l2.2 2.2 4.8-4.8" fill="none" stroke="#fff" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
6871
6895
|
info: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#3370ff"/><circle cx="8" cy="4.6" r="1" fill="#fff"/><rect x="7.2" y="7" width="1.6" height="4.2" rx="0.8" fill="#fff"/></svg>',
|
|
6872
|
-
warning: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#fad355"/><rect x="7.2" y="3.8" width="1.6" height="4.6" rx="0.8" fill="#
|
|
6896
|
+
warning: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#fad355"/><rect x="7.2" y="3.8" width="1.6" height="4.6" rx="0.8" fill="#fff"/><circle cx="8" cy="11.8" r="1" fill="#fff"/></svg>',
|
|
6873
6897
|
error: '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="7" fill="#f54a45"/><path d="M5.6 5.6l4.8 4.8M10.4 5.6l-4.8 4.8" stroke="#fff" stroke-width="1.6" stroke-linecap="round"/></svg>'
|
|
6874
6898
|
};
|
|
6875
6899
|
function escapeHTML(s) {
|
|
@@ -6878,7 +6902,8 @@ function escapeHTML(s) {
|
|
|
6878
6902
|
function renderToastHTML(type, opts) {
|
|
6879
6903
|
const maxLines = opts.maxLines ?? 1;
|
|
6880
6904
|
const styleAttr = maxLines > 1 ? ` style="-webkit-line-clamp:${maxLines};"` : "";
|
|
6881
|
-
|
|
6905
|
+
const variantClass = opts.variant === "outlined" ? " universal-card-toast--outlined" : "";
|
|
6906
|
+
return `<div class="universal-card-toast universal-card-toast--${type}${variantClass}" role="status" aria-live="polite"><span class="universal-card-toast__icon">${TYPE_ICON[type]}</span><span class="universal-card-toast__text"${styleAttr}>${escapeHTML(opts.content)}</span></div>`;
|
|
6882
6907
|
}
|
|
6883
6908
|
function createToastHost(container) {
|
|
6884
6909
|
const hostEl = typeof document === "undefined" ? null : container ?? document.body;
|
package/dist/styles.css
CHANGED
|
@@ -1067,16 +1067,38 @@
|
|
|
1067
1067
|
align-items: center;
|
|
1068
1068
|
gap: 8px;
|
|
1069
1069
|
max-width: 600px; /* 客户端 .ud__toast max-width:600px */
|
|
1070
|
-
padding:
|
|
1071
|
-
border-radius:
|
|
1070
|
+
padding: 9px 16px; /* 客户端 .ud__notice--filled padding:9px 0 9px 16px */
|
|
1071
|
+
border-radius: 6px; /* 客户端 .ud__notice border-radius:6px */
|
|
1072
1072
|
background: rgba(31, 35, 41, 0.92); /* N900 深色半透明,白字 */
|
|
1073
1073
|
color: #fff;
|
|
1074
1074
|
font-size: 14px;
|
|
1075
1075
|
line-height: 1.5;
|
|
1076
|
-
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
|
|
1076
|
+
box-shadow: var(--shadow-s4-down, 0 4px 16px rgba(0, 0, 0, 0.16));
|
|
1077
1077
|
margin-bottom: 16px; /* 客户端 .ud__toast margin-bottom:16px */
|
|
1078
1078
|
animation: universal-card-toast-in 0.3s cubic-bezier(0.2, 0, 0, 1);
|
|
1079
1079
|
}
|
|
1080
|
+
/* outlined 浅色变体:对齐客户端 .ud__notice--outlined.ud__notice-{type}
|
|
1081
|
+
浅底 + 同色描边 + 深色文字(真机第二张:浅橙底橙边 warning) */
|
|
1082
|
+
.universal-card-toast--outlined {
|
|
1083
|
+
background: #fff;
|
|
1084
|
+
color: #1f2329;
|
|
1085
|
+
}
|
|
1086
|
+
.universal-card-toast--outlined.universal-card-toast--warning {
|
|
1087
|
+
background: #fff7e6;
|
|
1088
|
+
border: 1px solid #ff9d4c;
|
|
1089
|
+
}
|
|
1090
|
+
.universal-card-toast--outlined.universal-card-toast--error {
|
|
1091
|
+
background: #fef1f1;
|
|
1092
|
+
border: 1px solid #f54a45;
|
|
1093
|
+
}
|
|
1094
|
+
.universal-card-toast--outlined.universal-card-toast--info {
|
|
1095
|
+
background: #e8f0ff;
|
|
1096
|
+
border: 1px solid #3370ff;
|
|
1097
|
+
}
|
|
1098
|
+
.universal-card-toast--outlined.universal-card-toast--success {
|
|
1099
|
+
background: #f0fbef;
|
|
1100
|
+
border: 1px solid #34c724;
|
|
1101
|
+
}
|
|
1080
1102
|
.universal-card-toast--leave {
|
|
1081
1103
|
animation: universal-card-toast-out 0.3s cubic-bezier(0.2, 0, 0, 1) forwards;
|
|
1082
1104
|
}
|