@open-feishu-card/adapter 0.3.10 → 0.3.11
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/expand-dsl-colors.d.ts +10 -4
- package/dist/expand-dsl-colors.d.ts.map +1 -1
- package/dist/index.cjs +28 -6
- package/dist/index.js +28 -6
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DSL config.style.color
|
|
2
|
+
* DSL config.style.color 中的自定义色别名在 dslToRaw 时展开为渲染器已支持的
|
|
3
3
|
* customBackgroundStyle / textStyle.customColor(对齐飞书 RAW 真机字段)。
|
|
4
|
+
*
|
|
5
|
+
* 别名不限于编辑器默认的 cus-*:业务卡也常用 mm_* 等任意 token 名登记在
|
|
6
|
+
* config.style.color,真机按 registry 键查找;仅认 cus- 前缀会导致背景/描边丢失。
|
|
4
7
|
*/
|
|
5
8
|
import type { CardElement, TextStyle } from './types.js';
|
|
6
9
|
export type CustomColorEntry = {
|
|
@@ -9,15 +12,18 @@ export type CustomColorEntry = {
|
|
|
9
12
|
};
|
|
10
13
|
export type ColorRegistry = Record<string, CustomColorEntry>;
|
|
11
14
|
export declare function readColorRegistry(card: Record<string, unknown>): ColorRegistry;
|
|
15
|
+
/** @deprecated 保留兼容;展开逻辑改为查 registry,不再依赖 cus- 前缀。 */
|
|
12
16
|
export declare function isCustomColorAlias(value: unknown): value is string;
|
|
13
|
-
/**
|
|
17
|
+
/** 是否为 config.style.color 中已登记的别名(任意 token 名)。 */
|
|
18
|
+
export declare function isRegisteredColorAlias(value: unknown, registry: ColorRegistry): value is string;
|
|
19
|
+
/** column / column_set / interactive_container background_style → customBackgroundStyle */
|
|
14
20
|
export declare function expandBackgroundStyleAlias(style: unknown, registry: ColorRegistry): {
|
|
15
21
|
light_mode: string;
|
|
16
22
|
dark_mode: string;
|
|
17
23
|
} | undefined;
|
|
18
|
-
/** textStyle.color
|
|
24
|
+
/** textStyle.color 登记别名 → customColor(去掉 color,避免被当成命名色) */
|
|
19
25
|
export declare function expandTextStyleColor(textStyle: TextStyle | undefined, registry: ColorRegistry): TextStyle | undefined;
|
|
20
|
-
/** border_color / background_style
|
|
26
|
+
/** border_color / background_style 等登记别名 → customBackgroundStyle 形态(供 RAW 渲染器读取) */
|
|
21
27
|
export declare function expandColorAlias(style: unknown, registry: ColorRegistry): {
|
|
22
28
|
light_mode: string;
|
|
23
29
|
dark_mode: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand-dsl-colors.d.ts","sourceRoot":"","sources":["../src/expand-dsl-colors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"expand-dsl-colors.d.ts","sourceRoot":"","sources":["../src/expand-dsl-colors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,MAAM,gBAAgB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AACzE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE7D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAiB9E;AAED,sDAAsD;AACtD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAElE;AAED,kDAAkD;AAClD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,aAAa,GACtB,KAAK,IAAI,MAAM,CAEjB;AAED,2FAA2F;AAC3F,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,aAAa,GACtB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAIvD;AAED,4DAA4D;AAC5D,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,QAAQ,EAAE,aAAa,GACtB,SAAS,GAAG,SAAS,CAUvB;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,aAAa,GACtB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAEvD;AAED,0CAA0C;AAC1C,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,WAAW,EAAE,GAAG,SAAS,EACnC,QAAQ,EAAE,aAAa,GACtB,WAAW,EAAE,GAAG,SAAS,CAG3B;AAuCD,4DAA4D;AAC5D,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,MAAM,CAGR"}
|
package/dist/index.cjs
CHANGED
|
@@ -621,21 +621,19 @@ function readColorRegistry(card) {
|
|
|
621
621
|
}
|
|
622
622
|
return out;
|
|
623
623
|
}
|
|
624
|
-
function
|
|
625
|
-
return typeof value === "string" && value.
|
|
624
|
+
function isRegisteredColorAlias(value, registry) {
|
|
625
|
+
return typeof value === "string" && !!value && Object.prototype.hasOwnProperty.call(registry, value);
|
|
626
626
|
}
|
|
627
627
|
function expandBackgroundStyleAlias(style, registry) {
|
|
628
|
-
if (!
|
|
628
|
+
if (!isRegisteredColorAlias(style, registry)) return void 0;
|
|
629
629
|
const entry = registry[style];
|
|
630
|
-
if (!entry) return void 0;
|
|
631
630
|
return { light_mode: entry.light_mode, dark_mode: entry.dark_mode };
|
|
632
631
|
}
|
|
633
632
|
function expandTextStyleColor(textStyle, registry) {
|
|
634
633
|
if (!textStyle) return textStyle;
|
|
635
634
|
const color = typeof textStyle.color === "string" ? textStyle.color.trim() : void 0;
|
|
636
|
-
if (!
|
|
635
|
+
if (!isRegisteredColorAlias(color, registry)) return textStyle;
|
|
637
636
|
const entry = registry[color];
|
|
638
|
-
if (!entry) return textStyle;
|
|
639
637
|
const { color: _drop, ...rest } = textStyle;
|
|
640
638
|
return {
|
|
641
639
|
...rest,
|
|
@@ -883,6 +881,30 @@ function buildProperty(el, tag, colors) {
|
|
|
883
881
|
continue;
|
|
884
882
|
}
|
|
885
883
|
}
|
|
884
|
+
if (tag === "interactive_container" && typeof v === "string") {
|
|
885
|
+
if (k === "width") {
|
|
886
|
+
if (v === "fill" || v === "auto" || v === "default") {
|
|
887
|
+
property.widthValue = { type: "builtin_interactive_container_width", value: v };
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
const px = pxValue(v);
|
|
891
|
+
if (px != null) {
|
|
892
|
+
property.widthValue = { type: "pixels", value: px };
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
if (k === "height") {
|
|
897
|
+
if (v === "auto" || v === "default") {
|
|
898
|
+
property.heightValue = { type: "builtin_interactive_container_height", value: v };
|
|
899
|
+
continue;
|
|
900
|
+
}
|
|
901
|
+
const px = pxValue(v);
|
|
902
|
+
if (px != null) {
|
|
903
|
+
property.heightValue = { type: "pixels", value: px };
|
|
904
|
+
continue;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
886
908
|
if (TEXT_LEAF_KEYS.has(k)) {
|
|
887
909
|
property[renameKey(k)] = wrapTextLeaf(v);
|
|
888
910
|
continue;
|
package/dist/index.js
CHANGED
|
@@ -619,21 +619,19 @@ function readColorRegistry(card) {
|
|
|
619
619
|
}
|
|
620
620
|
return out;
|
|
621
621
|
}
|
|
622
|
-
function
|
|
623
|
-
return typeof value === "string" && value.
|
|
622
|
+
function isRegisteredColorAlias(value, registry) {
|
|
623
|
+
return typeof value === "string" && !!value && Object.prototype.hasOwnProperty.call(registry, value);
|
|
624
624
|
}
|
|
625
625
|
function expandBackgroundStyleAlias(style, registry) {
|
|
626
|
-
if (!
|
|
626
|
+
if (!isRegisteredColorAlias(style, registry)) return void 0;
|
|
627
627
|
const entry = registry[style];
|
|
628
|
-
if (!entry) return void 0;
|
|
629
628
|
return { light_mode: entry.light_mode, dark_mode: entry.dark_mode };
|
|
630
629
|
}
|
|
631
630
|
function expandTextStyleColor(textStyle, registry) {
|
|
632
631
|
if (!textStyle) return textStyle;
|
|
633
632
|
const color = typeof textStyle.color === "string" ? textStyle.color.trim() : void 0;
|
|
634
|
-
if (!
|
|
633
|
+
if (!isRegisteredColorAlias(color, registry)) return textStyle;
|
|
635
634
|
const entry = registry[color];
|
|
636
|
-
if (!entry) return textStyle;
|
|
637
635
|
const { color: _drop, ...rest } = textStyle;
|
|
638
636
|
return {
|
|
639
637
|
...rest,
|
|
@@ -881,6 +879,30 @@ function buildProperty(el, tag, colors) {
|
|
|
881
879
|
continue;
|
|
882
880
|
}
|
|
883
881
|
}
|
|
882
|
+
if (tag === "interactive_container" && typeof v === "string") {
|
|
883
|
+
if (k === "width") {
|
|
884
|
+
if (v === "fill" || v === "auto" || v === "default") {
|
|
885
|
+
property.widthValue = { type: "builtin_interactive_container_width", value: v };
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
const px = pxValue(v);
|
|
889
|
+
if (px != null) {
|
|
890
|
+
property.widthValue = { type: "pixels", value: px };
|
|
891
|
+
continue;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
if (k === "height") {
|
|
895
|
+
if (v === "auto" || v === "default") {
|
|
896
|
+
property.heightValue = { type: "builtin_interactive_container_height", value: v };
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
const px = pxValue(v);
|
|
900
|
+
if (px != null) {
|
|
901
|
+
property.heightValue = { type: "pixels", value: px };
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
}
|
|
884
906
|
if (TEXT_LEAF_KEYS.has(k)) {
|
|
885
907
|
property[renameKey(k)] = wrapTextLeaf(v);
|
|
886
908
|
continue;
|