@linzjs/windows 8.3.0 → 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.
@@ -118,3 +118,11 @@ dialog.LuiModalAsync, div.LuiModalAsync {
118
118
  }
119
119
  }
120
120
 
121
+ dialog.LuiModalPrefab-file {
122
+ gap: lui.$unit-sm;
123
+ padding: lui.$unit-md;
124
+
125
+ .LuiModalAsync-content {
126
+ padding-bottom: lui.$unit-xs;
127
+ }
128
+ }
@@ -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) return;
45
- let input = d.querySelectorAll('[data-autofocus]')[0] as HTMLElement | undefined;
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
  };
@@ -7,4 +7,5 @@ export * from './LuiModalAsyncHeader';
7
7
  export * from './LuiModalAsyncInstanceContext';
8
8
  export * from './LuiModalAsyncMain';
9
9
  export * from './useLuiModalPrefab';
10
+ export * from './useLuiModalUpload';
10
11
  export * from './useShowAsyncModal';
@@ -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 React, { PropsWithChildren, ReactElement, useCallback, useMemo, useState } from 'react';
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<RT>
11
- extends Omit<LuiFileInputBoxProps, 'onValidFileSelected'>,
12
- LuiModalAsyncCallback<RT> {
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 = (props: PropsWithChildren<useLuiModalUploadProps<File>>): ReactElement => {
20
- const { validateFile, resolve } = props;
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 className={clsx('LuiModalPrefab', `LuiModalPrefab-file`)} closeOnOverlayClick={true}>
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={props.width ?? 512}
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: Omit<LuiFileInputBoxProps, 'onValidFileSelected'>): PromiseWithResolve<File> => {
66
+ (props: useLuiModalUploadProps): PromiseWithResolve<File> => {
53
67
  return showModal(LuiModalUpload, props) as PromiseWithResolve<File>;
54
68
  },
55
69
  [showModal],
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "popout"
14
14
  ],
15
15
  "main": "./dist/index.ts",
16
- "version": "8.3.0",
16
+ "version": "8.5.0",
17
17
  "peerDependencies": {
18
18
  "@linzjs/lui": ">=23",
19
19
  "lodash-es": ">=4",