@linzjs/windows 1.4.3 → 1.4.4
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 +1 -1
- package/src/modal/Modal.tsx +9 -4
- package/src/modal/ModalContext.scss +11 -0
- package/src/modal/ModalContextProvider.tsx +7 -4
- package/src/modal/PrefabModal.scss +21 -0
- package/src/modal/PrefabModal.tsx +7 -4
- package/src/panel/PanelsContextProvider.tsx +1 -1
- package/src/stories/modal/Modal.stories.tsx +1 -1
- package/src/stories/modal/PrefabModal.tsx +1 -3
- package/src/stories/modal/TestModal.scss +3 -23
- package/src/stories/modal/TestModal.tsx +8 -10
- package/src/stories/panel/PanelButtons/ShowPanel.tsx +5 -4
- package/src/stories/panel/ShowPanel/ShowPanel.tsx +3 -7
- package/src/stories/panel/ShowPanelDocking/ShowPanel.tsx +3 -7
- package/src/stories/panel/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +4 -4
- package/src/stories/panel/ShowTabbedPanel/ShowPanel.tsx +3 -7
package/package.json
CHANGED
package/src/modal/Modal.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ModalInstanceContext } from "./ModalInstanceContext";
|
|
2
|
+
import clsx from "clsx";
|
|
2
3
|
import { delay } from "lodash-es";
|
|
3
|
-
import { ReactElement, useContext, useEffect, useRef } from "react";
|
|
4
|
+
import { PropsWithChildren, ReactElement, useContext, useEffect, useRef } from "react";
|
|
4
5
|
|
|
5
6
|
export interface ModalProps {
|
|
6
|
-
|
|
7
|
+
className?: string;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export const Modal = ({ children }: ModalProps): ReactElement => {
|
|
10
|
+
export const Modal = ({ className, children }: PropsWithChildren<ModalProps>): ReactElement => {
|
|
10
11
|
const dialogRef = useRef<HTMLDialogElement>(null);
|
|
11
12
|
|
|
12
13
|
const { close } = useContext(ModalInstanceContext);
|
|
@@ -29,7 +30,11 @@ export const Modal = ({ children }: ModalProps): ReactElement => {
|
|
|
29
30
|
}, []);
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
|
-
<dialog
|
|
33
|
+
<dialog
|
|
34
|
+
className={clsx("linzjs-windows-dialog", className)}
|
|
35
|
+
ref={dialogRef}
|
|
36
|
+
onClick={(e) => e.target === e.currentTarget && close()}
|
|
37
|
+
>
|
|
33
38
|
{children}
|
|
34
39
|
</dialog>
|
|
35
40
|
);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import "./ModalContext.scss";
|
|
2
|
+
|
|
1
3
|
import { useInterval } from "../util/useInterval";
|
|
2
4
|
import { ComponentType, ModalContext } from "./ModalContext";
|
|
3
5
|
import { ModalInstanceContext } from "./ModalInstanceContext";
|
|
4
|
-
import { Fragment,
|
|
5
|
-
import
|
|
6
|
+
import React, { Fragment, ReactNode } from "react";
|
|
7
|
+
import { MutableRefObject, ReactElement, useCallback, useState } from "react";
|
|
8
|
+
import { createPortal } from "react-dom";
|
|
6
9
|
import { v4 as uuid } from "uuid";
|
|
7
10
|
|
|
8
11
|
export interface ModalInstance {
|
|
@@ -56,7 +59,7 @@ export interface ModalInstance {
|
|
|
56
59
|
* </li>
|
|
57
60
|
* </ol>
|
|
58
61
|
*/
|
|
59
|
-
export const ModalContextProvider = ({ children }: { children
|
|
62
|
+
export const ModalContextProvider = ({ children }: { children?: ReactNode | undefined }): ReactElement => {
|
|
60
63
|
const [modals, setModals] = useState<ModalInstance[]>([]);
|
|
61
64
|
|
|
62
65
|
/**
|
|
@@ -120,7 +123,7 @@ export const ModalContextProvider = ({ children }: { children: ReactElement }):
|
|
|
120
123
|
{modals
|
|
121
124
|
.filter(modalHasView)
|
|
122
125
|
.map((modalInstance) =>
|
|
123
|
-
|
|
126
|
+
createPortal(
|
|
124
127
|
<ModalInstanceContext.Provider value={{ close: () => modalInstance.resolve(undefined) }}>
|
|
125
128
|
{modalInstance.componentInstance}
|
|
126
129
|
</ModalInstanceContext.Provider>,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@use "node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars.scss" as colours;
|
|
2
|
+
|
|
3
|
+
dialog.linzjs-windows-dialog {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
padding: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
dialog.prefab-modal {
|
|
10
|
+
border-radius: 5px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
dialog.prefab-modal .lui-modal {
|
|
14
|
+
margin: 0 !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
dialog.prefab-modal .lui-button:focus {
|
|
18
|
+
outline: 2px solid colours.$brand-primary;
|
|
19
|
+
// make sure the button sits above the others so the outline is not cut off on focus
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import "./PrefabModal.scss";
|
|
2
|
+
|
|
1
3
|
import { Modal } from "./Modal";
|
|
2
4
|
import { ModalCallback } from "./ModalContext";
|
|
3
5
|
import { useShowModal } from "./useShowModal";
|
|
4
6
|
import { isEmpty } from "lodash-es";
|
|
5
|
-
import {
|
|
7
|
+
import React, { ReactElement } from "react";
|
|
6
8
|
|
|
7
9
|
import { LuiAlertModalButtons, LuiButton, LuiIcon } from "@linzjs/lui";
|
|
8
10
|
import { LuiButtonProps } from "@linzjs/lui/dist/components/LuiButton/LuiButton";
|
|
@@ -58,7 +60,7 @@ export const PrefabModal = ({ level = "warning", children, resolve, ...props }:
|
|
|
58
60
|
});
|
|
59
61
|
|
|
60
62
|
return (
|
|
61
|
-
<Modal>
|
|
63
|
+
<Modal className={"prefab-modal"}>
|
|
62
64
|
<div className={`lui-modal lui-box-shadow lui-modal-${level}`} style={{ minWidth: 400 }}>
|
|
63
65
|
<LuiIcon name={icon} alt={"warning"} size={"lg"} className={"lui-msg-status-icon"} />
|
|
64
66
|
{children}
|
|
@@ -91,11 +93,12 @@ export const usePrefabModal = () => {
|
|
|
91
93
|
) =>
|
|
92
94
|
showModal(PrefabModal, {
|
|
93
95
|
level,
|
|
96
|
+
|
|
94
97
|
children: (
|
|
95
|
-
|
|
98
|
+
<>
|
|
96
99
|
{typeof title === "string" ? <h2>{title}</h2> : title}
|
|
97
100
|
{typeof content === "string" ? <p>{content}</p> : content}
|
|
98
|
-
|
|
101
|
+
</>
|
|
99
102
|
),
|
|
100
103
|
buttons,
|
|
101
104
|
}) as Promise<RT>,
|
|
@@ -2,7 +2,7 @@ import { useInterval } from "../util/useInterval";
|
|
|
2
2
|
import { PanelInstanceContextProvider } from "./PanelInstanceContextProvider";
|
|
3
3
|
import { PanelInstance, PanelPosition, PanelsContext } from "./PanelsContext";
|
|
4
4
|
import { castArray, maxBy, sortBy } from "lodash-es";
|
|
5
|
-
import { Fragment, PropsWithChildren, ReactElement, useCallback, useMemo, useRef, useState } from "react";
|
|
5
|
+
import React, { Fragment, PropsWithChildren, ReactElement, useCallback, useMemo, useRef, useState } from "react";
|
|
6
6
|
|
|
7
7
|
export interface PanelsContextProviderProps {
|
|
8
8
|
baseZIndex?: number;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import "./TestModal.scss";
|
|
2
1
|
import "@linzjs/lui/dist/scss/base.scss";
|
|
3
2
|
|
|
4
|
-
import { ModalContextProvider } from "../../modal
|
|
5
|
-
import { usePrefabModal } from "../../modal/PrefabModal";
|
|
3
|
+
import { ModalContextProvider, usePrefabModal } from "../../modal";
|
|
6
4
|
|
|
7
5
|
// #Example: Modal Context Provider
|
|
8
6
|
// Don't forget to add a ModalContextProvider at the root of your project
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
@use "node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars.scss" as colours;
|
|
3
|
-
|
|
4
|
-
dialog > div {
|
|
5
|
-
padding: 20px;
|
|
1
|
+
dialog.testModal {
|
|
6
2
|
display: flex;
|
|
7
3
|
flex-direction: column;
|
|
4
|
+
padding: 20px;
|
|
8
5
|
gap: 16px;
|
|
6
|
+
border-radius: 5px;
|
|
9
7
|
|
|
10
8
|
div {
|
|
11
9
|
display: flex;
|
|
@@ -15,22 +13,4 @@ dialog > div {
|
|
|
15
13
|
button {
|
|
16
14
|
flex: 1;
|
|
17
15
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.lui-modal {
|
|
21
|
-
margin: 0 !important;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
button:focus {
|
|
25
|
-
outline: 2px solid colours.$brand-primary;
|
|
26
|
-
// make sure the button sits above the others so the outline is not cut off on focus
|
|
27
|
-
position: relative;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
dialog::backdrop {
|
|
31
|
-
background: rgb(0 0 0 / 60%);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
dialog {
|
|
35
|
-
border: none;
|
|
36
16
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./TestModal.scss";
|
|
2
2
|
|
|
3
|
-
import { Modal } from "../../modal
|
|
4
|
-
import { ModalCallback } from "../../modal
|
|
5
|
-
import { ModalContextProvider } from "../../modal
|
|
6
|
-
import { useShowModal } from "../../modal
|
|
3
|
+
import { Modal } from "../../modal";
|
|
4
|
+
import { ModalCallback } from "../../modal";
|
|
5
|
+
import { ModalContextProvider } from "../../modal";
|
|
6
|
+
import { useShowModal } from "../../modal";
|
|
7
7
|
|
|
8
8
|
// #Example: Modal Context Provider
|
|
9
9
|
// Don't forget to add a ModalContextProvider at the root of your project
|
|
@@ -21,13 +21,11 @@ export interface TestModalProps extends ModalCallback<number> {
|
|
|
21
21
|
|
|
22
22
|
// Close and resolve will be passed to your props magically!
|
|
23
23
|
export const TestModal = ({ text, close, resolve }: TestModalProps) => (
|
|
24
|
-
<Modal>
|
|
24
|
+
<Modal className={"testModal"}>
|
|
25
|
+
<div>This is the modal text: '{text}'</div>
|
|
25
26
|
<div>
|
|
26
|
-
<
|
|
27
|
-
<
|
|
28
|
-
<button onClick={close}>Close</button>
|
|
29
|
-
<button onClick={() => resolve(1)}>Return 1</button>
|
|
30
|
-
</div>
|
|
27
|
+
<button onClick={close}>Close</button>
|
|
28
|
+
<button onClick={() => resolve(1)}>Return 1</button>
|
|
31
29
|
</div>
|
|
32
30
|
</Modal>
|
|
33
31
|
);
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import "../story.scss";
|
|
2
2
|
import "@linzjs/lui/dist/scss/base.scss";
|
|
3
3
|
|
|
4
|
-
import { OpenPanelButton } from "../../../panel/OpenPanelButton";
|
|
5
4
|
import {
|
|
6
5
|
ButtonIconHorizontalGroup,
|
|
7
6
|
ButtonIconSeparator,
|
|
8
7
|
ButtonIconVerticalGroup,
|
|
8
|
+
OpenPanelButton,
|
|
9
9
|
OpenPanelIcon,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
Panel,
|
|
11
|
+
PanelContent,
|
|
12
|
+
PanelHeader,
|
|
13
|
+
} from "../../../panel";
|
|
13
14
|
|
|
14
15
|
/* exclude */
|
|
15
16
|
export interface ShowPanelProps {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import "../story.scss";
|
|
2
2
|
import "@linzjs/lui/dist/scss/base.scss";
|
|
3
3
|
|
|
4
|
-
import { OpenPanelButton } from "../../../panel/
|
|
5
|
-
import { Panel, PanelContent } from "../../../panel/Panel";
|
|
6
|
-
import { PanelHeader } from "../../../panel/PanelHeader";
|
|
7
|
-
import { PanelsContextProvider } from "../../../panel/PanelsContextProvider";
|
|
8
|
-
import { Fragment } from "react";
|
|
4
|
+
import { OpenPanelButton, Panel, PanelContent, PanelHeader, PanelsContextProvider } from "../../../panel/";
|
|
9
5
|
|
|
10
6
|
// #Example: Panel Context Provider
|
|
11
7
|
// Don't forget to add a PanelContextProvider at the root of your project
|
|
@@ -64,9 +60,9 @@ export const PanelContents = () => (
|
|
|
64
60
|
// #Example: Panel Invocation
|
|
65
61
|
export const TestShowPanel = () => {
|
|
66
62
|
return (
|
|
67
|
-
|
|
63
|
+
<>
|
|
68
64
|
<OpenPanelButton buttonText={"TestPanel 1"} component={() => <ShowPanelComponent data={1} />} />{" "}
|
|
69
65
|
<OpenPanelButton buttonText={"TestPanel 2"} component={() => <ShowPanelComponent data={2} />} />
|
|
70
|
-
|
|
66
|
+
</>
|
|
71
67
|
);
|
|
72
68
|
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import "../story.scss";
|
|
2
2
|
import "@linzjs/lui/dist/scss/base.scss";
|
|
3
3
|
|
|
4
|
-
import { OpenPanelButton } from "../../../panel/
|
|
5
|
-
import { Panel, PanelContent } from "../../../panel/Panel";
|
|
6
|
-
import { PanelDock } from "../../../panel/PanelDock";
|
|
7
|
-
import { PanelHeader } from "../../../panel/PanelHeader";
|
|
8
|
-
import { Fragment } from "react";
|
|
4
|
+
import { OpenPanelButton, Panel, PanelContent, PanelDock, PanelHeader } from "../../../panel/";
|
|
9
5
|
|
|
10
6
|
// #Example: Panel Component
|
|
11
7
|
export interface ShowPanelComponentProps {
|
|
@@ -57,9 +53,9 @@ export const PanelContents = () => {
|
|
|
57
53
|
// #Example: Panel Invocation
|
|
58
54
|
export const TestShowPanel = () => {
|
|
59
55
|
return (
|
|
60
|
-
|
|
56
|
+
<>
|
|
61
57
|
<OpenPanelButton buttonText={"TestPanel"} component={() => <ShowPanelComponent data={1} />} />
|
|
62
58
|
<PanelDock id={"leftSide"}>The Panel will dock in here</PanelDock>
|
|
63
|
-
|
|
59
|
+
</>
|
|
64
60
|
);
|
|
65
61
|
};
|
|
@@ -4,7 +4,7 @@ import "@linzjs/step-ag-grid/dist/GridTheme.scss";
|
|
|
4
4
|
import "@linzjs/step-ag-grid/dist/index.css";
|
|
5
5
|
|
|
6
6
|
import { OpenPanelButton, Panel, PanelContent, PanelContext, PanelHeader, PanelsContextProvider } from "../../../panel";
|
|
7
|
-
import {
|
|
7
|
+
import { useContext, useMemo, useState } from "react";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
ColDefT,
|
|
@@ -44,10 +44,10 @@ export const TestPanelResizing = ({ data }: TestPanelProps) => {
|
|
|
44
44
|
|
|
45
45
|
// #Example: Panel Invocation
|
|
46
46
|
export const TestShowPanelResizingAgGrid = () => (
|
|
47
|
-
|
|
47
|
+
<>
|
|
48
48
|
<OpenPanelButton buttonText={"TestPanel resizing 1"} component={() => <TestPanelResizing data={1} />} />{" "}
|
|
49
49
|
<OpenPanelButton buttonText={"TestPanel resizing 2"} component={() => <TestPanelResizing data={2} />} />
|
|
50
|
-
|
|
50
|
+
</>
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
/* exclude */
|
|
@@ -96,7 +96,7 @@ export const PanelContentsWithResize = () => {
|
|
|
96
96
|
GridPopoverMessage(
|
|
97
97
|
{
|
|
98
98
|
headerName: "Popout message",
|
|
99
|
-
cellRenderer: () =>
|
|
99
|
+
cellRenderer: () => <>Single Click me!</>,
|
|
100
100
|
exportable: false,
|
|
101
101
|
},
|
|
102
102
|
{
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import "../story.scss";
|
|
2
2
|
import "@linzjs/lui/dist/scss/base.scss";
|
|
3
3
|
|
|
4
|
-
import { OpenPanelButton } from "../../../panel/
|
|
5
|
-
import { Panel, PanelContent } from "../../../panel/Panel";
|
|
6
|
-
import { PanelHeader } from "../../../panel/PanelHeader";
|
|
7
|
-
import { PanelsContextProvider } from "../../../panel/PanelsContextProvider";
|
|
8
|
-
import { Fragment } from "react";
|
|
4
|
+
import { OpenPanelButton, Panel, PanelContent, PanelHeader, PanelsContextProvider } from "../../../panel/";
|
|
9
5
|
|
|
10
6
|
import { LuiTabs, LuiTabsGroup, LuiTabsPanel, LuiTabsPanelSwitch } from "@linzjs/lui";
|
|
11
7
|
|
|
@@ -69,9 +65,9 @@ export const PanelContents = () => (
|
|
|
69
65
|
// #Example: Panel Invocation
|
|
70
66
|
export const TestShowTabbedPanel = () => {
|
|
71
67
|
return (
|
|
72
|
-
|
|
68
|
+
<>
|
|
73
69
|
<OpenPanelButton buttonText={"TestPanel 1"} component={() => <ShowPanelComponent data={1} />} />{" "}
|
|
74
70
|
<OpenPanelButton buttonText={"TestPanel 2"} component={() => <ShowPanelComponent data={2} />} />
|
|
75
|
-
|
|
71
|
+
</>
|
|
76
72
|
);
|
|
77
73
|
};
|