plain-design 1.0.0-beta.83 → 1.0.0-beta.85
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/dist/plain-design.commonjs.min.js +2 -2
- package/dist/plain-design.min.css +5 -4
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/packages/components/$loading/index.tsx +3 -0
- package/src/packages/components/Application/service/createApplicationServiceManager.tsx +5 -2
- package/src/packages/components/Box/index.tsx +1 -0
- package/src/packages/components/Dialog/index.tsx +10 -20
- package/src/packages/components/PageRenderList/index.tsx +3 -3
- package/src/packages/components/ParagraphItem/index.tsx +1 -0
- package/src/packages/components/Table/table/use/useTableDraggier.row.tsx +18 -6
- package/src/packages/components/ThemeColorSelector/index.tsx +1 -1
- package/src/packages/components/ThemeLocaleSelector/index.tsx +1 -1
- package/src/packages/components/VirtualList/createVirtualDraggier.ts +2 -39
- package/src/packages/components/createAutoScrollManager/index.tsx +41 -0
- package/src/packages/components/createPlainAddressService/index.tsx +12 -6
- package/src/packages/components/createRequestInterceptor/index.ts +1 -1
- package/src/packages/components/createScrollDraggier/index.ts +2 -39
- package/src/packages/components/createTransitionHandler/index.ts +46 -0
- package/src/packages/components/loadFile/index.ts +20 -0
- package/src/packages/components/useDialog/DialogService.tsx +6 -6
- package/src/packages/components/useImage/ImageService.tsx +27 -4
- package/src/packages/components/useLoading/LoadingService.tsx +106 -0
- package/src/packages/components/useLoading/index.tsx +31 -0
- package/src/packages/components/useLoading/loading.service.scss +25 -0
- package/src/packages/components/useLoading/loading.service.utils.tsx +13 -0
- package/src/packages/components/useMessage/Message.tsx +4 -2
- package/src/packages/components/useNotice/Notice.tsx +4 -2
- package/src/packages/entry.tsx +3 -0
- package/src/packages/styles/global.import.scss +1 -1
- package/src/packages/utils/plainDate.ts +2 -2
@@ -0,0 +1,106 @@
|
|
1
|
+
import {createApplicationServiceComponent} from "../Application/service/createApplicationServiceComponent";
|
2
|
+
import {closeLoadingServiceHook, iLoadingServiceOption} from "./loading.service.utils";
|
3
|
+
import {computed, createHooks, getComponentCls, iHTMLDivElement, onBeforeUnmount, reactive, ref, useClasses, useRefs, useStyles} from "plain-design-composition";
|
4
|
+
import {ThemeStatus} from "../../uses/useStyle";
|
5
|
+
import {createTransitionHandler} from "../createTransitionHandler";
|
6
|
+
import './loading.service.scss';
|
7
|
+
import {delay} from "plain-utils/utils/delay";
|
8
|
+
import {createEffects} from "plain-utils/utils/createEffects";
|
9
|
+
|
10
|
+
export const LoadingService = createApplicationServiceComponent<iLoadingServiceOption>({
|
11
|
+
name: 'loading-service',
|
12
|
+
setup({ option, destroy }) {
|
13
|
+
|
14
|
+
const { refs, onRef } = useRefs({ el: iHTMLDivElement });
|
15
|
+
|
16
|
+
const isShow = ref(false);
|
17
|
+
const isOpen = ref(false);
|
18
|
+
|
19
|
+
const { effects: setupEffects } = createEffects();
|
20
|
+
const { effects: timerEffects } = createEffects();
|
21
|
+
|
22
|
+
const state = reactive({
|
23
|
+
option,
|
24
|
+
percent: 0,
|
25
|
+
});
|
26
|
+
|
27
|
+
const classes = useClasses(() => [
|
28
|
+
getComponentCls('loading-service'),
|
29
|
+
{
|
30
|
+
'loading-service-show': isShow.value
|
31
|
+
}
|
32
|
+
]);
|
33
|
+
|
34
|
+
const innerStyles = useStyles(style => {style.transform = `scaleX(${state.percent})`;});
|
35
|
+
|
36
|
+
const hooks = {
|
37
|
+
onOpen: createHooks(),
|
38
|
+
onClose: createHooks(),
|
39
|
+
};
|
40
|
+
|
41
|
+
const targetOption = computed(() => {
|
42
|
+
return {
|
43
|
+
...state.option,
|
44
|
+
status: state.option.status || ThemeStatus.primary,
|
45
|
+
maxTime: state.option.maxTime === undefined ? 60 * 1000 : state.option.maxTime
|
46
|
+
};
|
47
|
+
});
|
48
|
+
|
49
|
+
async function service(option: iLoadingServiceOption) {
|
50
|
+
state.option = option;
|
51
|
+
await delay(23);
|
52
|
+
isShow.value = true;
|
53
|
+
handleTransition();
|
54
|
+
await delay(78);
|
55
|
+
state.percent = 0.2;
|
56
|
+
|
57
|
+
if (targetOption.value.maxTime) {
|
58
|
+
const timer = setTimeout(() => hide(), targetOption.value.maxTime);
|
59
|
+
timerEffects.push(() => clearTimeout(timer));
|
60
|
+
}
|
61
|
+
|
62
|
+
const maxPercent = 0.9;
|
63
|
+
let spacePrefix = '0.0';
|
64
|
+
const interval = setInterval(() => {
|
65
|
+
const space = Number(`${spacePrefix}${Math.ceil(Math.random() * 10)}`);
|
66
|
+
state.percent = Math.min(maxPercent, state.percent + (space));
|
67
|
+
if (state.percent > 0.75 && spacePrefix.length === 3) {spacePrefix += '0';}
|
68
|
+
if (state.percent >= maxPercent) {clearInterval(interval);}
|
69
|
+
}, 500);
|
70
|
+
timerEffects.push(() => clearInterval(interval));
|
71
|
+
}
|
72
|
+
|
73
|
+
const hide = async () => {
|
74
|
+
state.percent = 1;
|
75
|
+
timerEffects.clear();
|
76
|
+
await delay(150);
|
77
|
+
isShow.value = false;
|
78
|
+
handleTransition();
|
79
|
+
};
|
80
|
+
|
81
|
+
const handleTransition = createTransitionHandler({
|
82
|
+
getTransitionElement: () => refs.el,
|
83
|
+
isShow, isOpen,
|
84
|
+
onOpen: () => hooks.onOpen.exec(undefined),
|
85
|
+
onClose: () => hooks.onClose.exec(undefined),
|
86
|
+
});
|
87
|
+
|
88
|
+
setupEffects.push(closeLoadingServiceHook.use(id => {(!id || (id === state.option.id)) && (hide());}));
|
89
|
+
setupEffects.push(hooks.onClose.use(() => {destroy();}));
|
90
|
+
|
91
|
+
onBeforeUnmount(setupEffects.clear);
|
92
|
+
|
93
|
+
return {
|
94
|
+
refer: {
|
95
|
+
service,
|
96
|
+
isShow,
|
97
|
+
isOpen,
|
98
|
+
},
|
99
|
+
render: () => (
|
100
|
+
<div ref={onRef.el} className={classes.value} data-service-id={state.option.id}>
|
101
|
+
<div className="loading-service-inner" style={innerStyles.value}/>
|
102
|
+
</div>
|
103
|
+
)
|
104
|
+
};
|
105
|
+
},
|
106
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import {closeLoadingServiceHook, iLoadingServiceOption} from "./loading.service.utils";
|
2
|
+
import {createApplicationService} from "../Application/service/createApplicationService";
|
3
|
+
import {createApplicationServiceManager} from "../Application/service/createApplicationServiceManager";
|
4
|
+
import {LoadingService} from "./LoadingService";
|
5
|
+
import {createCounter} from "plain-utils/utils/createCounter";
|
6
|
+
|
7
|
+
interface iLoadingServiceFunction {
|
8
|
+
(option?: iLoadingServiceOption): () => void;
|
9
|
+
}
|
10
|
+
|
11
|
+
const nextLoadingId = createCounter('loading');
|
12
|
+
|
13
|
+
export const useLoading = createApplicationService(
|
14
|
+
'loading',
|
15
|
+
createApplicationServiceManager({ name: 'loading', Service: LoadingService }),
|
16
|
+
(getManager) => {
|
17
|
+
|
18
|
+
const service: iLoadingServiceFunction = (_option) => {
|
19
|
+
const option: iLoadingServiceOption = _option || {};
|
20
|
+
!option.id && (option.id = nextLoadingId());
|
21
|
+
|
22
|
+
getManager().then(async manager => {await manager.service(option);});
|
23
|
+
|
24
|
+
return () => closeLoadingServiceHook.exec(option!.id!);
|
25
|
+
};
|
26
|
+
|
27
|
+
return { $loading: service };
|
28
|
+
},
|
29
|
+
);
|
30
|
+
|
31
|
+
export default useLoading;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
@include comp(loading-service) {
|
2
|
+
position: fixed;
|
3
|
+
top: 0;
|
4
|
+
left: 0;
|
5
|
+
right: 0;
|
6
|
+
height: 2px;
|
7
|
+
transition: all ease 300ms;
|
8
|
+
|
9
|
+
&:not(.loading-service-show) {
|
10
|
+
opacity: 0;
|
11
|
+
}
|
12
|
+
|
13
|
+
&.loading-service-show {
|
14
|
+
opacity: 1;
|
15
|
+
}
|
16
|
+
|
17
|
+
.loading-service-inner {
|
18
|
+
position: absolute;
|
19
|
+
inset: 0;
|
20
|
+
height: 100%;
|
21
|
+
background-color: plv(primary-6);
|
22
|
+
transition: all ease 500ms;
|
23
|
+
transform-origin: top left;
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import {ThemeStatus} from "../../uses/useStyle";
|
2
|
+
import {createHooks} from "plain-design-composition";
|
3
|
+
|
4
|
+
export interface iLoadingServiceOption {
|
5
|
+
id?: string,
|
6
|
+
hold?: boolean,
|
7
|
+
status?: typeof ThemeStatus.TYPE,
|
8
|
+
color?: string,
|
9
|
+
maxTime?: number | null,
|
10
|
+
onClose?: () => void,
|
11
|
+
}
|
12
|
+
|
13
|
+
export const closeLoadingServiceHook = createHooks<(id?: string) => void>();
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {designComponent, getComponentCls, iMouseEvent, nextIndex, onMounted, PropType, useClasses} from "plain-design-composition";
|
1
|
+
import {designComponent, getComponentCls, iMouseEvent, nextIndex, onBeforeUnmount, onMounted, PropType, useClasses} from "plain-design-composition";
|
2
2
|
import {closeMessageServiceHook, iMessageServiceOption} from "./message.service.utils";
|
3
3
|
import Icon from "../Icon";
|
4
4
|
import './message.scss';
|
@@ -51,7 +51,9 @@ export const Message = designComponent({
|
|
51
51
|
let closeTimer: number | null = null;
|
52
52
|
!!props.option.time && (closeTimer = setTimeout(close, props.option.time) as any);
|
53
53
|
|
54
|
-
|
54
|
+
onBeforeUnmount(
|
55
|
+
closeMessageServiceHook.use(id => {(!id || id === props.option.id) && close();})
|
56
|
+
);
|
55
57
|
|
56
58
|
return {
|
57
59
|
refer: {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import './notice.scss';
|
2
|
-
import {designComponent, getComponentCls, iMouseEvent, nextIndex, onMounted, PropType, useClasses} from "plain-design-composition";
|
2
|
+
import {designComponent, getComponentCls, iMouseEvent, nextIndex, onBeforeUnmount, onMounted, PropType, useClasses} from "plain-design-composition";
|
3
3
|
import {closeNoticeServiceHook, iNoticeServiceOption} from "./noitice.service.utils";
|
4
4
|
import Icon from "../Icon";
|
5
5
|
|
@@ -47,7 +47,9 @@ export const Notice = designComponent({
|
|
47
47
|
let closeTimer: number | null = null;
|
48
48
|
!!props.option.time && (closeTimer = setTimeout(close, props.option.time) as any);
|
49
49
|
|
50
|
-
|
50
|
+
onBeforeUnmount(
|
51
|
+
closeNoticeServiceHook.use(id => {(!id || id === props.option.id) && close();})
|
52
|
+
);
|
51
53
|
|
52
54
|
return {
|
53
55
|
refer: {
|
package/src/packages/entry.tsx
CHANGED
@@ -74,6 +74,7 @@ export {ImageUploader} from './components/ImageUploader';
|
|
74
74
|
export {Upload} from './components/Upload';
|
75
75
|
export {$file} from './components/$file';
|
76
76
|
export {$image} from './components/$image';
|
77
|
+
export {$loading} from './components/$loading';
|
77
78
|
export {useTooltip} from './components/useTooltip';
|
78
79
|
export {i18n} from './components/i18n';
|
79
80
|
export {KeepAlive} from './components/KeepAlive';
|
@@ -123,6 +124,7 @@ export {PageCardContent} from './components/PageCardContent';
|
|
123
124
|
export {RollingNumber} from './components/RollingNumber';
|
124
125
|
export {Paragraph} from './components/Paragraph';
|
125
126
|
export {ParagraphItem} from './components/ParagraphItem';
|
127
|
+
export {ImagePreviewer} from './components/ImagePreviewer/ImagePreviewer';
|
126
128
|
|
127
129
|
export {VirtualTable} from './components/VirtualTable';
|
128
130
|
export {Table} from './components/Table';
|
@@ -275,6 +277,7 @@ export type{iRequestInterceptor} from './components/createRequestInterceptor';
|
|
275
277
|
export {createVirtualDraggier} from './components/createVirtualDraggier';
|
276
278
|
export {createWebDraggier} from './components/createWebDraggier';
|
277
279
|
export {createScrollDraggier} from './components/createScrollDraggier';
|
280
|
+
export {loadFile} from './components/loadFile'
|
278
281
|
|
279
282
|
// @ts-ignore
|
280
283
|
setComponentPrefix(globalComponentPrefix);
|
@@ -55,7 +55,7 @@
|
|
55
55
|
}
|
56
56
|
|
57
57
|
@mixin hover($component) {
|
58
|
-
&:not(.#{$component}-disabled):not(.#{$component}-loading):not(.#{$component}-readonly) {
|
58
|
+
&:not(.#{$component}-disabled):not(.#{$component}-loading):not(.#{$component}-readonly):not(.#{$component}-focus) {
|
59
59
|
&:hover, &.#{$component}-hover {
|
60
60
|
@content;
|
61
61
|
}
|
@@ -192,11 +192,11 @@ const parse = (str: string | undefined | null, format: string) => {
|
|
192
192
|
* @author 韦胜健
|
193
193
|
* @date 2021/1/18 10:30
|
194
194
|
*/
|
195
|
-
const today = (displayFormat
|
195
|
+
const today = (displayFormat = 'YYYY-MM-DD', valueFormat = 'YYYY-MM-DD') => {
|
196
196
|
return wrapDate(new Date(), { displayFormat, valueFormat });
|
197
197
|
};
|
198
198
|
|
199
|
-
const now = (displayFormat
|
199
|
+
const now = (displayFormat = 'YYYY-MM-DD HH:mm:ss', valueFormat = 'YYYY-MM-DD HH:mm:ss') => {
|
200
200
|
return wrapDate(new Date(), { displayFormat, valueFormat });
|
201
201
|
};
|
202
202
|
|