km-card-layout-component-miniprogram 0.1.10 → 0.1.12
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/miniprogram_dist/components/card-layout/index.js +22 -1
- package/miniprogram_dist/components/card-layout/index.wxml +1 -1
- package/miniprogram_dist/vendor/km-card-layout-core/bindings.js +1 -11
- package/miniprogram_dist/vendor/km-card-layout-core/index.js +9 -18
- package/miniprogram_dist/vendor/km-card-layout-core/layout.js +1 -17
- package/miniprogram_dist/vendor/km-card-layout-core/ops/changeBackground.js +46 -97
- package/miniprogram_dist/vendor/km-card-layout-core/render/helpers.js +22 -15
- package/miniprogram_dist/vendor/km-card-layout-core/render/init.js +82 -0
- package/package.json +1 -1
- package/script/sync-core.js +0 -1
- package/src/components/card-layout/index.ts +30 -4
- package/src/components/card-layout/index.wxml +1 -1
- package/src/vendor/km-card-layout-core/bindings.ts +1 -17
- package/src/vendor/km-card-layout-core/index.ts +7 -26
- package/src/vendor/km-card-layout-core/interface/data/payload.ts +3 -3
- package/src/vendor/km-card-layout-core/interface/elements.ts +1 -0
- package/src/vendor/km-card-layout-core/interface/layout.ts +0 -1
- package/src/vendor/km-card-layout-core/layout.ts +0 -18
- package/src/vendor/km-card-layout-core/ops/changeBackground.ts +47 -130
- package/src/vendor/km-card-layout-core/render/helpers.ts +55 -32
- package/src/vendor/km-card-layout-core/render/init.ts +107 -0
- package/src/vendor/km-card-layout-core/types.d.ts +32 -95
- package/miniprogram_dist/vendor/km-card-layout-core/render/tool.js +0 -16
- package/miniprogram_dist/vendor/km-card-layout-core/utils.js +0 -25
- package/src/vendor/km-card-layout-core/render/tool.ts +0 -21
- package/src/vendor/km-card-layout-core/utils.ts +0 -13
|
@@ -10,17 +10,15 @@ import type {
|
|
|
10
10
|
CardLayoutInput,
|
|
11
11
|
CardLayoutSchema,
|
|
12
12
|
TemplateItem,
|
|
13
|
-
TemplateBackground
|
|
13
|
+
TemplateBackground,
|
|
14
14
|
} from './interface';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
currentBg: TemplateBackground[];
|
|
23
|
-
};
|
|
15
|
+
import type {
|
|
16
|
+
AbsoluteLayoutDefinition,
|
|
17
|
+
LayoutPanelElement,
|
|
18
|
+
TextElement,
|
|
19
|
+
ImageElement,
|
|
20
|
+
IconElement,
|
|
21
|
+
} from './interface/elements';
|
|
24
22
|
|
|
25
23
|
export function addUnit(
|
|
26
24
|
value: string | number | undefined | null,
|
|
@@ -48,9 +46,7 @@ export function roundToInt(value: number): number;
|
|
|
48
46
|
|
|
49
47
|
export function getAbsLayout(
|
|
50
48
|
el: CardElement
|
|
51
|
-
):
|
|
52
|
-
|
|
53
|
-
export function collectBindings(elements?: CardElement[]): string[];
|
|
49
|
+
): AbsoluteLayoutDefinition | null;
|
|
54
50
|
|
|
55
51
|
export function normalizeId(
|
|
56
52
|
id?: string | number | null
|
|
@@ -58,11 +54,6 @@ export function normalizeId(
|
|
|
58
54
|
|
|
59
55
|
export function parseLayout(input: unknown): CardLayoutSchema | null;
|
|
60
56
|
|
|
61
|
-
export function areChildrenEqual(
|
|
62
|
-
a?: CardLayoutSchema | null,
|
|
63
|
-
b?: CardLayoutSchema | null
|
|
64
|
-
): boolean;
|
|
65
|
-
|
|
66
57
|
export function resolveBindingValue(
|
|
67
58
|
binding: string | undefined,
|
|
68
59
|
rootData: Record<string, any>
|
|
@@ -74,76 +65,14 @@ export function stripLayoutBindings(
|
|
|
74
65
|
|
|
75
66
|
export function applyItemCollectBindings(
|
|
76
67
|
layouts: CardLayoutSchema[],
|
|
77
|
-
items?:
|
|
68
|
+
items?: TemplateItem[]
|
|
78
69
|
): CardLayoutSchema[];
|
|
79
70
|
|
|
80
|
-
export function getTemplateItems(
|
|
81
|
-
ids: string,
|
|
82
|
-
items: import('./interface/data/payload').TemplateItem[]
|
|
83
|
-
): import('./interface/data/payload').TemplateItem[];
|
|
84
|
-
|
|
85
|
-
export function getTemplateBackgrounds(
|
|
86
|
-
ids: string,
|
|
87
|
-
items: import('./interface/data/payload').TemplateBackground[]
|
|
88
|
-
): import('./interface/data/payload').TemplateBackground[];
|
|
89
|
-
|
|
90
71
|
export function backgroundChange(
|
|
91
|
-
bg:
|
|
72
|
+
bg: TemplateBackground,
|
|
92
73
|
layout: CardLayoutSchema
|
|
93
74
|
): CardLayoutSchema;
|
|
94
75
|
|
|
95
|
-
export const DEFAULT_DECOR_COLOR: string;
|
|
96
|
-
|
|
97
|
-
export function resolveSpecialStyle(
|
|
98
|
-
element: CardElement,
|
|
99
|
-
background?: {
|
|
100
|
-
id?: string | number;
|
|
101
|
-
name?: string;
|
|
102
|
-
imageUrl?: string;
|
|
103
|
-
mainColor?: string;
|
|
104
|
-
specialColors?: { name: string | string[]; color: string }[];
|
|
105
|
-
} | null
|
|
106
|
-
): Record<string, any>;
|
|
107
|
-
|
|
108
|
-
export function applySpecialStyle(
|
|
109
|
-
element: CardElement,
|
|
110
|
-
background?: {
|
|
111
|
-
id?: string | number;
|
|
112
|
-
name?: string;
|
|
113
|
-
imageUrl?: string;
|
|
114
|
-
mainColor?: string;
|
|
115
|
-
specialColors?: { name: string | string[]; color: string }[];
|
|
116
|
-
} | null,
|
|
117
|
-
options?: { overrideExisting?: boolean; defaultDecorColor?: string }
|
|
118
|
-
): CardElement;
|
|
119
|
-
|
|
120
|
-
export function applyBackground(
|
|
121
|
-
layout: CardLayoutSchema,
|
|
122
|
-
background: {
|
|
123
|
-
id?: string | number;
|
|
124
|
-
name?: string;
|
|
125
|
-
imageUrl?: string;
|
|
126
|
-
mainColor?: string;
|
|
127
|
-
specialColors?: { name: string | string[]; color: string }[];
|
|
128
|
-
},
|
|
129
|
-
options?: {
|
|
130
|
-
previousBackground?: {
|
|
131
|
-
id?: string | number;
|
|
132
|
-
name?: string;
|
|
133
|
-
imageUrl?: string;
|
|
134
|
-
mainColor?: string;
|
|
135
|
-
specialColors?: { name: string | string[]; color: string }[];
|
|
136
|
-
} | null;
|
|
137
|
-
defaultDecorColor?: string;
|
|
138
|
-
}
|
|
139
|
-
): CardLayoutSchema;
|
|
140
|
-
|
|
141
|
-
export function updateElementsStyle(
|
|
142
|
-
layout: CardLayoutSchema,
|
|
143
|
-
targetIds: string[],
|
|
144
|
-
updates: Record<string, any>
|
|
145
|
-
): CardLayoutSchema;
|
|
146
|
-
|
|
147
76
|
export function buildWrapperStyle(
|
|
148
77
|
el: CardElement,
|
|
149
78
|
unit?: 'px' | 'rpx'
|
|
@@ -164,35 +93,39 @@ export function buildBaseContentStyle(
|
|
|
164
93
|
): Record<string, any>;
|
|
165
94
|
|
|
166
95
|
export function buildPanelContentStyle(
|
|
167
|
-
el:
|
|
96
|
+
el: LayoutPanelElement,
|
|
168
97
|
unit?: 'px' | 'rpx'
|
|
169
98
|
): Record<string, any>;
|
|
170
99
|
|
|
171
100
|
export function buildTextContentStyle(
|
|
172
|
-
el:
|
|
101
|
+
el: TextElement,
|
|
102
|
+
unit?: 'px' | 'rpx'
|
|
103
|
+
): Record<string, any>;
|
|
104
|
+
|
|
105
|
+
export function buildTextValueStyle(
|
|
106
|
+
el: TextElement,
|
|
173
107
|
unit?: 'px' | 'rpx'
|
|
174
108
|
): Record<string, any>;
|
|
175
109
|
|
|
176
110
|
export function buildImageContentStyle(
|
|
177
|
-
el:
|
|
111
|
+
el: ImageElement,
|
|
112
|
+
unit?: 'px' | 'rpx'
|
|
178
113
|
): Record<string, any>;
|
|
179
114
|
|
|
180
115
|
export function getTextValue(
|
|
181
|
-
el:
|
|
116
|
+
el: TextElement,
|
|
182
117
|
data?: Record<string, any>
|
|
183
118
|
): string;
|
|
184
119
|
|
|
185
120
|
export function getImageSrc(
|
|
186
|
-
el:
|
|
121
|
+
el: ImageElement,
|
|
187
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[];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildRenderData = void 0;
|
|
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
|
-
}
|
|
16
|
-
exports.buildRenderData = buildRenderData;
|
|
@@ -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; } });
|
|
@@ -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
|
-
}
|