km-card-layout-component-miniprogram 0.1.8 → 0.1.10
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/example/pages/home/index.js +382 -16
- package/miniprogram_dist/components/card-layout/elements/custom-element/index.js +31 -0
- package/miniprogram_dist/components/card-layout/elements/custom-element/index.json +3 -0
- package/miniprogram_dist/components/card-layout/elements/custom-element/index.wxml +5 -0
- package/miniprogram_dist/components/card-layout/elements/custom-element/index.wxss +14 -0
- package/miniprogram_dist/components/card-layout/elements/icon-element/index.js +43 -0
- package/miniprogram_dist/components/card-layout/elements/icon-element/index.json +3 -0
- package/miniprogram_dist/components/card-layout/elements/icon-element/index.wxml +5 -0
- package/miniprogram_dist/components/card-layout/elements/icon-element/index.wxss +37 -0
- package/miniprogram_dist/components/card-layout/elements/image-element/index.js +36 -0
- package/miniprogram_dist/components/card-layout/elements/image-element/index.json +3 -0
- package/miniprogram_dist/components/card-layout/elements/image-element/index.wxml +8 -0
- package/miniprogram_dist/components/card-layout/elements/image-element/index.wxss +10 -0
- package/miniprogram_dist/components/card-layout/elements/text-element/index.js +52 -0
- package/miniprogram_dist/components/card-layout/elements/text-element/index.json +3 -0
- package/miniprogram_dist/components/card-layout/elements/text-element/index.wxml +29 -0
- package/miniprogram_dist/components/card-layout/elements/text-element/index.wxss +59 -0
- package/miniprogram_dist/components/card-layout/index.js +23 -38
- package/miniprogram_dist/components/card-layout/index.json +7 -1
- package/miniprogram_dist/components/card-layout/index.wxml +15 -63
- package/miniprogram_dist/components/card-layout/index.wxss +0 -65
- package/miniprogram_dist/utils/card-schema.js +12 -3
- package/miniprogram_dist/vendor/km-card-layout-core/bindings.js +4 -0
- package/miniprogram_dist/vendor/km-card-layout-core/data.js +1 -1
- package/miniprogram_dist/vendor/km-card-layout-core/index.js +37 -6
- package/miniprogram_dist/vendor/km-card-layout-core/interface/index.js +0 -1
- package/miniprogram_dist/vendor/km-card-layout-core/ops/changeBackground.js +8 -1
- package/miniprogram_dist/vendor/km-card-layout-core/render/helpers.js +143 -0
- package/miniprogram_dist/vendor/km-card-layout-core/render/tool.js +16 -0
- package/package.json +1 -1
- package/script/sync-core.js +3 -0
- package/src/components/card-layout/elements/custom-element/index.json +3 -0
- package/src/components/card-layout/elements/custom-element/index.ts +34 -0
- package/src/components/card-layout/elements/custom-element/index.wxml +5 -0
- package/src/components/card-layout/elements/custom-element/index.wxss +14 -0
- package/src/components/card-layout/elements/icon-element/index.json +3 -0
- package/src/components/card-layout/elements/icon-element/index.ts +46 -0
- package/src/components/card-layout/elements/icon-element/index.wxml +5 -0
- package/src/components/card-layout/elements/icon-element/index.wxss +37 -0
- package/src/components/card-layout/elements/image-element/index.json +3 -0
- package/src/components/card-layout/elements/image-element/index.ts +40 -0
- package/src/components/card-layout/elements/image-element/index.wxml +8 -0
- package/src/components/card-layout/elements/image-element/index.wxss +10 -0
- package/src/components/card-layout/elements/text-element/index.json +3 -0
- package/src/components/card-layout/elements/text-element/index.ts +57 -0
- package/src/components/card-layout/elements/text-element/index.wxml +29 -0
- package/src/components/card-layout/elements/text-element/index.wxss +59 -0
- package/src/components/card-layout/index.json +7 -1
- package/src/components/card-layout/index.ts +40 -47
- package/src/components/card-layout/index.wxml +15 -63
- package/src/components/card-layout/index.wxss +0 -65
- package/src/utils/card-schema.ts +11 -4
- package/src/vendor/km-card-layout-core/bindings.ts +3 -0
- package/src/vendor/km-card-layout-core/data.ts +1 -2
- package/src/vendor/km-card-layout-core/index.ts +37 -5
- package/src/vendor/km-card-layout-core/interface/data/payload.ts +1 -0
- package/src/vendor/km-card-layout-core/interface/index.ts +1 -2
- package/src/vendor/km-card-layout-core/ops/changeBackground.ts +14 -4
- package/src/vendor/km-card-layout-core/render/helpers.ts +159 -0
- package/src/vendor/km-card-layout-core/render/tool.ts +21 -0
- package/src/vendor/km-card-layout-core/types.d.ts +74 -15
- package/src/vendor/km-card-layout-core/utils.ts +4 -0
- package/miniprogram_dist/vendor/km-card-layout-core/interface/render.js +0 -2
- package/miniprogram_dist/vendor/km-card-layout-core/render/builder.js +0 -210
- package/src/vendor/km-card-layout-core/interface/render.ts +0 -53
- package/src/vendor/km-card-layout-core/render/builder.ts +0 -288
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildTextIconMeta = exports.getIconName = exports.getImageSrc = exports.getTextValue = exports.buildImageContentStyle = exports.buildTextContentStyle = exports.buildPanelContentStyle = exports.buildBaseContentStyle = exports.buildBackgroundStyle = exports.buildCardStyle = exports.buildWrapperStyle = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
const layout_1 = require("../layout");
|
|
6
|
+
const data_1 = require("../data");
|
|
7
|
+
const buildWrapperStyle = (el, unit = 'px') => {
|
|
8
|
+
const abs = (0, layout_1.getAbsLayout)(el);
|
|
9
|
+
if (!abs)
|
|
10
|
+
return {};
|
|
11
|
+
return {
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
left: (0, helpers_1.addUnit)(abs.x, unit),
|
|
14
|
+
top: (0, helpers_1.addUnit)(abs.y, unit),
|
|
15
|
+
width: (0, helpers_1.addUnit)(abs.width, unit),
|
|
16
|
+
height: (0, helpers_1.addUnit)(abs.height, unit),
|
|
17
|
+
zIndex: abs.zIndex,
|
|
18
|
+
boxSizing: 'border-box',
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.buildWrapperStyle = buildWrapperStyle;
|
|
22
|
+
const buildCardStyle = (layout, unit = 'px') => ({
|
|
23
|
+
width: (0, helpers_1.addUnit)(layout.width, unit),
|
|
24
|
+
height: (0, helpers_1.addUnit)(layout.height, unit),
|
|
25
|
+
color: layout.fontColor,
|
|
26
|
+
borderRadius: layout.borderRadius !== undefined
|
|
27
|
+
? (0, helpers_1.addUnit)(layout.borderRadius, unit)
|
|
28
|
+
: undefined,
|
|
29
|
+
padding: layout.padding !== undefined ? (0, helpers_1.addUnit)(layout.padding, unit) : undefined,
|
|
30
|
+
position: 'relative',
|
|
31
|
+
overflow: 'hidden',
|
|
32
|
+
boxSizing: 'border-box',
|
|
33
|
+
backgroundColor: 'transparent',
|
|
34
|
+
});
|
|
35
|
+
exports.buildCardStyle = buildCardStyle;
|
|
36
|
+
const buildBackgroundStyle = (layout, unit = 'px') => ({
|
|
37
|
+
zIndex: layout.backgroundZIndex,
|
|
38
|
+
borderRadius: layout.borderRadius !== undefined
|
|
39
|
+
? (0, helpers_1.addUnit)(layout.borderRadius, unit)
|
|
40
|
+
: undefined,
|
|
41
|
+
width: '100%',
|
|
42
|
+
height: '100%',
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
left: 0,
|
|
45
|
+
top: 0,
|
|
46
|
+
});
|
|
47
|
+
exports.buildBackgroundStyle = buildBackgroundStyle;
|
|
48
|
+
const buildBaseContentStyle = (el) => ({
|
|
49
|
+
...(el.style || {}),
|
|
50
|
+
boxSizing: 'border-box',
|
|
51
|
+
});
|
|
52
|
+
exports.buildBaseContentStyle = buildBaseContentStyle;
|
|
53
|
+
const buildPanelContentStyle = (el, unit = 'px') => ({
|
|
54
|
+
position: 'relative',
|
|
55
|
+
width: '100%',
|
|
56
|
+
height: '100%',
|
|
57
|
+
display: 'block',
|
|
58
|
+
boxSizing: 'border-box',
|
|
59
|
+
...(el.style || {}),
|
|
60
|
+
});
|
|
61
|
+
exports.buildPanelContentStyle = buildPanelContentStyle;
|
|
62
|
+
const buildTextContentStyle = (el, unit = 'px') => {
|
|
63
|
+
var _a, _b, _c, _d;
|
|
64
|
+
const textAlign = ((_a = el.style) === null || _a === void 0 ? void 0 : _a.textAlign) || el.align || undefined;
|
|
65
|
+
const style = {
|
|
66
|
+
...(el.style || {}),
|
|
67
|
+
fontSize: (0, helpers_1.addUnit)((_b = el.style) === null || _b === void 0 ? void 0 : _b.fontSize, unit),
|
|
68
|
+
whiteSpace: 'pre-wrap',
|
|
69
|
+
wordBreak: 'break-word',
|
|
70
|
+
lineHeight: ((_c = el.style) === null || _c === void 0 ? void 0 : _c.lineHeight) !== undefined && ((_d = el.style) === null || _d === void 0 ? void 0 : _d.lineHeight) !== null
|
|
71
|
+
? (0, helpers_1.addUnit)(el.style.lineHeight, unit)
|
|
72
|
+
: '1',
|
|
73
|
+
};
|
|
74
|
+
if (textAlign)
|
|
75
|
+
style.textAlign = textAlign;
|
|
76
|
+
return style;
|
|
77
|
+
};
|
|
78
|
+
exports.buildTextContentStyle = buildTextContentStyle;
|
|
79
|
+
const buildImageContentStyle = (el) => {
|
|
80
|
+
const style = { ...(el.style || {}) };
|
|
81
|
+
const borderWidth = Number(style.borderWidth);
|
|
82
|
+
if (Number.isFinite(borderWidth) && borderWidth > 0) {
|
|
83
|
+
if (!style.borderStyle)
|
|
84
|
+
style.borderStyle = 'solid';
|
|
85
|
+
if (!style.borderColor)
|
|
86
|
+
style.borderColor = '#000000';
|
|
87
|
+
}
|
|
88
|
+
return style;
|
|
89
|
+
};
|
|
90
|
+
exports.buildImageContentStyle = buildImageContentStyle;
|
|
91
|
+
const getTextValue = (el, data) => {
|
|
92
|
+
const bound = el.binding && data ? (0, data_1.resolveBindingValue)(el.binding, data) : undefined;
|
|
93
|
+
const val = bound !== undefined && bound !== null
|
|
94
|
+
? bound
|
|
95
|
+
: el.defaultValue !== undefined && el.defaultValue !== null
|
|
96
|
+
? el.defaultValue
|
|
97
|
+
: '';
|
|
98
|
+
return `${val !== null && val !== void 0 ? val : ''}`;
|
|
99
|
+
};
|
|
100
|
+
exports.getTextValue = getTextValue;
|
|
101
|
+
const getImageSrc = (el, data) => {
|
|
102
|
+
const bound = el.binding && data ? (0, data_1.resolveBindingValue)(el.binding, data) : undefined;
|
|
103
|
+
return bound || el.defaultUrl || el.defaultValue || '';
|
|
104
|
+
};
|
|
105
|
+
exports.getImageSrc = getImageSrc;
|
|
106
|
+
const getIconName = (el) => (el.name || el.defaultValue || '');
|
|
107
|
+
exports.getIconName = getIconName;
|
|
108
|
+
const buildTextIconMeta = (el, unit = 'px') => {
|
|
109
|
+
var _a, _b, _c, _d, _e, _f;
|
|
110
|
+
const icon = el.icon;
|
|
111
|
+
const enabled = (icon === null || icon === void 0 ? void 0 : icon.enable) === true;
|
|
112
|
+
if (!icon || !enabled)
|
|
113
|
+
return null;
|
|
114
|
+
const style = icon.style || 'fill';
|
|
115
|
+
const baseName = icon.name || el.key || el.binding || el.id;
|
|
116
|
+
let name;
|
|
117
|
+
if (style === 'dot')
|
|
118
|
+
name = 'round';
|
|
119
|
+
else if (style === 'line')
|
|
120
|
+
name = baseName ? `${baseName}-line` : undefined;
|
|
121
|
+
else
|
|
122
|
+
name = baseName || undefined;
|
|
123
|
+
if (!name)
|
|
124
|
+
return null;
|
|
125
|
+
const size = icon.size !== undefined && icon.size !== null
|
|
126
|
+
? icon.size
|
|
127
|
+
: (_a = el.style) === null || _a === void 0 ? void 0 : _a.fontSize;
|
|
128
|
+
const gap = icon.gap !== undefined && icon.gap !== null ? icon.gap : 4;
|
|
129
|
+
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);
|
|
130
|
+
return {
|
|
131
|
+
name: `${name}`,
|
|
132
|
+
size: (0, helpers_1.addUnit)(size, unit),
|
|
133
|
+
gap: (0, helpers_1.addUnit)(gap, unit),
|
|
134
|
+
color,
|
|
135
|
+
align: icon.align || 'left',
|
|
136
|
+
wrapperStyle: {
|
|
137
|
+
height: ((_d = el.style) === null || _d === void 0 ? void 0 : _d.lineHeight) !== undefined && ((_e = el.style) === null || _e === void 0 ? void 0 : _e.lineHeight) !== null
|
|
138
|
+
? (0, helpers_1.addUnit)(el.style.lineHeight, unit)
|
|
139
|
+
: (_f = el.style) === null || _f === void 0 ? void 0 : _f.fontSize,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
exports.buildTextIconMeta = buildTextIconMeta;
|
|
@@ -0,0 +1,16 @@
|
|
|
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;
|
package/package.json
CHANGED
package/script/sync-core.js
CHANGED
|
@@ -24,6 +24,9 @@ function ensureFileExists(filePath) {
|
|
|
24
24
|
|
|
25
25
|
function syncCore() {
|
|
26
26
|
ensureFileExists(coreRoot);
|
|
27
|
+
if (fs.existsSync(targetDir)) {
|
|
28
|
+
fs.rmSync(targetDir, { recursive: true, force: true });
|
|
29
|
+
}
|
|
27
30
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
28
31
|
|
|
29
32
|
filesToCopy.forEach((fileName) => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildBaseContentStyle,
|
|
3
|
+
buildWrapperStyle,
|
|
4
|
+
styleObjectToString,
|
|
5
|
+
type CustomElement,
|
|
6
|
+
} from '../../../../vendor/km-card-layout-core/index';
|
|
7
|
+
|
|
8
|
+
Component({
|
|
9
|
+
options: {
|
|
10
|
+
styleIsolation: 'apply-shared',
|
|
11
|
+
},
|
|
12
|
+
properties: {
|
|
13
|
+
element: {
|
|
14
|
+
type: Object,
|
|
15
|
+
value: {},
|
|
16
|
+
},
|
|
17
|
+
rootData: {
|
|
18
|
+
type: Object,
|
|
19
|
+
value: {},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
data: {
|
|
23
|
+
wrapperStyle: '',
|
|
24
|
+
contentStyle: '',
|
|
25
|
+
},
|
|
26
|
+
observers: {
|
|
27
|
+
element(el: CustomElement) {
|
|
28
|
+
if (!el) return;
|
|
29
|
+
const wrapperStyle = styleObjectToString(buildWrapperStyle(el, 'rpx'), 'rpx');
|
|
30
|
+
const contentStyle = styleObjectToString(buildBaseContentStyle(el), 'rpx');
|
|
31
|
+
this.setData({ wrapperStyle, contentStyle });
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildBaseContentStyle,
|
|
3
|
+
buildWrapperStyle,
|
|
4
|
+
getIconName,
|
|
5
|
+
styleObjectToString,
|
|
6
|
+
type IconElement,
|
|
7
|
+
} from '../../../../vendor/km-card-layout-core/index';
|
|
8
|
+
import { ICON_CODE_MAP } from '../../icon-map';
|
|
9
|
+
|
|
10
|
+
const mapIconGlyph = (name?: string, fallback?: string) => {
|
|
11
|
+
if (!name) return fallback;
|
|
12
|
+
const glyph = ICON_CODE_MAP[name];
|
|
13
|
+
if (glyph) return String.fromCharCode(parseInt(glyph, 16));
|
|
14
|
+
return fallback || name;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
Component({
|
|
18
|
+
options: {
|
|
19
|
+
styleIsolation: 'apply-shared',
|
|
20
|
+
},
|
|
21
|
+
properties: {
|
|
22
|
+
element: {
|
|
23
|
+
type: Object,
|
|
24
|
+
value: {},
|
|
25
|
+
},
|
|
26
|
+
rootData: {
|
|
27
|
+
type: Object,
|
|
28
|
+
value: {},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
data: {
|
|
32
|
+
wrapperStyle: '',
|
|
33
|
+
contentStyle: '',
|
|
34
|
+
iconText: '',
|
|
35
|
+
},
|
|
36
|
+
observers: {
|
|
37
|
+
element(el: IconElement) {
|
|
38
|
+
if (!el) return;
|
|
39
|
+
const wrapperStyle = styleObjectToString(buildWrapperStyle(el, 'rpx'), 'rpx');
|
|
40
|
+
const contentStyle = styleObjectToString(buildBaseContentStyle(el), 'rpx');
|
|
41
|
+
const name = getIconName(el);
|
|
42
|
+
const iconText = mapIconGlyph(name, name || '');
|
|
43
|
+
this.setData({ wrapperStyle, contentStyle, iconText });
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.km-node {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
color: inherit;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.km-node--icon {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.km-node__icon {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
font-family: 'km-icon', 'PingFang SC', 'Microsoft Yahei', sans-serif;
|
|
19
|
+
font-style: normal;
|
|
20
|
+
font-weight: normal;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@font-face {
|
|
24
|
+
font-family: 'km-icon';
|
|
25
|
+
src: url('data:font/woff;charset=utf-8;base64,d09GRgABAAAAAEl4AA0AAAAAcmgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAABJXAAAABoAAAAcrMtJV0dERUYAAEk8AAAAHgAAAB4AKQByT1MvMgAAAaQAAABGAAAAYDw3SVljbWFwAAAC7AAAAM8AAAIW8XL3K2dhc3AAAEk0AAAACAAAAAj//wADZ2x5ZgAABJgAAEBZAABkZPJymXJoZWFkAAABMAAAADEAAAA2MtZiFmhoZ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AnqCkQKrgtUC8QMEAxsDNQNFA1SDegONg6qDyQPgg/CEAIQxBEwEaQSHBLYE14T4hRcFPIVTBYMFkwWqBckGGAYxhmYGegaEBpeGuIbXhvwHPQd5B62Hygf6CBeILog9CFUIbgiBCJ0ItQjbCQSJGgkuCVsJcImKib0J44ocijOKSApUCo2KmQqtituK34sJixkLMgtdC3WLpgvPC+QMBww/DGCMagyMgAA') format('woff');
|
|
26
|
+
font-weight: normal;
|
|
27
|
+
font-style: normal;
|
|
28
|
+
font-display: swap;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.icon {
|
|
32
|
+
font-family: 'km-icon' !important;
|
|
33
|
+
font-size: 16px;
|
|
34
|
+
font-style: normal;
|
|
35
|
+
-webkit-font-smoothing: antialiased;
|
|
36
|
+
-moz-osx-font-smoothing: grayscale;
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildImageContentStyle,
|
|
3
|
+
buildWrapperStyle,
|
|
4
|
+
getImageSrc,
|
|
5
|
+
styleObjectToString,
|
|
6
|
+
type ImageElement,
|
|
7
|
+
} from '../../../../vendor/km-card-layout-core/index';
|
|
8
|
+
|
|
9
|
+
Component({
|
|
10
|
+
options: {
|
|
11
|
+
styleIsolation: 'apply-shared',
|
|
12
|
+
},
|
|
13
|
+
properties: {
|
|
14
|
+
element: {
|
|
15
|
+
type: Object,
|
|
16
|
+
value: {},
|
|
17
|
+
},
|
|
18
|
+
rootData: {
|
|
19
|
+
type: Object,
|
|
20
|
+
value: {},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
data: {
|
|
24
|
+
wrapperStyle: '',
|
|
25
|
+
contentStyle: '',
|
|
26
|
+
imageSrc: '',
|
|
27
|
+
mode: 'aspectFill',
|
|
28
|
+
},
|
|
29
|
+
observers: {
|
|
30
|
+
element(el: ImageElement) {
|
|
31
|
+
if (!el) return;
|
|
32
|
+
const data: Record<string, any> = this.data.rootData || {};
|
|
33
|
+
const wrapperStyle = styleObjectToString(buildWrapperStyle(el, 'rpx'), 'rpx');
|
|
34
|
+
const contentStyle = styleObjectToString(buildImageContentStyle(el), 'rpx');
|
|
35
|
+
const imageSrc = getImageSrc(el, data);
|
|
36
|
+
const mode = el.fit === 'contain' ? 'aspectFit' : 'aspectFill';
|
|
37
|
+
this.setData({ wrapperStyle, contentStyle, imageSrc, mode });
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildTextContentStyle,
|
|
3
|
+
buildTextIconMeta,
|
|
4
|
+
buildWrapperStyle,
|
|
5
|
+
getTextValue,
|
|
6
|
+
styleObjectToString,
|
|
7
|
+
type TextElement,
|
|
8
|
+
} from '../../../../vendor/km-card-layout-core/index';
|
|
9
|
+
import { ICON_CODE_MAP } from '../../icon-map';
|
|
10
|
+
|
|
11
|
+
const mapIconGlyph = (name?: string, fallback?: string) => {
|
|
12
|
+
if (!name) return fallback;
|
|
13
|
+
const glyph = ICON_CODE_MAP[name];
|
|
14
|
+
if (glyph) return String.fromCharCode(parseInt(glyph, 16));
|
|
15
|
+
return fallback || name;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Component({
|
|
19
|
+
options: {
|
|
20
|
+
styleIsolation: 'apply-shared',
|
|
21
|
+
},
|
|
22
|
+
properties: {
|
|
23
|
+
element: {
|
|
24
|
+
type: Object,
|
|
25
|
+
value: {},
|
|
26
|
+
},
|
|
27
|
+
rootData: {
|
|
28
|
+
type: Object,
|
|
29
|
+
value: {},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
data: {
|
|
33
|
+
wrapperStyle: '',
|
|
34
|
+
contentStyle: '',
|
|
35
|
+
textValue: '',
|
|
36
|
+
iconMeta: null as any,
|
|
37
|
+
},
|
|
38
|
+
observers: {
|
|
39
|
+
element(el: TextElement) {
|
|
40
|
+
if (!el) return;
|
|
41
|
+
const data: Record<string, any> = this.data.rootData || {};
|
|
42
|
+
const wrapperStyle = styleObjectToString(buildWrapperStyle(el, 'rpx'), 'rpx');
|
|
43
|
+
const contentStyle = styleObjectToString(buildTextContentStyle(el, 'rpx'), 'rpx');
|
|
44
|
+
const textValue = getTextValue(el, data);
|
|
45
|
+
const iconRaw = buildTextIconMeta(el, 'rpx');
|
|
46
|
+
const iconMeta =
|
|
47
|
+
iconRaw && iconRaw.name
|
|
48
|
+
? {
|
|
49
|
+
...iconRaw,
|
|
50
|
+
text: mapIconGlyph(iconRaw.name, iconRaw.name),
|
|
51
|
+
wrapperStyle: styleObjectToString(iconRaw.wrapperStyle, 'rpx'),
|
|
52
|
+
}
|
|
53
|
+
: iconRaw;
|
|
54
|
+
this.setData({ wrapperStyle, contentStyle, textValue, iconMeta });
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<view class="km-node km-node--text" style="{{wrapperStyle}}">
|
|
2
|
+
<view class="km-node__text" style="{{contentStyle}}">
|
|
3
|
+
<block wx:if="{{iconMeta && iconMeta.name}}">
|
|
4
|
+
<view class="km-node__text-content">
|
|
5
|
+
<block wx:if="{{iconMeta.align === 'right'}}">
|
|
6
|
+
<text class="km-node__text-value">{{textValue || ''}}</text>
|
|
7
|
+
<view style="{{iconMeta.wrapperStyle}}" class="km-node__text-icon--wrapper" >
|
|
8
|
+
<text
|
|
9
|
+
class="km-node__text-icon icon"
|
|
10
|
+
style="font-size: {{iconMeta.size || '16px'}}; color: {{iconMeta.color || ''}}; margin-right: {{iconMeta.gap || ''}};"
|
|
11
|
+
>{{iconMeta.text || iconMeta.name || ''}}</text>
|
|
12
|
+
</view>
|
|
13
|
+
</block>
|
|
14
|
+
<block wx:else>
|
|
15
|
+
<view style="{{iconMeta.wrapperStyle}}" class="km-node__text-icon--wrapper">
|
|
16
|
+
<text
|
|
17
|
+
class="km-node__text-icon icon"
|
|
18
|
+
style="font-size: {{iconMeta.size || '16px'}}; color: {{iconMeta.color || ''}}; margin-right: {{iconMeta.gap || ''}};"
|
|
19
|
+
>{{iconMeta.text || iconMeta.name || ''}}</text>
|
|
20
|
+
</view>
|
|
21
|
+
<text class="km-node__text-value">{{textValue || ''}}</text>
|
|
22
|
+
</block>
|
|
23
|
+
</view>
|
|
24
|
+
</block>
|
|
25
|
+
<block wx:else>
|
|
26
|
+
<text class="km-node__text-value">{{textValue || ''}}</text>
|
|
27
|
+
</block>
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.km-node {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
color: inherit;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.km-node--text {
|
|
7
|
+
/* overflow hidden if needed */
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.km-node--text text {
|
|
11
|
+
display: inline;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.km-node__text {
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
display: block;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
text-align: inherit;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.km-node__text-content {
|
|
23
|
+
display: inline-block;
|
|
24
|
+
vertical-align: middle;
|
|
25
|
+
height: 100%;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.km-node__text-icon {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.km-node__text-value {
|
|
35
|
+
display: inline-block;
|
|
36
|
+
white-space: pre-wrap;
|
|
37
|
+
word-break: break-word;
|
|
38
|
+
vertical-align: middle;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@font-face {
|
|
42
|
+
font-family: 'km-icon';
|
|
43
|
+
src: url('data:font/woff;charset=utf-8;base64,d09GRgABAAAAAEl4AA0AAAAAcmgAA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4VKVarVqFWnXoNGTZq1aNWmXYdOXbr16NWn34BBQ4aNGDVm3IRJU6bNmDVn3oJFS5atWLVm3YZNW7bt2LVn34FDR46dOHXm3IVLV67duHXn3oNHT8Hv2YtXbyFaot9HfMeMC4jztyL/vr4AXx4eawAAAAAAAAAAAACwAPIDSgQ8BLIFUgWUBcIF/gY8BpIHCgdAB3wHoAgOCHAIxgk+CV4JzAnqCkQKrgtUC8QMEAxsDNQNFA1SDegONg6qDyQPgg/CEAIQxBEwEaQSHBLYE14T4hRcFPIVTBYMFkwWqBckGGAYxhmYGegaEBpeGuIbXhvwHPQd5B62Hygf6CBeILog9CFUIbgiBCJ0ItQjbCQSJGgkuCVsJcImKib0J44ocijOKSApUCo2KmQqtituK34sJixkLMgtdC3WLpgvPC+QMBww/DGCMagyMgAA') format('woff');
|
|
44
|
+
font-weight: normal;
|
|
45
|
+
font-style: normal;
|
|
46
|
+
font-display: swap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.icon {
|
|
50
|
+
font-family: 'km-icon' !important;
|
|
51
|
+
font-size: 16px;
|
|
52
|
+
font-style: normal;
|
|
53
|
+
-webkit-font-smoothing: antialiased;
|
|
54
|
+
-moz-osx-font-smoothing: grayscale;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.km-node__text-icon--wrapper{
|
|
58
|
+
display: inline-block;
|
|
59
|
+
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"component": true
|
|
2
|
+
"component": true,
|
|
3
|
+
"usingComponents": {
|
|
4
|
+
"text-element": "./elements/text-element/index",
|
|
5
|
+
"image-element": "./elements/image-element/index",
|
|
6
|
+
"icon-element": "./elements/icon-element/index",
|
|
7
|
+
"custom-element": "./elements/custom-element/index"
|
|
8
|
+
}
|
|
3
9
|
}
|