@open-feishu-card/renderer 0.2.6 → 0.2.8
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/index.cjs +18 -9
- package/dist/index.js +19 -10
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -514,8 +514,6 @@ function vnodeToDom(node, doc) {
|
|
|
514
514
|
}
|
|
515
515
|
return el;
|
|
516
516
|
}
|
|
517
|
-
|
|
518
|
-
// src/registry.ts
|
|
519
517
|
var registry = {};
|
|
520
518
|
function registerComponent(tag, fn) {
|
|
521
519
|
registry[tag] = fn;
|
|
@@ -563,7 +561,7 @@ function resolveTextFontToken(raw) {
|
|
|
563
561
|
function textStyleToModifiers(textStyle) {
|
|
564
562
|
if (!textStyle) return [];
|
|
565
563
|
const out = [];
|
|
566
|
-
const color = textStyle
|
|
564
|
+
const color = adapter.resolveTextStyleColor(textStyle) ?? textStyle?.color?.trim();
|
|
567
565
|
if (color && color !== "default" && !/^(#|rgb|hsl)/i.test(color)) out.push(color);
|
|
568
566
|
const attrs = textStyle.attributes || [];
|
|
569
567
|
if (attrs.includes("bold")) out.push("bold");
|
|
@@ -578,11 +576,12 @@ function textStyleToStyle(textStyle) {
|
|
|
578
576
|
if (attrs.includes("bold")) style.fontWeight = "600";
|
|
579
577
|
if (attrs.includes("italic")) style.fontStyle = "italic";
|
|
580
578
|
if (attrs.includes("strikethrough")) style.textDecoration = "line-through";
|
|
581
|
-
|
|
582
|
-
|
|
579
|
+
const color = adapter.resolveTextStyleColor(textStyle) ?? textStyle.color;
|
|
580
|
+
if (color) {
|
|
581
|
+
const token = resolveTextFontToken(color);
|
|
583
582
|
if (token) style.color = `var(--${token})`;
|
|
584
583
|
else {
|
|
585
|
-
const c = resolveColor(
|
|
584
|
+
const c = resolveColor(color);
|
|
586
585
|
if (c) style.color = c;
|
|
587
586
|
}
|
|
588
587
|
}
|
|
@@ -723,6 +722,16 @@ function bgStyleToColor(style) {
|
|
|
723
722
|
if (v === "grey" || v === "gray" || v === "1") return "var(--bg-float-overlay)";
|
|
724
723
|
return resolveColor(v) || null;
|
|
725
724
|
}
|
|
725
|
+
function propertyBackgroundColor(property) {
|
|
726
|
+
if (!property) return null;
|
|
727
|
+
const custom = adapter.resolveCustomBackgroundLight(property);
|
|
728
|
+
if (custom) {
|
|
729
|
+
const c = resolveColor(custom);
|
|
730
|
+
if (c) return c;
|
|
731
|
+
}
|
|
732
|
+
const p = property;
|
|
733
|
+
return bgStyleToColor(p.backgroundStyle ?? p.background_style);
|
|
734
|
+
}
|
|
726
735
|
|
|
727
736
|
// src/chart-hydrate.ts
|
|
728
737
|
var CHART_SPEC_ATTR = "data-feishu-chart-spec";
|
|
@@ -5476,7 +5485,7 @@ function registerBuiltins() {
|
|
|
5476
5485
|
}
|
|
5477
5486
|
const mg = boxToStyle(p.margin);
|
|
5478
5487
|
if (mg) style.margin = mg;
|
|
5479
|
-
const bg =
|
|
5488
|
+
const bg = propertyBackgroundColor(p);
|
|
5480
5489
|
if (bg) style.background = bg;
|
|
5481
5490
|
const pad = boxToStyle(p.padding);
|
|
5482
5491
|
if (pad) style.padding = pad;
|
|
@@ -5512,7 +5521,7 @@ function registerBuiltins() {
|
|
|
5512
5521
|
}
|
|
5513
5522
|
const vGap = p.verticalSpacingValue?.value ?? p.vertical_spacing;
|
|
5514
5523
|
style.rowGap = (vGap != null ? spacingToPx(vGap) : 8) + "px";
|
|
5515
|
-
const bg =
|
|
5524
|
+
const bg = propertyBackgroundColor(p);
|
|
5516
5525
|
if (bg) style.background = bg;
|
|
5517
5526
|
const pad = boxToStyle(p.padding);
|
|
5518
5527
|
if (pad) style.padding = pad;
|
|
@@ -5685,7 +5694,7 @@ function registerBuiltins() {
|
|
|
5685
5694
|
const hasBorder = borderColor != null || p.hasBorder === true;
|
|
5686
5695
|
const cls = `${CLS}-interactive-container` + (hasBorder && !borderColor ? ` ${CLS}-interactive-container--bordered` : "") + (disabled ? ` ${CLS}-interactive-container--disabled` : "");
|
|
5687
5696
|
const style = {};
|
|
5688
|
-
const bg =
|
|
5697
|
+
const bg = propertyBackgroundColor(p);
|
|
5689
5698
|
if (bg) style.background = bg;
|
|
5690
5699
|
const pad = boxToStyle(p.padding);
|
|
5691
5700
|
if (pad) style.padding = pad;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dslToRaw } from '@open-feishu-card/adapter';
|
|
1
|
+
import { dslToRaw, resolveTextStyleColor, resolveCustomBackgroundLight } from '@open-feishu-card/adapter';
|
|
2
2
|
export { dslToRaw } from '@open-feishu-card/adapter';
|
|
3
3
|
|
|
4
4
|
// src/constants.ts
|
|
@@ -513,8 +513,6 @@ function vnodeToDom(node, doc) {
|
|
|
513
513
|
}
|
|
514
514
|
return el;
|
|
515
515
|
}
|
|
516
|
-
|
|
517
|
-
// src/registry.ts
|
|
518
516
|
var registry = {};
|
|
519
517
|
function registerComponent(tag, fn) {
|
|
520
518
|
registry[tag] = fn;
|
|
@@ -562,7 +560,7 @@ function resolveTextFontToken(raw) {
|
|
|
562
560
|
function textStyleToModifiers(textStyle) {
|
|
563
561
|
if (!textStyle) return [];
|
|
564
562
|
const out = [];
|
|
565
|
-
const color = textStyle
|
|
563
|
+
const color = resolveTextStyleColor(textStyle) ?? textStyle?.color?.trim();
|
|
566
564
|
if (color && color !== "default" && !/^(#|rgb|hsl)/i.test(color)) out.push(color);
|
|
567
565
|
const attrs = textStyle.attributes || [];
|
|
568
566
|
if (attrs.includes("bold")) out.push("bold");
|
|
@@ -577,11 +575,12 @@ function textStyleToStyle(textStyle) {
|
|
|
577
575
|
if (attrs.includes("bold")) style.fontWeight = "600";
|
|
578
576
|
if (attrs.includes("italic")) style.fontStyle = "italic";
|
|
579
577
|
if (attrs.includes("strikethrough")) style.textDecoration = "line-through";
|
|
580
|
-
|
|
581
|
-
|
|
578
|
+
const color = resolveTextStyleColor(textStyle) ?? textStyle.color;
|
|
579
|
+
if (color) {
|
|
580
|
+
const token = resolveTextFontToken(color);
|
|
582
581
|
if (token) style.color = `var(--${token})`;
|
|
583
582
|
else {
|
|
584
|
-
const c = resolveColor(
|
|
583
|
+
const c = resolveColor(color);
|
|
585
584
|
if (c) style.color = c;
|
|
586
585
|
}
|
|
587
586
|
}
|
|
@@ -722,6 +721,16 @@ function bgStyleToColor(style) {
|
|
|
722
721
|
if (v === "grey" || v === "gray" || v === "1") return "var(--bg-float-overlay)";
|
|
723
722
|
return resolveColor(v) || null;
|
|
724
723
|
}
|
|
724
|
+
function propertyBackgroundColor(property) {
|
|
725
|
+
if (!property) return null;
|
|
726
|
+
const custom = resolveCustomBackgroundLight(property);
|
|
727
|
+
if (custom) {
|
|
728
|
+
const c = resolveColor(custom);
|
|
729
|
+
if (c) return c;
|
|
730
|
+
}
|
|
731
|
+
const p = property;
|
|
732
|
+
return bgStyleToColor(p.backgroundStyle ?? p.background_style);
|
|
733
|
+
}
|
|
725
734
|
|
|
726
735
|
// src/chart-hydrate.ts
|
|
727
736
|
var CHART_SPEC_ATTR = "data-feishu-chart-spec";
|
|
@@ -5475,7 +5484,7 @@ function registerBuiltins() {
|
|
|
5475
5484
|
}
|
|
5476
5485
|
const mg = boxToStyle(p.margin);
|
|
5477
5486
|
if (mg) style.margin = mg;
|
|
5478
|
-
const bg =
|
|
5487
|
+
const bg = propertyBackgroundColor(p);
|
|
5479
5488
|
if (bg) style.background = bg;
|
|
5480
5489
|
const pad = boxToStyle(p.padding);
|
|
5481
5490
|
if (pad) style.padding = pad;
|
|
@@ -5511,7 +5520,7 @@ function registerBuiltins() {
|
|
|
5511
5520
|
}
|
|
5512
5521
|
const vGap = p.verticalSpacingValue?.value ?? p.vertical_spacing;
|
|
5513
5522
|
style.rowGap = (vGap != null ? spacingToPx(vGap) : 8) + "px";
|
|
5514
|
-
const bg =
|
|
5523
|
+
const bg = propertyBackgroundColor(p);
|
|
5515
5524
|
if (bg) style.background = bg;
|
|
5516
5525
|
const pad = boxToStyle(p.padding);
|
|
5517
5526
|
if (pad) style.padding = pad;
|
|
@@ -5684,7 +5693,7 @@ function registerBuiltins() {
|
|
|
5684
5693
|
const hasBorder = borderColor != null || p.hasBorder === true;
|
|
5685
5694
|
const cls = `${CLS}-interactive-container` + (hasBorder && !borderColor ? ` ${CLS}-interactive-container--bordered` : "") + (disabled ? ` ${CLS}-interactive-container--disabled` : "");
|
|
5686
5695
|
const style = {};
|
|
5687
|
-
const bg =
|
|
5696
|
+
const bg = propertyBackgroundColor(p);
|
|
5688
5697
|
if (bg) style.background = bg;
|
|
5689
5698
|
const pad = boxToStyle(p.padding);
|
|
5690
5699
|
if (pad) style.padding = pad;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-feishu-card/renderer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "零框架依赖的飞书卡片渲染引擎:Web / DOM / SSR,输入 RAW 或公开 DSL,输出真实 DOM 或 HTML 字符串",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"./dist/*.cjs"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@open-feishu-card/adapter": "0.3.
|
|
31
|
+
"@open-feishu-card/adapter": "0.3.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"tsup": "^8.3.5",
|