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.
Files changed (92) hide show
  1. package/README.md +3 -3
  2. package/package.json +42 -42
  3. package/src/components/action-sheet.tsx +419 -419
  4. package/src/components/button-push-animation.tsx +147 -138
  5. package/src/components/button.tsx +55 -55
  6. package/src/components/desktop-footer.tsx +17 -17
  7. package/src/components/desktop-header.tsx +52 -52
  8. package/src/components/drag-refresh.tsx +129 -129
  9. package/src/components/editable-label.tsx +83 -83
  10. package/src/components/float-window.tsx +233 -233
  11. package/src/components/grid.tsx +18 -18
  12. package/src/components/html-load.tsx +41 -41
  13. package/src/components/html-var.tsx +81 -81
  14. package/src/components/index.ts +43 -44
  15. package/src/components/input-with-title.tsx +24 -24
  16. package/src/components/link-item.tsx +13 -13
  17. package/src/components/link-list.tsx +62 -62
  18. package/src/components/menu-bar.tsx +219 -219
  19. package/src/components/menu-item-props.tsx +13 -13
  20. package/src/components/menu-sidebar.tsx +325 -318
  21. package/src/components/message-box.tsx +44 -44
  22. package/src/components/meta-data.tsx +36 -36
  23. package/src/components/meta-description.tsx +12 -12
  24. package/src/components/mobile-components/icon-menu-item-props.ts +6 -6
  25. package/src/components/mobile-components/index.ts +8 -9
  26. package/src/components/mobile-components/mobile-footer-menu.tsx +95 -95
  27. package/src/components/mobile-components/mobile-header-component.tsx +101 -101
  28. package/src/components/mobile-components/mobile-header-title-icon.tsx +109 -101
  29. package/src/components/mobile-components/mobile-header-with-back.tsx +127 -117
  30. package/src/components/mobile-components/mobile-side-menu.tsx +154 -154
  31. package/src/components/mobile-components/mobile-top-sys-icon.tsx +18 -18
  32. package/src/components/mobile-components/mobile-top-sys-menu.tsx +62 -62
  33. package/src/components/modal.tsx +33 -33
  34. package/src/components/notice-message.tsx +118 -118
  35. package/src/components/page-title.tsx +6 -6
  36. package/src/components/paging-link.tsx +175 -175
  37. package/src/components/panel.tsx +21 -21
  38. package/src/components/popup-menu.tsx +289 -289
  39. package/src/components/progress.tsx +91 -91
  40. package/src/components/radio-label-component.tsx +36 -36
  41. package/src/components/redirect.tsx +19 -19
  42. package/src/components/resizable-splitter.tsx +128 -128
  43. package/src/components/select-angle-component.tsx +127 -127
  44. package/src/components/select-with-title.tsx +37 -37
  45. package/src/components/slide-tab-component.tsx +144 -149
  46. package/src/components/spinner.tsx +106 -100
  47. package/src/components/stars-component.tsx +66 -66
  48. package/src/components/svg.tsx +24 -24
  49. package/src/components/tabs.tsx +279 -279
  50. package/src/components/text-glow.tsx +37 -37
  51. package/src/components/text-scale.tsx +42 -42
  52. package/src/components/text-wave.tsx +55 -55
  53. package/src/components/theme-selector.tsx +28 -28
  54. package/src/components/toggle-base.tsx +285 -269
  55. package/src/components/toggle-switch.tsx +160 -160
  56. package/src/frames/index.ts +3 -3
  57. package/src/frames/responsive-frame.tsx +83 -83
  58. package/src/frames/slider-frame.tsx +111 -111
  59. package/src/frames/top-frame.tsx +30 -30
  60. package/src/index.ts +5 -5
  61. package/src/lib/back-action-helper.ts +54 -54
  62. package/src/lib/base62.ts +23 -23
  63. package/src/lib/blob-utils.ts +23 -23
  64. package/src/lib/calculate-text-width.ts +13 -13
  65. package/src/lib/date-utils.ts +317 -317
  66. package/src/lib/deep-merge.ts +37 -37
  67. package/src/lib/document-ready.ts +34 -34
  68. package/src/lib/dom-utils.ts +32 -32
  69. package/src/lib/download-file.ts +118 -118
  70. package/src/lib/download-link.ts +12 -12
  71. package/src/lib/download-stream.ts +19 -19
  72. package/src/lib/drag-util.ts +118 -118
  73. package/src/lib/dynamical-load.ts +134 -134
  74. package/src/lib/encode-html.ts +27 -27
  75. package/src/lib/find-parent-tag.ts +8 -8
  76. package/src/lib/format-bytes.ts +11 -11
  77. package/src/lib/index.ts +24 -24
  78. package/src/lib/lite-dom.ts +225 -225
  79. package/src/lib/message-hub.ts +103 -104
  80. package/src/lib/observable.ts +188 -188
  81. package/src/lib/path-utils.ts +42 -42
  82. package/src/lib/promise-timeout.ts +1 -1
  83. package/src/lib/simple-storage.ts +40 -40
  84. package/src/lib/stop-propagation.ts +7 -7
  85. package/src/lib/upload-file.ts +101 -101
  86. package/src/styles/base-themes.ts +17 -17
  87. package/src/styles/dark-themes.ts +99 -99
  88. package/src/styles/index.ts +5 -5
  89. package/src/styles/light-themes.ts +106 -106
  90. package/src/styles/media-query.ts +93 -93
  91. package/src/styles/shared-themes.ts +57 -57
  92. package/tsconfig.json +113 -113
@@ -1,419 +1,419 @@
1
- import { CssProps, RefProps, VNode, mountInnerComponent } from 'lupine.web';
2
- import { backActionHelper } from '../lib';
3
-
4
- export type ActionSheetCloseProps = (reason?: ActionSheetCloseReasonProps) => void;
5
-
6
- export type ActionSheetCloseReasonProps = 'cancel' | 'confirm' | 'select' | undefined;
7
-
8
- export type ActionSheetShowProps = {
9
- title: string;
10
- children: string | VNode<any>;
11
- contentMaxWidth?: string;
12
- contentMaxHeight?: string;
13
- closeEvent?: (reason?: ActionSheetCloseReasonProps) => void;
14
- closeWhenClickOutside?: boolean; // default true
15
- confirmButtonText?: string; // no showing if not set
16
- handleConfirmClicked?: (close: ActionSheetCloseProps) => void;
17
- cancelButtonText?: string; // no showing if not set
18
- zIndex?: string;
19
- };
20
-
21
- // because it's over a mask, so it can use primary colors
22
- export class ActionSheet {
23
- static hostNode: HTMLElement;
24
-
25
- static async show({
26
- title,
27
- children,
28
- contentMaxWidth,
29
- contentMaxHeight,
30
- closeEvent,
31
- closeWhenClickOutside = true,
32
- confirmButtonText = '',
33
- handleConfirmClicked,
34
- cancelButtonText = 'Cancel',
35
- zIndex,
36
- }: ActionSheetShowProps): Promise<ActionSheetCloseProps> {
37
- const onConfirm = () => {
38
- if (handleConfirmClicked) {
39
- handleConfirmClicked(handleClose);
40
- } else {
41
- handleClose('confirm');
42
- }
43
- };
44
- const onCancel = () => {
45
- handleClose('cancel');
46
- };
47
- const onClickContainer = (event: any) => {
48
- if (closeWhenClickOutside !== false && event.target.classList.contains('act-sheet-box')) {
49
- handleClose('cancel');
50
- }
51
- };
52
- const handleClose = (reason?: ActionSheetCloseReasonProps) => {
53
- closeEvent?.(reason);
54
- ref.current.classList.remove('animation-open');
55
- setTimeout(() => {
56
- base.remove();
57
- }, 300);
58
- };
59
-
60
- const base = document.createElement('div');
61
- const ref: RefProps = {
62
- onLoad: async () => {
63
- setTimeout(() => {
64
- ref.current.classList.add('animation-open');
65
- }, 1);
66
- },
67
- };
68
- const cssContainer: CssProps = {
69
- position: 'fixed',
70
- top: 0,
71
- left: 0,
72
- width: '100%',
73
- height: '100%',
74
- backgroundColor: 'var(--cover-mask-bg-color)',
75
- '.act-sheet-body': {
76
- display: 'flex',
77
- flexDirection: 'column',
78
- textAlign: 'center',
79
- position: 'fixed',
80
- bottom: '0px',
81
- left: '0px',
82
- width: '100%',
83
- maxHeight: contentMaxHeight ? contentMaxHeight : '100%',
84
- color: 'var(--primary-color)',
85
- padding: '8px',
86
- transition: 'all 0.3s',
87
- transform: 'translateY(100%)',
88
- '&.animation-open': {
89
- transform: 'translateY(0)',
90
- },
91
- '.act-sheet-title': {
92
- padding: '20px 15px 10px 15px',
93
- opacity: 0.5,
94
- },
95
- '.act-sheet-content': {
96
- display: 'flex',
97
- flexDirection: 'column',
98
- flex: 1,
99
- overflowY: 'auto',
100
- borderRadius: '8px',
101
- backgroundColor: 'var(--cover-bg-color)', //'#fefefe',
102
- width: '100%',
103
- maxWidth: contentMaxWidth ? contentMaxWidth : `clamp(200px, 90%, 600px)`,
104
- margin: '0 auto',
105
- },
106
- '.act-sheet-bottom-item, .act-sheet-item': {
107
- backgroundColor: 'var(--cover-bg-color)', //'#fefefe',
108
- padding: '20px 0',
109
- cursor: 'pointer',
110
- transition: 'all 0.3s ease',
111
- width: '100%',
112
- maxWidth: contentMaxWidth ? contentMaxWidth : `clamp(200px, 90%, 600px)`,
113
- borderTop: '1px solid var(--primary-border-color)',
114
- },
115
- '.act-sheet-bottom-item': {
116
- borderRadius: '8px',
117
- margin: '0 auto',
118
- marginTop: '4px',
119
- },
120
- '.act-sheet-bottom-item:hover, .act-sheet-item:hover': {
121
- fontWeight: 'bold',
122
- },
123
- '.act-sheet-confirm, .act-sheet-item': {
124
- borderRadius: 'unset',
125
- marginTop: 'unset',
126
- maxWidth: 'unset',
127
- },
128
- },
129
- };
130
- const component = (
131
- <div
132
- css={cssContainer}
133
- class='act-sheet-box'
134
- onClick={onClickContainer}
135
- data-back-action={backActionHelper.genBackActionId()}
136
- >
137
- <div ref={ref} class='act-sheet-body'>
138
- <div class='act-sheet-content'>
139
- <div class='act-sheet-title'>{title}</div>
140
- {children}
141
- {confirmButtonText && (
142
- <div class='act-sheet-bottom-item act-sheet-confirm' onClick={onConfirm}>
143
- {confirmButtonText}
144
- </div>
145
- )}
146
- </div>
147
- {cancelButtonText && (
148
- <div class='act-sheet-bottom-item' onClick={onCancel}>
149
- {cancelButtonText}
150
- </div>
151
- )}
152
- </div>
153
- </div>
154
- );
155
- base.style.position = 'fixed';
156
- base.style.zIndex = zIndex || 'var(--layer-actionsheet-window)';
157
- document.body.appendChild(base);
158
- await mountInnerComponent(base, component);
159
- return handleClose;
160
- }
161
- }
162
-
163
- export const ActionSheetSelectOptionsProps = {
164
- YesNo: ['Yes', 'No'],
165
- Ok: ['OK'],
166
- };
167
- export type ActionSheetSelectProps = Omit<ActionSheetShowProps, 'children'> & {
168
- options: string[];
169
- handleClicked: (index: number, close: ActionSheetCloseProps) => void;
170
- };
171
-
172
- export class ActionSheetSelect {
173
- static async show({
174
- title,
175
- contentMaxHeight,
176
- options = ActionSheetSelectOptionsProps.Ok,
177
- closeEvent,
178
- handleClicked,
179
- closeWhenClickOutside = true,
180
- confirmButtonText,
181
- handleConfirmClicked,
182
- cancelButtonText = 'Cancel',
183
- }: ActionSheetSelectProps): Promise<ActionSheetCloseProps> {
184
- const handleClose = await ActionSheet.show({
185
- title,
186
- children: (
187
- <div>
188
- {options.map((option, index) => (
189
- <div class='act-sheet-item' key={index} onClick={() => handleClicked(index, handleClose)}>
190
- {option}
191
- </div>
192
- ))}
193
- </div>
194
- ),
195
- contentMaxHeight,
196
- confirmButtonText,
197
- handleConfirmClicked,
198
- cancelButtonText,
199
- closeEvent,
200
- closeWhenClickOutside,
201
- });
202
- return handleClose;
203
- }
204
- }
205
-
206
- export type ActionSheetMessageProps = Omit<ActionSheetShowProps, 'children' | 'handleClicked' | 'closeEvent'> & {
207
- message: string | VNode<any>;
208
- };
209
- export class ActionSheetMessage {
210
- static async show({
211
- title,
212
- message,
213
- contentMaxWidth,
214
- contentMaxHeight,
215
- closeWhenClickOutside = true,
216
- confirmButtonText,
217
- handleConfirmClicked,
218
- cancelButtonText = '',
219
- }: ActionSheetMessageProps): Promise<ActionSheetCloseProps> {
220
- const handleClose = await ActionSheet.show({
221
- title,
222
- children: (
223
- <div
224
- css={{ padding: '8px', borderTop: '1px solid var(--primary-border-color)' }}
225
- onClick={() => handleClose('select')}
226
- >
227
- {message}
228
- </div>
229
- ),
230
- contentMaxWidth,
231
- contentMaxHeight,
232
- confirmButtonText,
233
- handleConfirmClicked,
234
- cancelButtonText,
235
- closeWhenClickOutside,
236
- });
237
- return handleClose;
238
- }
239
- }
240
-
241
- export type ActionSheetMessagePromiseProps = {
242
- message: string | VNode<any>;
243
- title: string;
244
- contentMaxWidth?: string;
245
- contentMaxHeight?: string;
246
- closeWhenClickOutside?: boolean;
247
- confirmButtonText?: string;
248
- zIndex?: string;
249
- };
250
- export const ActionSheetMessagePromise = async ({
251
- title,
252
- message,
253
- contentMaxWidth,
254
- contentMaxHeight,
255
- closeWhenClickOutside = true,
256
- confirmButtonText,
257
- zIndex,
258
- }: ActionSheetMessagePromiseProps): Promise<void> => {
259
- return new Promise(async (resolve, reject) => {
260
- const closeEvent = (reason?: ActionSheetCloseReasonProps) => {
261
- resolve();
262
- };
263
- await ActionSheet.show({
264
- title,
265
- children: <div css={{ padding: '8px', borderTop: '1px solid var(--primary-border-color)' }}>{message}</div>,
266
- contentMaxWidth,
267
- contentMaxHeight,
268
- confirmButtonText,
269
- closeEvent,
270
- closeWhenClickOutside,
271
- zIndex,
272
- });
273
- });
274
- };
275
-
276
- export type ActionSheetInputProps = Omit<
277
- ActionSheetShowProps,
278
- 'children' | 'handleClicked' | 'closeEvent' | 'handleConfirmClicked'
279
- > & {
280
- defaultValue?: string;
281
- handleConfirmValue: (value: string, close: ActionSheetCloseProps) => void;
282
- };
283
- export class ActionSheetInput {
284
- static async show({
285
- title,
286
- defaultValue,
287
- contentMaxHeight,
288
- closeWhenClickOutside = true,
289
- confirmButtonText = 'OK',
290
- handleConfirmValue: handleConfirmValue,
291
- cancelButtonText = 'Cancel',
292
- }: ActionSheetInputProps): Promise<ActionSheetCloseProps> {
293
- let value: string = defaultValue || '';
294
- const handleClose = await ActionSheet.show({
295
- title,
296
- children: (
297
- <div css={{ padding: '8px', borderTop: '1px solid var(--primary-border-color)' }}>
298
- <input
299
- class='input-base w-100p'
300
- type='text'
301
- value={value}
302
- onInput={(e) => (value = (e.target as HTMLInputElement).value)}
303
- />
304
- </div>
305
- ),
306
- contentMaxHeight,
307
- confirmButtonText,
308
- handleConfirmClicked: (close) => {
309
- handleConfirmValue(value, close);
310
- },
311
- cancelButtonText,
312
- closeWhenClickOutside,
313
- });
314
- return handleClose;
315
- }
316
- }
317
-
318
- export type ActionSheetInputPromiseProps = {
319
- defaultValue?: string;
320
- title: string;
321
- contentMaxWidth?: string;
322
- contentMaxHeight?: string;
323
- closeWhenClickOutside?: boolean;
324
- confirmButtonText?: string;
325
- cancelButtonText?: string;
326
- zIndex?: string;
327
- };
328
- export const ActionSheetInputPromise = async ({
329
- title,
330
- defaultValue,
331
- contentMaxWidth,
332
- contentMaxHeight,
333
- closeWhenClickOutside = true,
334
- confirmButtonText = 'OK',
335
- cancelButtonText = 'Cancel',
336
- zIndex,
337
- }: ActionSheetInputPromiseProps): Promise<string | undefined> => {
338
- return new Promise(async (resolve, reject) => {
339
- const closeEvent = (reason?: ActionSheetCloseReasonProps) => {
340
- if (reason !== 'confirm') {
341
- resolve(undefined);
342
- }
343
- };
344
- let value: string = defaultValue || '';
345
- await ActionSheet.show({
346
- title,
347
- children: (
348
- <div css={{ padding: '8px', borderTop: '1px solid var(--primary-border-color)' }}>
349
- <input
350
- class='input-base w-100p'
351
- type='text'
352
- value={value}
353
- onInput={(e) => (value = (e.target as HTMLInputElement).value)}
354
- />
355
- </div>
356
- ),
357
- contentMaxWidth,
358
- contentMaxHeight,
359
- confirmButtonText,
360
- handleConfirmClicked: (close) => {
361
- resolve(value);
362
- close('confirm');
363
- },
364
- closeEvent,
365
- cancelButtonText,
366
- closeWhenClickOutside,
367
- zIndex,
368
- });
369
- });
370
- };
371
-
372
- export type ActionSheetSelectPromiseProps = {
373
- title: string;
374
- contentMaxWidth?: string;
375
- contentMaxHeight?: string;
376
- options?: string[];
377
- closeWhenClickOutside?: boolean;
378
- cancelButtonText?: string;
379
- zIndex?: string;
380
- };
381
- export const ActionSheetSelectPromise = async ({
382
- title,
383
- contentMaxWidth,
384
- contentMaxHeight,
385
- options = ActionSheetSelectOptionsProps.Ok,
386
- closeWhenClickOutside = true,
387
- cancelButtonText = 'Cancel',
388
- zIndex,
389
- }: ActionSheetSelectPromiseProps): Promise<number> => {
390
- return new Promise(async (resolve, reject) => {
391
- const handleClicked = async (index: number, close: ActionSheetCloseProps) => {
392
- resolve(index);
393
- close('select');
394
- };
395
- const closeEvent = (reason?: ActionSheetCloseReasonProps) => {
396
- if (reason !== 'select') {
397
- resolve(-1);
398
- }
399
- };
400
- const handleClose = await ActionSheet.show({
401
- title,
402
- children: (
403
- <div>
404
- {options.map((option, index) => (
405
- <div class='act-sheet-item' key={index} onClick={() => handleClicked(index, handleClose)}>
406
- {option}
407
- </div>
408
- ))}
409
- </div>
410
- ),
411
- contentMaxWidth,
412
- contentMaxHeight,
413
- cancelButtonText,
414
- closeEvent,
415
- closeWhenClickOutside,
416
- zIndex,
417
- });
418
- });
419
- };
1
+ import { CssProps, RefProps, VNode, mountInnerComponent } from 'lupine.web';
2
+ import { backActionHelper } from '../lib';
3
+
4
+ export type ActionSheetCloseProps = (reason?: ActionSheetCloseReasonProps) => void;
5
+
6
+ export type ActionSheetCloseReasonProps = 'cancel' | 'confirm' | 'select' | undefined;
7
+
8
+ export type ActionSheetShowProps = {
9
+ title: string;
10
+ children: string | VNode<any>;
11
+ contentMaxWidth?: string;
12
+ contentMaxHeight?: string;
13
+ closeEvent?: (reason?: ActionSheetCloseReasonProps) => void;
14
+ closeWhenClickOutside?: boolean; // default true
15
+ confirmButtonText?: string; // no showing if not set
16
+ handleConfirmClicked?: (close: ActionSheetCloseProps) => void;
17
+ cancelButtonText?: string; // no showing if not set
18
+ zIndex?: string;
19
+ };
20
+
21
+ // because it's over a mask, so it can use primary colors
22
+ export class ActionSheet {
23
+ static hostNode: HTMLElement;
24
+
25
+ static async show({
26
+ title,
27
+ children,
28
+ contentMaxWidth,
29
+ contentMaxHeight,
30
+ closeEvent,
31
+ closeWhenClickOutside = true,
32
+ confirmButtonText = '',
33
+ handleConfirmClicked,
34
+ cancelButtonText = 'Cancel',
35
+ zIndex,
36
+ }: ActionSheetShowProps): Promise<ActionSheetCloseProps> {
37
+ const onConfirm = () => {
38
+ if (handleConfirmClicked) {
39
+ handleConfirmClicked(handleClose);
40
+ } else {
41
+ handleClose('confirm');
42
+ }
43
+ };
44
+ const onCancel = () => {
45
+ handleClose('cancel');
46
+ };
47
+ const onClickContainer = (event: any) => {
48
+ if (closeWhenClickOutside !== false && event.target.classList.contains('act-sheet-box')) {
49
+ handleClose('cancel');
50
+ }
51
+ };
52
+ const handleClose = (reason?: ActionSheetCloseReasonProps) => {
53
+ closeEvent?.(reason);
54
+ ref.current.classList.remove('animation-open');
55
+ setTimeout(() => {
56
+ base.remove();
57
+ }, 300);
58
+ };
59
+
60
+ const base = document.createElement('div');
61
+ const ref: RefProps = {
62
+ onLoad: async () => {
63
+ setTimeout(() => {
64
+ ref.current.classList.add('animation-open');
65
+ }, 1);
66
+ },
67
+ };
68
+ const cssContainer: CssProps = {
69
+ position: 'fixed',
70
+ top: 0,
71
+ left: 0,
72
+ width: '100%',
73
+ height: '100%',
74
+ backgroundColor: 'var(--cover-mask-bg-color)',
75
+ '.act-sheet-body': {
76
+ display: 'flex',
77
+ flexDirection: 'column',
78
+ textAlign: 'center',
79
+ position: 'fixed',
80
+ bottom: '0px',
81
+ left: '0px',
82
+ width: '100%',
83
+ maxHeight: contentMaxHeight ? contentMaxHeight : '100%',
84
+ color: 'var(--primary-color)',
85
+ padding: '8px',
86
+ transition: 'all 0.3s',
87
+ transform: 'translateY(100%)',
88
+ '&.animation-open': {
89
+ transform: 'translateY(0)',
90
+ },
91
+ '.act-sheet-title': {
92
+ padding: '20px 15px 10px 15px',
93
+ opacity: 0.5,
94
+ },
95
+ '.act-sheet-content': {
96
+ display: 'flex',
97
+ flexDirection: 'column',
98
+ flex: 1,
99
+ overflowY: 'auto',
100
+ borderRadius: '8px',
101
+ backgroundColor: 'var(--cover-bg-color)', //'#fefefe',
102
+ width: '100%',
103
+ maxWidth: contentMaxWidth ? contentMaxWidth : `clamp(200px, 90%, 600px)`,
104
+ margin: '0 auto',
105
+ },
106
+ '.act-sheet-bottom-item, .act-sheet-item': {
107
+ backgroundColor: 'var(--cover-bg-color)', //'#fefefe',
108
+ padding: '20px 0',
109
+ cursor: 'pointer',
110
+ transition: 'all 0.3s ease',
111
+ width: '100%',
112
+ maxWidth: contentMaxWidth ? contentMaxWidth : `clamp(200px, 90%, 600px)`,
113
+ borderTop: '1px solid var(--primary-border-color)',
114
+ },
115
+ '.act-sheet-bottom-item': {
116
+ borderRadius: '8px',
117
+ margin: '0 auto',
118
+ marginTop: '4px',
119
+ },
120
+ '.act-sheet-bottom-item:hover, .act-sheet-item:hover': {
121
+ fontWeight: 'bold',
122
+ },
123
+ '.act-sheet-confirm, .act-sheet-item': {
124
+ borderRadius: 'unset',
125
+ marginTop: 'unset',
126
+ maxWidth: 'unset',
127
+ },
128
+ },
129
+ };
130
+ const component = (
131
+ <div
132
+ css={cssContainer}
133
+ class='act-sheet-box'
134
+ onClick={onClickContainer}
135
+ data-back-action={backActionHelper.genBackActionId()}
136
+ >
137
+ <div ref={ref} class='act-sheet-body'>
138
+ <div class='act-sheet-content'>
139
+ <div class='act-sheet-title'>{title}</div>
140
+ {children}
141
+ {confirmButtonText && (
142
+ <div class='act-sheet-bottom-item act-sheet-confirm' onClick={onConfirm}>
143
+ {confirmButtonText}
144
+ </div>
145
+ )}
146
+ </div>
147
+ {cancelButtonText && (
148
+ <div class='act-sheet-bottom-item' onClick={onCancel}>
149
+ {cancelButtonText}
150
+ </div>
151
+ )}
152
+ </div>
153
+ </div>
154
+ );
155
+ base.style.position = 'fixed';
156
+ base.style.zIndex = zIndex || 'var(--layer-actionsheet-window)';
157
+ document.body.appendChild(base);
158
+ await mountInnerComponent(base, component);
159
+ return handleClose;
160
+ }
161
+ }
162
+
163
+ export const ActionSheetSelectOptionsProps = {
164
+ YesNo: ['Yes', 'No'],
165
+ Ok: ['OK'],
166
+ };
167
+ export type ActionSheetSelectProps = Omit<ActionSheetShowProps, 'children'> & {
168
+ options: string[];
169
+ handleClicked: (index: number, close: ActionSheetCloseProps) => void;
170
+ };
171
+
172
+ export class ActionSheetSelect {
173
+ static async show({
174
+ title,
175
+ contentMaxHeight,
176
+ options = ActionSheetSelectOptionsProps.Ok,
177
+ closeEvent,
178
+ handleClicked,
179
+ closeWhenClickOutside = true,
180
+ confirmButtonText,
181
+ handleConfirmClicked,
182
+ cancelButtonText = 'Cancel',
183
+ }: ActionSheetSelectProps): Promise<ActionSheetCloseProps> {
184
+ const handleClose = await ActionSheet.show({
185
+ title,
186
+ children: (
187
+ <div>
188
+ {options.map((option, index) => (
189
+ <div class='act-sheet-item' key={index} onClick={() => handleClicked(index, handleClose)}>
190
+ {option}
191
+ </div>
192
+ ))}
193
+ </div>
194
+ ),
195
+ contentMaxHeight,
196
+ confirmButtonText,
197
+ handleConfirmClicked,
198
+ cancelButtonText,
199
+ closeEvent,
200
+ closeWhenClickOutside,
201
+ });
202
+ return handleClose;
203
+ }
204
+ }
205
+
206
+ export type ActionSheetMessageProps = Omit<ActionSheetShowProps, 'children' | 'handleClicked' | 'closeEvent'> & {
207
+ message: string | VNode<any>;
208
+ };
209
+ export class ActionSheetMessage {
210
+ static async show({
211
+ title,
212
+ message,
213
+ contentMaxWidth,
214
+ contentMaxHeight,
215
+ closeWhenClickOutside = true,
216
+ confirmButtonText,
217
+ handleConfirmClicked,
218
+ cancelButtonText = '',
219
+ }: ActionSheetMessageProps): Promise<ActionSheetCloseProps> {
220
+ const handleClose = await ActionSheet.show({
221
+ title,
222
+ children: (
223
+ <div
224
+ css={{ padding: '8px', borderTop: '1px solid var(--primary-border-color)' }}
225
+ onClick={() => handleClose('select')}
226
+ >
227
+ {message}
228
+ </div>
229
+ ),
230
+ contentMaxWidth,
231
+ contentMaxHeight,
232
+ confirmButtonText,
233
+ handleConfirmClicked,
234
+ cancelButtonText,
235
+ closeWhenClickOutside,
236
+ });
237
+ return handleClose;
238
+ }
239
+ }
240
+
241
+ export type ActionSheetMessagePromiseProps = {
242
+ message: string | VNode<any>;
243
+ title: string;
244
+ contentMaxWidth?: string;
245
+ contentMaxHeight?: string;
246
+ closeWhenClickOutside?: boolean;
247
+ confirmButtonText?: string;
248
+ zIndex?: string;
249
+ };
250
+ export const ActionSheetMessagePromise = async ({
251
+ title,
252
+ message,
253
+ contentMaxWidth,
254
+ contentMaxHeight,
255
+ closeWhenClickOutside = true,
256
+ confirmButtonText,
257
+ zIndex,
258
+ }: ActionSheetMessagePromiseProps): Promise<void> => {
259
+ return new Promise(async (resolve, reject) => {
260
+ const closeEvent = (reason?: ActionSheetCloseReasonProps) => {
261
+ resolve();
262
+ };
263
+ await ActionSheet.show({
264
+ title,
265
+ children: <div css={{ padding: '8px', borderTop: '1px solid var(--primary-border-color)' }}>{message}</div>,
266
+ contentMaxWidth,
267
+ contentMaxHeight,
268
+ confirmButtonText,
269
+ closeEvent,
270
+ closeWhenClickOutside,
271
+ zIndex,
272
+ });
273
+ });
274
+ };
275
+
276
+ export type ActionSheetInputProps = Omit<
277
+ ActionSheetShowProps,
278
+ 'children' | 'handleClicked' | 'closeEvent' | 'handleConfirmClicked'
279
+ > & {
280
+ defaultValue?: string;
281
+ handleConfirmValue: (value: string, close: ActionSheetCloseProps) => void;
282
+ };
283
+ export class ActionSheetInput {
284
+ static async show({
285
+ title,
286
+ defaultValue,
287
+ contentMaxHeight,
288
+ closeWhenClickOutside = true,
289
+ confirmButtonText = 'OK',
290
+ handleConfirmValue: handleConfirmValue,
291
+ cancelButtonText = 'Cancel',
292
+ }: ActionSheetInputProps): Promise<ActionSheetCloseProps> {
293
+ let value: string = defaultValue || '';
294
+ const handleClose = await ActionSheet.show({
295
+ title,
296
+ children: (
297
+ <div css={{ padding: '8px', borderTop: '1px solid var(--primary-border-color)' }}>
298
+ <input
299
+ class='input-base w-100p'
300
+ type='text'
301
+ value={value}
302
+ onInput={(e) => (value = (e.target as HTMLInputElement).value)}
303
+ />
304
+ </div>
305
+ ),
306
+ contentMaxHeight,
307
+ confirmButtonText,
308
+ handleConfirmClicked: (close) => {
309
+ handleConfirmValue(value, close);
310
+ },
311
+ cancelButtonText,
312
+ closeWhenClickOutside,
313
+ });
314
+ return handleClose;
315
+ }
316
+ }
317
+
318
+ export type ActionSheetInputPromiseProps = {
319
+ defaultValue?: string;
320
+ title: string;
321
+ contentMaxWidth?: string;
322
+ contentMaxHeight?: string;
323
+ closeWhenClickOutside?: boolean;
324
+ confirmButtonText?: string;
325
+ cancelButtonText?: string;
326
+ zIndex?: string;
327
+ };
328
+ export const ActionSheetInputPromise = async ({
329
+ title,
330
+ defaultValue,
331
+ contentMaxWidth,
332
+ contentMaxHeight,
333
+ closeWhenClickOutside = true,
334
+ confirmButtonText = 'OK',
335
+ cancelButtonText = 'Cancel',
336
+ zIndex,
337
+ }: ActionSheetInputPromiseProps): Promise<string | undefined> => {
338
+ return new Promise(async (resolve, reject) => {
339
+ const closeEvent = (reason?: ActionSheetCloseReasonProps) => {
340
+ if (reason !== 'confirm') {
341
+ resolve(undefined);
342
+ }
343
+ };
344
+ let value: string = defaultValue || '';
345
+ await ActionSheet.show({
346
+ title,
347
+ children: (
348
+ <div css={{ padding: '8px', borderTop: '1px solid var(--primary-border-color)' }}>
349
+ <input
350
+ class='input-base w-100p'
351
+ type='text'
352
+ value={value}
353
+ onInput={(e) => (value = (e.target as HTMLInputElement).value)}
354
+ />
355
+ </div>
356
+ ),
357
+ contentMaxWidth,
358
+ contentMaxHeight,
359
+ confirmButtonText,
360
+ handleConfirmClicked: (close) => {
361
+ resolve(value);
362
+ close('confirm');
363
+ },
364
+ closeEvent,
365
+ cancelButtonText,
366
+ closeWhenClickOutside,
367
+ zIndex,
368
+ });
369
+ });
370
+ };
371
+
372
+ export type ActionSheetSelectPromiseProps = {
373
+ title: string;
374
+ contentMaxWidth?: string;
375
+ contentMaxHeight?: string;
376
+ options?: string[];
377
+ closeWhenClickOutside?: boolean;
378
+ cancelButtonText?: string;
379
+ zIndex?: string;
380
+ };
381
+ export const ActionSheetSelectPromise = async ({
382
+ title,
383
+ contentMaxWidth,
384
+ contentMaxHeight,
385
+ options = ActionSheetSelectOptionsProps.Ok,
386
+ closeWhenClickOutside = true,
387
+ cancelButtonText = 'Cancel',
388
+ zIndex,
389
+ }: ActionSheetSelectPromiseProps): Promise<number> => {
390
+ return new Promise(async (resolve, reject) => {
391
+ const handleClicked = async (index: number, close: ActionSheetCloseProps) => {
392
+ resolve(index);
393
+ close('select');
394
+ };
395
+ const closeEvent = (reason?: ActionSheetCloseReasonProps) => {
396
+ if (reason !== 'select') {
397
+ resolve(-1);
398
+ }
399
+ };
400
+ const handleClose = await ActionSheet.show({
401
+ title,
402
+ children: (
403
+ <div>
404
+ {options.map((option, index) => (
405
+ <div class='act-sheet-item' key={index} onClick={() => handleClicked(index, handleClose)}>
406
+ {option}
407
+ </div>
408
+ ))}
409
+ </div>
410
+ ),
411
+ contentMaxWidth,
412
+ contentMaxHeight,
413
+ cancelButtonText,
414
+ closeEvent,
415
+ closeWhenClickOutside,
416
+ zIndex,
417
+ });
418
+ });
419
+ };