km-card-layout-component-miniprogram 0.1.5
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/.editorconfig +15 -0
- package/.gitmodules +3 -0
- package/LICENSE +9 -0
- package/README.md +37 -0
- package/example/app.js +5 -0
- package/example/app.json +11 -0
- package/example/app.wxss +4 -0
- package/example/pages/home/index.js +270 -0
- package/example/pages/home/index.json +6 -0
- package/example/pages/home/index.wxml +7 -0
- package/example/pages/home/index.wxss +22 -0
- package/example/project.config.json +19 -0
- package/example/sitemap.json +9 -0
- package/miniprogram_dist/components/card-layout/icon-map.js +121 -0
- package/miniprogram_dist/components/card-layout/index.js +80 -0
- package/miniprogram_dist/components/card-layout/index.json +3 -0
- package/miniprogram_dist/components/card-layout/index.wxml +66 -0
- package/miniprogram_dist/components/card-layout/index.wxss +521 -0
- package/miniprogram_dist/index.js +12 -0
- package/miniprogram_dist/utils/card-schema.js +10 -0
- package/miniprogram_dist/vendor/km-card-layout-core/index.js +511 -0
- package/package.json +37 -0
- package/script/gulpfile.js +57 -0
- package/script/sync-core.js +35 -0
- package/src/components/card-layout/icon-map.ts +118 -0
- package/src/components/card-layout/index.json +3 -0
- package/src/components/card-layout/index.ts +96 -0
- package/src/components/card-layout/index.wxml +66 -0
- package/src/components/card-layout/index.wxss +521 -0
- package/src/index.ts +9 -0
- package/src/utils/card-schema.ts +17 -0
- package/src/vendor/km-card-layout-core/index.ts +768 -0
- package/src/vendor/km-card-layout-core/types.d.ts +191 -0
- package/tsconfig.json +16 -0
- package/types/index.d.ts +7 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declaration file for km-card-layout-core.
|
|
3
|
+
* Mirrors the exported types/functions from index.ts.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type CardElementType =
|
|
7
|
+
| 'text'
|
|
8
|
+
| 'image'
|
|
9
|
+
| 'icon'
|
|
10
|
+
| 'custom'
|
|
11
|
+
| 'layout-panel'
|
|
12
|
+
| 'repeatable-group';
|
|
13
|
+
|
|
14
|
+
export interface AbsoluteLayoutDefinition {
|
|
15
|
+
mode: 'absolute';
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
zIndex?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface FlexItemOptions {
|
|
24
|
+
flexGrow?: number;
|
|
25
|
+
flexShrink?: number;
|
|
26
|
+
flexBasis?: number | string;
|
|
27
|
+
order?: number;
|
|
28
|
+
alignSelf?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface FlexItemLayoutDefinition {
|
|
32
|
+
mode: 'flex';
|
|
33
|
+
item?: FlexItemOptions;
|
|
34
|
+
width?: number;
|
|
35
|
+
height?: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type ElementLayout = AbsoluteLayoutDefinition | FlexItemLayoutDefinition;
|
|
39
|
+
|
|
40
|
+
export interface CardElementBase {
|
|
41
|
+
id: string;
|
|
42
|
+
type: CardElementType;
|
|
43
|
+
layout: ElementLayout;
|
|
44
|
+
visible?: boolean;
|
|
45
|
+
binding?: string;
|
|
46
|
+
style?: Record<string, string | number | undefined>;
|
|
47
|
+
defaultValue?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface TextElement extends CardElementBase {
|
|
51
|
+
type: 'text';
|
|
52
|
+
align?: 'left' | 'center' | 'right';
|
|
53
|
+
multiline?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface ImageElement extends CardElementBase {
|
|
57
|
+
type: 'image';
|
|
58
|
+
alt?: string;
|
|
59
|
+
fit?: 'cover' | 'contain';
|
|
60
|
+
defaultUrl?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface IconElement extends CardElementBase {
|
|
64
|
+
type: 'icon';
|
|
65
|
+
name?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface CustomElement extends CardElementBase {
|
|
69
|
+
type: 'custom';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface LayoutPanelElement extends CardElementBase {
|
|
73
|
+
type: 'layout-panel';
|
|
74
|
+
container: {
|
|
75
|
+
mode: 'absolute' | 'flex';
|
|
76
|
+
options?: {
|
|
77
|
+
direction?: 'row' | 'column';
|
|
78
|
+
wrap?: 'nowrap' | 'wrap';
|
|
79
|
+
justifyContent?:
|
|
80
|
+
| 'flex-start'
|
|
81
|
+
| 'flex-end'
|
|
82
|
+
| 'center'
|
|
83
|
+
| 'space-between'
|
|
84
|
+
| 'space-around'
|
|
85
|
+
| 'space-evenly';
|
|
86
|
+
alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
|
87
|
+
gap?: number | { row: number; column: number };
|
|
88
|
+
padding?: number | [number, number] | [number, number, number, number];
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
children?: CardElement[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface RepeatableGroupItem {
|
|
95
|
+
id: string;
|
|
96
|
+
elements: CardElement[];
|
|
97
|
+
data?: Record<string, any>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface RepeatableGroupElement extends CardElementBase {
|
|
101
|
+
type: 'repeatable-group';
|
|
102
|
+
dataPath: string;
|
|
103
|
+
itemTemplate: CardElement[];
|
|
104
|
+
items: RepeatableGroupItem[];
|
|
105
|
+
maxItems?: number;
|
|
106
|
+
mutualExcludes?: string[];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type CardElement =
|
|
110
|
+
| TextElement
|
|
111
|
+
| ImageElement
|
|
112
|
+
| IconElement
|
|
113
|
+
| CustomElement
|
|
114
|
+
| LayoutPanelElement
|
|
115
|
+
| RepeatableGroupElement;
|
|
116
|
+
|
|
117
|
+
export interface CardLayoutSchema {
|
|
118
|
+
name?: string;
|
|
119
|
+
container: {
|
|
120
|
+
mode: 'absolute';
|
|
121
|
+
};
|
|
122
|
+
width: number;
|
|
123
|
+
height: number;
|
|
124
|
+
backgroundImage?: string;
|
|
125
|
+
backgroundZIndex?: number;
|
|
126
|
+
fontColor?: string;
|
|
127
|
+
borderRadius?: number;
|
|
128
|
+
padding?: number;
|
|
129
|
+
children: CardElement[];
|
|
130
|
+
thumbnail?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface RenderNode {
|
|
134
|
+
id: string;
|
|
135
|
+
type: CardElementType | 'text';
|
|
136
|
+
wrapperStyle: string;
|
|
137
|
+
contentStyle: string;
|
|
138
|
+
name?: string;
|
|
139
|
+
text?: string;
|
|
140
|
+
src?: string;
|
|
141
|
+
mode?: string;
|
|
142
|
+
children?: RenderNode[];
|
|
143
|
+
visible?: boolean;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface RenderPageResult {
|
|
147
|
+
renderTree: RenderNode[];
|
|
148
|
+
cardStyle: string;
|
|
149
|
+
backgroundImage: string;
|
|
150
|
+
backgroundStyle: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type RenderResult = RenderPageResult[];
|
|
154
|
+
|
|
155
|
+
export interface BindingContext {
|
|
156
|
+
contextBinding?: string;
|
|
157
|
+
contextData?: any;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function addUnit(
|
|
161
|
+
value: string | number | undefined | null,
|
|
162
|
+
unit: 'px' | 'rpx'
|
|
163
|
+
): string | undefined;
|
|
164
|
+
|
|
165
|
+
export function styleObjectToString(
|
|
166
|
+
style?: Record<string, any>,
|
|
167
|
+
unit?: 'px' | 'rpx'
|
|
168
|
+
): string;
|
|
169
|
+
|
|
170
|
+
export type CardLayoutInput = CardLayoutSchema[] | string | null | undefined;
|
|
171
|
+
|
|
172
|
+
export function normalizeLayout(layout: CardLayoutInput): CardLayoutSchema[];
|
|
173
|
+
|
|
174
|
+
export function resolveBindingValue(
|
|
175
|
+
binding: string | undefined,
|
|
176
|
+
rootData: Record<string, any>,
|
|
177
|
+
context?: BindingContext
|
|
178
|
+
): any;
|
|
179
|
+
|
|
180
|
+
export function buildRenderNodes(
|
|
181
|
+
children: CardElement[],
|
|
182
|
+
data: Record<string, any>,
|
|
183
|
+
unit?: 'px' | 'rpx',
|
|
184
|
+
context?: BindingContext
|
|
185
|
+
): RenderNode[];
|
|
186
|
+
|
|
187
|
+
export function buildRenderResult(
|
|
188
|
+
layout: CardLayoutInput,
|
|
189
|
+
data: Record<string, any>,
|
|
190
|
+
unit?: 'px' | 'rpx'
|
|
191
|
+
): RenderResult;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"lib": ["es2018", "dom"],
|
|
7
|
+
"rootDir": "src",
|
|
8
|
+
"outDir": "miniprogram_dist",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"types": ["miniprogram-api-typings"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*.ts"]
|
|
16
|
+
}
|