lupine.components 1.0.15 → 1.0.17
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
CHANGED
|
@@ -4,10 +4,13 @@ export type ActionSheetCloseProps = () => void;
|
|
|
4
4
|
|
|
5
5
|
export type ActionSheetShowProps = {
|
|
6
6
|
title: string;
|
|
7
|
-
children: VNode<any>;
|
|
7
|
+
children: string | VNode<any>;
|
|
8
|
+
contentMaxWidth?: string;
|
|
8
9
|
contentMaxHeight?: string;
|
|
9
10
|
closeEvent?: () => void;
|
|
10
11
|
closeWhenClickOutside?: boolean; // default true
|
|
12
|
+
confirmButtonText?: string; // no showing if not set
|
|
13
|
+
handleConfirmClicked?: (close: ActionSheetCloseProps) => void;
|
|
11
14
|
cancelButtonText?: string; // no showing if not set
|
|
12
15
|
zIndex?: string;
|
|
13
16
|
};
|
|
@@ -19,12 +22,22 @@ export class ActionSheet {
|
|
|
19
22
|
static async show({
|
|
20
23
|
title,
|
|
21
24
|
children,
|
|
25
|
+
contentMaxWidth,
|
|
22
26
|
contentMaxHeight,
|
|
23
27
|
closeEvent,
|
|
24
28
|
closeWhenClickOutside = true,
|
|
29
|
+
confirmButtonText = '',
|
|
30
|
+
handleConfirmClicked,
|
|
25
31
|
cancelButtonText = 'Cancel',
|
|
26
32
|
zIndex,
|
|
27
33
|
}: ActionSheetShowProps): Promise<ActionSheetCloseProps> {
|
|
34
|
+
const onConfirm = () => {
|
|
35
|
+
if (handleConfirmClicked) {
|
|
36
|
+
handleConfirmClicked(handleClose);
|
|
37
|
+
} else {
|
|
38
|
+
handleClose();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
28
41
|
const onCancel = () => {
|
|
29
42
|
handleClose();
|
|
30
43
|
};
|
|
@@ -64,7 +77,7 @@ export class ActionSheet {
|
|
|
64
77
|
bottom: '0px',
|
|
65
78
|
left: '0px',
|
|
66
79
|
width: '100%',
|
|
67
|
-
maxHeight: contentMaxHeight ? contentMaxHeight : '',
|
|
80
|
+
maxHeight: contentMaxHeight ? contentMaxHeight : '100%',
|
|
68
81
|
color: 'var(--primary-color)',
|
|
69
82
|
padding: '8px',
|
|
70
83
|
transition: 'all 0.3s',
|
|
@@ -84,7 +97,7 @@ export class ActionSheet {
|
|
|
84
97
|
borderRadius: '8px',
|
|
85
98
|
backgroundColor: 'var(--cover-bg-color)', //'#fefefe',
|
|
86
99
|
width: '100%',
|
|
87
|
-
maxWidth:
|
|
100
|
+
maxWidth: contentMaxWidth ? contentMaxWidth : `clamp(200px, 70%, 800px)`,
|
|
88
101
|
margin: '0 auto',
|
|
89
102
|
},
|
|
90
103
|
'.act-sheet-bottom-item, .act-sheet-item': {
|
|
@@ -93,7 +106,7 @@ export class ActionSheet {
|
|
|
93
106
|
cursor: 'pointer',
|
|
94
107
|
transition: 'all 0.3s ease',
|
|
95
108
|
width: '100%',
|
|
96
|
-
maxWidth:
|
|
109
|
+
maxWidth: contentMaxWidth ? contentMaxWidth : `clamp(200px, 70%, 800px)`,
|
|
97
110
|
borderTop: '1px solid var(--primary-border-color)',
|
|
98
111
|
},
|
|
99
112
|
'.act-sheet-bottom-item': {
|
|
@@ -104,6 +117,11 @@ export class ActionSheet {
|
|
|
104
117
|
'.act-sheet-bottom-item:hover, .act-sheet-item:hover': {
|
|
105
118
|
fontWeight: 'bold',
|
|
106
119
|
},
|
|
120
|
+
'.act-sheet-confirm, .act-sheet-item': {
|
|
121
|
+
borderRadius: 'unset',
|
|
122
|
+
marginTop: 'unset',
|
|
123
|
+
maxWidth: 'unset',
|
|
124
|
+
},
|
|
107
125
|
},
|
|
108
126
|
};
|
|
109
127
|
const component = (
|
|
@@ -112,6 +130,11 @@ export class ActionSheet {
|
|
|
112
130
|
<div class='act-sheet-content'>
|
|
113
131
|
<div class='act-sheet-title'>{title}</div>
|
|
114
132
|
{children}
|
|
133
|
+
{confirmButtonText && (
|
|
134
|
+
<div class='act-sheet-bottom-item act-sheet-confirm' onClick={onConfirm}>
|
|
135
|
+
{confirmButtonText}
|
|
136
|
+
</div>
|
|
137
|
+
)}
|
|
115
138
|
</div>
|
|
116
139
|
{cancelButtonText && (
|
|
117
140
|
<div class='act-sheet-bottom-item' onClick={onCancel}>
|
|
@@ -131,7 +154,7 @@ export class ActionSheet {
|
|
|
131
154
|
|
|
132
155
|
export const ActionSheetSelectOptionsProps = {
|
|
133
156
|
YesNo: ['Yes', 'No'],
|
|
134
|
-
|
|
157
|
+
Ok: ['OK'],
|
|
135
158
|
};
|
|
136
159
|
export type ActionSheetSelectProps = Omit<ActionSheetShowProps, 'children'> & {
|
|
137
160
|
options: string[];
|
|
@@ -142,10 +165,12 @@ export class ActionSheetSelect {
|
|
|
142
165
|
static async show({
|
|
143
166
|
title,
|
|
144
167
|
contentMaxHeight,
|
|
145
|
-
options = ActionSheetSelectOptionsProps.
|
|
168
|
+
options = ActionSheetSelectOptionsProps.Ok,
|
|
146
169
|
closeEvent,
|
|
147
170
|
handleClicked,
|
|
148
171
|
closeWhenClickOutside = true,
|
|
172
|
+
confirmButtonText,
|
|
173
|
+
handleConfirmClicked,
|
|
149
174
|
cancelButtonText = 'Cancel',
|
|
150
175
|
}: ActionSheetSelectProps): Promise<ActionSheetCloseProps> {
|
|
151
176
|
const handleClose = await ActionSheet.show({
|
|
@@ -160,6 +185,8 @@ export class ActionSheetSelect {
|
|
|
160
185
|
</div>
|
|
161
186
|
),
|
|
162
187
|
contentMaxHeight,
|
|
188
|
+
confirmButtonText,
|
|
189
|
+
handleConfirmClicked,
|
|
163
190
|
cancelButtonText,
|
|
164
191
|
closeEvent,
|
|
165
192
|
closeWhenClickOutside,
|
|
@@ -169,7 +196,7 @@ export class ActionSheetSelect {
|
|
|
169
196
|
}
|
|
170
197
|
|
|
171
198
|
export type ActionSheetMessageProps = Omit<ActionSheetShowProps, 'children' | 'handleClicked' | 'closeEvent'> & {
|
|
172
|
-
message: string
|
|
199
|
+
message: string | VNode<any>;
|
|
173
200
|
};
|
|
174
201
|
export class ActionSheetMessage {
|
|
175
202
|
static async show({
|
|
@@ -177,13 +204,17 @@ export class ActionSheetMessage {
|
|
|
177
204
|
message,
|
|
178
205
|
contentMaxHeight,
|
|
179
206
|
closeWhenClickOutside = true,
|
|
207
|
+
confirmButtonText,
|
|
208
|
+
handleConfirmClicked,
|
|
180
209
|
cancelButtonText = '',
|
|
181
210
|
}: ActionSheetMessageProps): Promise<ActionSheetCloseProps> {
|
|
182
211
|
const handleClose = await ActionSheet.show({
|
|
183
212
|
title,
|
|
184
|
-
children: <div css={{ padding: '
|
|
213
|
+
children: <div css={{ padding: '8px',borderTop: '1px solid var(--primary-border-color)', }}>{message}</div>,
|
|
185
214
|
contentMaxHeight,
|
|
186
|
-
|
|
215
|
+
confirmButtonText,
|
|
216
|
+
handleConfirmClicked,
|
|
217
|
+
cancelButtonText,
|
|
187
218
|
closeWhenClickOutside,
|
|
188
219
|
});
|
|
189
220
|
return handleClose;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RefProps, VNode
|
|
1
|
+
import { RefProps, VNode } from 'lupine.web';
|
|
2
2
|
|
|
3
3
|
export type HtmlVarResult = { value: string | VNode<any>; ref: RefProps; node: VNode<any> };
|
|
4
4
|
export const HtmlVar = (initial?: string | VNode<any>): HtmlVarResult => {
|
|
@@ -6,12 +6,7 @@ export const HtmlVar = (initial?: string | VNode<any>): HtmlVarResult => {
|
|
|
6
6
|
let _dirty = false;
|
|
7
7
|
const waitUpdate = async (value: string | VNode<any>) => {
|
|
8
8
|
if (!ref.current) return;
|
|
9
|
-
|
|
10
|
-
await mountComponents(ref.current, value);
|
|
11
|
-
} else {
|
|
12
|
-
await replaceInnerhtml(ref.current, value as string);
|
|
13
|
-
// ref.current.innerHTML = value;
|
|
14
|
-
}
|
|
9
|
+
await ref.loadContent!(value);
|
|
15
10
|
_dirty = false;
|
|
16
11
|
};
|
|
17
12
|
const ref: RefProps = {
|
|
@@ -19,10 +14,6 @@ export const HtmlVar = (initial?: string | VNode<any>): HtmlVarResult => {
|
|
|
19
14
|
_dirty && waitUpdate(_value);
|
|
20
15
|
},
|
|
21
16
|
};
|
|
22
|
-
const FragmentRef = (props: any) => {
|
|
23
|
-
return <>{props.children}</>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
17
|
return {
|
|
27
18
|
set value(value: string | VNode<any>) {
|
|
28
19
|
_value = value;
|
|
@@ -35,10 +26,10 @@ export const HtmlVar = (initial?: string | VNode<any>): HtmlVarResult => {
|
|
|
35
26
|
get ref() {
|
|
36
27
|
return ref;
|
|
37
28
|
},
|
|
38
|
-
// _fragment_ref is a special id to add ref to a fragment and it is processed in mount-components
|
|
39
29
|
get node() {
|
|
40
30
|
_dirty = false;
|
|
41
|
-
|
|
31
|
+
// the Fragment Tag will be present in the html if ref is assigned
|
|
32
|
+
return { type: 'Fragment', props: { ref, children: _value }, html: [] };
|
|
42
33
|
},
|
|
43
34
|
};
|
|
44
35
|
};
|
|
@@ -35,7 +35,7 @@ export const Spinner02 = ({
|
|
|
35
35
|
color?: string;
|
|
36
36
|
}) => {
|
|
37
37
|
const base = parseInt(size.replace('px', ''));
|
|
38
|
-
const ballSize = Array.from({ length: 7 }, (_, i) => `${i * base / 15 / 7}px`);
|
|
38
|
+
const ballSize = Array.from({ length: 7 }, (_, i) => `${(i * base / 15 / 7).toFixed(2)}px`);
|
|
39
39
|
const css: any = {
|
|
40
40
|
width: size,
|
|
41
41
|
height: size,
|
package/src/lib/upload-file.ts
CHANGED
|
@@ -73,9 +73,12 @@ export const uploadFile = async (
|
|
|
73
73
|
chunkSize = _saveChunkSize.size;
|
|
74
74
|
}
|
|
75
75
|
if (len <= chunkSize) {
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
78
|
-
return
|
|
76
|
+
const result = await uploadFileChunk(file, 0, 1, uploadUrl, key, retryCount, retryMessage);
|
|
77
|
+
if (!result || result.status !== 'ok') {
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
if (progressFn) {
|
|
81
|
+
progressFn(1, 0, len);
|
|
79
82
|
}
|
|
80
83
|
return true;
|
|
81
84
|
}
|
|
@@ -85,11 +88,11 @@ export const uploadFile = async (
|
|
|
85
88
|
const start = i * chunkSize;
|
|
86
89
|
const end = Math.min((i + 1) * chunkSize, len);
|
|
87
90
|
const chunk = file.slice(start, end);
|
|
88
|
-
const
|
|
89
|
-
if (!
|
|
90
|
-
return
|
|
91
|
+
const result = await uploadFileChunk(chunk, i, totalChunks, uploadUrl, key, retryCount, retryMessage);
|
|
92
|
+
if (!result || result.status !== 'ok') {
|
|
93
|
+
return result;
|
|
91
94
|
}
|
|
92
|
-
key =
|
|
95
|
+
key = result.key;
|
|
93
96
|
if (progressFn) {
|
|
94
97
|
progressFn(Math.round(((i + 1) / totalChunks) * 100) / 100, i, totalChunks);
|
|
95
98
|
}
|