lupine.components 1.1.13 → 1.1.15
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/README.md +3 -3
- package/package.json +42 -42
- package/src/components/action-sheet.tsx +419 -419
- package/src/components/button-push-animation.tsx +147 -138
- package/src/components/button.tsx +55 -55
- package/src/components/desktop-footer.tsx +17 -17
- package/src/components/desktop-header.tsx +52 -52
- package/src/components/drag-refresh.tsx +129 -129
- package/src/components/editable-label.tsx +83 -83
- package/src/components/float-window.tsx +233 -233
- package/src/components/grid.tsx +18 -18
- package/src/components/html-load.tsx +41 -41
- package/src/components/html-var.tsx +81 -81
- package/src/components/index.ts +43 -44
- package/src/components/input-with-title.tsx +24 -24
- package/src/components/link-item.tsx +13 -13
- package/src/components/link-list.tsx +62 -62
- package/src/components/menu-bar.tsx +219 -219
- package/src/components/menu-item-props.tsx +13 -13
- package/src/components/menu-sidebar.tsx +325 -318
- package/src/components/message-box.tsx +44 -44
- package/src/components/meta-data.tsx +36 -36
- package/src/components/meta-description.tsx +12 -12
- package/src/components/mobile-components/icon-menu-item-props.ts +6 -6
- package/src/components/mobile-components/index.ts +8 -9
- package/src/components/mobile-components/mobile-footer-menu.tsx +95 -95
- package/src/components/mobile-components/mobile-header-component.tsx +101 -101
- package/src/components/mobile-components/mobile-header-title-icon.tsx +109 -101
- package/src/components/mobile-components/mobile-header-with-back.tsx +127 -117
- package/src/components/mobile-components/mobile-side-menu.tsx +154 -154
- package/src/components/mobile-components/mobile-top-sys-icon.tsx +18 -18
- package/src/components/mobile-components/mobile-top-sys-menu.tsx +62 -62
- package/src/components/modal.tsx +33 -33
- package/src/components/notice-message.tsx +118 -118
- package/src/components/page-title.tsx +6 -6
- package/src/components/paging-link.tsx +175 -175
- package/src/components/panel.tsx +21 -21
- package/src/components/popup-menu.tsx +289 -289
- package/src/components/progress.tsx +91 -91
- package/src/components/radio-label-component.tsx +36 -36
- package/src/components/redirect.tsx +19 -19
- package/src/components/resizable-splitter.tsx +128 -128
- package/src/components/select-angle-component.tsx +127 -127
- package/src/components/select-with-title.tsx +37 -37
- package/src/components/slide-tab-component.tsx +144 -149
- package/src/components/spinner.tsx +106 -100
- package/src/components/stars-component.tsx +66 -66
- package/src/components/svg.tsx +24 -24
- package/src/components/tabs.tsx +279 -279
- package/src/components/text-glow.tsx +37 -37
- package/src/components/text-scale.tsx +42 -42
- package/src/components/text-wave.tsx +55 -55
- package/src/components/theme-selector.tsx +28 -28
- package/src/components/toggle-base.tsx +285 -269
- package/src/components/toggle-switch.tsx +160 -160
- package/src/frames/index.ts +3 -3
- package/src/frames/responsive-frame.tsx +83 -83
- package/src/frames/slider-frame.tsx +111 -111
- package/src/frames/top-frame.tsx +30 -30
- package/src/index.ts +5 -5
- package/src/lib/back-action-helper.ts +54 -54
- package/src/lib/base62.ts +23 -23
- package/src/lib/blob-utils.ts +23 -23
- package/src/lib/calculate-text-width.ts +13 -13
- package/src/lib/date-utils.ts +317 -317
- package/src/lib/deep-merge.ts +37 -37
- package/src/lib/document-ready.ts +34 -34
- package/src/lib/dom-utils.ts +32 -32
- package/src/lib/download-file.ts +118 -118
- package/src/lib/download-link.ts +12 -12
- package/src/lib/download-stream.ts +19 -19
- package/src/lib/drag-util.ts +118 -118
- package/src/lib/dynamical-load.ts +134 -134
- package/src/lib/encode-html.ts +27 -27
- package/src/lib/find-parent-tag.ts +8 -8
- package/src/lib/format-bytes.ts +11 -11
- package/src/lib/index.ts +24 -24
- package/src/lib/lite-dom.ts +225 -225
- package/src/lib/message-hub.ts +103 -104
- package/src/lib/observable.ts +188 -188
- package/src/lib/path-utils.ts +42 -42
- package/src/lib/promise-timeout.ts +1 -1
- package/src/lib/simple-storage.ts +40 -40
- package/src/lib/stop-propagation.ts +7 -7
- package/src/lib/upload-file.ts +101 -101
- package/src/styles/base-themes.ts +17 -17
- package/src/styles/dark-themes.ts +99 -99
- package/src/styles/index.ts +5 -5
- package/src/styles/light-themes.ts +106 -106
- package/src/styles/media-query.ts +93 -93
- package/src/styles/shared-themes.ts +57 -57
- package/tsconfig.json +113 -113
|
@@ -1,289 +1,289 @@
|
|
|
1
|
-
import { CssProps, RefProps, VNode } from 'lupine.web';
|
|
2
|
-
import { stopPropagation } from '../lib';
|
|
3
|
-
|
|
4
|
-
export type PopupMenuHookProps = {
|
|
5
|
-
openMenu?: (event?: MouseEvent) => void;
|
|
6
|
-
getValue?: () => string;
|
|
7
|
-
setLabel?: (label: string) => void;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// defaultValue=<i class='ifc-icon co-cil-hamburger-menu'></i>
|
|
11
|
-
export const PopupMenuWithIcon = (props: PopupMenuProps) => {
|
|
12
|
-
const hook: PopupMenuHookProps = {};
|
|
13
|
-
const css: CssProps = {
|
|
14
|
-
cursor: 'pointer',
|
|
15
|
-
display: 'flex',
|
|
16
|
-
flexDirection: 'row',
|
|
17
|
-
alignItems: 'center',
|
|
18
|
-
fontSize: '24px',
|
|
19
|
-
};
|
|
20
|
-
return (
|
|
21
|
-
<div
|
|
22
|
-
onClick={() => {
|
|
23
|
-
hook.openMenu && hook.openMenu();
|
|
24
|
-
}}
|
|
25
|
-
css={css}
|
|
26
|
-
>
|
|
27
|
-
<PopupMenu
|
|
28
|
-
list={props.list}
|
|
29
|
-
defaultValue={props.defaultValue}
|
|
30
|
-
tips={props.tips}
|
|
31
|
-
minWidth={props.minWidth}
|
|
32
|
-
maxWidth={props.maxWidth}
|
|
33
|
-
maxHeight={props.maxHeight}
|
|
34
|
-
handleSelected={props.handleSelected}
|
|
35
|
-
handleOpened={props.handleOpened}
|
|
36
|
-
handleClosed={props.handleClosed}
|
|
37
|
-
noUpdateLabel={props.noUpdateLabel}
|
|
38
|
-
hook={hook}
|
|
39
|
-
noTriangleIcon={props.noTriangleIcon}
|
|
40
|
-
></PopupMenu>
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type PopupMenuProps = {
|
|
46
|
-
list: string[];
|
|
47
|
-
defaultValue: string;
|
|
48
|
-
tips?: string;
|
|
49
|
-
minWidth?: string;
|
|
50
|
-
maxWidth?: string;
|
|
51
|
-
maxHeight?: string;
|
|
52
|
-
handleSelected?: Function;
|
|
53
|
-
handleOpened?: Function;
|
|
54
|
-
handleClosed?: Function;
|
|
55
|
-
noUpdateLabel?: boolean;
|
|
56
|
-
hook?: PopupMenuHookProps;
|
|
57
|
-
noTriangleIcon?: boolean;
|
|
58
|
-
align?: 'left' | 'right';
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export type PopupMenuWithButtonProps = { label: string } & PopupMenuProps;
|
|
62
|
-
|
|
63
|
-
export const PopupMenuWithButton = (props: PopupMenuWithButtonProps) => {
|
|
64
|
-
const hook: PopupMenuHookProps = {};
|
|
65
|
-
return (
|
|
66
|
-
<button
|
|
67
|
-
class='button-base'
|
|
68
|
-
onClick={() => {
|
|
69
|
-
hook.openMenu && hook.openMenu();
|
|
70
|
-
}}
|
|
71
|
-
css={{ '>div': { float: 'right', textAlign: 'left' } }}
|
|
72
|
-
>
|
|
73
|
-
{props.label}:{' '}
|
|
74
|
-
<PopupMenu
|
|
75
|
-
list={props.list}
|
|
76
|
-
defaultValue={props.defaultValue}
|
|
77
|
-
tips={props.tips}
|
|
78
|
-
minWidth={props.minWidth}
|
|
79
|
-
maxWidth={props.maxWidth}
|
|
80
|
-
maxHeight={props.maxHeight}
|
|
81
|
-
handleSelected={props.handleSelected}
|
|
82
|
-
handleOpened={props.handleOpened}
|
|
83
|
-
handleClosed={props.handleClosed}
|
|
84
|
-
noUpdateLabel={props.noUpdateLabel}
|
|
85
|
-
hook={hook}
|
|
86
|
-
noTriangleIcon={props.noTriangleIcon}
|
|
87
|
-
align={props.align}
|
|
88
|
-
></PopupMenu>
|
|
89
|
-
</button>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export type PopupMenuWithLabelProps = { label: string } & PopupMenuProps;
|
|
94
|
-
|
|
95
|
-
export const PopupMenuWithLabel = (props: PopupMenuWithLabelProps) => {
|
|
96
|
-
const hook: PopupMenuHookProps = {};
|
|
97
|
-
return (
|
|
98
|
-
<div
|
|
99
|
-
onClick={() => {
|
|
100
|
-
hook.openMenu && hook.openMenu();
|
|
101
|
-
}}
|
|
102
|
-
css={{ cursor: 'pointer', '>div': { float: 'right', textAlign: 'left' } }}
|
|
103
|
-
>
|
|
104
|
-
{props.label}:{' '}
|
|
105
|
-
<PopupMenu
|
|
106
|
-
list={props.list}
|
|
107
|
-
defaultValue={props.defaultValue}
|
|
108
|
-
tips={props.tips}
|
|
109
|
-
minWidth={props.minWidth}
|
|
110
|
-
maxWidth={props.maxWidth}
|
|
111
|
-
maxHeight={props.maxHeight}
|
|
112
|
-
handleSelected={props.handleSelected}
|
|
113
|
-
handleOpened={props.handleOpened}
|
|
114
|
-
handleClosed={props.handleClosed}
|
|
115
|
-
noUpdateLabel={props.noUpdateLabel}
|
|
116
|
-
hook={hook}
|
|
117
|
-
noTriangleIcon={props.noTriangleIcon}
|
|
118
|
-
align={props.align}
|
|
119
|
-
></PopupMenu>
|
|
120
|
-
</div>
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export const PopupMenu = ({
|
|
125
|
-
list,
|
|
126
|
-
defaultValue,
|
|
127
|
-
tips = '',
|
|
128
|
-
minWidth,
|
|
129
|
-
maxWidth,
|
|
130
|
-
maxHeight,
|
|
131
|
-
handleSelected,
|
|
132
|
-
handleOpened,
|
|
133
|
-
handleClosed,
|
|
134
|
-
noUpdateLabel,
|
|
135
|
-
hook,
|
|
136
|
-
align = 'right',
|
|
137
|
-
noTriangleIcon,
|
|
138
|
-
}: PopupMenuProps) => {
|
|
139
|
-
const css: CssProps = {
|
|
140
|
-
'.popup-menu-item': {
|
|
141
|
-
padding: '0 0 1px 0',
|
|
142
|
-
display: 'inline-block',
|
|
143
|
-
position: 'relative',
|
|
144
|
-
'.triangle-icon': {
|
|
145
|
-
display: 'inline-block',
|
|
146
|
-
cursor: 'pointer',
|
|
147
|
-
whiteSpace: 'nowrap',
|
|
148
|
-
marginRight: '15px',
|
|
149
|
-
},
|
|
150
|
-
// cover-box-shadow
|
|
151
|
-
'.triangle-icon::after': {
|
|
152
|
-
content: '""',
|
|
153
|
-
position: 'absolute',
|
|
154
|
-
top: '50%',
|
|
155
|
-
transform: 'translateY(-50%)',
|
|
156
|
-
marginLeft: '3px',
|
|
157
|
-
width: 0,
|
|
158
|
-
height: 0,
|
|
159
|
-
borderLeft: '5px solid transparent',
|
|
160
|
-
borderRight: '5px solid transparent',
|
|
161
|
-
borderTop: '5px solid var(--primary-color)',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
'.popup-menu-item:hover': {
|
|
165
|
-
padding: '1px 0 0 0',
|
|
166
|
-
},
|
|
167
|
-
'.popup-menu-bottom': {
|
|
168
|
-
position: 'relative',
|
|
169
|
-
height: '1px',
|
|
170
|
-
'.popup-menu-list': {
|
|
171
|
-
display: 'none',
|
|
172
|
-
position: 'absolute',
|
|
173
|
-
fontSize: 'var(--menu-font-size)',
|
|
174
|
-
top: 0,
|
|
175
|
-
width: '100px',
|
|
176
|
-
color: 'var(--activatable-color-normal)',
|
|
177
|
-
backgroundColor: 'var(--activatable-bg-color-normal)',
|
|
178
|
-
zIndex: 'var(--layer-menu)',
|
|
179
|
-
borderRadius: '4px',
|
|
180
|
-
border: '1px solid #ddd',
|
|
181
|
-
padding: '5px 0px',
|
|
182
|
-
overflow: 'auto',
|
|
183
|
-
'line-height': '1.2em',
|
|
184
|
-
'min-width': minWidth || 'auto',
|
|
185
|
-
'max-width': maxWidth || '200px',
|
|
186
|
-
'max-height': maxHeight || '300px',
|
|
187
|
-
'box-shadow': 'var(--cover-box-shadow)', //'#0000004c 0px 19px 38px, #00000038 0px 15px 12px',
|
|
188
|
-
'.menu-focus': {
|
|
189
|
-
position: 'absolute',
|
|
190
|
-
height: '0px',
|
|
191
|
-
},
|
|
192
|
-
'.item': {
|
|
193
|
-
padding: '2px 12px',
|
|
194
|
-
},
|
|
195
|
-
'.item:hover': {
|
|
196
|
-
padding: '2px 11px 2px 13px',
|
|
197
|
-
color: 'var(--activatable-color-hover)',
|
|
198
|
-
backgroundColor: 'var(--activatable-bg-color-hover)',
|
|
199
|
-
cursor: 'pointer',
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
'.popup-menu-list.left-align': {
|
|
203
|
-
left: '2px',
|
|
204
|
-
},
|
|
205
|
-
'.popup-menu-list.right-align': {
|
|
206
|
-
right: '2px',
|
|
207
|
-
},
|
|
208
|
-
'.popup-menu-list.open': {
|
|
209
|
-
display: 'inline-block',
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
let ref: RefProps = { id: '' };
|
|
215
|
-
let isShowing = false;
|
|
216
|
-
let selectedValue = defaultValue;
|
|
217
|
-
const openMenu = (event?: MouseEvent) => {
|
|
218
|
-
stopPropagation(event);
|
|
219
|
-
|
|
220
|
-
handleOpened && handleOpened();
|
|
221
|
-
// console.log('=======22', event);
|
|
222
|
-
isShowing = !isShowing;
|
|
223
|
-
const listDom = ref.$('.popup-menu-list');
|
|
224
|
-
if (align === 'left') {
|
|
225
|
-
listDom.classList.add('left-align');
|
|
226
|
-
} else {
|
|
227
|
-
listDom.classList.add('right-align');
|
|
228
|
-
}
|
|
229
|
-
listDom.classList.toggle('open', isShowing);
|
|
230
|
-
ref.$('.popup-menu-list .menu-focus').focus();
|
|
231
|
-
};
|
|
232
|
-
if (hook) {
|
|
233
|
-
hook.openMenu = openMenu;
|
|
234
|
-
hook.getValue = () => selectedValue;
|
|
235
|
-
hook.setLabel = (label: string) => {
|
|
236
|
-
ref.$('.popup-menu-item .popup-menu-text').innerText = label;
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
const itemClick = (event: any) => {
|
|
240
|
-
stopPropagation(event);
|
|
241
|
-
|
|
242
|
-
// console.log('=======', event);
|
|
243
|
-
isShowing = false;
|
|
244
|
-
ref.$('.popup-menu-list').classList.remove('open');
|
|
245
|
-
if (event.target) {
|
|
246
|
-
selectedValue = event.target.innerText;
|
|
247
|
-
if (noUpdateLabel !== true) {
|
|
248
|
-
ref.$('.popup-menu-item .popup-menu-text').innerText = event.target.innerText;
|
|
249
|
-
}
|
|
250
|
-
if (handleSelected) {
|
|
251
|
-
handleSelected(event.target.innerText);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
handleClosed && handleClosed();
|
|
255
|
-
};
|
|
256
|
-
const onBlur = (event: any) => {
|
|
257
|
-
setTimeout(() => {
|
|
258
|
-
ref.$('.popup-menu-list').classList.remove('open');
|
|
259
|
-
isShowing && handleClosed && handleClosed();
|
|
260
|
-
isShowing = false;
|
|
261
|
-
}, 300);
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
return (
|
|
265
|
-
<div ref={ref} css={css} onClick={openMenu} title={tips}>
|
|
266
|
-
<div class='popup-menu-item'>
|
|
267
|
-
<span class={'popup-menu-text' + (noTriangleIcon !== true ? ' triangle-icon' : '')}>
|
|
268
|
-
{defaultValue || ' '}
|
|
269
|
-
</span>
|
|
270
|
-
</div>
|
|
271
|
-
<div class='popup-menu-bottom'>
|
|
272
|
-
<div class='popup-menu-list'>
|
|
273
|
-
<div>
|
|
274
|
-
{list.map((item) => {
|
|
275
|
-
return item === '' ? (
|
|
276
|
-
<hr />
|
|
277
|
-
) : (
|
|
278
|
-
<div class='item' onClick={itemClick}>
|
|
279
|
-
{item}
|
|
280
|
-
</div>
|
|
281
|
-
);
|
|
282
|
-
})}
|
|
283
|
-
</div>
|
|
284
|
-
<div class='menu-focus' onBlur={onBlur} tabIndex={0}></div>
|
|
285
|
-
</div>
|
|
286
|
-
</div>
|
|
287
|
-
</div>
|
|
288
|
-
);
|
|
289
|
-
};
|
|
1
|
+
import { CssProps, RefProps, VNode } from 'lupine.web';
|
|
2
|
+
import { stopPropagation } from '../lib';
|
|
3
|
+
|
|
4
|
+
export type PopupMenuHookProps = {
|
|
5
|
+
openMenu?: (event?: MouseEvent) => void;
|
|
6
|
+
getValue?: () => string;
|
|
7
|
+
setLabel?: (label: string) => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// defaultValue=<i class='ifc-icon co-cil-hamburger-menu'></i>
|
|
11
|
+
export const PopupMenuWithIcon = (props: PopupMenuProps) => {
|
|
12
|
+
const hook: PopupMenuHookProps = {};
|
|
13
|
+
const css: CssProps = {
|
|
14
|
+
cursor: 'pointer',
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flexDirection: 'row',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
fontSize: '24px',
|
|
19
|
+
};
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
onClick={() => {
|
|
23
|
+
hook.openMenu && hook.openMenu();
|
|
24
|
+
}}
|
|
25
|
+
css={css}
|
|
26
|
+
>
|
|
27
|
+
<PopupMenu
|
|
28
|
+
list={props.list}
|
|
29
|
+
defaultValue={props.defaultValue}
|
|
30
|
+
tips={props.tips}
|
|
31
|
+
minWidth={props.minWidth}
|
|
32
|
+
maxWidth={props.maxWidth}
|
|
33
|
+
maxHeight={props.maxHeight}
|
|
34
|
+
handleSelected={props.handleSelected}
|
|
35
|
+
handleOpened={props.handleOpened}
|
|
36
|
+
handleClosed={props.handleClosed}
|
|
37
|
+
noUpdateLabel={props.noUpdateLabel}
|
|
38
|
+
hook={hook}
|
|
39
|
+
noTriangleIcon={props.noTriangleIcon}
|
|
40
|
+
></PopupMenu>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type PopupMenuProps = {
|
|
46
|
+
list: string[];
|
|
47
|
+
defaultValue: string;
|
|
48
|
+
tips?: string;
|
|
49
|
+
minWidth?: string;
|
|
50
|
+
maxWidth?: string;
|
|
51
|
+
maxHeight?: string;
|
|
52
|
+
handleSelected?: Function;
|
|
53
|
+
handleOpened?: Function;
|
|
54
|
+
handleClosed?: Function;
|
|
55
|
+
noUpdateLabel?: boolean;
|
|
56
|
+
hook?: PopupMenuHookProps;
|
|
57
|
+
noTriangleIcon?: boolean;
|
|
58
|
+
align?: 'left' | 'right';
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type PopupMenuWithButtonProps = { label: string } & PopupMenuProps;
|
|
62
|
+
|
|
63
|
+
export const PopupMenuWithButton = (props: PopupMenuWithButtonProps) => {
|
|
64
|
+
const hook: PopupMenuHookProps = {};
|
|
65
|
+
return (
|
|
66
|
+
<button
|
|
67
|
+
class='button-base'
|
|
68
|
+
onClick={() => {
|
|
69
|
+
hook.openMenu && hook.openMenu();
|
|
70
|
+
}}
|
|
71
|
+
css={{ '>div': { float: 'right', textAlign: 'left' } }}
|
|
72
|
+
>
|
|
73
|
+
{props.label}:{' '}
|
|
74
|
+
<PopupMenu
|
|
75
|
+
list={props.list}
|
|
76
|
+
defaultValue={props.defaultValue}
|
|
77
|
+
tips={props.tips}
|
|
78
|
+
minWidth={props.minWidth}
|
|
79
|
+
maxWidth={props.maxWidth}
|
|
80
|
+
maxHeight={props.maxHeight}
|
|
81
|
+
handleSelected={props.handleSelected}
|
|
82
|
+
handleOpened={props.handleOpened}
|
|
83
|
+
handleClosed={props.handleClosed}
|
|
84
|
+
noUpdateLabel={props.noUpdateLabel}
|
|
85
|
+
hook={hook}
|
|
86
|
+
noTriangleIcon={props.noTriangleIcon}
|
|
87
|
+
align={props.align}
|
|
88
|
+
></PopupMenu>
|
|
89
|
+
</button>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type PopupMenuWithLabelProps = { label: string } & PopupMenuProps;
|
|
94
|
+
|
|
95
|
+
export const PopupMenuWithLabel = (props: PopupMenuWithLabelProps) => {
|
|
96
|
+
const hook: PopupMenuHookProps = {};
|
|
97
|
+
return (
|
|
98
|
+
<div
|
|
99
|
+
onClick={() => {
|
|
100
|
+
hook.openMenu && hook.openMenu();
|
|
101
|
+
}}
|
|
102
|
+
css={{ cursor: 'pointer', '>div': { float: 'right', textAlign: 'left' } }}
|
|
103
|
+
>
|
|
104
|
+
{props.label}:{' '}
|
|
105
|
+
<PopupMenu
|
|
106
|
+
list={props.list}
|
|
107
|
+
defaultValue={props.defaultValue}
|
|
108
|
+
tips={props.tips}
|
|
109
|
+
minWidth={props.minWidth}
|
|
110
|
+
maxWidth={props.maxWidth}
|
|
111
|
+
maxHeight={props.maxHeight}
|
|
112
|
+
handleSelected={props.handleSelected}
|
|
113
|
+
handleOpened={props.handleOpened}
|
|
114
|
+
handleClosed={props.handleClosed}
|
|
115
|
+
noUpdateLabel={props.noUpdateLabel}
|
|
116
|
+
hook={hook}
|
|
117
|
+
noTriangleIcon={props.noTriangleIcon}
|
|
118
|
+
align={props.align}
|
|
119
|
+
></PopupMenu>
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const PopupMenu = ({
|
|
125
|
+
list,
|
|
126
|
+
defaultValue,
|
|
127
|
+
tips = '',
|
|
128
|
+
minWidth,
|
|
129
|
+
maxWidth,
|
|
130
|
+
maxHeight,
|
|
131
|
+
handleSelected,
|
|
132
|
+
handleOpened,
|
|
133
|
+
handleClosed,
|
|
134
|
+
noUpdateLabel,
|
|
135
|
+
hook,
|
|
136
|
+
align = 'right',
|
|
137
|
+
noTriangleIcon,
|
|
138
|
+
}: PopupMenuProps) => {
|
|
139
|
+
const css: CssProps = {
|
|
140
|
+
'.popup-menu-item': {
|
|
141
|
+
padding: '0 0 1px 0',
|
|
142
|
+
display: 'inline-block',
|
|
143
|
+
position: 'relative',
|
|
144
|
+
'.triangle-icon': {
|
|
145
|
+
display: 'inline-block',
|
|
146
|
+
cursor: 'pointer',
|
|
147
|
+
whiteSpace: 'nowrap',
|
|
148
|
+
marginRight: '15px',
|
|
149
|
+
},
|
|
150
|
+
// cover-box-shadow
|
|
151
|
+
'.triangle-icon::after': {
|
|
152
|
+
content: '""',
|
|
153
|
+
position: 'absolute',
|
|
154
|
+
top: '50%',
|
|
155
|
+
transform: 'translateY(-50%)',
|
|
156
|
+
marginLeft: '3px',
|
|
157
|
+
width: 0,
|
|
158
|
+
height: 0,
|
|
159
|
+
borderLeft: '5px solid transparent',
|
|
160
|
+
borderRight: '5px solid transparent',
|
|
161
|
+
borderTop: '5px solid var(--primary-color)',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
'.popup-menu-item:hover': {
|
|
165
|
+
padding: '1px 0 0 0',
|
|
166
|
+
},
|
|
167
|
+
'.popup-menu-bottom': {
|
|
168
|
+
position: 'relative',
|
|
169
|
+
height: '1px',
|
|
170
|
+
'.popup-menu-list': {
|
|
171
|
+
display: 'none',
|
|
172
|
+
position: 'absolute',
|
|
173
|
+
fontSize: 'var(--menu-font-size)',
|
|
174
|
+
top: 0,
|
|
175
|
+
width: '100px',
|
|
176
|
+
color: 'var(--activatable-color-normal)',
|
|
177
|
+
backgroundColor: 'var(--activatable-bg-color-normal)',
|
|
178
|
+
zIndex: 'var(--layer-menu)',
|
|
179
|
+
borderRadius: '4px',
|
|
180
|
+
border: '1px solid #ddd',
|
|
181
|
+
padding: '5px 0px',
|
|
182
|
+
overflow: 'auto',
|
|
183
|
+
'line-height': '1.2em',
|
|
184
|
+
'min-width': minWidth || 'auto',
|
|
185
|
+
'max-width': maxWidth || '200px',
|
|
186
|
+
'max-height': maxHeight || '300px',
|
|
187
|
+
'box-shadow': 'var(--cover-box-shadow)', //'#0000004c 0px 19px 38px, #00000038 0px 15px 12px',
|
|
188
|
+
'.menu-focus': {
|
|
189
|
+
position: 'absolute',
|
|
190
|
+
height: '0px',
|
|
191
|
+
},
|
|
192
|
+
'.item': {
|
|
193
|
+
padding: '2px 12px',
|
|
194
|
+
},
|
|
195
|
+
'.item:hover': {
|
|
196
|
+
padding: '2px 11px 2px 13px',
|
|
197
|
+
color: 'var(--activatable-color-hover)',
|
|
198
|
+
backgroundColor: 'var(--activatable-bg-color-hover)',
|
|
199
|
+
cursor: 'pointer',
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
'.popup-menu-list.left-align': {
|
|
203
|
+
left: '2px',
|
|
204
|
+
},
|
|
205
|
+
'.popup-menu-list.right-align': {
|
|
206
|
+
right: '2px',
|
|
207
|
+
},
|
|
208
|
+
'.popup-menu-list.open': {
|
|
209
|
+
display: 'inline-block',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
let ref: RefProps = { id: '' };
|
|
215
|
+
let isShowing = false;
|
|
216
|
+
let selectedValue = defaultValue;
|
|
217
|
+
const openMenu = (event?: MouseEvent) => {
|
|
218
|
+
stopPropagation(event);
|
|
219
|
+
|
|
220
|
+
handleOpened && handleOpened();
|
|
221
|
+
// console.log('=======22', event);
|
|
222
|
+
isShowing = !isShowing;
|
|
223
|
+
const listDom = ref.$('.popup-menu-list');
|
|
224
|
+
if (align === 'left') {
|
|
225
|
+
listDom.classList.add('left-align');
|
|
226
|
+
} else {
|
|
227
|
+
listDom.classList.add('right-align');
|
|
228
|
+
}
|
|
229
|
+
listDom.classList.toggle('open', isShowing);
|
|
230
|
+
ref.$('.popup-menu-list .menu-focus').focus();
|
|
231
|
+
};
|
|
232
|
+
if (hook) {
|
|
233
|
+
hook.openMenu = openMenu;
|
|
234
|
+
hook.getValue = () => selectedValue;
|
|
235
|
+
hook.setLabel = (label: string) => {
|
|
236
|
+
ref.$('.popup-menu-item .popup-menu-text').innerText = label;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
const itemClick = (event: any) => {
|
|
240
|
+
stopPropagation(event);
|
|
241
|
+
|
|
242
|
+
// console.log('=======', event);
|
|
243
|
+
isShowing = false;
|
|
244
|
+
ref.$('.popup-menu-list').classList.remove('open');
|
|
245
|
+
if (event.target) {
|
|
246
|
+
selectedValue = event.target.innerText;
|
|
247
|
+
if (noUpdateLabel !== true) {
|
|
248
|
+
ref.$('.popup-menu-item .popup-menu-text').innerText = event.target.innerText;
|
|
249
|
+
}
|
|
250
|
+
if (handleSelected) {
|
|
251
|
+
handleSelected(event.target.innerText);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
handleClosed && handleClosed();
|
|
255
|
+
};
|
|
256
|
+
const onBlur = (event: any) => {
|
|
257
|
+
setTimeout(() => {
|
|
258
|
+
ref.$('.popup-menu-list').classList.remove('open');
|
|
259
|
+
isShowing && handleClosed && handleClosed();
|
|
260
|
+
isShowing = false;
|
|
261
|
+
}, 300);
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<div ref={ref} css={css} onClick={openMenu} title={tips}>
|
|
266
|
+
<div class='popup-menu-item'>
|
|
267
|
+
<span class={'popup-menu-text' + (noTriangleIcon !== true ? ' triangle-icon' : '')}>
|
|
268
|
+
{defaultValue || ' '}
|
|
269
|
+
</span>
|
|
270
|
+
</div>
|
|
271
|
+
<div class='popup-menu-bottom'>
|
|
272
|
+
<div class='popup-menu-list'>
|
|
273
|
+
<div>
|
|
274
|
+
{list.map((item) => {
|
|
275
|
+
return item === '' ? (
|
|
276
|
+
<hr />
|
|
277
|
+
) : (
|
|
278
|
+
<div class='item' onClick={itemClick}>
|
|
279
|
+
{item}
|
|
280
|
+
</div>
|
|
281
|
+
);
|
|
282
|
+
})}
|
|
283
|
+
</div>
|
|
284
|
+
<div class='menu-focus' onBlur={onBlur} tabIndex={0}></div>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
);
|
|
289
|
+
};
|