@linzjs/windows 8.4.1 → 8.5.0
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.
|
@@ -41,13 +41,15 @@ export const LuiModalAsync = ({
|
|
|
41
41
|
// For example we don't want to select the help button by default, so we add data-noautofocus
|
|
42
42
|
delay(() => {
|
|
43
43
|
const d = dialogRef.current;
|
|
44
|
-
if (!d)
|
|
45
|
-
|
|
46
|
-
if (!input) {
|
|
47
|
-
input = d.querySelectorAll('button:not([data-noautofocus]),input:not([data-noautofocus])')[0] as
|
|
48
|
-
| HTMLElement
|
|
49
|
-
| undefined;
|
|
44
|
+
if (!d) {
|
|
45
|
+
return;
|
|
50
46
|
}
|
|
47
|
+
const input = (d.querySelectorAll('[data-autofocus]')[0] ??
|
|
48
|
+
d.querySelectorAll('[type=file]')[0] ??
|
|
49
|
+
d.querySelectorAll('button:not([data-noautofocus]),input:not([data-noautofocus])')[0]) as
|
|
50
|
+
| HTMLElement
|
|
51
|
+
| undefined;
|
|
52
|
+
|
|
51
53
|
if (input) {
|
|
52
54
|
input.focus?.();
|
|
53
55
|
if ('select' in input) {
|
|
@@ -4,11 +4,13 @@ import { LuiButton, LuiIcon } from '@linzjs/lui';
|
|
|
4
4
|
import { LuiIconName } from '@linzjs/lui/dist/assets/svg-content';
|
|
5
5
|
import React, { PropsWithChildren, ReactElement, useContext } from 'react';
|
|
6
6
|
|
|
7
|
+
import { PanelHeaderButton } from '../panel';
|
|
7
8
|
import { LuiModalAsyncInstanceContext } from './LuiModalAsyncInstanceContext';
|
|
8
9
|
|
|
9
10
|
export interface LuiModalAsyncHeaderProps {
|
|
10
11
|
icon?: LuiIconName | ReactElement | null;
|
|
11
12
|
title: string;
|
|
13
|
+
closeButton?: true;
|
|
12
14
|
helpLink?: string;
|
|
13
15
|
onHelpClick?: () => void;
|
|
14
16
|
helpButtonLevel?: 'text' | 'plain-text' | 'primary' | 'secondary' | 'tertiary' | 'success' | 'error';
|
|
@@ -20,11 +22,12 @@ export interface LuiModalAsyncHeaderProps {
|
|
|
20
22
|
export const LuiModalAsyncHeader = ({
|
|
21
23
|
icon,
|
|
22
24
|
title,
|
|
25
|
+
closeButton,
|
|
23
26
|
helpLink,
|
|
24
27
|
onHelpClick,
|
|
25
28
|
helpButtonLevel,
|
|
26
29
|
}: PropsWithChildren<LuiModalAsyncHeaderProps>) => {
|
|
27
|
-
const { ownerRef } = useContext(LuiModalAsyncInstanceContext);
|
|
30
|
+
const { ownerRef, close } = useContext(LuiModalAsyncInstanceContext);
|
|
28
31
|
|
|
29
32
|
return (
|
|
30
33
|
<div className={'LuiModalAsync-header'}>
|
|
@@ -57,6 +60,7 @@ export const LuiModalAsyncHeader = ({
|
|
|
57
60
|
<LuiIcon name="ic_help_outline" alt="Help" size="md" className={'LuiModalAsync-help-icon'} />
|
|
58
61
|
</LuiButton>
|
|
59
62
|
)}
|
|
63
|
+
{closeButton && <PanelHeaderButton aria-label={'Close'} onClick={close} icon={'ic_clear'} />}
|
|
60
64
|
</div>
|
|
61
65
|
);
|
|
62
66
|
};
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import { LuiFileInputBox } from '@linzjs/lui';
|
|
2
2
|
import { LuiFileInputBoxProps } from '@linzjs/lui/dist/components/LuiFormElements/LuiFileInputBox/LuiFileInputBox';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import
|
|
4
|
+
import { ReactElement, useCallback, useMemo, useState } from 'react';
|
|
5
5
|
|
|
6
6
|
import { LuiModalAsync } from './LuiModalAsync';
|
|
7
|
+
import { LuiModalAsyncContent } from './LuiModalAsyncContent';
|
|
7
8
|
import { LuiModalAsyncCallback, PromiseWithResolve } from './LuiModalAsyncContext';
|
|
9
|
+
import { LuiModalAsyncHeader } from './LuiModalAsyncHeader';
|
|
8
10
|
import { useShowAsyncModal } from './useShowAsyncModal';
|
|
9
11
|
|
|
10
|
-
export interface useLuiModalUploadProps<
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
export interface useLuiModalUploadProps extends Omit<LuiFileInputBoxProps, 'onValidFileSelected'> {
|
|
13
|
+
title?: string;
|
|
14
|
+
content?: ReactElement | string;
|
|
13
15
|
validateFile?: (file: File) => string;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* A generic template for common types of modals.
|
|
18
20
|
*/
|
|
19
|
-
export const LuiModalUpload = (
|
|
20
|
-
|
|
21
|
+
export const LuiModalUpload = ({
|
|
22
|
+
validateFile,
|
|
23
|
+
resolve,
|
|
24
|
+
title,
|
|
25
|
+
width,
|
|
26
|
+
content,
|
|
27
|
+
...props
|
|
28
|
+
}: useLuiModalUploadProps & LuiModalAsyncCallback<File>): ReactElement => {
|
|
21
29
|
const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);
|
|
22
30
|
|
|
23
31
|
const uploadFile = useCallback(
|
|
@@ -33,10 +41,16 @@ export const LuiModalUpload = (props: PropsWithChildren<useLuiModalUploadProps<F
|
|
|
33
41
|
);
|
|
34
42
|
|
|
35
43
|
return (
|
|
36
|
-
<LuiModalAsync
|
|
44
|
+
<LuiModalAsync
|
|
45
|
+
className={clsx('LuiModalPrefab', `LuiModalPrefab-file`)}
|
|
46
|
+
closeOnOverlayClick={true}
|
|
47
|
+
style={{ width: width ?? 512 }}
|
|
48
|
+
>
|
|
49
|
+
{title && <LuiModalAsyncHeader title={title ?? 'Upload file...'} closeButton />}
|
|
50
|
+
{content && <LuiModalAsyncContent>{content}</LuiModalAsyncContent>}
|
|
37
51
|
<LuiFileInputBox
|
|
38
52
|
{...props}
|
|
39
|
-
width={
|
|
53
|
+
width={'100%'}
|
|
40
54
|
showMustSelectFileError={!!errorMessage}
|
|
41
55
|
customFileErrorMessage={errorMessage}
|
|
42
56
|
onValidFileSelected={uploadFile}
|
|
@@ -49,7 +63,7 @@ export const useLuiModalUpload = () => {
|
|
|
49
63
|
const { showModal, modalOwnerRef } = useShowAsyncModal();
|
|
50
64
|
|
|
51
65
|
const showUploadModal = useCallback(
|
|
52
|
-
(props:
|
|
66
|
+
(props: useLuiModalUploadProps): PromiseWithResolve<File> => {
|
|
53
67
|
return showModal(LuiModalUpload, props) as PromiseWithResolve<File>;
|
|
54
68
|
},
|
|
55
69
|
[showModal],
|