@jetlinks-web/components 1.0.5 → 2.0.0
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/index.ts +54 -15
- package/package.json +9 -6
- package/src/AMap/Map.vue +110 -107
- package/src/BadgeStatus/Badge.vue +41 -40
- package/src/BadgeStatus/color.ts +25 -23
- package/src/CardSelect/CardSelect.vue +136 -0
- package/src/CardSelect/index.ts +3 -0
- package/src/CheckButton/CheckButton.vue +146 -0
- package/src/CheckButton/index.md +27 -0
- package/src/CheckButton/index.ts +3 -0
- package/src/ConfigProvider/context.ts +17 -0
- package/src/ConfigProvider/index.tsx +42 -0
- package/src/Echarts/Echarts.vue +43 -43
- package/src/Ellipsis/Ellipsis.vue +182 -0
- package/src/Ellipsis/index.ts +3 -0
- package/src/Empty/Empty.vue +43 -0
- package/src/Empty/image.ts +3 -0
- package/src/Empty/index.ts +2 -0
- package/src/FullPage/{index.vue → FullPage.vue} +30 -27
- package/src/FullPage/index.ts +3 -0
- package/src/Icon/icon.tsx +40 -0
- package/src/Icon/index.ts +3 -0
- package/src/MonacoEditor/Monaco.vue +242 -0
- package/src/MonacoEditor/index.md +26 -0
- package/src/MonacoEditor/index.ts +2 -0
- package/src/PermissionButton/index.tsx +95 -92
- package/src/ProLayout/Basic/BasicLayout.less +66 -0
- package/src/ProLayout/Basic/BasicLayout.tsx +392 -0
- package/src/ProLayout/Basic/Header.less +8 -0
- package/src/ProLayout/Basic/Header.tsx +115 -0
- package/src/ProLayout/PageContainer/index.less +103 -0
- package/src/ProLayout/PageContainer/index.tsx +441 -0
- package/src/ProLayout/PageContainer/typings.ts +56 -0
- package/src/ProLayout/RouteContext.ts +87 -0
- package/src/ProLayout/SiderMenu/BaseMenu.tsx +296 -0
- package/src/ProLayout/SiderMenu/SiderMenu.tsx +320 -0
- package/src/ProLayout/SiderMenu/index.less +212 -0
- package/src/ProLayout/SiderMenu/index.ts +2 -0
- package/src/ProLayout/SiderMenu/typings.ts +49 -0
- package/src/ProLayout/TopHeader/index.less +174 -0
- package/src/ProLayout/TopHeader/index.tsx +210 -0
- package/src/ProLayout/defaultSettings.ts +106 -0
- package/src/ProLayout/index.ts +6 -0
- package/src/ProLayout/style/default.less +4 -0
- package/src/ProLayout/style/index.ts +1 -0
- package/src/ProLayout/style/style.less +7 -0
- package/src/ProLayout/typings.ts +87 -0
- package/src/ProLayout/util.ts +64 -0
- package/src/ProTable/index.md +53 -0
- package/src/ProTable/index.tsx +551 -0
- package/src/ProTable/proTableTypes.ts +70 -0
- package/src/ProTable/style/index.less +92 -0
- package/src/ProTable/style/index.ts +1 -0
- package/src/Scrollbar/Bar.vue +75 -0
- package/src/Scrollbar/Scrollbar.vue +260 -0
- package/src/Scrollbar/Thumb.vue +163 -0
- package/src/Scrollbar/constants.ts +10 -0
- package/src/Scrollbar/index.ts +4 -0
- package/src/Scrollbar/scrollbar.ts +108 -0
- package/src/Scrollbar/thumb.ts +16 -0
- package/src/Scrollbar/util.ts +38 -0
- package/src/Search/Advanced/History.vue +140 -0
- package/src/Search/Advanced/SaveHistory.vue +108 -0
- package/src/Search/Advanced/index.vue +435 -0
- package/src/Search/Item.vue +525 -0
- package/src/Search/Search.vue +398 -0
- package/src/Search/hooks/index.ts +1 -0
- package/src/Search/hooks/useSearchItems.ts +68 -0
- package/src/Search/index.md +57 -0
- package/src/Search/index.ts +5 -0
- package/src/Search/setting.ts +55 -0
- package/src/Search/typing.ts +76 -0
- package/src/Search/util.ts +263 -0
- package/src/ValueItem/ValueItem.vue +50 -35
- package/src/ValueItem/util.ts +2 -1
- package/src/style/index.ts +3 -0
- package/src/style/variable.less +4 -0
- package/src/GeoComponent/GeoComponent.vue +0 -139
- package/src/GeoComponent/index.ts +0 -3
- package/src/PermissionButton/hooks.ts +0 -20
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import { withInstall } from 'ant-design-vue/es/_util/type';
|
|
2
|
+
import {
|
|
3
|
+
TabPaneProps,
|
|
4
|
+
Affix,
|
|
5
|
+
Spin,
|
|
6
|
+
PageHeader,
|
|
7
|
+
Tabs,
|
|
8
|
+
Button,
|
|
9
|
+
} from 'ant-design-vue';
|
|
10
|
+
import type {
|
|
11
|
+
ExtractPropTypes,
|
|
12
|
+
FunctionalComponent,
|
|
13
|
+
PropType,
|
|
14
|
+
VNodeChild,
|
|
15
|
+
CSSProperties,
|
|
16
|
+
} from 'vue';
|
|
17
|
+
import { defineComponent, unref, toRefs, computed } from 'vue';
|
|
18
|
+
import { pageHeaderProps } from 'ant-design-vue/lib/page-header';
|
|
19
|
+
import type { DefaultPropRender, PageHeaderRender } from '../typings';
|
|
20
|
+
import type { AffixProps, TabBarExtraContent } from './typings';
|
|
21
|
+
import { useRouteContext } from '../RouteContext';
|
|
22
|
+
import { getSlotVNode } from '../util';
|
|
23
|
+
import { VueNode } from 'ant-design-vue/lib/_util/type';
|
|
24
|
+
import './index.less';
|
|
25
|
+
|
|
26
|
+
export const pageHeaderTabConfig = {
|
|
27
|
+
/**
|
|
28
|
+
* @name tabs 的列表
|
|
29
|
+
*/
|
|
30
|
+
tabList: {
|
|
31
|
+
type: [Object, Function, Array] as PropType<
|
|
32
|
+
(Omit<TabPaneProps, 'id'> & { key?: string; class: string })[]
|
|
33
|
+
>,
|
|
34
|
+
default: () => undefined,
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* @name 当前选中 tab 的 key
|
|
38
|
+
*/
|
|
39
|
+
tabActiveKey: String, //PropTypes.string,
|
|
40
|
+
/**
|
|
41
|
+
* @name tab 上多余的区域
|
|
42
|
+
*/
|
|
43
|
+
tabBarExtraContent: {
|
|
44
|
+
type: [Object, Function] as PropType<TabBarExtraContent>,
|
|
45
|
+
default: () => undefined,
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* @name tabs 的其他配置
|
|
49
|
+
*/
|
|
50
|
+
tabProps: {
|
|
51
|
+
type: Object, //as PropType<TabsProps>,
|
|
52
|
+
default: () => undefined,
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* @name 固定 PageHeader 到页面顶部
|
|
56
|
+
*/
|
|
57
|
+
fixedHeader: Boolean, //PropTypes.looseBool,
|
|
58
|
+
// events
|
|
59
|
+
onTabChange: Function, //PropTypes.func,
|
|
60
|
+
pure: Boolean,
|
|
61
|
+
};
|
|
62
|
+
export type PageHeaderTabConfig = Partial<
|
|
63
|
+
ExtractPropTypes<typeof pageHeaderTabConfig>
|
|
64
|
+
>;
|
|
65
|
+
|
|
66
|
+
export const pageContainerProps = {
|
|
67
|
+
...pageHeaderTabConfig,
|
|
68
|
+
...pageHeaderProps,
|
|
69
|
+
prefixCls: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: 'ant-pro',
|
|
72
|
+
}, //PropTypes.string.def('ant-pro'),
|
|
73
|
+
title: {
|
|
74
|
+
type: [
|
|
75
|
+
Object,
|
|
76
|
+
String,
|
|
77
|
+
Boolean,
|
|
78
|
+
Function,
|
|
79
|
+
] as PropType<DefaultPropRender>,
|
|
80
|
+
default: () => null,
|
|
81
|
+
},
|
|
82
|
+
subTitle: {
|
|
83
|
+
type: [
|
|
84
|
+
Object,
|
|
85
|
+
String,
|
|
86
|
+
Boolean,
|
|
87
|
+
Function,
|
|
88
|
+
] as PropType<DefaultPropRender>,
|
|
89
|
+
default: () => null,
|
|
90
|
+
},
|
|
91
|
+
content: {
|
|
92
|
+
type: [
|
|
93
|
+
Object,
|
|
94
|
+
String,
|
|
95
|
+
Boolean,
|
|
96
|
+
Function,
|
|
97
|
+
] as PropType<DefaultPropRender>,
|
|
98
|
+
default: () => null,
|
|
99
|
+
},
|
|
100
|
+
extra: {
|
|
101
|
+
type: [
|
|
102
|
+
Object,
|
|
103
|
+
String,
|
|
104
|
+
Boolean,
|
|
105
|
+
Function,
|
|
106
|
+
] as PropType<DefaultPropRender>,
|
|
107
|
+
default: () => null,
|
|
108
|
+
},
|
|
109
|
+
extraContent: {
|
|
110
|
+
type: [
|
|
111
|
+
Object,
|
|
112
|
+
String,
|
|
113
|
+
Boolean,
|
|
114
|
+
Function,
|
|
115
|
+
] as PropType<DefaultPropRender>,
|
|
116
|
+
default: () => null,
|
|
117
|
+
},
|
|
118
|
+
header: {
|
|
119
|
+
type: [
|
|
120
|
+
Object,
|
|
121
|
+
String,
|
|
122
|
+
Boolean,
|
|
123
|
+
Function,
|
|
124
|
+
] as PropType<DefaultPropRender>,
|
|
125
|
+
default: () => null,
|
|
126
|
+
},
|
|
127
|
+
pageHeaderRender: {
|
|
128
|
+
type: [Object, Function, Boolean] as PropType<PageHeaderRender>,
|
|
129
|
+
default: () => undefined,
|
|
130
|
+
},
|
|
131
|
+
affixProps: {
|
|
132
|
+
type: [Object, Function] as PropType<AffixProps>,
|
|
133
|
+
},
|
|
134
|
+
ghost: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
default: () => false,
|
|
137
|
+
}, //PropTypes.looseBool,
|
|
138
|
+
loading: {
|
|
139
|
+
type: Boolean,
|
|
140
|
+
default: () => undefined,
|
|
141
|
+
}, //PropTypes.looseBool,
|
|
142
|
+
childrenFullHeight: {
|
|
143
|
+
type: Boolean,
|
|
144
|
+
default: () => true,
|
|
145
|
+
},
|
|
146
|
+
pure: {
|
|
147
|
+
type: Boolean,
|
|
148
|
+
default: false,
|
|
149
|
+
},
|
|
150
|
+
showBack: {
|
|
151
|
+
type: Boolean,
|
|
152
|
+
default: false,
|
|
153
|
+
},
|
|
154
|
+
contentStyle: {
|
|
155
|
+
type: Object,
|
|
156
|
+
default: () => ({}),
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type PageContainerProps = Partial<
|
|
161
|
+
ExtractPropTypes<typeof pageContainerProps>
|
|
162
|
+
>;
|
|
163
|
+
|
|
164
|
+
const renderFooter = (
|
|
165
|
+
props: Omit<PageContainerProps, 'title'>,
|
|
166
|
+
): VNodeChild | JSX.Element => {
|
|
167
|
+
const { tabList, tabActiveKey, onTabChange, tabBarExtraContent, tabProps } =
|
|
168
|
+
props;
|
|
169
|
+
const tabPane = (item: any) => {
|
|
170
|
+
return (
|
|
171
|
+
<span class={item.class || `tab-pane-${item.key}`}>{item.tab}</span>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
if (tabList && tabList.length) {
|
|
175
|
+
return (
|
|
176
|
+
<Tabs
|
|
177
|
+
class={`page-container-tabs`}
|
|
178
|
+
activeKey={tabActiveKey}
|
|
179
|
+
onChange={(key: string | number) => {
|
|
180
|
+
if (onTabChange) {
|
|
181
|
+
onTabChange(key);
|
|
182
|
+
}
|
|
183
|
+
}}
|
|
184
|
+
tabBarExtraContent={tabBarExtraContent}
|
|
185
|
+
{...tabProps}
|
|
186
|
+
>
|
|
187
|
+
{tabList.map((item) => (
|
|
188
|
+
<Tabs.TabPane
|
|
189
|
+
{...item}
|
|
190
|
+
tab={tabPane(item)}
|
|
191
|
+
key={item.key}
|
|
192
|
+
/>
|
|
193
|
+
))}
|
|
194
|
+
</Tabs>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const renderPageHeader = (
|
|
201
|
+
content: VueNode,
|
|
202
|
+
extraContent: VueNode | any,
|
|
203
|
+
prefixedClassName: string,
|
|
204
|
+
): VNodeChild | JSX.Element | null => {
|
|
205
|
+
if (!content && !extraContent) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
return (
|
|
209
|
+
<div class={`${prefixedClassName}-detail`}>
|
|
210
|
+
<div class={`${prefixedClassName}-main`}>
|
|
211
|
+
<div class={`${prefixedClassName}-row`}>
|
|
212
|
+
{content && (
|
|
213
|
+
<div class={`${prefixedClassName}-content`}>
|
|
214
|
+
{
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
(typeof content === 'function' && content()) ||
|
|
217
|
+
content
|
|
218
|
+
}
|
|
219
|
+
</div>
|
|
220
|
+
)}
|
|
221
|
+
{extraContent && (
|
|
222
|
+
<div class={`${prefixedClassName}-extraContent`}>
|
|
223
|
+
{
|
|
224
|
+
// @ts-ignore
|
|
225
|
+
(typeof extraContent === 'function' &&
|
|
226
|
+
extraContent()) ||
|
|
227
|
+
extraContent
|
|
228
|
+
}
|
|
229
|
+
</div>
|
|
230
|
+
)}
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const ProPageHeader: FunctionalComponent<
|
|
238
|
+
PageContainerProps & { prefixedClassName: string }
|
|
239
|
+
> = (props) => {
|
|
240
|
+
const {
|
|
241
|
+
title,
|
|
242
|
+
tabList,
|
|
243
|
+
tabActiveKey,
|
|
244
|
+
content,
|
|
245
|
+
pageHeaderRender,
|
|
246
|
+
header,
|
|
247
|
+
extraContent,
|
|
248
|
+
prefixedClassName,
|
|
249
|
+
prefixCls,
|
|
250
|
+
fixedHeader: _,
|
|
251
|
+
showBack,
|
|
252
|
+
...restProps
|
|
253
|
+
} = props;
|
|
254
|
+
|
|
255
|
+
const value = useRouteContext();
|
|
256
|
+
|
|
257
|
+
if (pageHeaderRender === false) {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (pageHeaderRender) {
|
|
262
|
+
return pageHeaderRender({ ...props });
|
|
263
|
+
}
|
|
264
|
+
let pageHeaderTitle = title;
|
|
265
|
+
if (!title && title !== false) {
|
|
266
|
+
pageHeaderTitle = value.title;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const unrefBreadcrumb = unref(value.breadcrumb || {});
|
|
270
|
+
const breadcrumb = (props as any).breadcrumb || {
|
|
271
|
+
...unrefBreadcrumb,
|
|
272
|
+
routes: unrefBreadcrumb.routes,
|
|
273
|
+
itemRender: unrefBreadcrumb.itemRender,
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const backProps: any = {};
|
|
277
|
+
|
|
278
|
+
if (showBack) {
|
|
279
|
+
// @ts-ignore
|
|
280
|
+
backProps.backIcon = <Button>返回</Button>;
|
|
281
|
+
backProps.onBack = () => {
|
|
282
|
+
value.back?.();
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<div class={`${prefixedClassName}-wrap`}>
|
|
288
|
+
<PageHeader
|
|
289
|
+
{...backProps}
|
|
290
|
+
{...restProps}
|
|
291
|
+
// {...value}
|
|
292
|
+
title={pageHeaderTitle}
|
|
293
|
+
breadcrumb={breadcrumb}
|
|
294
|
+
footer={renderFooter({
|
|
295
|
+
...restProps,
|
|
296
|
+
tabList,
|
|
297
|
+
tabActiveKey,
|
|
298
|
+
})}
|
|
299
|
+
prefixCls={prefixCls}
|
|
300
|
+
>
|
|
301
|
+
{header ||
|
|
302
|
+
renderPageHeader(content, extraContent, prefixedClassName)}
|
|
303
|
+
</PageHeader>
|
|
304
|
+
</div>
|
|
305
|
+
);
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
const PageContainer = defineComponent({
|
|
309
|
+
name: 'JPageContainer',
|
|
310
|
+
inheritAttrs: false,
|
|
311
|
+
props: pageContainerProps,
|
|
312
|
+
setup(props, { slots, attrs }) {
|
|
313
|
+
const { loading, affixProps, ghost, childrenFullHeight } =
|
|
314
|
+
toRefs(props);
|
|
315
|
+
|
|
316
|
+
const value = useRouteContext();
|
|
317
|
+
const { getPrefixCls } = value;
|
|
318
|
+
const prefixCls = props.prefixCls || getPrefixCls();
|
|
319
|
+
|
|
320
|
+
const prefixedClassName = computed(() => `${prefixCls}-page-container`);
|
|
321
|
+
const classNames = computed(() => {
|
|
322
|
+
return {
|
|
323
|
+
[prefixedClassName.value]: true,
|
|
324
|
+
[`${prefixCls}-page-container-ghost`]: ghost.value,
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
const headerDom = computed(() => {
|
|
329
|
+
// const tags = getSlotVNode<DefaultPropRender>(slots, props, 'tags');
|
|
330
|
+
const headerContent = getSlotVNode<DefaultPropRender>(
|
|
331
|
+
slots,
|
|
332
|
+
props,
|
|
333
|
+
'content',
|
|
334
|
+
);
|
|
335
|
+
const extra = getSlotVNode<DefaultPropRender>(
|
|
336
|
+
slots,
|
|
337
|
+
props,
|
|
338
|
+
'extra',
|
|
339
|
+
);
|
|
340
|
+
const extraContent = getSlotVNode<DefaultPropRender>(
|
|
341
|
+
slots,
|
|
342
|
+
props,
|
|
343
|
+
'extraContent',
|
|
344
|
+
);
|
|
345
|
+
const subTitle = getSlotVNode<DefaultPropRender>(
|
|
346
|
+
slots,
|
|
347
|
+
props,
|
|
348
|
+
'subTitle',
|
|
349
|
+
);
|
|
350
|
+
const title = getSlotVNode<DefaultPropRender>(
|
|
351
|
+
slots,
|
|
352
|
+
props,
|
|
353
|
+
'title',
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
// @ts-ignore
|
|
357
|
+
return (
|
|
358
|
+
<ProPageHeader
|
|
359
|
+
{...props}
|
|
360
|
+
prefixCls={undefined}
|
|
361
|
+
prefixedClassName={prefixedClassName.value}
|
|
362
|
+
ghost={ghost.value}
|
|
363
|
+
title={title}
|
|
364
|
+
subTitle={subTitle}
|
|
365
|
+
content={headerContent}
|
|
366
|
+
// tags={tags}
|
|
367
|
+
extra={extra}
|
|
368
|
+
extraContent={extraContent}
|
|
369
|
+
/>
|
|
370
|
+
);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
return () => {
|
|
374
|
+
const { fixedHeader, pure } = props;
|
|
375
|
+
return (
|
|
376
|
+
<>
|
|
377
|
+
{pure ? (
|
|
378
|
+
<div class={classNames.value}>{slots.default?.()}</div>
|
|
379
|
+
) : (
|
|
380
|
+
<div
|
|
381
|
+
class={classNames.value}
|
|
382
|
+
style={{
|
|
383
|
+
...((attrs.style as CSSProperties) || {}),
|
|
384
|
+
}}
|
|
385
|
+
>
|
|
386
|
+
{fixedHeader && headerDom.value ? (
|
|
387
|
+
<Affix
|
|
388
|
+
{...affixProps.value}
|
|
389
|
+
offsetTop={
|
|
390
|
+
value.hasHeader && value.fixedHeader
|
|
391
|
+
? value.headerHeight
|
|
392
|
+
: 0
|
|
393
|
+
}
|
|
394
|
+
>
|
|
395
|
+
{headerDom.value}
|
|
396
|
+
</Affix>
|
|
397
|
+
) : (
|
|
398
|
+
headerDom.value
|
|
399
|
+
)}
|
|
400
|
+
<div
|
|
401
|
+
class={`${prefixedClassName.value}-grid-content`}
|
|
402
|
+
>
|
|
403
|
+
{loading.value ? (
|
|
404
|
+
<Spin />
|
|
405
|
+
) : slots.default ? (
|
|
406
|
+
<div>
|
|
407
|
+
<div
|
|
408
|
+
class={`${
|
|
409
|
+
prefixedClassName.value
|
|
410
|
+
}-children-content ${
|
|
411
|
+
childrenFullHeight.value
|
|
412
|
+
? 'children-full-height'
|
|
413
|
+
: ''
|
|
414
|
+
}`}
|
|
415
|
+
style={{
|
|
416
|
+
...((props.contentStyle as CSSProperties) ||
|
|
417
|
+
{}),
|
|
418
|
+
}}
|
|
419
|
+
>
|
|
420
|
+
{slots.default()}
|
|
421
|
+
</div>
|
|
422
|
+
{value.hasFooterToolbar && (
|
|
423
|
+
<div
|
|
424
|
+
style={{
|
|
425
|
+
height: 48,
|
|
426
|
+
marginTop: 24,
|
|
427
|
+
}}
|
|
428
|
+
/>
|
|
429
|
+
)}
|
|
430
|
+
</div>
|
|
431
|
+
) : null}
|
|
432
|
+
</div>
|
|
433
|
+
</div>
|
|
434
|
+
)}
|
|
435
|
+
</>
|
|
436
|
+
);
|
|
437
|
+
};
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
export default withInstall(PageContainer);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { VNodeChild, CSSProperties, VNode } from 'vue';
|
|
2
|
+
|
|
3
|
+
export interface Tab {
|
|
4
|
+
key: string;
|
|
5
|
+
tab: string | VNode | JSX.Element;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type TabBarType = 'line' | 'card' | 'editable-card';
|
|
9
|
+
export type TabSize = 'default' | 'large' | 'small';
|
|
10
|
+
export type TabPosition = 'left' | 'right';
|
|
11
|
+
export type TabBarExtraPosition = TabPosition;
|
|
12
|
+
|
|
13
|
+
export type TabBarExtraMap = Partial<Record<TabBarExtraPosition, VNodeChild>>;
|
|
14
|
+
|
|
15
|
+
export type TabBarExtraContent = VNodeChild | TabBarExtraMap;
|
|
16
|
+
|
|
17
|
+
export interface TabsProps {
|
|
18
|
+
prefixCls?: string;
|
|
19
|
+
class?: string | string[];
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
id?: string;
|
|
22
|
+
|
|
23
|
+
activeKey?: string;
|
|
24
|
+
hideAdd?: boolean;
|
|
25
|
+
// Unchangeable
|
|
26
|
+
// size?: TabSize;
|
|
27
|
+
tabBarStyle?: CSSProperties;
|
|
28
|
+
tabPosition?: TabPosition;
|
|
29
|
+
type?: TabBarType;
|
|
30
|
+
tabBarGutter?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface AffixProps {
|
|
34
|
+
offsetBottom: number;
|
|
35
|
+
offsetTop: number;
|
|
36
|
+
target?: () => HTMLElement;
|
|
37
|
+
|
|
38
|
+
onChange?: (affixed: boolean) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TabPaneProps {
|
|
42
|
+
tab?: string | VNodeChild | JSX.Element;
|
|
43
|
+
class?: string | string[];
|
|
44
|
+
style?: CSSProperties;
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
forceRender?: boolean;
|
|
47
|
+
closable?: boolean;
|
|
48
|
+
closeIcon?: VNodeChild | JSX.Element;
|
|
49
|
+
|
|
50
|
+
prefixCls?: string;
|
|
51
|
+
tabKey?: string;
|
|
52
|
+
id: string;
|
|
53
|
+
animated?: boolean;
|
|
54
|
+
active?: boolean;
|
|
55
|
+
destroyInactiveTabPane?: boolean;
|
|
56
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { provide, reactive } from 'vue';
|
|
2
|
+
import type { InjectionKey, Ref, VNodeChild, ComputedRef } from 'vue';
|
|
3
|
+
import { useContext } from '@jetlinks-web/hooks';
|
|
4
|
+
import type { MenuDataItem, FormatMessage, WithFalse } from './typings';
|
|
5
|
+
import type { DefaultSettingProps } from './defaultSettings';
|
|
6
|
+
|
|
7
|
+
export interface Route {
|
|
8
|
+
path: string;
|
|
9
|
+
breadcrumbName: string;
|
|
10
|
+
children?: Omit<Route, 'children'>[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface BreadcrumbProps {
|
|
14
|
+
prefixCls?: string;
|
|
15
|
+
routes?: Route[];
|
|
16
|
+
params?: any;
|
|
17
|
+
separator?: VNodeChild;
|
|
18
|
+
itemRender?: (opts: {
|
|
19
|
+
route: Route;
|
|
20
|
+
params: any;
|
|
21
|
+
routes: Array<Route>;
|
|
22
|
+
paths: Array<string>;
|
|
23
|
+
}) => VNodeChild;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type BreadcrumbListReturn = Pick<
|
|
27
|
+
BreadcrumbProps,
|
|
28
|
+
Extract<keyof BreadcrumbProps, 'routes' | 'itemRender'>
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
export interface MenuState {
|
|
32
|
+
selectedKeys: string[];
|
|
33
|
+
openKeys: string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RouteContextProps
|
|
37
|
+
extends Partial<DefaultSettingProps>,
|
|
38
|
+
MenuState {
|
|
39
|
+
menuData: MenuDataItem[];
|
|
40
|
+
flatMenuData?: MenuDataItem[];
|
|
41
|
+
|
|
42
|
+
getPrefixCls?: (suffixCls?: string, customizePrefixCls?: string) => string;
|
|
43
|
+
locale?: WithFalse<FormatMessage>;
|
|
44
|
+
breadcrumb?: BreadcrumbListReturn | ComputedRef<BreadcrumbListReturn>;
|
|
45
|
+
prefixCls?: string;
|
|
46
|
+
collapsed?: boolean;
|
|
47
|
+
hasSideMenu?: boolean;
|
|
48
|
+
hasHeader?: boolean;
|
|
49
|
+
siderWidth?: number;
|
|
50
|
+
headerHeight?: number;
|
|
51
|
+
hasSide?: boolean;
|
|
52
|
+
/* 附加属性 */
|
|
53
|
+
[key: string]: any;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const defaultPrefixCls = 'ant-pro';
|
|
57
|
+
|
|
58
|
+
export const getPrefixCls = (
|
|
59
|
+
suffixCls?: string,
|
|
60
|
+
customizePrefixCls?: string,
|
|
61
|
+
) => {
|
|
62
|
+
if (customizePrefixCls) return customizePrefixCls;
|
|
63
|
+
return suffixCls ? `${defaultPrefixCls}-${suffixCls}` : defaultPrefixCls;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const defaultRouteContext = reactive({
|
|
67
|
+
getPrefixCls,
|
|
68
|
+
locale: (t: string) => t,
|
|
69
|
+
contentWidth: 'Fluid',
|
|
70
|
+
hasFooterToolbar: false,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export const routeContextInjectKey: InjectionKey<RouteContextProps> = Symbol(
|
|
74
|
+
'jetlinks-route-context',
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
export const provideRouteContext = (
|
|
78
|
+
value: RouteContextProps | Ref<RouteContextProps>,
|
|
79
|
+
) => {
|
|
80
|
+
provide(routeContextInjectKey, value);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const useRouteContext = () =>
|
|
84
|
+
useContext<Required<RouteContextProps>>(
|
|
85
|
+
routeContextInjectKey,
|
|
86
|
+
defaultRouteContext,
|
|
87
|
+
);
|