lupine.components 1.1.6 → 1.1.8
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
|
@@ -226,3 +226,45 @@ export class ActionSheetMessage {
|
|
|
226
226
|
return handleClose;
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
+
|
|
230
|
+
export type ActionSheetInputProps = Omit<
|
|
231
|
+
ActionSheetShowProps,
|
|
232
|
+
'children' | 'handleClicked' | 'closeEvent' | 'handleConfirmClicked'
|
|
233
|
+
> & {
|
|
234
|
+
defaultValue?: string;
|
|
235
|
+
handleConfirmValue: (value: string, close: ActionSheetCloseProps) => void;
|
|
236
|
+
};
|
|
237
|
+
export class ActionSheetInput {
|
|
238
|
+
static async show({
|
|
239
|
+
title,
|
|
240
|
+
defaultValue,
|
|
241
|
+
contentMaxHeight,
|
|
242
|
+
closeWhenClickOutside = true,
|
|
243
|
+
confirmButtonText = 'OK',
|
|
244
|
+
handleConfirmValue: handleConfirmValue,
|
|
245
|
+
cancelButtonText = 'Cancel',
|
|
246
|
+
}: ActionSheetInputProps): Promise<ActionSheetCloseProps> {
|
|
247
|
+
let value: string = defaultValue || '';
|
|
248
|
+
const handleClose = await ActionSheet.show({
|
|
249
|
+
title,
|
|
250
|
+
children: (
|
|
251
|
+
<div css={{ padding: '8px', borderTop: '1px solid var(--primary-border-color)' }}>
|
|
252
|
+
<input
|
|
253
|
+
class='input-base w-100p'
|
|
254
|
+
type='text'
|
|
255
|
+
value={value}
|
|
256
|
+
onInput={(e) => (value = (e.target as HTMLInputElement).value)}
|
|
257
|
+
/>
|
|
258
|
+
</div>
|
|
259
|
+
),
|
|
260
|
+
contentMaxHeight,
|
|
261
|
+
confirmButtonText,
|
|
262
|
+
handleConfirmClicked: (close) => {
|
|
263
|
+
handleConfirmValue(value, close);
|
|
264
|
+
},
|
|
265
|
+
cancelButtonText,
|
|
266
|
+
closeWhenClickOutside,
|
|
267
|
+
});
|
|
268
|
+
return handleClose;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -20,17 +20,17 @@ export class HtmlVar implements HtmlVarResult {
|
|
|
20
20
|
// in case new resolve is created while updating
|
|
21
21
|
const res = this.resolve;
|
|
22
22
|
if (this._dirty) {
|
|
23
|
-
await this.update(
|
|
23
|
+
await this.update();
|
|
24
24
|
}
|
|
25
25
|
res();
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
private async update(
|
|
30
|
+
private async update(): Promise<void> {
|
|
31
|
+
await this._ref.mountInnerComponent!(this._value);
|
|
31
32
|
this._dirty = false;
|
|
32
33
|
this._value = '';
|
|
33
|
-
await this._ref.mountInnerComponent!(value);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// need to wait before use ref.current
|
|
@@ -40,14 +40,17 @@ export class HtmlVar implements HtmlVarResult {
|
|
|
40
40
|
|
|
41
41
|
set value(value: string | VNode<any>) {
|
|
42
42
|
this._value = value;
|
|
43
|
-
if (this._dirty
|
|
43
|
+
if (this._dirty) {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
this._dirty = true;
|
|
48
|
+
if (!this._ref.current) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
48
51
|
this.promise = new Promise<void>(async (res) => {
|
|
49
52
|
this.resolve = res;
|
|
50
|
-
await this.update(
|
|
53
|
+
await this.update();
|
|
51
54
|
this.resolve();
|
|
52
55
|
});
|
|
53
56
|
}
|
|
@@ -4,6 +4,7 @@ import { stopPropagation } from '../lib';
|
|
|
4
4
|
export type PopupMenuHookProps = {
|
|
5
5
|
openMenu?: (event?: MouseEvent) => void;
|
|
6
6
|
getValue?: () => string;
|
|
7
|
+
setLabel?: (label: string) => void;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
// defaultValue=<i class='ifc-icon co-cil-hamburger-menu'></i>
|
|
@@ -231,6 +232,9 @@ export const PopupMenu = ({
|
|
|
231
232
|
if (hook) {
|
|
232
233
|
hook.openMenu = openMenu;
|
|
233
234
|
hook.getValue = () => selectedValue;
|
|
235
|
+
hook.setLabel = (label: string) => {
|
|
236
|
+
ref.$('.popup-menu-item .popup-menu-text').innerText = label;
|
|
237
|
+
};
|
|
234
238
|
}
|
|
235
239
|
const itemClick = (event: any) => {
|
|
236
240
|
stopPropagation(event);
|