@linzjs/windows 1.4.2 → 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 +2 -1
- package/src/modal/Modal.tsx +9 -4
- package/src/modal/ModalContext.scss +11 -0
- package/src/modal/ModalContextProvider.tsx +19 -18
- package/src/modal/PrefabModal.scss +21 -0
- package/src/modal/PrefabModal.tsx +5 -2
- 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 +1 -4
- package/src/stories/panel/ShowPanelDocking/ShowPanel.tsx +1 -4
- package/src/stories/panel/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +1 -5
- package/src/stories/panel/ShowTabbedPanel/ShowPanel.tsx +1 -4
- package/index.ts +0 -1
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
|
/**
|
|
@@ -116,21 +119,19 @@ export const ModalContextProvider = ({ children }: { children: ReactElement }):
|
|
|
116
119
|
showModal,
|
|
117
120
|
}}
|
|
118
121
|
>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<Fragment key={"children"}>{children}</Fragment>
|
|
133
|
-
</>
|
|
122
|
+
<Fragment key={"modals"}>
|
|
123
|
+
{modals
|
|
124
|
+
.filter(modalHasView)
|
|
125
|
+
.map((modalInstance) =>
|
|
126
|
+
createPortal(
|
|
127
|
+
<ModalInstanceContext.Provider value={{ close: () => modalInstance.resolve(undefined) }}>
|
|
128
|
+
{modalInstance.componentInstance}
|
|
129
|
+
</ModalInstanceContext.Provider>,
|
|
130
|
+
(modalInstance.ownerElement?.ownerDocument ?? document).body,
|
|
131
|
+
),
|
|
132
|
+
)}
|
|
133
|
+
</Fragment>
|
|
134
|
+
<Fragment key={"children"}>{children}</Fragment>
|
|
134
135
|
</ModalContext.Provider>
|
|
135
136
|
);
|
|
136
137
|
};
|
|
@@ -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 { ReactElement } from "react";
|
|
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,6 +93,7 @@ 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}
|
|
@@ -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,10 +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";
|
|
4
|
+
import { OpenPanelButton, Panel, PanelContent, PanelHeader, PanelsContextProvider } from "../../../panel/";
|
|
8
5
|
|
|
9
6
|
// #Example: Panel Context Provider
|
|
10
7
|
// Don't forget to add a PanelContextProvider at the root of your project
|
|
@@ -1,10 +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";
|
|
4
|
+
import { OpenPanelButton, Panel, PanelContent, PanelDock, PanelHeader } from "../../../panel/";
|
|
8
5
|
|
|
9
6
|
// #Example: Panel Component
|
|
10
7
|
export interface ShowPanelComponentProps {
|
|
@@ -3,11 +3,7 @@ import "@linzjs/lui/dist/scss/base.scss";
|
|
|
3
3
|
import "@linzjs/step-ag-grid/dist/GridTheme.scss";
|
|
4
4
|
import "@linzjs/step-ag-grid/dist/index.css";
|
|
5
5
|
|
|
6
|
-
import { OpenPanelButton } from "../../../panel
|
|
7
|
-
import { Panel, PanelContent } from "../../../panel/Panel";
|
|
8
|
-
import { PanelContext } from "../../../panel/PanelContext";
|
|
9
|
-
import { PanelHeader } from "../../../panel/PanelHeader";
|
|
10
|
-
import { PanelsContextProvider } from "../../../panel/PanelsContextProvider";
|
|
6
|
+
import { OpenPanelButton, Panel, PanelContent, PanelContext, PanelHeader, PanelsContextProvider } from "../../../panel";
|
|
11
7
|
import { useContext, useMemo, useState } from "react";
|
|
12
8
|
|
|
13
9
|
import {
|
|
@@ -1,10 +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";
|
|
4
|
+
import { OpenPanelButton, Panel, PanelContent, PanelHeader, PanelsContextProvider } from "../../../panel/";
|
|
8
5
|
|
|
9
6
|
import { LuiTabs, LuiTabsGroup, LuiTabsPanel, LuiTabsPanelSwitch } from "@linzjs/lui";
|
|
10
7
|
|
package/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src";
|