km-card-layout-core 0.1.25 → 0.1.27
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/README.md +1 -2
- package/bindings.ts +9 -20
- package/data.ts +1 -3
- package/dist/bindings.js +6 -14
- package/dist/data.js +1 -1
- package/dist/index.js +9 -18
- package/dist/interface/index.js +0 -1
- package/dist/layout.js +1 -17
- package/dist/ops/changeBackground.js +45 -97
- package/dist/render/helpers.js +41 -21
- package/dist/render/init.js +81 -0
- package/index.ts +7 -26
- package/interface/data/payload.ts +3 -3
- package/interface/elements.ts +2 -1
- package/interface/index.ts +0 -1
- package/interface/layout.ts +2 -1
- package/layout.ts +0 -18
- package/ops/changeBackground.ts +47 -130
- package/package.json +1 -1
- package/render/helpers.ts +72 -28
- package/render/init.ts +107 -0
- package/types.d.ts +35 -98
- package/dist/interface/context.js +0 -2
- package/dist/interface/render.js +0 -2
- package/dist/render/builder.js +0 -209
- package/dist/render/tool.js +0 -15
- package/dist/utils.js +0 -25
- package/interface/context.ts +0 -6
- package/render/tool.ts +0 -21
- package/utils.ts +0 -13
package/types.d.ts
CHANGED
|
@@ -6,22 +6,19 @@
|
|
|
6
6
|
export * from './interface';
|
|
7
7
|
|
|
8
8
|
import type {
|
|
9
|
-
BindingContext,
|
|
10
9
|
CardElement,
|
|
11
10
|
CardLayoutInput,
|
|
12
11
|
CardLayoutSchema,
|
|
13
12
|
TemplateItem,
|
|
14
|
-
TemplateBackground
|
|
13
|
+
TemplateBackground,
|
|
15
14
|
} from './interface';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
currentBg: TemplateBackground[];
|
|
24
|
-
};
|
|
15
|
+
import type {
|
|
16
|
+
AbsoluteLayoutDefinition,
|
|
17
|
+
LayoutPanelElement,
|
|
18
|
+
TextElement,
|
|
19
|
+
ImageElement,
|
|
20
|
+
IconElement,
|
|
21
|
+
} from './interface/elements';
|
|
25
22
|
|
|
26
23
|
export function addUnit(
|
|
27
24
|
value: string | number | undefined | null,
|
|
@@ -49,9 +46,7 @@ export function roundToInt(value: number): number;
|
|
|
49
46
|
|
|
50
47
|
export function getAbsLayout(
|
|
51
48
|
el: CardElement
|
|
52
|
-
):
|
|
53
|
-
|
|
54
|
-
export function collectBindings(elements?: CardElement[]): string[];
|
|
49
|
+
): AbsoluteLayoutDefinition | null;
|
|
55
50
|
|
|
56
51
|
export function normalizeId(
|
|
57
52
|
id?: string | number | null
|
|
@@ -59,15 +54,9 @@ export function normalizeId(
|
|
|
59
54
|
|
|
60
55
|
export function parseLayout(input: unknown): CardLayoutSchema | null;
|
|
61
56
|
|
|
62
|
-
export function areChildrenEqual(
|
|
63
|
-
a?: CardLayoutSchema | null,
|
|
64
|
-
b?: CardLayoutSchema | null
|
|
65
|
-
): boolean;
|
|
66
|
-
|
|
67
57
|
export function resolveBindingValue(
|
|
68
58
|
binding: string | undefined,
|
|
69
|
-
rootData: Record<string, any
|
|
70
|
-
context?: BindingContext
|
|
59
|
+
rootData: Record<string, any>
|
|
71
60
|
): any;
|
|
72
61
|
|
|
73
62
|
export function stripLayoutBindings(
|
|
@@ -76,76 +65,14 @@ export function stripLayoutBindings(
|
|
|
76
65
|
|
|
77
66
|
export function applyItemCollectBindings(
|
|
78
67
|
layouts: CardLayoutSchema[],
|
|
79
|
-
items?:
|
|
68
|
+
items?: TemplateItem[]
|
|
80
69
|
): CardLayoutSchema[];
|
|
81
70
|
|
|
82
|
-
export function getTemplateItems(
|
|
83
|
-
ids: string,
|
|
84
|
-
items: import('./interface/data/payload').TemplateItem[]
|
|
85
|
-
): import('./interface/data/payload').TemplateItem[];
|
|
86
|
-
|
|
87
|
-
export function getTemplateBackgrounds(
|
|
88
|
-
ids: string,
|
|
89
|
-
items: import('./interface/data/payload').TemplateBackground[]
|
|
90
|
-
): import('./interface/data/payload').TemplateBackground[];
|
|
91
|
-
|
|
92
71
|
export function backgroundChange(
|
|
93
|
-
bg:
|
|
72
|
+
bg: TemplateBackground,
|
|
94
73
|
layout: CardLayoutSchema
|
|
95
74
|
): CardLayoutSchema;
|
|
96
75
|
|
|
97
|
-
export const DEFAULT_DECOR_COLOR: string;
|
|
98
|
-
|
|
99
|
-
export function resolveSpecialStyle(
|
|
100
|
-
element: CardElement,
|
|
101
|
-
background?: {
|
|
102
|
-
id?: string | number;
|
|
103
|
-
name?: string;
|
|
104
|
-
imageUrl?: string;
|
|
105
|
-
mainColor?: string;
|
|
106
|
-
specialColors?: { name: string | string[]; color: string }[];
|
|
107
|
-
} | null
|
|
108
|
-
): Record<string, any>;
|
|
109
|
-
|
|
110
|
-
export function applySpecialStyle(
|
|
111
|
-
element: CardElement,
|
|
112
|
-
background?: {
|
|
113
|
-
id?: string | number;
|
|
114
|
-
name?: string;
|
|
115
|
-
imageUrl?: string;
|
|
116
|
-
mainColor?: string;
|
|
117
|
-
specialColors?: { name: string | string[]; color: string }[];
|
|
118
|
-
} | null,
|
|
119
|
-
options?: { overrideExisting?: boolean; defaultDecorColor?: string }
|
|
120
|
-
): CardElement;
|
|
121
|
-
|
|
122
|
-
export function applyBackground(
|
|
123
|
-
layout: CardLayoutSchema,
|
|
124
|
-
background: {
|
|
125
|
-
id?: string | number;
|
|
126
|
-
name?: string;
|
|
127
|
-
imageUrl?: string;
|
|
128
|
-
mainColor?: string;
|
|
129
|
-
specialColors?: { name: string | string[]; color: string }[];
|
|
130
|
-
},
|
|
131
|
-
options?: {
|
|
132
|
-
previousBackground?: {
|
|
133
|
-
id?: string | number;
|
|
134
|
-
name?: string;
|
|
135
|
-
imageUrl?: string;
|
|
136
|
-
mainColor?: string;
|
|
137
|
-
specialColors?: { name: string | string[]; color: string }[];
|
|
138
|
-
} | null;
|
|
139
|
-
defaultDecorColor?: string;
|
|
140
|
-
}
|
|
141
|
-
): CardLayoutSchema;
|
|
142
|
-
|
|
143
|
-
export function updateElementsStyle(
|
|
144
|
-
layout: CardLayoutSchema,
|
|
145
|
-
targetIds: string[],
|
|
146
|
-
updates: Record<string, any>
|
|
147
|
-
): CardLayoutSchema;
|
|
148
|
-
|
|
149
76
|
export function buildWrapperStyle(
|
|
150
77
|
el: CardElement,
|
|
151
78
|
unit?: 'px' | 'rpx'
|
|
@@ -166,33 +93,39 @@ export function buildBaseContentStyle(
|
|
|
166
93
|
): Record<string, any>;
|
|
167
94
|
|
|
168
95
|
export function buildPanelContentStyle(
|
|
169
|
-
el:
|
|
96
|
+
el: LayoutPanelElement,
|
|
170
97
|
unit?: 'px' | 'rpx'
|
|
171
98
|
): Record<string, any>;
|
|
172
99
|
|
|
173
100
|
export function buildTextContentStyle(
|
|
174
|
-
el:
|
|
101
|
+
el: TextElement,
|
|
102
|
+
unit?: 'px' | 'rpx'
|
|
103
|
+
): Record<string, any>;
|
|
104
|
+
|
|
105
|
+
export function buildTextValueStyle(
|
|
106
|
+
el: TextElement,
|
|
175
107
|
unit?: 'px' | 'rpx'
|
|
176
108
|
): Record<string, any>;
|
|
177
109
|
|
|
178
110
|
export function buildImageContentStyle(
|
|
179
|
-
el:
|
|
111
|
+
el: ImageElement,
|
|
112
|
+
unit?: 'px' | 'rpx'
|
|
180
113
|
): Record<string, any>;
|
|
181
114
|
|
|
182
115
|
export function getTextValue(
|
|
183
|
-
el:
|
|
116
|
+
el: TextElement,
|
|
117
|
+
data?: Record<string, any>
|
|
184
118
|
): string;
|
|
185
119
|
|
|
186
120
|
export function getImageSrc(
|
|
187
|
-
el:
|
|
121
|
+
el: ImageElement,
|
|
122
|
+
data?: Record<string, any>
|
|
188
123
|
): string;
|
|
189
124
|
|
|
190
|
-
export function getIconName(
|
|
191
|
-
el: import('./interface/elements').IconElement
|
|
192
|
-
): string;
|
|
125
|
+
export function getIconName(el: IconElement): string;
|
|
193
126
|
|
|
194
127
|
export function buildTextIconMeta(
|
|
195
|
-
el:
|
|
128
|
+
el: TextElement,
|
|
196
129
|
unit?: 'px' | 'rpx'
|
|
197
130
|
): {
|
|
198
131
|
name: string;
|
|
@@ -203,8 +136,12 @@ export function buildTextIconMeta(
|
|
|
203
136
|
wrapperStyle?: Record<string, any>;
|
|
204
137
|
} | null;
|
|
205
138
|
|
|
206
|
-
export function
|
|
139
|
+
export function handleSpecialFields(data: { user: Record<string, any> }): {
|
|
140
|
+
user: Record<string, any>;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
export function processCardLayout(
|
|
207
145
|
layout: CardLayoutSchema[],
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
): CardLayoutSchema[];
|
|
146
|
+
data: Data
|
|
147
|
+
): CardLayoutSchema[];
|
package/dist/interface/render.js
DELETED
package/dist/render/builder.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildRenderResult = exports.buildRenderNodes = void 0;
|
|
4
|
-
const helpers_1 = require("../helpers");
|
|
5
|
-
const layout_1 = require("../layout");
|
|
6
|
-
const data_1 = require("../data");
|
|
7
|
-
const buildCardStyle = (layout, unit) => (0, helpers_1.styleObjectToString)({
|
|
8
|
-
width: (0, helpers_1.addUnit)(layout.width, unit),
|
|
9
|
-
height: (0, helpers_1.addUnit)(layout.height, unit),
|
|
10
|
-
color: layout.fontColor,
|
|
11
|
-
borderRadius: layout.borderRadius !== undefined
|
|
12
|
-
? (0, helpers_1.addUnit)(layout.borderRadius, unit)
|
|
13
|
-
: undefined,
|
|
14
|
-
padding: layout.padding !== undefined ? (0, helpers_1.addUnit)(layout.padding, unit) : undefined,
|
|
15
|
-
position: 'relative',
|
|
16
|
-
overflow: 'hidden',
|
|
17
|
-
boxSizing: 'border-box',
|
|
18
|
-
backgroundColor: 'transparent',
|
|
19
|
-
}, unit);
|
|
20
|
-
const buildBackgroundStyle = (layout, unit) => (0, helpers_1.styleObjectToString)({
|
|
21
|
-
zIndex: layout.backgroundZIndex,
|
|
22
|
-
borderRadius: layout.borderRadius !== undefined
|
|
23
|
-
? (0, helpers_1.addUnit)(layout.borderRadius, unit)
|
|
24
|
-
: undefined,
|
|
25
|
-
width: '100%',
|
|
26
|
-
height: '100%',
|
|
27
|
-
position: 'absolute',
|
|
28
|
-
left: 0,
|
|
29
|
-
top: 0,
|
|
30
|
-
}, unit);
|
|
31
|
-
const buildWrapperStyle = (el, unit) => {
|
|
32
|
-
const abs = (0, layout_1.getAbsLayout)(el);
|
|
33
|
-
if (!abs)
|
|
34
|
-
return '';
|
|
35
|
-
return (0, helpers_1.styleObjectToString)({
|
|
36
|
-
position: 'absolute',
|
|
37
|
-
left: (0, helpers_1.addUnit)(abs.x, unit),
|
|
38
|
-
top: (0, helpers_1.addUnit)(abs.y, unit),
|
|
39
|
-
width: (0, helpers_1.addUnit)(abs.width, unit),
|
|
40
|
-
height: (0, helpers_1.addUnit)(abs.height, unit),
|
|
41
|
-
zIndex: abs.zIndex,
|
|
42
|
-
boxSizing: 'border-box',
|
|
43
|
-
}, unit);
|
|
44
|
-
};
|
|
45
|
-
const buildPanelContentStyle = (el, unit) => (0, helpers_1.styleObjectToString)({
|
|
46
|
-
position: 'relative',
|
|
47
|
-
width: '100%',
|
|
48
|
-
height: '100%',
|
|
49
|
-
display: 'block',
|
|
50
|
-
boxSizing: 'border-box',
|
|
51
|
-
...(el.style || {}),
|
|
52
|
-
}, unit);
|
|
53
|
-
const buildTextContentStyle = (el, unit) => {
|
|
54
|
-
var _a, _b, _c;
|
|
55
|
-
const textAlign = ((_a = el.style) === null || _a === void 0 ? void 0 : _a.textAlign) || el.align || undefined;
|
|
56
|
-
const style = {
|
|
57
|
-
...(el.style || {}),
|
|
58
|
-
whiteSpace: 'pre-wrap',
|
|
59
|
-
wordBreak: 'break-word',
|
|
60
|
-
lineHeight: ((_b = el.style) === null || _b === void 0 ? void 0 : _b.lineHeight) !== undefined && ((_c = el.style) === null || _c === void 0 ? void 0 : _c.lineHeight) !== null
|
|
61
|
-
? el.style.lineHeight
|
|
62
|
-
: '1',
|
|
63
|
-
};
|
|
64
|
-
if (textAlign)
|
|
65
|
-
style.textAlign = textAlign;
|
|
66
|
-
return (0, helpers_1.styleObjectToString)(style, unit);
|
|
67
|
-
};
|
|
68
|
-
const buildBaseContentStyle = (el, unit) => (0, helpers_1.styleObjectToString)({
|
|
69
|
-
...(el.style || {}),
|
|
70
|
-
boxSizing: 'border-box',
|
|
71
|
-
}, unit);
|
|
72
|
-
const buildImageContentStyle = (el, unit) => {
|
|
73
|
-
const style = { ...(el.style || {}) };
|
|
74
|
-
const borderWidth = Number(style.borderWidth);
|
|
75
|
-
if (Number.isFinite(borderWidth) && borderWidth > 0) {
|
|
76
|
-
if (!style.borderStyle)
|
|
77
|
-
style.borderStyle = 'solid';
|
|
78
|
-
if (!style.borderColor)
|
|
79
|
-
style.borderColor = '#000000';
|
|
80
|
-
}
|
|
81
|
-
return (0, helpers_1.styleObjectToString)(style, unit);
|
|
82
|
-
};
|
|
83
|
-
const buildTextIcon = (el, unit) => {
|
|
84
|
-
var _a, _b, _c, _d, _e;
|
|
85
|
-
const icon = el.icon;
|
|
86
|
-
const enabled = (icon === null || icon === void 0 ? void 0 : icon.enable) === true;
|
|
87
|
-
if (!icon || !enabled)
|
|
88
|
-
return undefined;
|
|
89
|
-
const style = icon.style || 'fill';
|
|
90
|
-
const baseName = icon.name || el.key || el.binding || el.id;
|
|
91
|
-
let name;
|
|
92
|
-
if (style === 'dot')
|
|
93
|
-
name = 'round';
|
|
94
|
-
else if (style === 'line')
|
|
95
|
-
name = baseName ? `${baseName}-line` : undefined;
|
|
96
|
-
else
|
|
97
|
-
name = baseName || undefined;
|
|
98
|
-
if (!name)
|
|
99
|
-
return undefined;
|
|
100
|
-
const size = icon.size !== undefined && icon.size !== null
|
|
101
|
-
? icon.size
|
|
102
|
-
: (_a = el.style) === null || _a === void 0 ? void 0 : _a.fontSize;
|
|
103
|
-
const gap = icon.gap !== undefined && icon.gap !== null ? icon.gap : 4;
|
|
104
|
-
const color = (_b = icon.color) !== null && _b !== void 0 ? _b : (typeof ((_c = el.style) === null || _c === void 0 ? void 0 : _c.color) === 'string' ? el.style.color : undefined);
|
|
105
|
-
return {
|
|
106
|
-
name: `${name}`,
|
|
107
|
-
text: `${name}`,
|
|
108
|
-
size: (0, helpers_1.addUnit)(size, unit),
|
|
109
|
-
gap: (0, helpers_1.addUnit)(gap, unit),
|
|
110
|
-
color: color,
|
|
111
|
-
align: icon.align || 'left',
|
|
112
|
-
wrapperStyle: (0, helpers_1.styleObjectToString)({
|
|
113
|
-
height: ((_d = el.style) === null || _d === void 0 ? void 0 : _d.lineHeight) || ((_e = el.style) === null || _e === void 0 ? void 0 : _e.fontSize),
|
|
114
|
-
}, unit),
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
const buildNode = (el, rootData, unit, context) => {
|
|
118
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
119
|
-
if (!el || el.visible === false)
|
|
120
|
-
return null;
|
|
121
|
-
const wrapperStyle = buildWrapperStyle(el, unit);
|
|
122
|
-
if (el.type === 'layout-panel') {
|
|
123
|
-
return {
|
|
124
|
-
id: el.id,
|
|
125
|
-
type: el.type,
|
|
126
|
-
visible: el.visible,
|
|
127
|
-
wrapperStyle,
|
|
128
|
-
contentStyle: buildPanelContentStyle(el, unit),
|
|
129
|
-
children: (0, exports.buildRenderNodes)(el.children || [], rootData, unit, context),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
const baseStyle = buildBaseContentStyle(el, unit);
|
|
133
|
-
if (el.type === 'text') {
|
|
134
|
-
const value = (_b = (_a = (0, data_1.resolveBindingValue)(el.binding, rootData, context)) !== null && _a !== void 0 ? _a : el.defaultValue) !== null && _b !== void 0 ? _b : '';
|
|
135
|
-
return {
|
|
136
|
-
id: el.id,
|
|
137
|
-
type: el.type,
|
|
138
|
-
wrapperStyle,
|
|
139
|
-
contentStyle: buildTextContentStyle(el, unit),
|
|
140
|
-
text: `${value}`,
|
|
141
|
-
visible: el.visible,
|
|
142
|
-
icon: buildTextIcon(el, unit),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
if (el.type === 'image') {
|
|
146
|
-
const src = (_e = (_d = (_c = (0, data_1.resolveBindingValue)(el.binding, rootData, context)) !== null && _c !== void 0 ? _c : el.defaultUrl) !== null && _d !== void 0 ? _d : el.defaultValue) !== null && _e !== void 0 ? _e : '';
|
|
147
|
-
const mode = el.fit === 'contain' ? 'aspectFit' : 'aspectFill';
|
|
148
|
-
return {
|
|
149
|
-
id: el.id,
|
|
150
|
-
type: el.type,
|
|
151
|
-
wrapperStyle,
|
|
152
|
-
contentStyle: buildImageContentStyle(el, unit),
|
|
153
|
-
src,
|
|
154
|
-
mode,
|
|
155
|
-
visible: el.visible,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
if (el.type === 'icon') {
|
|
159
|
-
const name = (_h = (_g = (_f = (0, data_1.resolveBindingValue)(el.binding, rootData, context)) !== null && _f !== void 0 ? _f : el.name) !== null && _g !== void 0 ? _g : el.defaultValue) !== null && _h !== void 0 ? _h : '';
|
|
160
|
-
return {
|
|
161
|
-
id: el.id,
|
|
162
|
-
type: el.type,
|
|
163
|
-
wrapperStyle,
|
|
164
|
-
contentStyle: baseStyle,
|
|
165
|
-
name: `${name}`,
|
|
166
|
-
text: `${name}`,
|
|
167
|
-
visible: el.visible,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
if (el.type === 'custom') {
|
|
171
|
-
return {
|
|
172
|
-
id: el.id,
|
|
173
|
-
type: el.type,
|
|
174
|
-
wrapperStyle,
|
|
175
|
-
contentStyle: baseStyle,
|
|
176
|
-
visible: el.visible,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
};
|
|
181
|
-
const buildRenderNodes = (children, rootData, unit = 'px', context = {}) => {
|
|
182
|
-
if (!Array.isArray(children))
|
|
183
|
-
return [];
|
|
184
|
-
const nodes = [];
|
|
185
|
-
children.forEach(el => {
|
|
186
|
-
if (!el || el.visible === false)
|
|
187
|
-
return;
|
|
188
|
-
const node = buildNode(el, rootData, unit, context);
|
|
189
|
-
if (node)
|
|
190
|
-
nodes.push(node);
|
|
191
|
-
});
|
|
192
|
-
return nodes;
|
|
193
|
-
};
|
|
194
|
-
exports.buildRenderNodes = buildRenderNodes;
|
|
195
|
-
const buildRenderResult = (layoutInput, dataInput, unit = 'px') => {
|
|
196
|
-
const layouts = (0, layout_1.normalizeLayout)(layoutInput);
|
|
197
|
-
return layouts.map(layout => {
|
|
198
|
-
const cardStyle = buildCardStyle(layout, unit);
|
|
199
|
-
const bgStyle = buildBackgroundStyle(layout, unit);
|
|
200
|
-
const renderTree = (0, exports.buildRenderNodes)(layout.children || [], dataInput || {}, unit);
|
|
201
|
-
return {
|
|
202
|
-
renderTree,
|
|
203
|
-
cardStyle,
|
|
204
|
-
backgroundImage: layout.backgroundImage || '',
|
|
205
|
-
backgroundStyle: bgStyle,
|
|
206
|
-
};
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
exports.buildRenderResult = buildRenderResult;
|
package/dist/render/tool.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildRenderData = buildRenderData;
|
|
4
|
-
const changeBackground_1 = require("../ops/changeBackground");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
function buildRenderData(layout, items, config) {
|
|
7
|
-
// 绑定数据
|
|
8
|
-
let renderLayout = (0, utils_1.applyItemCollectBindings)(layout, items);
|
|
9
|
-
// 设置显示逻辑
|
|
10
|
-
renderLayout = (0, changeBackground_1.setElementVisible)(renderLayout, 'image', config.showAvatar);
|
|
11
|
-
renderLayout = (0, changeBackground_1.setElementVisible)(renderLayout, 'logo', config.showLogo);
|
|
12
|
-
// 设置背景
|
|
13
|
-
renderLayout = renderLayout.map((la, index) => config.currentBg[index] ? (0, changeBackground_1.backgroundChange)(config.currentBg[index], la) : la);
|
|
14
|
-
return renderLayout;
|
|
15
|
-
}
|
package/dist/utils.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.DEFAULT_DECOR_COLOR = exports.resolveSpecialStyle = exports.updateElementsStyle = exports.applyBackground = exports.applySpecialStyle = exports.backgroundChange = void 0;
|
|
18
|
-
__exportStar(require("./bindings"), exports);
|
|
19
|
-
var changeBackground_1 = require("./ops/changeBackground");
|
|
20
|
-
Object.defineProperty(exports, "backgroundChange", { enumerable: true, get: function () { return changeBackground_1.backgroundChange; } });
|
|
21
|
-
Object.defineProperty(exports, "applySpecialStyle", { enumerable: true, get: function () { return changeBackground_1.applySpecialStyle; } });
|
|
22
|
-
Object.defineProperty(exports, "applyBackground", { enumerable: true, get: function () { return changeBackground_1.applyBackground; } });
|
|
23
|
-
Object.defineProperty(exports, "updateElementsStyle", { enumerable: true, get: function () { return changeBackground_1.updateElementsStyle; } });
|
|
24
|
-
Object.defineProperty(exports, "resolveSpecialStyle", { enumerable: true, get: function () { return changeBackground_1.resolveSpecialStyle; } });
|
|
25
|
-
Object.defineProperty(exports, "DEFAULT_DECOR_COLOR", { enumerable: true, get: function () { return changeBackground_1.DEFAULT_DECOR_COLOR; } });
|
package/interface/context.ts
DELETED
package/render/tool.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { CardLayoutSchema, TemplateItem } from '../interface';
|
|
2
|
-
import { backgroundChange, setElementVisible } from '../ops/changeBackground';
|
|
3
|
-
import { Config } from '../types';
|
|
4
|
-
import { applyItemCollectBindings } from '../utils';
|
|
5
|
-
|
|
6
|
-
export function buildRenderData(
|
|
7
|
-
layout: CardLayoutSchema[],
|
|
8
|
-
items: TemplateItem[],
|
|
9
|
-
config: Config
|
|
10
|
-
): CardLayoutSchema[] {
|
|
11
|
-
// 绑定数据
|
|
12
|
-
let renderLayout = applyItemCollectBindings(layout, items);
|
|
13
|
-
// 设置显示逻辑
|
|
14
|
-
renderLayout = setElementVisible(renderLayout, 'image', config.showAvatar);
|
|
15
|
-
renderLayout = setElementVisible(renderLayout, 'logo', config.showLogo);
|
|
16
|
-
// 设置背景
|
|
17
|
-
renderLayout = renderLayout.map((la, index) =>
|
|
18
|
-
config.currentBg[index] ? backgroundChange(config.currentBg[index], la) : la
|
|
19
|
-
);
|
|
20
|
-
return renderLayout;
|
|
21
|
-
}
|