@linzjs/windows 4.1.0 → 4.1.2
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.
|
@@ -17,6 +17,7 @@ import React, {
|
|
|
17
17
|
} from "react";
|
|
18
18
|
import { createPortal } from "react-dom";
|
|
19
19
|
import { useInterval } from "usehooks-ts";
|
|
20
|
+
import { v4 } from "uuid";
|
|
20
21
|
|
|
21
22
|
export interface LuiModalAsyncInstance {
|
|
22
23
|
uuid: string;
|
|
@@ -106,7 +107,7 @@ export const LuiModalAsyncContextProvider = ({ children }: PropsWithChildren<unk
|
|
|
106
107
|
args: any,
|
|
107
108
|
showModalProps?: ShowModalProps,
|
|
108
109
|
): PromiseWithResolve<any> => {
|
|
109
|
-
const uuid =
|
|
110
|
+
const uuid = v4();
|
|
110
111
|
let extResolve: PromiseWithResolve<any>["resolve"];
|
|
111
112
|
const promise = new Promise((resolve) => {
|
|
112
113
|
extResolve = resolve;
|
|
@@ -7,11 +7,11 @@ interface OpenPanelButtonProps extends OpenPanelOptions {
|
|
|
7
7
|
buttonText: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const OpenPanelButton = ({ buttonText, ...openPanelOptions }: OpenPanelButtonProps) => {
|
|
10
|
+
export const OpenPanelButton = ({ buttonText, uniqueId = buttonText, ...openPanelOptions }: OpenPanelButtonProps) => {
|
|
11
11
|
const { openPanel, openPanels } = useContext(PanelsContext);
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<button onClick={() => openPanel(openPanelOptions)}>
|
|
14
|
+
<button onClick={() => openPanel({ uniqueId, ...openPanelOptions })}>
|
|
15
15
|
Show {buttonText} {openPanels.has(buttonText) ? "(Open)" : ""}
|
|
16
16
|
</button>
|
|
17
17
|
);
|
|
@@ -2,7 +2,7 @@ import "./OpenPanelIcon.scss";
|
|
|
2
2
|
|
|
3
3
|
import { OpenPanelOptions, PanelsContext } from "./PanelsContext";
|
|
4
4
|
import clsx from "clsx";
|
|
5
|
-
import { ReactNode, useContext
|
|
5
|
+
import { ReactNode, useContext } from "react";
|
|
6
6
|
|
|
7
7
|
import { LuiIcon } from "@linzjs/lui";
|
|
8
8
|
import { IconName } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
|
|
@@ -35,10 +35,10 @@ export const OpenPanelIcon = ({
|
|
|
35
35
|
className,
|
|
36
36
|
disabled,
|
|
37
37
|
testId,
|
|
38
|
+
uniqueId = iconTitle,
|
|
38
39
|
...openPanelOptions
|
|
39
40
|
}: OpenPanelIconProps) => {
|
|
40
41
|
const { openPanel, openPanels } = useContext(PanelsContext);
|
|
41
|
-
const id = useRef(openPanelOptions.uniqueId ?? crypto.randomUUID());
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
44
|
<button
|
|
@@ -46,11 +46,11 @@ export const OpenPanelIcon = ({
|
|
|
46
46
|
className={clsx(
|
|
47
47
|
className,
|
|
48
48
|
"lui-button lui-button-secondary lui-button-toolbar panel-button",
|
|
49
|
-
openPanels.has(
|
|
49
|
+
openPanels.has(uniqueId) && "OpenPanelIcon-selected",
|
|
50
50
|
disabled && "OpenPanelIcon-disabled",
|
|
51
51
|
)}
|
|
52
52
|
title={iconTitle}
|
|
53
|
-
onClick={() => openPanel(openPanelOptions)}
|
|
53
|
+
onClick={() => openPanel({ uniqueId, ...openPanelOptions })}
|
|
54
54
|
disabled={disabled}
|
|
55
55
|
data-testid={testId}
|
|
56
56
|
>
|
|
@@ -5,6 +5,7 @@ import React, { Fragment, PropsWithChildren, ReactElement, useCallback, useMemo,
|
|
|
5
5
|
import { useInterval } from "usehooks-ts";
|
|
6
6
|
import { PanelStateOptions } from "./types/PanelStateOptions";
|
|
7
7
|
import { PanelPosition } from "./types";
|
|
8
|
+
import { v4 } from "uuid";
|
|
8
9
|
|
|
9
10
|
export interface PanelsContextProviderProps {
|
|
10
11
|
baseZIndex?: number;
|
|
@@ -58,7 +59,7 @@ export const PanelsContextProvider = ({
|
|
|
58
59
|
);
|
|
59
60
|
|
|
60
61
|
const openPanel = useCallback(
|
|
61
|
-
({ componentFn, poppedOut = false, uniqueId =
|
|
62
|
+
({ componentFn, poppedOut = false, uniqueId = v4() }: OpenPanelOptions): void => {
|
|
62
63
|
try {
|
|
63
64
|
const existingPanelInstance = panelInstances.find((pi) => pi.uniqueId === uniqueId);
|
|
64
65
|
if (existingPanelInstance) {
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"popout"
|
|
14
14
|
],
|
|
15
15
|
"main": "./dist/index.ts",
|
|
16
|
-
"version": "4.1.
|
|
16
|
+
"version": "4.1.2",
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@linzjs/lui": ">=21",
|
|
19
19
|
"lodash-es": ">=4",
|
|
@@ -49,9 +49,11 @@
|
|
|
49
49
|
"@emotion/cache": "^11.13.5",
|
|
50
50
|
"@emotion/react": "^11.13.5",
|
|
51
51
|
"@emotion/styled": "^11.13.5",
|
|
52
|
+
"@types/uuid": "^10.0.0",
|
|
52
53
|
"lodash-es": ">=4",
|
|
53
54
|
"react-rnd": "^10.4.13",
|
|
54
|
-
"usehooks-ts": "^3.1.0"
|
|
55
|
+
"usehooks-ts": "^3.1.0",
|
|
56
|
+
"uuid": "^11.0.4"
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
59
|
"@chromatic-com/storybook": "^3.2.2",
|