km-card-layout-component-miniprogram 0.1.16 → 0.1.17
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/vendor/km-card-layout-core/index.js +4 -1
- package/miniprogram_dist/vendor/km-card-layout-core/render/tool.js +23 -0
- package/package.json +1 -1
- package/src/vendor/km-card-layout-core/index.ts +1 -0
- package/src/vendor/km-card-layout-core/render/tool.ts +34 -0
- package/src/vendor/km-card-layout-core/types.d.ts +10 -1
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.processCardLayout = exports.handleSpecialFields = exports.buildTextIconMeta = exports.getIconName = exports.getImageSrc = exports.getTextValue = exports.buildImageContentStyle = exports.buildTextValueStyle = exports.buildTextContentStyle = exports.buildPanelContentStyle = exports.buildBaseContentStyle = exports.buildBackgroundStyle = exports.buildCardStyle = exports.buildWrapperStyle = exports.backgroundChange = exports.applyItemCollectBindings = exports.stripLayoutBindings = exports.resolveBindingValue = exports.parseLayout = exports.normalizeId = exports.getAbsLayout = exports.roundToInt = exports.sanitizeElement = exports.sanitizeLayout = exports.normalizeLayout = exports.isObject = exports.toNumber = exports.styleObjectToString = exports.addUnit = void 0;
|
|
17
|
+
exports.processCardLayout = exports.handleSpecialFields = exports.setElementVisible = exports.buildRenderData = exports.buildTextIconMeta = exports.getIconName = exports.getImageSrc = exports.getTextValue = exports.buildImageContentStyle = exports.buildTextValueStyle = exports.buildTextContentStyle = exports.buildPanelContentStyle = exports.buildBaseContentStyle = exports.buildBackgroundStyle = exports.buildCardStyle = exports.buildWrapperStyle = exports.backgroundChange = exports.applyItemCollectBindings = exports.stripLayoutBindings = exports.resolveBindingValue = exports.parseLayout = exports.normalizeId = exports.getAbsLayout = exports.roundToInt = exports.sanitizeElement = exports.sanitizeLayout = exports.normalizeLayout = exports.isObject = exports.toNumber = exports.styleObjectToString = exports.addUnit = void 0;
|
|
18
18
|
/**
|
|
19
19
|
* Core exports for card layout helpers.
|
|
20
20
|
* Platform-agnostic utilities shared by web/mini-program renderers.
|
|
@@ -53,6 +53,9 @@ Object.defineProperty(exports, "getTextValue", { enumerable: true, get: function
|
|
|
53
53
|
Object.defineProperty(exports, "getImageSrc", { enumerable: true, get: function () { return helpers_2.getImageSrc; } });
|
|
54
54
|
Object.defineProperty(exports, "getIconName", { enumerable: true, get: function () { return helpers_2.getIconName; } });
|
|
55
55
|
Object.defineProperty(exports, "buildTextIconMeta", { enumerable: true, get: function () { return helpers_2.buildTextIconMeta; } });
|
|
56
|
+
var tool_1 = require("./render/tool");
|
|
57
|
+
Object.defineProperty(exports, "buildRenderData", { enumerable: true, get: function () { return tool_1.buildRenderData; } });
|
|
58
|
+
Object.defineProperty(exports, "setElementVisible", { enumerable: true, get: function () { return tool_1.setElementVisible; } });
|
|
56
59
|
var init_1 = require("./render/init");
|
|
57
60
|
Object.defineProperty(exports, "handleSpecialFields", { enumerable: true, get: function () { return init_1.handleSpecialFields; } });
|
|
58
61
|
Object.defineProperty(exports, "processCardLayout", { enumerable: true, get: function () { return init_1.processCardLayout; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildRenderData = exports.setElementVisible = void 0;
|
|
4
|
+
const bindings_1 = require("../bindings");
|
|
5
|
+
const changeBackground_1 = require("../ops/changeBackground");
|
|
6
|
+
const setElementVisible = (layout, key, visible) => {
|
|
7
|
+
return layout.map(la => ({
|
|
8
|
+
...la,
|
|
9
|
+
children: la.children.map(el => (el.key === key ? { ...el, visible } : el)),
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
exports.setElementVisible = setElementVisible;
|
|
13
|
+
function buildRenderData(layout, items, config) {
|
|
14
|
+
// 绑定数据
|
|
15
|
+
let renderLayout = (0, bindings_1.applyItemCollectBindings)(layout, items);
|
|
16
|
+
// 设置显示逻辑
|
|
17
|
+
renderLayout = (0, exports.setElementVisible)(renderLayout, 'image', config.showAvatar);
|
|
18
|
+
renderLayout = (0, exports.setElementVisible)(renderLayout, 'logo', config.showLogo);
|
|
19
|
+
// 设置背景
|
|
20
|
+
renderLayout = renderLayout.map((la, index) => config.currentBg[index] ? (0, changeBackground_1.backgroundChange)(config.currentBg[index], la) : la);
|
|
21
|
+
return renderLayout;
|
|
22
|
+
}
|
|
23
|
+
exports.buildRenderData = buildRenderData;
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { applyItemCollectBindings } from '../bindings';
|
|
2
|
+
import { CardLayoutSchema, TemplateItem } from '../interface';
|
|
3
|
+
import { backgroundChange } from '../ops/changeBackground';
|
|
4
|
+
import { Config } from '../types';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export const setElementVisible = (
|
|
8
|
+
layout: CardLayoutSchema[],
|
|
9
|
+
key: string,
|
|
10
|
+
visible: boolean
|
|
11
|
+
): CardLayoutSchema[] => {
|
|
12
|
+
return layout.map(la => ({
|
|
13
|
+
...la,
|
|
14
|
+
children: la.children.map(el => (el.key === key ? { ...el, visible } : el)),
|
|
15
|
+
}));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export function buildRenderData(
|
|
20
|
+
layout: CardLayoutSchema[],
|
|
21
|
+
items: TemplateItem[],
|
|
22
|
+
config: Config
|
|
23
|
+
): CardLayoutSchema[] {
|
|
24
|
+
// 绑定数据
|
|
25
|
+
let renderLayout = applyItemCollectBindings(layout, items);
|
|
26
|
+
// 设置显示逻辑
|
|
27
|
+
renderLayout = setElementVisible(renderLayout, 'image', config.showAvatar);
|
|
28
|
+
renderLayout = setElementVisible(renderLayout, 'logo', config.showLogo);
|
|
29
|
+
// 设置背景
|
|
30
|
+
renderLayout = renderLayout.map((la, index) =>
|
|
31
|
+
config.currentBg[index] ? backgroundChange(config.currentBg[index], la) : la
|
|
32
|
+
);
|
|
33
|
+
return renderLayout;
|
|
34
|
+
}
|
|
@@ -144,4 +144,13 @@ export function handleSpecialFields(data: { user: Record<string, any> }): {
|
|
|
144
144
|
export function processCardLayout(
|
|
145
145
|
layout: CardLayoutSchema[],
|
|
146
146
|
data: Data
|
|
147
|
-
): CardLayoutSchema[];
|
|
147
|
+
): CardLayoutSchema[];
|
|
148
|
+
|
|
149
|
+
export type Config = {
|
|
150
|
+
showAvatar: boolean;
|
|
151
|
+
showLogo: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* 当前背景 (0 为正面背景 1 为背面背景)
|
|
154
|
+
*/
|
|
155
|
+
currentBg: TemplateBackground[];
|
|
156
|
+
};
|