plain-design 1.0.0-beta.22 → 1.0.0-beta.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/plain-design.commonjs.min.js +2 -2
- package/dist/plain-design.min.css +1 -0
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +5 -5
- package/package.json +3 -3
- package/src/packages/components/CascadePanel/list/CascadeListPanelItem.tsx +3 -3
- package/src/packages/components/Select/createPublicSelectRender.tsx +1 -1
- package/src/packages/components/Table/standard/PlcExpand.tsx +12 -20
- package/src/packages/components/Table/table/Table.tsx +10 -3
- package/src/packages/components/Table/table/utils/createTableHooks.ts +3 -1
- package/src/packages/components/Table/table/utils/table.utils.ts +6 -1
- package/src/packages/components/ThemeEditor/index.tsx +160 -0
- package/src/packages/components/ThemeEditor/theme-editor.scss +94 -0
- package/src/packages/components/Tree/RenderTreeNode.tsx +1 -1
- package/src/packages/components/Tree/index.tsx +3 -3
- package/src/packages/components/VirtualList/index.tsx +3 -3
- package/src/packages/components/VirtualList/useVirtualList.tsx +46 -47
- package/src/packages/components/VirtualTable/index.tsx +4 -4
- package/src/packages/entry.tsx +1 -0
- package/src/pages/index/Demo/DemoRow.scss +9 -6
- package/src/pages/index/Demo/DemoRowController.tsx +2 -2
- package/src/pages/index/components/normal/DemoDropdown.tsx +1 -1
- package/src/pages/index/components/normal/DemoVirtualList.tsx +9 -9
- package/src/pages/index/components/table/DemoTableExpand.tsx +41 -19
- package/src/pages/index/components/table/DemoVirtualTable.tsx +4 -4
- package/src/pages/index/home/AppHead.tsx +3 -90
@@ -1,4 +1,4 @@
|
|
1
|
-
import {computed, getComponentCls, onMounted, onUpdated, reactive, useClasses, useStyles, watch} from "plain-design-composition";
|
1
|
+
import {computed, createCounter, getComponentCls, onMounted, onUpdated, reactive, useClasses, useStyles, watch} from "plain-design-composition";
|
2
2
|
import {delay} from "plain-utils/utils/delay";
|
3
3
|
import './virtual-list.scss';
|
4
4
|
import Scroll from "../Scroll";
|
@@ -9,13 +9,15 @@ interface DataNode {
|
|
9
9
|
top: number;
|
10
10
|
bottom: number;
|
11
11
|
height: number;
|
12
|
-
|
13
|
-
|
14
|
-
index: number
|
12
|
+
item: any;
|
13
|
+
id: string;
|
14
|
+
index: number,
|
15
15
|
}
|
16
16
|
|
17
17
|
const ScrollDirection = createEnum(['up', 'down', 'none'] as const);
|
18
18
|
|
19
|
+
const nextRowId = createCounter('__v__');
|
20
|
+
|
19
21
|
export function useVirtualList(
|
20
22
|
{
|
21
23
|
props,
|
@@ -53,10 +55,30 @@ export function useVirtualList(
|
|
53
55
|
};
|
54
56
|
/*响应式属性*/
|
55
57
|
const state = reactive({
|
56
|
-
nodes: [] as DataNode[], // 格式化的data数组数据
|
57
58
|
scrollTop: 0, // 当前滚动scrollTop(非实时的)
|
58
59
|
pageSize: 0, // 页大小
|
59
60
|
scrollDirection: ScrollDirection.none as typeof ScrollDirection.TYPE,
|
61
|
+
id2height: {} as Record<string, number | undefined>,
|
62
|
+
avgHeight: props.size
|
63
|
+
});
|
64
|
+
|
65
|
+
const idMap = new WeakMap<object, string>();
|
66
|
+
let prevBottom = 0;
|
67
|
+
|
68
|
+
const nodes = computed(() => {
|
69
|
+
prevBottom = 0;
|
70
|
+
return props.data.map((item, index): DataNode => {
|
71
|
+
let id = idMap.get(item);
|
72
|
+
if (!id) {
|
73
|
+
id = nextRowId();
|
74
|
+
idMap.set(item, id);
|
75
|
+
}
|
76
|
+
const height: number = state.id2height[id] || state.avgHeight;
|
77
|
+
let top = prevBottom;
|
78
|
+
let bottom = top + height;
|
79
|
+
prevBottom = bottom;
|
80
|
+
return { id: id!, item, height, top, bottom, index };
|
81
|
+
});
|
60
82
|
});
|
61
83
|
|
62
84
|
/**
|
@@ -64,22 +86,21 @@ export function useVirtualList(
|
|
64
86
|
* @author 韦胜健
|
65
87
|
* @date 2020/11/15 9:28
|
66
88
|
*/
|
67
|
-
const offsetData = computed((): { list: { item: any, index: number }[], startPageIndex: number, start: number } => {
|
89
|
+
const offsetData = computed((): { list: { item: any, id: string, index: number }[], startPageIndex: number, start: number } => {
|
68
90
|
const { pageSize, scrollTop } = state;
|
69
|
-
const data = props.data || [];
|
70
91
|
if (!pageSize) {
|
71
92
|
return { list: [], startPageIndex: 0, start: 0 };
|
72
93
|
}
|
73
94
|
if (props.disabled) {
|
74
95
|
return {
|
75
|
-
list:
|
96
|
+
list: nodes.value,
|
76
97
|
start: 0,
|
77
98
|
startPageIndex: 0,
|
78
99
|
};
|
79
100
|
}
|
80
101
|
const { start, end, pageIndex } = utils.getPageIndex(scrollTop, pageSize);
|
81
102
|
return {
|
82
|
-
list:
|
103
|
+
list: nodes.value.slice(start, end),
|
83
104
|
startPageIndex: pageIndex,
|
84
105
|
start,
|
85
106
|
};
|
@@ -116,7 +137,7 @@ export function useVirtualList(
|
|
116
137
|
if (!props.dynamicSize) {
|
117
138
|
style.height = `${(props.data || []).length * props.size}px`;
|
118
139
|
} else {
|
119
|
-
style.height = `${
|
140
|
+
style.height = `${nodes.value[nodes.value.length - 1].bottom}px`;
|
120
141
|
}
|
121
142
|
});
|
122
143
|
|
@@ -140,7 +161,7 @@ export function useVirtualList(
|
|
140
161
|
if (!props.dynamicSize) {
|
141
162
|
top = start * props.size;
|
142
163
|
} else {
|
143
|
-
top =
|
164
|
+
top = nodes.value[start].top;
|
144
165
|
}
|
145
166
|
|
146
167
|
if (transform !== false) {
|
@@ -165,13 +186,13 @@ export function useVirtualList(
|
|
165
186
|
// console.log('not dynamic》》》getIndex', top / props.size)
|
166
187
|
return Math.floor(top / props.size);
|
167
188
|
} else {
|
168
|
-
const
|
189
|
+
const _nodes = nodes.value;
|
169
190
|
let start = 0;
|
170
|
-
let end =
|
191
|
+
let end = _nodes.length - 1;
|
171
192
|
let temp = 0;
|
172
193
|
while (start <= end) {
|
173
194
|
let middle = Math.floor((start + end) / 2);
|
174
|
-
let middleBottom =
|
195
|
+
let middleBottom = _nodes[middle].bottom;
|
175
196
|
if (middleBottom === top) {
|
176
197
|
return middle + 1;
|
177
198
|
} else if (middleBottom < top) {
|
@@ -240,21 +261,6 @@ export function useVirtualList(
|
|
240
261
|
pageIndex,
|
241
262
|
};
|
242
263
|
},
|
243
|
-
/**
|
244
|
-
* 格式化props.data为 DataNode数组
|
245
|
-
* @author 韦胜健
|
246
|
-
* @date 2020/11/15 9:29
|
247
|
-
*/
|
248
|
-
resetData: (data: any[]) => {
|
249
|
-
// console.log('resetData')
|
250
|
-
state.nodes = data.map((item, index) => ({
|
251
|
-
data: item,
|
252
|
-
index,
|
253
|
-
top: props.size * index,
|
254
|
-
height: props.size,
|
255
|
-
bottom: props.size * (index + 1),
|
256
|
-
}));
|
257
|
-
}
|
258
264
|
};
|
259
265
|
|
260
266
|
/*---------------------------------------handler-------------------------------------------*/
|
@@ -282,9 +288,7 @@ export function useVirtualList(
|
|
282
288
|
if (!props.dynamicSize) {
|
283
289
|
return;
|
284
290
|
}
|
285
|
-
!!refs.scroll && refs.scroll.methods.scrollTop(0, 0);
|
286
|
-
/*如果是动态高度,则刷state.nodes*/
|
287
|
-
utils.resetData(data);
|
291
|
+
// !!refs.scroll && refs.scroll.methods.scrollTop(0, 0);
|
288
292
|
});
|
289
293
|
|
290
294
|
onMounted(() => {
|
@@ -299,9 +303,6 @@ export function useVirtualList(
|
|
299
303
|
}
|
300
304
|
|
301
305
|
state.pageSize = Math.floor(hostHeight / props.size);
|
302
|
-
if (props.dynamicSize && !props.disabled) {
|
303
|
-
utils.resetData(props.data);
|
304
|
-
}
|
305
306
|
});
|
306
307
|
|
307
308
|
onUpdated(async () => {
|
@@ -313,7 +314,9 @@ export function useVirtualList(
|
|
313
314
|
}
|
314
315
|
await delay();
|
315
316
|
// console.log('dynamic scan height')
|
316
|
-
const elNodes = (
|
317
|
+
const elNodes = (refs.content?.querySelectorAll('[data-vid],[vid]') || []) as HTMLElement[];
|
318
|
+
let newAvgHeight = state.avgHeight;
|
319
|
+
|
317
320
|
for (let i = 0; i < elNodes.length; i++) {
|
318
321
|
const el = elNodes[i];
|
319
322
|
const { offsetHeight: height } = el;
|
@@ -321,19 +324,15 @@ export function useVirtualList(
|
|
321
324
|
if (vid == null) {
|
322
325
|
throw new Error('Each item of the virtual-list must have an attribute named "vid", please set :vid="index" or :data-vid="index"');
|
323
326
|
}
|
324
|
-
vid
|
325
|
-
|
326
|
-
|
327
|
-
let deltaHeight = prevHeight - height;
|
328
|
-
if (deltaHeight !== 0) {
|
329
|
-
prevNode.height = height;
|
330
|
-
prevNode.bottom = prevNode.bottom - deltaHeight;
|
331
|
-
for (let j = vid + 1; j < state.nodes!.length; j++) {
|
332
|
-
state.nodes![j].top = state.nodes![j - 1].bottom;
|
333
|
-
state.nodes![j].bottom = state.nodes![j].bottom - deltaHeight;
|
334
|
-
}
|
327
|
+
if (state.id2height[vid] != height) {
|
328
|
+
state.id2height[vid] = height;
|
329
|
+
newAvgHeight = Number(((state.avgHeight + height) / 2).toFixed(0));
|
335
330
|
}
|
336
331
|
}
|
332
|
+
|
333
|
+
if (newAvgHeight != state.avgHeight) {
|
334
|
+
state.avgHeight = newAvgHeight;
|
335
|
+
}
|
337
336
|
});
|
338
337
|
|
339
338
|
return {
|
@@ -29,7 +29,7 @@ export const VirtualTable = designComponent({
|
|
29
29
|
},
|
30
30
|
slots: ['colgroup', 'head', 'headColgroup'],
|
31
31
|
scopeSlots: {
|
32
|
-
default: (scope: { item: any, index: number,
|
32
|
+
default: (scope: { item: any, index: number, vIndex: number, vid: string }) => {},
|
33
33
|
},
|
34
34
|
setup({ props, slots, scopeSlots, event: { emit } }) {
|
35
35
|
|
@@ -70,7 +70,7 @@ export const VirtualTable = designComponent({
|
|
70
70
|
const strutStyles = useStyles(style => {
|
71
71
|
Object.assign(style, virtual.strutStyles.value);
|
72
72
|
!!props.width && (style.width = unit(props.width));
|
73
|
-
style.minHeight = bodyTableWrapperStyles.value.minHeight
|
73
|
+
style.minHeight = bodyTableWrapperStyles.value.minHeight;
|
74
74
|
});
|
75
75
|
|
76
76
|
const contentStyles = useStyles(style => {
|
@@ -168,7 +168,7 @@ export const VirtualTable = designComponent({
|
|
168
168
|
<div className="virtual-table-body-table-wrapper" ref={onRef.body} style={bodyTableWrapperStyles.value}>
|
169
169
|
<table className="virtual-table-body-table" {...{ ...PublicTableAttrs, style: tableStyles.value }}>
|
170
170
|
{slots.colgroup()}
|
171
|
-
<tbody>{list.map((
|
171
|
+
<tbody>{list.map((item, vIndex) => scopeSlots.default({ ...item, vIndex, vid: item.id }))}</tbody>
|
172
172
|
</table>
|
173
173
|
</div>
|
174
174
|
</div>
|
@@ -177,7 +177,7 @@ export const VirtualTable = designComponent({
|
|
177
177
|
<div className="virtual-table-summary-table-wrapper" ref={onRef.summary}>
|
178
178
|
<table className="virtual-table-summary-table" style={summaryTableStyles.value}{...PublicTableAttrs} data-virtual-foot>
|
179
179
|
{slots.colgroup()}
|
180
|
-
<tbody>{!props.summaryData ? null : props.summaryData.map((item, index) => scopeSlots.default({ item, index,
|
180
|
+
<tbody>{!props.summaryData ? null : props.summaryData.map((item, index) => scopeSlots.default({ item, index, vIndex: index, vid: `__smy__${index}` }))}</tbody>
|
181
181
|
</table>
|
182
182
|
</div>
|
183
183
|
)}
|
package/src/packages/entry.tsx
CHANGED
@@ -189,6 +189,7 @@ export type {
|
|
189
189
|
} from './components/AutoTable/use/useTableOption.cache.utils';
|
190
190
|
export {PageThemeUtils} from './components/PageThemeUtils';
|
191
191
|
export {ThemePrimaryColors} from './components/ThemePrimaryColors';
|
192
|
+
export {ThemeEditor} from './components/ThemeEditor';
|
192
193
|
export {useReferenceTrigger} from './components/useReferenceTrigger';
|
193
194
|
export {usePopupTrigger} from './components/usePopupTrigger';
|
194
195
|
export {useWatchAutoClear} from './components/useWatchAutoClear';
|
@@ -93,8 +93,8 @@
|
|
93
93
|
|
94
94
|
.demo-row-collector-operator {
|
95
95
|
position: fixed;
|
96
|
-
bottom:
|
97
|
-
right:
|
96
|
+
bottom: 8px;
|
97
|
+
right: 0;
|
98
98
|
display: flex;
|
99
99
|
align-items: center;
|
100
100
|
|
@@ -105,16 +105,19 @@
|
|
105
105
|
font-size: 12px;
|
106
106
|
cursor: pointer;
|
107
107
|
color: plv(text-2);
|
108
|
+
display: flex;
|
109
|
+
align-items: center;
|
108
110
|
|
109
111
|
&:first-child {
|
110
112
|
border-right: none;
|
111
|
-
border-bottom-left-radius:
|
112
|
-
border-top-left-radius:
|
113
|
+
border-bottom-left-radius: plv(box-size-normal-border-radius);
|
114
|
+
border-top-left-radius: plv(box-size-normal-border-radius);
|
113
115
|
}
|
114
116
|
|
115
117
|
&:last-child {
|
116
|
-
border-bottom-right-radius:
|
117
|
-
border-top-right-radius:
|
118
|
+
border-bottom-right-radius: 0;
|
119
|
+
border-top-right-radius: 0;
|
120
|
+
border-right: none;
|
118
121
|
}
|
119
122
|
|
120
123
|
& > span {
|
@@ -26,11 +26,11 @@ export const DemoRowController = designComponent({
|
|
26
26
|
<div className="demo-row-collector-operator">
|
27
27
|
<div onClick={() => methods.changeAll(false)}>
|
28
28
|
<span>全部收起</span>
|
29
|
-
<Icon icon="pi-
|
29
|
+
<Icon icon="pi-fullscreen-exit"/>
|
30
30
|
</div>
|
31
31
|
<div onClick={() => methods.changeAll(true)}>
|
32
32
|
<span>全部展开</span>
|
33
|
-
<Icon icon="pi-
|
33
|
+
<Icon icon="pi-fullscreen"/>
|
34
34
|
</div>
|
35
35
|
</div>
|
36
36
|
</>
|
@@ -432,7 +432,7 @@ export const demoDropdownScroll = designPage(() => {
|
|
432
432
|
|
433
433
|
export const demoDropdownVirtualList = designPage(() => {
|
434
434
|
|
435
|
-
const options = new Array(
|
435
|
+
const options = new Array(1000).fill({});
|
436
436
|
|
437
437
|
return () => (
|
438
438
|
<DemoRow title="虚拟滚动,长列表">
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {computed, designPage, getComponentCls, classnames,reactive} from "plain-design-composition";
|
1
|
+
import {computed, designPage, getComponentCls, classnames, reactive} from "plain-design-composition";
|
2
2
|
import data2 from '../../../data/data-2.json';
|
3
3
|
import {DemoRow} from "../../Demo/DemoRow";
|
4
4
|
import {Alert, ApplicationConfigurationProvider, Checkbox, VirtualList} from "../../../../packages";
|
@@ -11,7 +11,7 @@ export const demo1 = designPage(() => {
|
|
11
11
|
if (colors.length === 0) {colors = [...sourceColors];}
|
12
12
|
const palette = colors.splice(Math.floor(Math.random() * colors.length), 1);
|
13
13
|
const backgroundColor = `var(--${getComponentCls(`${palette}-1`)})`;
|
14
|
-
const color = `var(--${getComponentCls(`${palette}-6`)})
|
14
|
+
const color = `var(--${getComponentCls(`${palette}-6`)})`;
|
15
15
|
return { backgroundColor, color };
|
16
16
|
};
|
17
17
|
const list = computed(() => data2.slice(0, 188).map(item => ({ ...item, color: getRandomColor() })));
|
@@ -91,7 +91,7 @@ export const demo2 = designPage(() => {
|
|
91
91
|
if (colors.length === 0) {colors = [...sourceColors];}
|
92
92
|
const palette = colors.splice(Math.floor(Math.random() * colors.length), 1);
|
93
93
|
const backgroundColor = `var(--${getComponentCls(`${palette}-1`)})`;
|
94
|
-
const color = `var(--${getComponentCls(`${palette}-6`)})
|
94
|
+
const color = `var(--${getComponentCls(`${palette}-6`)})`;
|
95
95
|
return { backgroundColor, color };
|
96
96
|
};
|
97
97
|
const list = computed(() => data2.slice(0, 188).map(item => ({ ...item, color: getRandomColor() })));
|
@@ -100,11 +100,11 @@ export const demo2 = designPage(() => {
|
|
100
100
|
<DemoRow title={'动态高度'}>
|
101
101
|
<div style={{ width: '300px', height: '400px', backgroundColor: '#f6f6f6' }}>
|
102
102
|
<VirtualList data={list.value} size={60} dynamicSize v-slots={{
|
103
|
-
default: ({ item, index }) => (
|
103
|
+
default: ({ item, vid, index, vIndex }) => (
|
104
104
|
<div
|
105
|
-
key={
|
106
|
-
data-vid={
|
107
|
-
onClick={() => console.log(
|
105
|
+
key={vIndex}
|
106
|
+
data-vid={vid}
|
107
|
+
onClick={() => console.log(vid, { ...item })}
|
108
108
|
style={{
|
109
109
|
...item.color,
|
110
110
|
height: item.size + 'px',
|
@@ -165,7 +165,7 @@ export const demo3 = designPage(() => {
|
|
165
165
|
if (colors.length === 0) {colors = [...sourceColors];}
|
166
166
|
const palette = colors.splice(Math.floor(Math.random() * colors.length), 1);
|
167
167
|
const backgroundColor = `var(--${getComponentCls(`${palette}-1`)})`;
|
168
|
-
const color = `var(--${getComponentCls(`${palette}-6`)})
|
168
|
+
const color = `var(--${getComponentCls(`${palette}-6`)})`;
|
169
169
|
return { backgroundColor, color };
|
170
170
|
};
|
171
171
|
const list = computed(() => data2.map(item => ({ ...item, color: getRandomColor() })));
|
@@ -250,7 +250,7 @@ export const demo4 = designPage(() => {
|
|
250
250
|
if (colors.length === 0) {colors = [...sourceColors];}
|
251
251
|
const palette = colors.splice(Math.floor(Math.random() * colors.length), 1);
|
252
252
|
const backgroundColor = `var(--${getComponentCls(`${palette}-1`)})`;
|
253
|
-
const color = `var(--${getComponentCls(`${palette}-6`)})
|
253
|
+
const color = `var(--${getComponentCls(`${palette}-6`)})`;
|
254
254
|
return { backgroundColor, color };
|
255
255
|
};
|
256
256
|
const list = computed(() => data2.map(item => ({ ...item, color: getRandomColor() })));
|
@@ -8,7 +8,19 @@ import {ColorPicker, DatePicker, Form, FormItem, Input, InputNumber, Plc, PlcExp
|
|
8
8
|
export const demoExpand = designPage(() => {
|
9
9
|
|
10
10
|
const state = reactive({
|
11
|
-
data
|
11
|
+
data: data.map((item) => {
|
12
|
+
return {
|
13
|
+
...item,
|
14
|
+
children: new Array(Math.ceil(Math.random() * 5 + 2)).fill(null).map((_, index) => {
|
15
|
+
return {
|
16
|
+
id: index,
|
17
|
+
date: item.date,
|
18
|
+
name: item.name + `_${index + 1}`,
|
19
|
+
address: item.addr,
|
20
|
+
};
|
21
|
+
})
|
22
|
+
};
|
23
|
+
}),
|
12
24
|
});
|
13
25
|
|
14
26
|
const summaryData = deepcopy(data.slice(0, 2));
|
@@ -19,6 +31,8 @@ export const demoExpand = designPage(() => {
|
|
19
31
|
data={state.data}
|
20
32
|
summaryData={summaryData}
|
21
33
|
virtual
|
34
|
+
virtualRowType="realIndex"
|
35
|
+
dynamicSize
|
22
36
|
showRows={10}
|
23
37
|
>
|
24
38
|
<PlcIndex/>
|
@@ -27,14 +41,12 @@ export const demoExpand = designPage(() => {
|
|
27
41
|
v-slots={{
|
28
42
|
expand: ({ row }) => {
|
29
43
|
return (
|
30
|
-
<div style={{ padding: '
|
31
|
-
<
|
32
|
-
<
|
33
|
-
<
|
34
|
-
<
|
35
|
-
|
36
|
-
<FormItem label={'颜色'}><ColorPicker v-model={row.color}/></FormItem>
|
37
|
-
</Form>
|
44
|
+
<div style={{ padding: '20px' }}>
|
45
|
+
<Table data={row.children} showRows="auto" size="small">
|
46
|
+
<Plc title="名称" field="name"/>
|
47
|
+
<Plc title="日期" field="date"/>
|
48
|
+
<Plc title="地址" field="address"/>
|
49
|
+
</Table>
|
38
50
|
</div>
|
39
51
|
);
|
40
52
|
}
|
@@ -68,7 +80,19 @@ export const demoExpand = designPage(() => {
|
|
68
80
|
export const demoExpandVirtualCOlumn = designPage(() => {
|
69
81
|
|
70
82
|
const state = reactive({
|
71
|
-
data
|
83
|
+
data: data.map((item) => {
|
84
|
+
return {
|
85
|
+
...item,
|
86
|
+
children: new Array(Math.ceil(Math.random() * 5 + 2)).fill(null).map((_, index) => {
|
87
|
+
return {
|
88
|
+
id: index,
|
89
|
+
date: item.date,
|
90
|
+
name: item.name + `_${index + 1}`,
|
91
|
+
address: item.addr,
|
92
|
+
};
|
93
|
+
})
|
94
|
+
};
|
95
|
+
}),
|
72
96
|
});
|
73
97
|
|
74
98
|
const summaryData = deepcopy(data.slice(0, 2));
|
@@ -80,23 +104,21 @@ export const demoExpandVirtualCOlumn = designPage(() => {
|
|
80
104
|
summaryData={summaryData}
|
81
105
|
virtual
|
82
106
|
showRows={10}
|
107
|
+
dynamicSize
|
83
108
|
virtualColumn
|
84
109
|
>
|
85
110
|
<PlcIndex/>
|
86
111
|
<PlcExpand
|
87
|
-
toggleOnClickRow
|
88
112
|
fixedWidth
|
89
113
|
v-slots={{
|
90
114
|
expand: ({ row }) => {
|
91
115
|
return (
|
92
|
-
<div style={{ padding: '
|
93
|
-
<
|
94
|
-
<
|
95
|
-
<
|
96
|
-
<
|
97
|
-
|
98
|
-
<FormItem label={'颜色'}><ColorPicker v-model={row.color}/></FormItem>
|
99
|
-
</Form>
|
116
|
+
<div style={{ padding: '20px' }}>
|
117
|
+
<Table data={row.children} showRows="auto" size="small">
|
118
|
+
<Plc title="名称" field="name"/>
|
119
|
+
<Plc title="日期" field="date"/>
|
120
|
+
<Plc title="地址" field="address"/>
|
121
|
+
</Table>
|
100
122
|
</div>
|
101
123
|
);
|
102
124
|
}
|
@@ -69,8 +69,8 @@ export const demo1 = designPage(() => {
|
|
69
69
|
</tr>
|
70
70
|
))
|
71
71
|
),
|
72
|
-
default: ({ item,
|
73
|
-
<tr key={
|
72
|
+
default: ({ item, vid, vIndex }) => (
|
73
|
+
<tr key={vIndex} data-vid={vid} style={{ height: '40px', borderBottom: 'solid 1px #ececec', backgroundColor: "item.color" }}>
|
74
74
|
{Object.keys(DATA[0] as any).map((key: string) => (
|
75
75
|
<td key={key}>{(item as any)[key]}</td>
|
76
76
|
))}
|
@@ -104,8 +104,8 @@ export const demo1 = designPage(() => {
|
|
104
104
|
</tr>
|
105
105
|
))
|
106
106
|
),
|
107
|
-
default: ({ item,
|
108
|
-
<tr key={
|
107
|
+
default: ({ item, vIndex, vid }) => (
|
108
|
+
<tr key={vIndex} data-vid={vid} style={{ height: '40px', borderBottom: 'solid 1px #ececec', backgroundColor: "item.color" }}>
|
109
109
|
{Object.keys(DATA[0] as any).map((key: string) => (
|
110
110
|
<td key={key}>{(item as any)[key]}</td>
|
111
111
|
))}
|
@@ -1,48 +1,9 @@
|
|
1
|
-
import {designPage
|
1
|
+
import {designPage} from "plain-design-composition";
|
2
2
|
import {PlainLogo} from 'plain-icons/src/packages/component/logo/react';
|
3
|
-
import {PageThemeUtils, Select, SelectOption, ThemePrimaryColors} from "../../../packages";
|
4
|
-
import ClientZoom from "../../../packages/components/ClientZoom";
|
5
3
|
import logoImage from './plain-design.png';
|
4
|
+
import {ThemeEditor} from "../../../packages/components/ThemeEditor";
|
6
5
|
|
7
6
|
export const AppHead = designPage(() => {
|
8
|
-
|
9
|
-
const state = reactive({
|
10
|
-
size: PageThemeUtils.state.size || 'normal',
|
11
|
-
dark: PageThemeUtils.state.dark ? 'dark' : 'light',
|
12
|
-
shape: PageThemeUtils.state.shape || 'square',
|
13
|
-
zoom: PageThemeUtils.state.zoom || null,
|
14
|
-
primaryKey: PageThemeUtils.state.primaryKey as string || 'default',
|
15
|
-
inputMode: PageThemeUtils.state.inputMode || 'flat',
|
16
|
-
});
|
17
|
-
|
18
|
-
const onSizeChange = () => {
|
19
|
-
PageThemeUtils.size(state.size);
|
20
|
-
};
|
21
|
-
|
22
|
-
const onShapeChange = () => {
|
23
|
-
PageThemeUtils.shape(state.shape);
|
24
|
-
};
|
25
|
-
|
26
|
-
const onZoomChange = () => {
|
27
|
-
PageThemeUtils.zoom(state.zoom);
|
28
|
-
ClientZoom.set(state.zoom);
|
29
|
-
};
|
30
|
-
|
31
|
-
const onDarkChange = () => {
|
32
|
-
const val = !state.dark ? false : state.dark === 'dark';
|
33
|
-
PageThemeUtils.toggle(val);
|
34
|
-
};
|
35
|
-
|
36
|
-
const onPrimaryChange = () => {
|
37
|
-
PageThemeUtils.primary(state.primaryKey);
|
38
|
-
};
|
39
|
-
|
40
|
-
const onInputModeChange = () => {
|
41
|
-
PageThemeUtils.inputMode(state.inputMode);
|
42
|
-
};
|
43
|
-
|
44
|
-
const publicPopperAttrs = { trigger: 'hover' };
|
45
|
-
|
46
7
|
return () => (
|
47
8
|
<div className="app-head">
|
48
9
|
<div className="app-head-logo">
|
@@ -50,55 +11,7 @@ export const AppHead = designPage(() => {
|
|
50
11
|
<img src={logoImage}/>
|
51
12
|
</div>
|
52
13
|
<div className="app-head-operation">
|
53
|
-
<
|
54
|
-
<SelectOption label="输入框:填充" val="flat"/>
|
55
|
-
<SelectOption label="输入框:描边" val="stroke"/>
|
56
|
-
</Select>
|
57
|
-
|
58
|
-
<Select v-model={state.primaryKey} onChange={onPrimaryChange} size="mini" width="90" placeholder="主题色" popperAttrs={publicPopperAttrs}>
|
59
|
-
{Object.entries(ThemePrimaryColors).map(([key, value]) => (
|
60
|
-
<SelectOption label={value!.label} val={key} key={key}>
|
61
|
-
{!!value!.primary && <span style={{ height: '1em', width: '1em', display: 'inline-block', marginRight: '4px', background: value!.primary }}/>}
|
62
|
-
<span>{value!.label}</span>
|
63
|
-
</SelectOption>
|
64
|
-
))}
|
65
|
-
</Select>
|
66
|
-
|
67
|
-
<Select v-model={state.size} onChange={onSizeChange} size="mini" width="90" placeholder="主题尺寸" popperAttrs={publicPopperAttrs}>
|
68
|
-
<SelectOption label="大尺寸" val="large"/>
|
69
|
-
<SelectOption label="中等尺寸" val="normal"/>
|
70
|
-
<SelectOption label="小尺寸" val="small"/>
|
71
|
-
<SelectOption label="极小尺寸" val="mini"/>
|
72
|
-
</Select>
|
73
|
-
|
74
|
-
<Select v-model={state.dark} onChange={onDarkChange} size="mini" width="90" placeholder="黑白主题" popperAttrs={publicPopperAttrs}>
|
75
|
-
<SelectOption label="黑色主题" val="dark"/>
|
76
|
-
<SelectOption label="白色主题" val="light"/>
|
77
|
-
</Select>
|
78
|
-
|
79
|
-
<Select v-model={state.shape} onChange={onShapeChange} size="mini" width="90" placeholder="圆角类型" popperAttrs={publicPopperAttrs}>
|
80
|
-
<SelectOption label="圆角" val="round"/>
|
81
|
-
<SelectOption label="小圆角" val="square"/>
|
82
|
-
<SelectOption label="无圆角" val="none"/>
|
83
|
-
</Select>
|
84
|
-
|
85
|
-
<Select v-model={state.zoom} onChange={onZoomChange} size="mini" width="90" placeholder="页面缩放" popperAttrs={publicPopperAttrs}>
|
86
|
-
<SelectOption label="0.6" val={0.6}/>
|
87
|
-
<SelectOption label="0.7" val={0.7}/>
|
88
|
-
<SelectOption label="0.8" val={0.8}/>
|
89
|
-
<SelectOption label="0.9" val={0.9}/>
|
90
|
-
<SelectOption label="1.0" val={null}/>
|
91
|
-
<SelectOption label="1.1" val={1.1}/>
|
92
|
-
<SelectOption label="1.2" val={1.2}/>
|
93
|
-
<SelectOption label="1.3" val={1.3}/>
|
94
|
-
<SelectOption label="1.4" val={1.4}/>
|
95
|
-
<SelectOption label="1.5" val={1.5}/>
|
96
|
-
<SelectOption label="1.6" val={1.6}/>
|
97
|
-
<SelectOption label="1.7" val={1.7}/>
|
98
|
-
<SelectOption label="1.8" val={1.8}/>
|
99
|
-
<SelectOption label="1.9" val={1.9}/>
|
100
|
-
<SelectOption label="2.0" val={2.0}/>
|
101
|
-
</Select>
|
14
|
+
<ThemeEditor/>
|
102
15
|
</div>
|
103
16
|
</div>
|
104
17
|
);
|