@linzjs/windows 10.3.0 → 11.0.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.
- package/dist/LuiModalAsync/LuiModalAsync.d.ts +14 -0
- package/dist/LuiModalAsync/LuiModalAsync.js +45 -0
- package/dist/LuiModalAsync/LuiModalAsync.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsync.scss +0 -1
- package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.d.ts +19 -0
- package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.js +27 -0
- package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncContent.d.ts +6 -0
- package/dist/LuiModalAsync/LuiModalAsyncContent.js +7 -0
- package/dist/LuiModalAsync/LuiModalAsyncContent.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncContext.d.ts +28 -0
- package/dist/LuiModalAsync/LuiModalAsyncContext.js +9 -0
- package/dist/LuiModalAsync/LuiModalAsyncContext.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncContextProvider.d.ts +54 -0
- package/dist/LuiModalAsync/LuiModalAsyncContextProvider.js +160 -0
- package/dist/LuiModalAsync/LuiModalAsyncContextProvider.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncHeader.d.ts +15 -0
- package/dist/LuiModalAsync/LuiModalAsyncHeader.js +23 -0
- package/dist/LuiModalAsync/LuiModalAsyncHeader.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.d.ts +13 -0
- package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.js +13 -0
- package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncMain.d.ts +5 -0
- package/dist/LuiModalAsync/LuiModalAsyncMain.js +6 -0
- package/dist/LuiModalAsync/LuiModalAsyncMain.js.map +1 -0
- package/dist/LuiModalAsync/index.js +12 -0
- package/dist/LuiModalAsync/index.js.map +1 -0
- package/dist/LuiModalAsync/useLuiModalPrefab.d.ts +56 -0
- package/dist/LuiModalAsync/useLuiModalPrefab.js +118 -0
- package/dist/LuiModalAsync/useLuiModalPrefab.js.map +1 -0
- package/dist/LuiModalAsync/useLuiModalUpload.d.ts +16 -0
- package/dist/LuiModalAsync/useLuiModalUpload.js +34 -0
- package/dist/LuiModalAsync/useLuiModalUpload.js.map +1 -0
- package/dist/LuiModalAsync/useShowAsyncModal.d.ts +6 -0
- package/dist/LuiModalAsync/useShowAsyncModal.js +13 -0
- package/dist/LuiModalAsync/useShowAsyncModal.js.map +1 -0
- package/dist/common/debug.d.ts +1 -0
- package/dist/common/debug.js +11 -0
- package/dist/common/debug.js.map +1 -0
- package/dist/common/index.js +3 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/useConstFunction.d.ts +5 -0
- package/dist/common/useConstFunction.js +17 -0
- package/dist/common/useConstFunction.js.map +1 -0
- package/dist/common/useInterval.d.ts +17 -0
- package/dist/common/{useInterval.ts → useInterval.js} +21 -25
- package/dist/common/useInterval.js.map +1 -0
- package/dist/common/useIsomorphicLayoutEffect.d.ts +17 -0
- package/dist/common/{useIsomorphicLayoutEffect.ts → useIsomorphicLayoutEffect.js} +1 -1
- package/dist/common/useIsomorphicLayoutEffect.js.map +1 -0
- package/dist/common/util.d.ts +3 -0
- package/dist/common/util.js +25 -0
- package/dist/common/util.js.map +1 -0
- package/dist/common/uuid.d.ts +1 -0
- package/dist/common/{uuid.ts → uuid.js} +1 -1
- package/dist/common/uuid.js.map +1 -0
- package/dist/components/CopyableText.d.ts +9 -0
- package/dist/components/CopyableText.js +29 -0
- package/dist/components/CopyableText.js.map +1 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/panel/OpenPanelButton.d.ts +8 -0
- package/dist/panel/OpenPanelButton.js +11 -0
- package/dist/panel/OpenPanelButton.js.map +1 -0
- package/dist/panel/Panel.d.ts +10 -0
- package/dist/panel/Panel.js +122 -0
- package/dist/panel/Panel.js.map +1 -0
- package/dist/panel/PanelContext.d.ts +10 -0
- package/dist/panel/PanelContext.js +13 -0
- package/dist/panel/PanelContext.js.map +1 -0
- package/dist/panel/PanelDock.d.ts +5 -0
- package/dist/panel/PanelDock.js +9 -0
- package/dist/panel/PanelDock.js.map +1 -0
- package/dist/panel/PanelHeader.d.ts +15 -0
- package/dist/panel/PanelHeader.js +33 -0
- package/dist/panel/PanelHeader.js.map +1 -0
- package/dist/panel/PanelHeaderButton.d.ts +8 -0
- package/dist/panel/PanelHeaderButton.js +16 -0
- package/dist/panel/PanelHeaderButton.js.map +1 -0
- package/dist/panel/PanelInline.d.ts +10 -0
- package/dist/panel/PanelInline.js +26 -0
- package/dist/panel/PanelInline.js.map +1 -0
- package/dist/panel/PanelInstanceContext.d.ts +21 -0
- package/dist/panel/PanelInstanceContext.js +25 -0
- package/dist/panel/PanelInstanceContext.js.map +1 -0
- package/dist/panel/PanelInstanceContextProvider.d.ts +11 -0
- package/dist/panel/PanelInstanceContextProvider.js +50 -0
- package/dist/panel/PanelInstanceContextProvider.js.map +1 -0
- package/dist/panel/PanelsContext.d.ts +33 -0
- package/dist/panel/PanelsContext.js +19 -0
- package/dist/panel/PanelsContext.js.map +1 -0
- package/dist/panel/PanelsContextProvider.d.ts +12 -0
- package/dist/panel/PanelsContextProvider.js +145 -0
- package/dist/panel/PanelsContextProvider.js.map +1 -0
- package/dist/panel/PopinWIndow.d.ts +11 -0
- package/dist/panel/PopinWIndow.js +74 -0
- package/dist/panel/PopinWIndow.js.map +1 -0
- package/dist/panel/PopoutWindow.d.ts +17 -0
- package/dist/panel/PopoutWindow.js +72 -0
- package/dist/panel/PopoutWindow.js.map +1 -0
- package/dist/panel/generateId.d.ts +6 -0
- package/dist/panel/{generateId.ts → generateId.js} +3 -4
- package/dist/panel/generateId.js.map +1 -0
- package/dist/panel/handleStyleSheetsChanges.d.ts +9 -0
- package/dist/panel/handleStyleSheetsChanges.js +65 -0
- package/dist/panel/handleStyleSheetsChanges.js.map +1 -0
- package/dist/panel/index.js +13 -0
- package/dist/panel/index.js.map +1 -0
- package/dist/panel/openExternalWindow.d.ts +23 -0
- package/dist/panel/openExternalWindow.js +62 -0
- package/dist/panel/openExternalWindow.js.map +1 -0
- package/dist/panel/types/{PanelPosition.ts → PanelPosition.d.ts} +2 -2
- package/dist/panel/types/PanelPosition.js +2 -0
- package/dist/panel/types/PanelPosition.js.map +1 -0
- package/dist/panel/types/PanelProps.d.ts +19 -0
- package/dist/panel/types/PanelProps.js +2 -0
- package/dist/panel/types/PanelProps.js.map +1 -0
- package/dist/panel/types/{PanelRestoredState.ts → PanelRestoredState.d.ts} +3 -4
- package/dist/panel/types/PanelRestoredState.js +2 -0
- package/dist/panel/types/PanelRestoredState.js.map +1 -0
- package/dist/panel/types/PanelSize.d.ts +8 -0
- package/dist/panel/types/PanelSize.js +2 -0
- package/dist/panel/types/PanelSize.js.map +1 -0
- package/dist/panel/types/{PanelState.ts → PanelState.d.ts} +5 -8
- package/dist/panel/types/PanelState.js +2 -0
- package/dist/panel/types/PanelState.js.map +1 -0
- package/dist/panel/types/{PanelStateOptions.ts → PanelStateOptions.d.ts} +4 -6
- package/dist/panel/types/PanelStateOptions.js +2 -0
- package/dist/panel/types/PanelStateOptions.js.map +1 -0
- package/dist/panel/types/index.js +7 -0
- package/dist/panel/types/index.js.map +1 -0
- package/dist/panel/usePanelStateHandler.d.ts +8 -0
- package/dist/panel/usePanelStateHandler.js +81 -0
- package/dist/panel/usePanelStateHandler.js.map +1 -0
- package/dist/ribbon/RibbonButton.d.ts +21 -0
- package/dist/ribbon/RibbonButton.js +28 -0
- package/dist/ribbon/RibbonButton.js.map +1 -0
- package/dist/ribbon/RibbonButtonLink.d.ts +12 -0
- package/dist/ribbon/RibbonButtonLink.js +11 -0
- package/dist/ribbon/RibbonButtonLink.js.map +1 -0
- package/dist/ribbon/RibbonButtonOpenPanel.d.ts +5 -0
- package/dist/ribbon/RibbonButtonOpenPanel.js +11 -0
- package/dist/ribbon/RibbonButtonOpenPanel.js.map +1 -0
- package/dist/ribbon/RibbonButtonSlider.d.ts +11 -0
- package/dist/ribbon/RibbonButtonSlider.js +28 -0
- package/dist/ribbon/RibbonButtonSlider.js.map +1 -0
- package/dist/ribbon/RibbonButtonSliderContext.d.ts +25 -0
- package/dist/ribbon/RibbonButtonSliderContext.js +25 -0
- package/dist/ribbon/RibbonButtonSliderContext.js.map +1 -0
- package/dist/ribbon/RibbonContainer.d.ts +10 -0
- package/dist/ribbon/RibbonContainer.js +7 -0
- package/dist/ribbon/RibbonContainer.js.map +1 -0
- package/dist/ribbon/RibbonDeprecated.d.ts +10 -0
- package/dist/ribbon/RibbonDeprecated.js +13 -0
- package/dist/ribbon/RibbonDeprecated.js.map +1 -0
- package/dist/ribbon/RibbonMenu.d.ts +7 -0
- package/dist/ribbon/RibbonMenu.js +12 -0
- package/dist/ribbon/RibbonMenu.js.map +1 -0
- package/dist/ribbon/RibbonMenuOption.d.ts +17 -0
- package/dist/ribbon/RibbonMenuOption.js +26 -0
- package/dist/ribbon/RibbonMenuOption.js.map +1 -0
- package/dist/ribbon/RibbonMenuSeparator.d.ts +2 -0
- package/dist/ribbon/RibbonMenuSeparator.js +6 -0
- package/dist/ribbon/RibbonMenuSeparator.js.map +1 -0
- package/dist/ribbon/RibbonSeparator.d.ts +2 -0
- package/dist/ribbon/RibbonSeparator.js +4 -0
- package/dist/ribbon/RibbonSeparator.js.map +1 -0
- package/dist/ribbon/index.js +12 -0
- package/dist/ribbon/index.js.map +1 -0
- package/package.json +14 -8
- package/dist/LuiModalAsync/LuiModalAsync.tsx +0 -82
- package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.tsx +0 -55
- package/dist/LuiModalAsync/LuiModalAsyncContent.tsx +0 -9
- package/dist/LuiModalAsync/LuiModalAsyncContext.tsx +0 -52
- package/dist/LuiModalAsync/LuiModalAsyncContextProvider.tsx +0 -223
- package/dist/LuiModalAsync/LuiModalAsyncHeader.tsx +0 -67
- package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.ts +0 -24
- package/dist/LuiModalAsync/LuiModalAsyncMain.tsx +0 -8
- package/dist/LuiModalAsync/useLuiModalPrefab.tsx +0 -227
- package/dist/LuiModalAsync/useLuiModalUpload.tsx +0 -79
- package/dist/LuiModalAsync/useShowAsyncModal.ts +0 -34
- package/dist/common/debug.ts +0 -9
- package/dist/common/useConstFunction.ts +0 -22
- package/dist/common/util.ts +0 -31
- package/dist/components/CopyableText.tsx +0 -58
- package/dist/panel/OpenPanelButton.tsx +0 -52
- package/dist/panel/Panel.tsx +0 -211
- package/dist/panel/PanelContext.ts +0 -22
- package/dist/panel/PanelDock.tsx +0 -20
- package/dist/panel/PanelHeader.tsx +0 -105
- package/dist/panel/PanelHeaderButton.tsx +0 -26
- package/dist/panel/PanelInline.tsx +0 -46
- package/dist/panel/PanelInstanceContext.ts +0 -44
- package/dist/panel/PanelInstanceContextProvider.tsx +0 -75
- package/dist/panel/PanelsContext.tsx +0 -56
- package/dist/panel/PanelsContextProvider.tsx +0 -220
- package/dist/panel/PopinWIndow.tsx +0 -147
- package/dist/panel/PopoutWindow.tsx +0 -117
- package/dist/panel/handleStyleSheetsChanges.ts +0 -71
- package/dist/panel/openExternalWindow.ts +0 -98
- package/dist/panel/types/PanelProps.ts +0 -22
- package/dist/panel/types/PanelSize.ts +0 -9
- package/dist/panel/usePanelStateHandler.tsx +0 -102
- package/dist/ribbon/RibbonButton.tsx +0 -112
- package/dist/ribbon/RibbonButtonLink.tsx +0 -27
- package/dist/ribbon/RibbonButtonOpenPanel.tsx +0 -23
- package/dist/ribbon/RibbonButtonSlider.tsx +0 -66
- package/dist/ribbon/RibbonButtonSliderContext.tsx +0 -34
- package/dist/ribbon/RibbonContainer.tsx +0 -19
- package/dist/ribbon/RibbonDeprecated.tsx +0 -27
- package/dist/ribbon/RibbonMenu.tsx +0 -25
- package/dist/ribbon/RibbonMenuOption.tsx +0 -67
- package/dist/ribbon/RibbonMenuSeparator.tsx +0 -5
- package/dist/ribbon/RibbonSeparator.tsx +0 -3
- /package/dist/LuiModalAsync/{index.ts → index.d.ts} +0 -0
- /package/dist/common/{index.ts → index.d.ts} +0 -0
- /package/dist/components/{index.ts → index.d.ts} +0 -0
- /package/dist/{index.ts → index.d.ts} +0 -0
- /package/dist/panel/{index.ts → index.d.ts} +0 -0
- /package/dist/panel/types/{index.ts → index.d.ts} +0 -0
- /package/dist/ribbon/{index.ts → index.d.ts} +0 -0
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { LuiButton, LuiCheckboxInput, LuiIcon, LuiMiniSpinner } from '@linzjs/lui';
|
|
2
|
-
import { LuiButtonProps } from '@linzjs/lui/dist/components/LuiButton/LuiButton';
|
|
3
|
-
import { IconName } from '@linzjs/lui/dist/components/LuiIcon/LuiIcon';
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
import { flatMap, omit, pick } from 'lodash-es';
|
|
6
|
-
import React, { PropsWithChildren, ReactElement, useCallback, useMemo, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { debugLog } from '../common/debug';
|
|
9
|
-
import { LuiModalAsync, LuiModalAsyncProps } from './LuiModalAsync';
|
|
10
|
-
import { LuiModalAsyncButtonGroup } from './LuiModalAsyncButtonGroup';
|
|
11
|
-
import { LuiModalAsyncContent } from './LuiModalAsyncContent';
|
|
12
|
-
import { LuiModalAsyncCallback, PromiseWithResolve } from './LuiModalAsyncContext';
|
|
13
|
-
import { LuiModalAsyncHeader } from './LuiModalAsyncHeader';
|
|
14
|
-
import { LuiModalAsyncMain } from './LuiModalAsyncMain';
|
|
15
|
-
import { useShowAsyncModal } from './useShowAsyncModal';
|
|
16
|
-
|
|
17
|
-
export type PrefabType = 'outline' | 'success' | 'info' | 'warning' | 'error' | 'progress' | 'blocked';
|
|
18
|
-
|
|
19
|
-
export interface LuiModalAsyncPrefabButton<RT> {
|
|
20
|
-
default?: boolean;
|
|
21
|
-
level?: LuiButtonProps['level'] | 'secondary-error';
|
|
22
|
-
title: string;
|
|
23
|
-
icon?: IconName;
|
|
24
|
-
value?: RT;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface useLuiModalPrefabProps<RT = string> extends LuiModalAsyncProps {
|
|
28
|
-
showOnAllWindows?: boolean;
|
|
29
|
-
level: PrefabType;
|
|
30
|
-
title: string;
|
|
31
|
-
helpLink?: string;
|
|
32
|
-
onHelpClick?: () => void;
|
|
33
|
-
buttons?: LuiModalAsyncPrefabButton<RT>[];
|
|
34
|
-
dontShowAgainSessionKey?: string;
|
|
35
|
-
polledCloseCondition?: () => boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface LuiModalAsyncPrefabProps<RT> extends useLuiModalPrefabProps<RT>, LuiModalAsyncCallback<RT> {
|
|
39
|
-
//
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
43
|
-
export const getIconForLevel = (level: PrefabType): IconName | 'custom_progress' | null => {
|
|
44
|
-
switch (level) {
|
|
45
|
-
case 'success':
|
|
46
|
-
return 'ic_check_circle_outline';
|
|
47
|
-
case 'info':
|
|
48
|
-
return 'ic_info_outline';
|
|
49
|
-
case 'warning':
|
|
50
|
-
return 'ic_warning_outline';
|
|
51
|
-
case 'error':
|
|
52
|
-
return 'ic_error_outline';
|
|
53
|
-
case 'progress':
|
|
54
|
-
return 'custom_progress';
|
|
55
|
-
case 'blocked':
|
|
56
|
-
return 'ic_lock_alt';
|
|
57
|
-
case 'outline':
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const LuiModalDontShowSessionStorageKey = (userKey: string): string => `__LuiModalContext_dontshowagain_${userKey}`;
|
|
63
|
-
|
|
64
|
-
export const LuiModalDontShowSessionSet = (userKey: string): void =>
|
|
65
|
-
window.sessionStorage.setItem(LuiModalDontShowSessionStorageKey(userKey), 'true');
|
|
66
|
-
|
|
67
|
-
export const LuiModalDontShowSessionRemove = (userKey: string): void =>
|
|
68
|
-
window.sessionStorage.removeItem(LuiModalDontShowSessionStorageKey(userKey));
|
|
69
|
-
|
|
70
|
-
export const LuiModalDontShowSessionCheck = (userKey: string): boolean =>
|
|
71
|
-
!!window.sessionStorage.getItem(LuiModalDontShowSessionStorageKey(userKey));
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* A generic template for common types of modals.
|
|
75
|
-
*/
|
|
76
|
-
export const LuiModalPrefab = (props: PropsWithChildren<LuiModalAsyncPrefabProps<unknown>>): ReactElement => {
|
|
77
|
-
const {
|
|
78
|
-
level = 'warning',
|
|
79
|
-
className,
|
|
80
|
-
style,
|
|
81
|
-
title,
|
|
82
|
-
helpLink,
|
|
83
|
-
onHelpClick,
|
|
84
|
-
children,
|
|
85
|
-
resolve,
|
|
86
|
-
closeOnOverlayClick,
|
|
87
|
-
dontShowAgainSessionKey,
|
|
88
|
-
} = props;
|
|
89
|
-
const [dontShowAgain, setDontShowAgain] = useState(false);
|
|
90
|
-
|
|
91
|
-
const icon = getIconForLevel(level);
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Default buttons
|
|
95
|
-
* Warning, Info, Error, Success: "Dismiss"
|
|
96
|
-
* Progress: "Cancel"
|
|
97
|
-
*/
|
|
98
|
-
const buttons: LuiModalAsyncPrefabButton<unknown>[] = props.buttons ?? [
|
|
99
|
-
{
|
|
100
|
-
title: level === 'progress' ? 'Cancel' : 'Dismiss',
|
|
101
|
-
},
|
|
102
|
-
];
|
|
103
|
-
|
|
104
|
-
// If there are two options, option 1 is secondary, option 2 is primary
|
|
105
|
-
// Otherwise all options are secondary
|
|
106
|
-
if (buttons.length === 2) {
|
|
107
|
-
buttons.forEach((b, i) => {
|
|
108
|
-
if (!b.level) {
|
|
109
|
-
// Last button is primary all others are secondary
|
|
110
|
-
b.level = i === buttons.length - 1 ? 'primary' : 'secondary';
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* When dialog closes save the "don't show" property
|
|
117
|
-
*/
|
|
118
|
-
const setDontShow = () => {
|
|
119
|
-
if (dontShowAgainSessionKey && dontShowAgain) {
|
|
120
|
-
LuiModalDontShowSessionSet(dontShowAgainSessionKey);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<LuiModalAsync
|
|
126
|
-
className={clsx('LuiModalPrefab', `LuiModalPrefab-${level}`, className)}
|
|
127
|
-
style={style}
|
|
128
|
-
closeOnOverlayClick={closeOnOverlayClick}
|
|
129
|
-
>
|
|
130
|
-
<LuiModalAsyncMain>
|
|
131
|
-
<LuiModalAsyncHeader
|
|
132
|
-
title={title}
|
|
133
|
-
icon={icon === 'custom_progress' ? <LuiMiniSpinner size={24} /> : icon}
|
|
134
|
-
helpLink={helpLink}
|
|
135
|
-
onHelpClick={onHelpClick}
|
|
136
|
-
/>
|
|
137
|
-
<LuiModalAsyncContent>{children}</LuiModalAsyncContent>
|
|
138
|
-
{dontShowAgainSessionKey && (
|
|
139
|
-
<LuiCheckboxInput
|
|
140
|
-
className={'LuiCheckboxInput--nomargin'}
|
|
141
|
-
label={"Don't show me this again"}
|
|
142
|
-
value={'dontShowAgain'}
|
|
143
|
-
isChecked={dontShowAgain}
|
|
144
|
-
onChange={(e) => setDontShowAgain(e.target.checked)}
|
|
145
|
-
/>
|
|
146
|
-
)}
|
|
147
|
-
</LuiModalAsyncMain>
|
|
148
|
-
<LuiModalAsyncButtonGroup>
|
|
149
|
-
{buttons.map((pf, i) => (
|
|
150
|
-
<LuiButton
|
|
151
|
-
key={i}
|
|
152
|
-
level={pf.level === 'secondary-error' ? 'secondary' : (pf.level ?? 'secondary')}
|
|
153
|
-
className={clsx(
|
|
154
|
-
pf.icon && 'lui-button-icon',
|
|
155
|
-
pf.level === 'secondary-error' && 'lui-button-secondary-error',
|
|
156
|
-
)}
|
|
157
|
-
onClick={() => {
|
|
158
|
-
setDontShow();
|
|
159
|
-
resolve(pf.value);
|
|
160
|
-
}}
|
|
161
|
-
buttonProps={pf.default ? { 'data-autofocus': true } : undefined}
|
|
162
|
-
>
|
|
163
|
-
{pf.icon && <LuiIcon name={pf.icon} alt={pf.title} size={'md'} />}
|
|
164
|
-
{pf.title}
|
|
165
|
-
</LuiButton>
|
|
166
|
-
))}
|
|
167
|
-
</LuiModalAsyncButtonGroup>
|
|
168
|
-
</LuiModalAsync>
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Instantiate a generic template for common types of modals.
|
|
174
|
-
*
|
|
175
|
-
* Usage:
|
|
176
|
-
* const { modalOwnerRef, showPrefabModal } = useLuiModalPrefab();
|
|
177
|
-
*
|
|
178
|
-
* return (
|
|
179
|
-
* <button
|
|
180
|
-
* ref={modalOwnerRef}
|
|
181
|
-
* onClick={() =>
|
|
182
|
-
* showPrefabModal({
|
|
183
|
-
* level: 'info',
|
|
184
|
-
* title: 'You are a fantastic person',
|
|
185
|
-
* children: 'Keep it up!',
|
|
186
|
-
* })
|
|
187
|
-
* }>
|
|
188
|
-
* Open Modal
|
|
189
|
-
* </button>
|
|
190
|
-
*/
|
|
191
|
-
export const useLuiModalPrefab = () => {
|
|
192
|
-
const { showModal, modalOwnerRef } = useShowAsyncModal();
|
|
193
|
-
|
|
194
|
-
const showPrefabModal = useCallback(
|
|
195
|
-
<RT = string,>(props: PropsWithChildren<useLuiModalPrefabProps<RT>>): PromiseWithResolve<RT> => {
|
|
196
|
-
debugLog(`Show '${props.level}' prefab-modal '${props.title}'`, props);
|
|
197
|
-
if (typeof props.children === 'string') {
|
|
198
|
-
// Convert \n to <br/>
|
|
199
|
-
const split = props.children.split('\n');
|
|
200
|
-
props.children = flatMap(split.map((part, i) => (i !== split.length - 1 ? [part, <br key={i} />] : part)));
|
|
201
|
-
}
|
|
202
|
-
if (
|
|
203
|
-
(props.dontShowAgainSessionKey && LuiModalDontShowSessionCheck(props.dontShowAgainSessionKey)) ||
|
|
204
|
-
(props.polledCloseCondition && props.polledCloseCondition())
|
|
205
|
-
) {
|
|
206
|
-
// Add resolve method to make the signature of showPrefabModal consistent
|
|
207
|
-
const prom = Promise.resolve(undefined) as PromiseWithResolve<RT>;
|
|
208
|
-
prom.resolve = (_val: RT | undefined) => {};
|
|
209
|
-
return prom;
|
|
210
|
-
}
|
|
211
|
-
return showModal(
|
|
212
|
-
LuiModalPrefab,
|
|
213
|
-
omit(props, ['showOnAllWindows', 'polledCloseCondition']),
|
|
214
|
-
pick(props, ['showOnAllWindows', 'polledCloseCondition']),
|
|
215
|
-
) as PromiseWithResolve<RT>;
|
|
216
|
-
},
|
|
217
|
-
[showModal],
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
return useMemo(
|
|
221
|
-
() => ({
|
|
222
|
-
modalOwnerRef,
|
|
223
|
-
showPrefabModal,
|
|
224
|
-
}),
|
|
225
|
-
[modalOwnerRef, showPrefabModal],
|
|
226
|
-
);
|
|
227
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { LuiFileInputBox } from '@linzjs/lui';
|
|
2
|
-
import { LuiFileInputBoxProps } from '@linzjs/lui/dist/components/LuiFormElements/LuiFileInputBox/LuiFileInputBox';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { ReactElement, useCallback, useMemo, useState } from 'react';
|
|
5
|
-
|
|
6
|
-
import { LuiModalAsync } from './LuiModalAsync';
|
|
7
|
-
import { LuiModalAsyncCallback, PromiseWithResolve } from './LuiModalAsyncContext';
|
|
8
|
-
import { LuiModalAsyncHeader } from './LuiModalAsyncHeader';
|
|
9
|
-
import { useShowAsyncModal } from './useShowAsyncModal';
|
|
10
|
-
|
|
11
|
-
export interface useLuiModalUploadProps extends Omit<LuiFileInputBoxProps, 'onValidFileSelected'> {
|
|
12
|
-
title?: string;
|
|
13
|
-
content?: ReactElement | string;
|
|
14
|
-
validateFile?: (file: File) => string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* A generic template for common types of modals.
|
|
19
|
-
*/
|
|
20
|
-
export const LuiModalUpload = ({
|
|
21
|
-
validateFile,
|
|
22
|
-
resolve,
|
|
23
|
-
title,
|
|
24
|
-
width,
|
|
25
|
-
height,
|
|
26
|
-
content,
|
|
27
|
-
...props
|
|
28
|
-
}: useLuiModalUploadProps & LuiModalAsyncCallback<File>): ReactElement => {
|
|
29
|
-
const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);
|
|
30
|
-
|
|
31
|
-
const uploadFile = useCallback(
|
|
32
|
-
(file: File) => {
|
|
33
|
-
const error = validateFile?.(file);
|
|
34
|
-
if (error) {
|
|
35
|
-
setErrorMessage(error);
|
|
36
|
-
} else {
|
|
37
|
-
resolve(file);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
[resolve, validateFile],
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<LuiModalAsync
|
|
45
|
-
className={clsx('LuiModalPrefab', `LuiModalPrefab-file`)}
|
|
46
|
-
closeOnOverlayClick={true}
|
|
47
|
-
style={{ width: width ?? 512, minHeight: height, height: height }}
|
|
48
|
-
>
|
|
49
|
-
{title && <LuiModalAsyncHeader title={title ?? 'Upload file...'} closeButton />}
|
|
50
|
-
{content}
|
|
51
|
-
<LuiFileInputBox
|
|
52
|
-
{...props}
|
|
53
|
-
width={'100%'}
|
|
54
|
-
showMustSelectFileError={!!errorMessage}
|
|
55
|
-
customFileErrorMessage={errorMessage ?? props.customFileErrorMessage}
|
|
56
|
-
onValidFileSelected={uploadFile}
|
|
57
|
-
/>
|
|
58
|
-
</LuiModalAsync>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const useLuiModalUpload = () => {
|
|
63
|
-
const { showModal, modalOwnerRef } = useShowAsyncModal();
|
|
64
|
-
|
|
65
|
-
const showUploadModal = useCallback(
|
|
66
|
-
(props: useLuiModalUploadProps): PromiseWithResolve<File> => {
|
|
67
|
-
return showModal(LuiModalUpload, props) as PromiseWithResolve<File>;
|
|
68
|
-
},
|
|
69
|
-
[showModal],
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
return useMemo(
|
|
73
|
-
() => ({
|
|
74
|
-
modalOwnerRef,
|
|
75
|
-
showUploadModal,
|
|
76
|
-
}),
|
|
77
|
-
[modalOwnerRef, showUploadModal],
|
|
78
|
-
);
|
|
79
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ComponentProps, useCallback, useContext, useMemo, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ComponentType,
|
|
5
|
-
LuiModalAsyncContext,
|
|
6
|
-
openModalOnAllWindows,
|
|
7
|
-
PromiseWithResolve,
|
|
8
|
-
ShowModalProps,
|
|
9
|
-
} from './LuiModalAsyncContext';
|
|
10
|
-
|
|
11
|
-
export const useShowAsyncModal = () => {
|
|
12
|
-
const { showModal } = useContext(LuiModalAsyncContext);
|
|
13
|
-
|
|
14
|
-
// eslint-disable-next-line
|
|
15
|
-
const modalOwnerRef = useRef<any>(document.body);
|
|
16
|
-
|
|
17
|
-
const showModalAsync = useCallback(
|
|
18
|
-
<CT extends ComponentType>(
|
|
19
|
-
component: CT,
|
|
20
|
-
args: Omit<ComponentProps<CT>, 'resolve' | 'close'>,
|
|
21
|
-
props?: ShowModalProps,
|
|
22
|
-
): PromiseWithResolve<Parameters<ComponentProps<CT>['resolve']>[0]> =>
|
|
23
|
-
showModal(props?.showOnAllWindows ? openModalOnAllWindows : modalOwnerRef, component, args, props),
|
|
24
|
-
[showModal],
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
return useMemo(
|
|
28
|
-
() => ({
|
|
29
|
-
showModal: showModalAsync,
|
|
30
|
-
modalOwnerRef,
|
|
31
|
-
}),
|
|
32
|
-
[showModalAsync],
|
|
33
|
-
);
|
|
34
|
-
};
|
package/dist/common/debug.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
const VoidFn = () => {
|
|
4
|
-
// empty
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* When calling external non-react components, and you can't update the function when state changes,
|
|
9
|
-
* use this to proxy the dynamic function with a static function.
|
|
10
|
-
*/
|
|
11
|
-
export const useConstFunction = <Args extends never[], R, TFn extends ((...args: Args) => R) | null | undefined>(
|
|
12
|
-
fn: TFn = VoidFn as TFn,
|
|
13
|
-
): TFn => {
|
|
14
|
-
const functionRef = useRef<TFn>(fn);
|
|
15
|
-
const proxyRef = useRef<TFn>(((...args: Args) => functionRef.current?.(...args)) as TFn);
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
functionRef.current = fn;
|
|
19
|
-
}, [fn]);
|
|
20
|
-
|
|
21
|
-
return proxyRef.current;
|
|
22
|
-
};
|
package/dist/common/util.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const tabToNextSiblingElement = (): void => tabToSiblingElement(1);
|
|
2
|
-
export const tabToPreviousSiblingElement = (): void => tabToSiblingElement(-1);
|
|
3
|
-
|
|
4
|
-
export const tabToSiblingElement = (direction: 1 | -1): void => {
|
|
5
|
-
const active = document.activeElement as HTMLElement | null;
|
|
6
|
-
if (!active) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const selector = [
|
|
11
|
-
'a[href]',
|
|
12
|
-
'area[href]',
|
|
13
|
-
'button:not([disabled])',
|
|
14
|
-
'input:not([disabled]):not([type="hidden"])',
|
|
15
|
-
'select:not([disabled])',
|
|
16
|
-
'textarea:not([disabled])',
|
|
17
|
-
'iframe',
|
|
18
|
-
'[tabindex]:not([tabindex="-1"])',
|
|
19
|
-
'[contenteditable="true"]',
|
|
20
|
-
].join(',');
|
|
21
|
-
|
|
22
|
-
const focusables = Array.from(active.parentElement?.querySelectorAll<HTMLElement>(selector) ?? []).filter(
|
|
23
|
-
(el) => el.offsetParent !== null && getComputedStyle(el).visibility !== 'hidden',
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const next = focusables.indexOf(active) + direction;
|
|
27
|
-
|
|
28
|
-
if (next >= 0 && next < focusables.length) {
|
|
29
|
-
focusables[next]?.focus();
|
|
30
|
-
}
|
|
31
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import '../index.scss';
|
|
2
|
-
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { CSSProperties, MouseEvent, ReactElement, useEffect, useRef, useState } from 'react';
|
|
5
|
-
|
|
6
|
-
export interface CopyableTextProps {
|
|
7
|
-
dataTestId?: string;
|
|
8
|
-
style?: CSSProperties;
|
|
9
|
-
className?: string;
|
|
10
|
-
text: string | number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const CopyableText = (props: CopyableTextProps): ReactElement => {
|
|
14
|
-
const [copied, setCopied] = useState(false);
|
|
15
|
-
|
|
16
|
-
const { dataTestId, style, className, text } = props;
|
|
17
|
-
const timeoutRefDisplay = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
18
|
-
|
|
19
|
-
const copy = (event: MouseEvent<HTMLSpanElement>) => {
|
|
20
|
-
const win = event.currentTarget.ownerDocument.defaultView ?? window;
|
|
21
|
-
win.navigator.clipboard.writeText(String(text)).then(
|
|
22
|
-
() => {
|
|
23
|
-
setCopied(true);
|
|
24
|
-
timeoutRefDisplay.current = setTimeout(() => void setCopied(false), 3000);
|
|
25
|
-
},
|
|
26
|
-
(err: Error) => {
|
|
27
|
-
alert(`Data copy failed: ${err.message}`);
|
|
28
|
-
},
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
useEffect(
|
|
33
|
-
() => () => {
|
|
34
|
-
if (timeoutRefDisplay.current) {
|
|
35
|
-
clearTimeout(timeoutRefDisplay.current);
|
|
36
|
-
timeoutRefDisplay.current = null;
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
[],
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<span
|
|
44
|
-
data-testid={dataTestId}
|
|
45
|
-
style={style}
|
|
46
|
-
className={clsx('windows_tooltip', className)}
|
|
47
|
-
onClick={(event) => {
|
|
48
|
-
event.stopPropagation();
|
|
49
|
-
copy(event);
|
|
50
|
-
}}
|
|
51
|
-
>
|
|
52
|
-
<span className="windows_tooltiptext" style={{ width: copied ? '62px' : '47px' }}>
|
|
53
|
-
{copied ? 'Copied!' : 'Copy'}
|
|
54
|
-
</span>
|
|
55
|
-
{text}
|
|
56
|
-
</span>
|
|
57
|
-
);
|
|
58
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// Simple button to open panel and show panel state
|
|
2
|
-
import { useContext } from 'react';
|
|
3
|
-
|
|
4
|
-
import { OpenPanelOptions, PanelsContext } from './PanelsContext';
|
|
5
|
-
|
|
6
|
-
interface OpenPanelButtonProps extends OpenPanelOptions {
|
|
7
|
-
uniqueId?: string;
|
|
8
|
-
testId?: string;
|
|
9
|
-
buttonText: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const OpenPanelButton = ({
|
|
13
|
-
buttonText,
|
|
14
|
-
testId,
|
|
15
|
-
uniqueId = buttonText,
|
|
16
|
-
...openPanelOptions
|
|
17
|
-
}: OpenPanelButtonProps) => {
|
|
18
|
-
const { openPanel, closePanel, hidePanel, unhidePanel, hasOpenPanel, hasHiddenPanel } = useContext(PanelsContext);
|
|
19
|
-
|
|
20
|
-
const open = hasOpenPanel(uniqueId);
|
|
21
|
-
const hidden = hasHiddenPanel(uniqueId);
|
|
22
|
-
return (
|
|
23
|
-
<div>
|
|
24
|
-
<b>
|
|
25
|
-
{buttonText} {open ? '(Open)' : ''}
|
|
26
|
-
</b>
|
|
27
|
-
<br />
|
|
28
|
-
|
|
29
|
-
{!open && (
|
|
30
|
-
<button data-testid={testId + 'Open'} onClick={() => openPanel({ uniqueId, ...openPanelOptions })}>
|
|
31
|
-
Open
|
|
32
|
-
</button>
|
|
33
|
-
)}
|
|
34
|
-
{open && (
|
|
35
|
-
<>
|
|
36
|
-
<button data-testid={testId + 'Close'} onClick={() => closePanel(uniqueId)}>
|
|
37
|
-
Close
|
|
38
|
-
</button>
|
|
39
|
-
{hidden ? (
|
|
40
|
-
<button data-testid={testId + 'Unhide'} onClick={() => unhidePanel(uniqueId)}>
|
|
41
|
-
Unhide
|
|
42
|
-
</button>
|
|
43
|
-
) : (
|
|
44
|
-
<button data-testid={testId + 'Hide'} onClick={() => hidePanel(uniqueId)}>
|
|
45
|
-
Hide
|
|
46
|
-
</button>
|
|
47
|
-
)}
|
|
48
|
-
</>
|
|
49
|
-
)}
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
};
|