mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-26 10:45:57 +08:00
feat: add autofill and onClose params in notification service api (#7162)
This PR add autofill and onClose params in notification service api for better user experiences. [Related PR in blocksuite](https://github.com/toeverything/blocksuite/pull/7230)
This commit is contained in:
@@ -169,14 +169,19 @@ export function patchNotificationService(
|
|||||||
confirmText,
|
confirmText,
|
||||||
placeholder,
|
placeholder,
|
||||||
cancelText,
|
cancelText,
|
||||||
|
autofill,
|
||||||
abort,
|
abort,
|
||||||
}) => {
|
}) => {
|
||||||
return new Promise<string | null>(resolve => {
|
return new Promise<string | null>(resolve => {
|
||||||
let value = '';
|
let value = autofill || '';
|
||||||
const description = (
|
const description = (
|
||||||
<div>
|
<div>
|
||||||
<span style={{ marginBottom: 12 }}>{toReactNode(message)}</span>
|
<span style={{ marginBottom: 12 }}>{toReactNode(message)}</span>
|
||||||
<Input placeholder={placeholder} onChange={e => (value = e)} />
|
<Input
|
||||||
|
placeholder={placeholder}
|
||||||
|
defaultValue={value}
|
||||||
|
onChange={e => (value = e)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
openConfirmModal({
|
openConfirmModal({
|
||||||
@@ -189,7 +194,6 @@ export function patchNotificationService(
|
|||||||
cancelButtonOptions: {
|
cancelButtonOptions: {
|
||||||
children: cancelText ?? 'Cancel',
|
children: cancelText ?? 'Cancel',
|
||||||
},
|
},
|
||||||
|
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
resolve(value);
|
resolve(value);
|
||||||
},
|
},
|
||||||
@@ -229,9 +233,12 @@ export function patchNotificationService(
|
|||||||
onClick: notification.action.onClick,
|
onClick: notification.action.onClick,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
onDismiss: notification.onClose,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
duration: notification.duration || 0,
|
duration: notification.duration || 0,
|
||||||
|
onDismiss: notification.onClose,
|
||||||
|
onAutoClose: notification.onClose,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user