lupine.components 1.0.24 → 1.0.26
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/package.json +1 -1
- package/src/components/float-window.tsx +1 -1
- package/src/components/html-var.tsx +52 -31
- package/src/components/mobile-components/index.ts +1 -1
- package/src/components/mobile-components/mobile-header-component.tsx +3 -3
- package/src/components/mobile-components/mobile-header-title-icon.tsx +7 -24
- package/src/components/mobile-components/{mobile-frame-with-header.tsx → mobile-header-with-back.tsx} +7 -33
- package/src/components/modal.tsx +2 -0
- package/src/components/progress.tsx +2 -2
- package/src/frames/slider-frame.tsx +1 -1
package/package.json
CHANGED
|
@@ -46,7 +46,7 @@ export class FloatWindow {
|
|
|
46
46
|
handleClicked,
|
|
47
47
|
closeWhenClickOutside = false,
|
|
48
48
|
zIndex,
|
|
49
|
-
contentOverflowY = 'auto',
|
|
49
|
+
contentOverflowY = 'auto', // set to unset for having popup menu inside
|
|
50
50
|
}: FloatWindowShowProps): Promise<FloatWindowCloseProps> {
|
|
51
51
|
const onClickContainer = (event: any) => {
|
|
52
52
|
if (closeWhenClickOutside !== false && event.target.className === 'fwin-box') {
|
|
@@ -1,35 +1,56 @@
|
|
|
1
1
|
import { RefProps, VNode } from 'lupine.web';
|
|
2
2
|
|
|
3
3
|
export type HtmlVarResult = { value: string | VNode<any>; ref: RefProps; node: VNode<any> };
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
4
|
+
|
|
5
|
+
export class HtmlVar implements HtmlVarResult {
|
|
6
|
+
private _value: string | VNode<any>;
|
|
7
|
+
private _dirty = false;
|
|
8
|
+
private _ref: RefProps;
|
|
9
|
+
|
|
10
|
+
constructor(initial?: string | VNode<any>) {
|
|
11
|
+
this._value = initial || '';
|
|
12
|
+
this._ref = {
|
|
13
|
+
onLoad: async (el: Element) => {
|
|
14
|
+
this._dirty && this.waitUpdate(this._value);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private async waitUpdate(value: string | VNode<any>): Promise<void> {
|
|
20
|
+
if (!this._ref.current) return;
|
|
21
|
+
await this._ref.mountInnerComponent!(value);
|
|
22
|
+
this._dirty = false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
set value(value: string | VNode<any>) {
|
|
26
|
+
this._value = value;
|
|
27
|
+
this._dirty = true;
|
|
28
|
+
this.waitUpdate(value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get value(): string | VNode<any> {
|
|
32
|
+
return this._ref.current ? this._ref.current.innerHTML : this._value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get ref(): RefProps {
|
|
36
|
+
return this._ref;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get node(): VNode<any> {
|
|
40
|
+
this._dirty = false;
|
|
41
|
+
// the Fragment Tag will be present in the html if ref is assigned
|
|
42
|
+
return {
|
|
43
|
+
type: 'Fragment',
|
|
44
|
+
props: {
|
|
45
|
+
ref: this._ref,
|
|
46
|
+
children: this._value
|
|
47
|
+
},
|
|
48
|
+
html: []
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// For backward compatibility
|
|
54
|
+
export const createHtmlVar = (initial?: string | VNode<any>): HtmlVarResult => {
|
|
55
|
+
return new HtmlVar(initial);
|
|
35
56
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './icon-menu-item-props';
|
|
2
2
|
export * from './mobile-footer-menu';
|
|
3
|
-
export * from './mobile-
|
|
3
|
+
export * from './mobile-header-with-back';
|
|
4
4
|
export * from './mobile-header-component';
|
|
5
5
|
export * from './mobile-header-title-icon';
|
|
6
6
|
export * from './mobile-side-menu';
|
|
@@ -15,9 +15,9 @@ import { CssProps, HtmlVar, VNode } from 'lupine.components';
|
|
|
15
15
|
export class MobileHeaderHelper {
|
|
16
16
|
private static instance: MobileHeaderHelper;
|
|
17
17
|
|
|
18
|
-
private leftContent = HtmlVar('');
|
|
19
|
-
private centerContent = HtmlVar('');
|
|
20
|
-
private rightContent = HtmlVar('');
|
|
18
|
+
private leftContent = new HtmlVar('');
|
|
19
|
+
private centerContent = new HtmlVar('');
|
|
20
|
+
private rightContent = new HtmlVar('');
|
|
21
21
|
private constructor() {}
|
|
22
22
|
|
|
23
23
|
public static getInstance(): MobileHeaderHelper {
|
|
@@ -17,20 +17,14 @@ export const MobileHeaderEmptyIcon = () => {
|
|
|
17
17
|
return <div class='mhti-empty-icon' style={{ width: '28px' }}></div>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export interface MobileHeaderTitleIconHookProps {
|
|
21
|
-
updateTitle?: (title: VNode<any> | string) => void;
|
|
22
|
-
updateLeft?: (left: VNode<any>) => void;
|
|
23
|
-
updateRight?: (right: VNode<any>) => void;
|
|
24
|
-
}
|
|
25
20
|
export interface MobileHeaderTitleIconProps {
|
|
26
|
-
title: VNode<any> | string;
|
|
21
|
+
title: VNode<any> | string | HtmlVar;
|
|
27
22
|
onBack?: (event: Event) => void;
|
|
28
|
-
left?: VNode<any
|
|
29
|
-
right?: VNode<any
|
|
30
|
-
hook?: MobileHeaderTitleIconHookProps;
|
|
23
|
+
left?: VNode<any> | HtmlVar;
|
|
24
|
+
right?: VNode<any> | HtmlVar;
|
|
31
25
|
}
|
|
32
26
|
// there may have a few MobileHeaderTitleIcon for different pages
|
|
33
|
-
export const MobileHeaderTitleIcon = ({ title, onBack, left, right
|
|
27
|
+
export const MobileHeaderTitleIcon = ({ title, onBack, left, right }: MobileHeaderTitleIconProps) => {
|
|
34
28
|
// const processBack = (event: Event) => {
|
|
35
29
|
// if (onBack) {
|
|
36
30
|
// onBack(event);
|
|
@@ -81,20 +75,9 @@ export const MobileHeaderTitleIcon = ({ title, onBack, left, right, hook }: Mobi
|
|
|
81
75
|
},
|
|
82
76
|
};
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
hook.updateLeft = (left: VNode<any>) => {
|
|
89
|
-
domLeft.value = left;
|
|
90
|
-
};
|
|
91
|
-
hook.updateRight = (right: VNode<any>) => {
|
|
92
|
-
domRight.value = right;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
const domLeft = HtmlVar(left);
|
|
96
|
-
const domCenter = HtmlVar(title);
|
|
97
|
-
const domRight = HtmlVar(right);
|
|
78
|
+
const domLeft = left instanceof HtmlVar ? left : new HtmlVar(left);
|
|
79
|
+
const domCenter = title instanceof HtmlVar ? title : new HtmlVar(title);
|
|
80
|
+
const domRight = right instanceof HtmlVar ? right : new HtmlVar(right);
|
|
98
81
|
return (
|
|
99
82
|
<div css={css} class='mobile-header-title-icon-top'>
|
|
100
83
|
<div class='mhti-left'>{domLeft.node}</div>
|
|
@@ -20,11 +20,6 @@ export const HeaderWithBackFrameEmpty = () => {
|
|
|
20
20
|
return <div class='header-back-top-empty'></div>;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export interface HeaderWithBackFrameHookProps {
|
|
24
|
-
updateTitle?: (title: VNode<any> | string) => void;
|
|
25
|
-
updateLeft?: (left: VNode<any>) => void;
|
|
26
|
-
updateRight?: (right: VNode<any>) => void;
|
|
27
|
-
}
|
|
28
23
|
// there may have a few HeaderWithBackFrame one over another at the same time
|
|
29
24
|
export const HeaderWithBackFrame = ({
|
|
30
25
|
children,
|
|
@@ -32,15 +27,13 @@ export const HeaderWithBackFrame = ({
|
|
|
32
27
|
onBack,
|
|
33
28
|
left,
|
|
34
29
|
right,
|
|
35
|
-
hook,
|
|
36
30
|
noHeader = false,
|
|
37
31
|
}: {
|
|
38
32
|
children: VNode<any>;
|
|
39
|
-
title: VNode<any> | string;
|
|
33
|
+
title: VNode<any> | string | HtmlVar;
|
|
40
34
|
onBack: (event: Event) => void;
|
|
41
|
-
left?: VNode<any
|
|
42
|
-
right?: VNode<any
|
|
43
|
-
hook?: HeaderWithBackFrameHookProps;
|
|
35
|
+
left?: VNode<any> | HtmlVar;
|
|
36
|
+
right?: VNode<any> | HtmlVar;
|
|
44
37
|
noHeader?: boolean;
|
|
45
38
|
}) => {
|
|
46
39
|
left = left || <HeaderWithBackFrameLeft onClick={onBack} />;
|
|
@@ -94,32 +87,13 @@ export const HeaderWithBackFrame = ({
|
|
|
94
87
|
},
|
|
95
88
|
};
|
|
96
89
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
};
|
|
101
|
-
hook.updateLeft = (left: VNode<any>) => {
|
|
102
|
-
domLeft.value = left;
|
|
103
|
-
};
|
|
104
|
-
hook.updateRight = (right: VNode<any>) => {
|
|
105
|
-
domRight.value = right;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
const domLeft = HtmlVar(left);
|
|
109
|
-
const domCenter = HtmlVar(title);
|
|
110
|
-
const domRight = HtmlVar(right);
|
|
90
|
+
const domLeft = left instanceof HtmlVar ? left : new HtmlVar(left);
|
|
91
|
+
const domCenter = title instanceof HtmlVar ? title : new HtmlVar(title);
|
|
92
|
+
const domRight = right instanceof HtmlVar ? right : new HtmlVar(right);
|
|
111
93
|
const ref: RefProps = {};
|
|
112
94
|
return (
|
|
113
95
|
<div ref={ref} css={css} class='header-back-frame'>
|
|
114
|
-
{!noHeader &&
|
|
115
|
-
<MobileHeaderTitleIcon
|
|
116
|
-
onBack={onBack}
|
|
117
|
-
left={domLeft.node}
|
|
118
|
-
title={domCenter.node}
|
|
119
|
-
right={domRight.node}
|
|
120
|
-
hook={hook}
|
|
121
|
-
/>
|
|
122
|
-
)}
|
|
96
|
+
{!noHeader && <MobileHeaderTitleIcon onBack={onBack} left={domLeft} title={domCenter} right={domRight} />}
|
|
123
97
|
<div class='header-back-content'>{children}</div>
|
|
124
98
|
</div>
|
|
125
99
|
);
|
package/src/components/modal.tsx
CHANGED
|
@@ -13,6 +13,7 @@ export class ModalWindow {
|
|
|
13
13
|
handleClicked,
|
|
14
14
|
closeWhenClickOutside = true,
|
|
15
15
|
zIndex,
|
|
16
|
+
contentOverflowY,
|
|
16
17
|
}: FloatWindowShowProps): Promise<FloatWindowCloseProps> {
|
|
17
18
|
return FloatWindow.show({
|
|
18
19
|
title,
|
|
@@ -26,6 +27,7 @@ export class ModalWindow {
|
|
|
26
27
|
handleClicked,
|
|
27
28
|
closeWhenClickOutside,
|
|
28
29
|
zIndex,
|
|
30
|
+
contentOverflowY,
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
}
|
|
@@ -74,8 +74,8 @@ export const Progress = (props: ProgressProps) => {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
const ref: RefProps = {};
|
|
77
|
-
const domTitle = HtmlVar('Progress');
|
|
78
|
-
const dom = HtmlVar('0 %');
|
|
77
|
+
const domTitle = new HtmlVar('Progress');
|
|
78
|
+
const dom = new HtmlVar('0 %');
|
|
79
79
|
return (
|
|
80
80
|
<div ref={ref} css={css} class='progress-top d-none'>
|
|
81
81
|
<div class='progress-box'>
|
|
@@ -51,7 +51,7 @@ export const SliderFrame = (props: SliderFrameProps) => {
|
|
|
51
51
|
ref.current?.classList.add(className);
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
const dom = HtmlVar(<div class='slider-frame-default'>{props.defaultContent || '(No Content)'}</div>);
|
|
54
|
+
const dom = new HtmlVar(<div class='slider-frame-default'>{props.defaultContent || '(No Content)'}</div>);
|
|
55
55
|
const ref: RefProps = {};
|
|
56
56
|
const css: CssProps = {
|
|
57
57
|
display: 'flex',
|