@linzjs/windows 5.5.0 → 5.6.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.
@@ -1,72 +1,72 @@
1
- @use "@linzjs/lui/dist/scss/Core" as lui;
2
-
3
- .lui-button.lui-button-toolbar {
4
- border-color: transparent;
5
- padding: 4px;
6
- line-height: 12px;
7
- margin: 2px;
8
- }
9
-
10
- .OpenPanelIcon-selected {
11
- cursor: pointer;
12
- color: lui.$white !important;
13
- background-color: lui.$blue-75 !important;
14
- box-shadow: inset 0 2px 4px rgb(41 92 130);
15
-
16
- fill: lui.$white !important;
17
-
18
- svg * {
19
- fill: lui.$white !important;
20
- }
21
-
22
- svg * {
23
- color: lui.$white !important;
24
- fill: lui.$white !important;
25
- }
26
- }
27
-
28
- .OpenPanelIcon-disabled {
29
- background-color: lui.$white !important;
30
-
31
- fill: lui.$grey-20 !important;
32
-
33
- svg * {
34
- fill: lui.$grey-20 !important;
35
- }
36
- }
37
-
38
- %OpenPanelIcon-Group {
39
- background-color: white;
40
- border-radius: 4px;
41
- padding: 4px;
42
- align-items: center;
43
- box-shadow: 0 0 10px rgb(0 0 0 / 20%);
44
- display: inline-flex;
45
- }
46
-
47
- .OpenPanelIcon-verticalGroup {
48
- @extend %OpenPanelIcon-Group;
49
- flex-direction: column;
50
-
51
- .OpenPanelIcon-separator {
52
- margin: 6px 0;
53
- height: 2px;
54
- width: 100%;
55
- background-color: lui.$grey-10;
56
- }
57
- }
58
-
59
- .OpenPanelIcon-horizontalGroup {
60
- @extend %OpenPanelIcon-Group;
61
- flex-direction: row;
62
-
63
- .OpenPanelIcon-separator {
64
- height: 100%;
65
- margin-left: 6px;
66
- margin-right: 6px;
67
- margin-top: -3px;
68
- padding-bottom: 8px;
69
- width: 2px;
70
- background-color: lui.$grey-10;
71
- }
1
+ @use "@linzjs/lui/dist/scss/Core" as lui;
2
+
3
+ .lui-button.lui-button-toolbar {
4
+ border-color: transparent;
5
+ padding: 4px;
6
+ line-height: 12px;
7
+ margin: 2px;
8
+ }
9
+
10
+ .OpenPanelIcon-selected {
11
+ cursor: pointer;
12
+ color: lui.$white !important;
13
+ background-color: lui.$blue-75 !important;
14
+ box-shadow: inset 0 2px 4px rgb(41 92 130);
15
+
16
+ fill: lui.$white !important;
17
+
18
+ svg * {
19
+ fill: lui.$white !important;
20
+ }
21
+
22
+ svg * {
23
+ color: lui.$white !important;
24
+ fill: lui.$white !important;
25
+ }
26
+ }
27
+
28
+ .OpenPanelIcon-disabled {
29
+ background-color: lui.$white !important;
30
+
31
+ fill: lui.$grey-20 !important;
32
+
33
+ svg * {
34
+ fill: lui.$grey-20 !important;
35
+ }
36
+ }
37
+
38
+ %OpenPanelIcon-Group {
39
+ background-color: white;
40
+ border-radius: 4px;
41
+ padding: 4px;
42
+ align-items: center;
43
+ box-shadow: 0 0 10px rgb(0 0 0 / 20%);
44
+ display: inline-flex;
45
+ }
46
+
47
+ .OpenPanelIcon-verticalGroup {
48
+ @extend %OpenPanelIcon-Group;
49
+ flex-direction: column;
50
+
51
+ .OpenPanelIcon-separator {
52
+ margin: 6px 0;
53
+ height: 2px;
54
+ width: 100%;
55
+ background-color: lui.$grey-10;
56
+ }
57
+ }
58
+
59
+ .OpenPanelIcon-horizontalGroup {
60
+ @extend %OpenPanelIcon-Group;
61
+ flex-direction: row;
62
+
63
+ .OpenPanelIcon-separator {
64
+ height: 100%;
65
+ margin-left: 6px;
66
+ margin-right: 6px;
67
+ margin-top: -3px;
68
+ padding-bottom: 8px;
69
+ width: 2px;
70
+ background-color: lui.$grey-10;
71
+ }
72
72
  }
@@ -1,123 +1,123 @@
1
- @use "@linzjs/lui/dist/scss/Core" as lui;
2
-
3
- .panelDock > .panelDock-content:not(:empty) + .panelDock-empty {
4
- display: none;
5
- }
6
-
7
- .WindowPanel-children {
8
- display: flex;
9
- overflow: hidden;
10
- text-overflow: ellipsis;
11
- flex: 1;
12
- }
13
-
14
- .WindowPanel-header {
15
- height: 48px;
16
- line-height: 48px;
17
- user-select: none;
18
- color: lui.$charcoal;
19
- padding: 0 16px;
20
- display: flex;
21
- overflow: hidden;
22
- justify-content: space-between;
23
- border-bottom: 2px lui.$lily solid;
24
- font-size: 1em;
25
- font-weight: 600;
26
- flex-direction: row;
27
- align-items: center;
28
-
29
- .LuiTabsGroup {
30
- margin-top: 4px;
31
- line-height: 16px;
32
-
33
- .LuiTab {
34
- min-width: 0;
35
- padding-left: 8px;
36
- padding-right: 8px;
37
- padding-bottom: 11px;
38
- }
39
-
40
- .LuiTab:not(.LuiTab--active):focus {
41
- padding-top: 8px;
42
- padding-bottom: 8px;
43
- }
44
-
45
- .LuiTab--active {
46
- padding-left: 7px;
47
- padding-right: 7px;
48
- }
49
-
50
- .LuiTab--active::after, .LuiTab--active:focus::after {
51
- padding: 0;
52
- }
53
- }
54
-
55
- .lui-button + .lui-button, a.lui-button + .lui-button {
56
- margin-left: 0 !important;
57
- }
58
- }
59
-
60
- .WindowPanel {
61
- box-shadow: 0 1px 6px 0 #00000026, 0 6px 10px 0 #00000040;
62
- background-color: #fff;
63
- display: flex;
64
- flex-direction: column;
65
- border-radius: 9px;
66
-
67
- .WindowPanel-header {
68
- border-radius: 9px 9px 0 0;
69
- }
70
- }
71
-
72
- %WindowPanel-divider {
73
- border-left: 2px solid lui.$lily;
74
- background-color: lui.$lily;
75
- width: 0;
76
- height: 19px;
77
- }
78
-
79
- .WindowPanel-divider-left {
80
- @extend %WindowPanel-divider;
81
- margin-right: 15px;
82
- margin-left: 19px;
83
- }
84
-
85
- .WindowPanel-divider-right {
86
- @extend %WindowPanel-divider;
87
- margin-right: 8px;
88
- margin-left: 8px;
89
- }
90
-
91
- .WindowPanel-buttons {
92
- display: flex;
93
- align-items: center;
94
-
95
- a.lui-button,
96
- button.lui-button {
97
- display: flex;
98
- align-items: center;
99
-
100
- span.LuiIcon {
101
- margin-left: auto;
102
- margin-right: auto;
103
- }
104
- }
105
- }
106
-
107
- .WindowPanel-header-title {
108
- display: flex;
109
- align-items: center;
110
- white-space: nowrap;
111
- }
112
-
113
- .WindowPanel-header-title-icon {
114
- fill: lui.$fuscous !important;
115
- margin-right: 8px;
116
- }
117
-
118
- .WindowPanel-content {
119
- flex: 1;
120
- overflow: auto;
121
- display: flex;
122
- flex-direction: column;
123
- }
1
+ @use "@linzjs/lui/dist/scss/Core" as lui;
2
+
3
+ .panelDock > .panelDock-content:not(:empty) + .panelDock-empty {
4
+ display: none;
5
+ }
6
+
7
+ .WindowPanel-children {
8
+ display: flex;
9
+ overflow: hidden;
10
+ text-overflow: ellipsis;
11
+ flex: 1;
12
+ }
13
+
14
+ .WindowPanel-header {
15
+ height: 48px;
16
+ line-height: 48px;
17
+ user-select: none;
18
+ color: lui.$charcoal;
19
+ padding: 0 16px;
20
+ display: flex;
21
+ overflow: hidden;
22
+ justify-content: space-between;
23
+ border-bottom: 2px lui.$lily solid;
24
+ font-size: 1em;
25
+ font-weight: 600;
26
+ flex-direction: row;
27
+ align-items: center;
28
+
29
+ .LuiTabsGroup {
30
+ margin-top: 4px;
31
+ line-height: 16px;
32
+
33
+ .LuiTab {
34
+ min-width: 0;
35
+ padding-left: 8px;
36
+ padding-right: 8px;
37
+ padding-bottom: 11px;
38
+ }
39
+
40
+ .LuiTab:not(.LuiTab--active):focus {
41
+ padding-top: 8px;
42
+ padding-bottom: 8px;
43
+ }
44
+
45
+ .LuiTab--active {
46
+ padding-left: 7px;
47
+ padding-right: 7px;
48
+ }
49
+
50
+ .LuiTab--active::after, .LuiTab--active:focus::after {
51
+ padding: 0;
52
+ }
53
+ }
54
+
55
+ .lui-button + .lui-button, a.lui-button + .lui-button {
56
+ margin-left: 0 !important;
57
+ }
58
+ }
59
+
60
+ .WindowPanel {
61
+ box-shadow: 0 1px 6px 0 #00000026, 0 6px 10px 0 #00000040;
62
+ background-color: #fff;
63
+ display: flex;
64
+ flex-direction: column;
65
+ border-radius: 9px;
66
+
67
+ .WindowPanel-header {
68
+ border-radius: 9px 9px 0 0;
69
+ }
70
+ }
71
+
72
+ %WindowPanel-divider {
73
+ border-left: 2px solid lui.$lily;
74
+ background-color: lui.$lily;
75
+ width: 0;
76
+ height: 19px;
77
+ }
78
+
79
+ .WindowPanel-divider-left {
80
+ @extend %WindowPanel-divider;
81
+ margin-right: 15px;
82
+ margin-left: 19px;
83
+ }
84
+
85
+ .WindowPanel-divider-right {
86
+ @extend %WindowPanel-divider;
87
+ margin-right: 8px;
88
+ margin-left: 8px;
89
+ }
90
+
91
+ .WindowPanel-buttons {
92
+ display: flex;
93
+ align-items: center;
94
+
95
+ a.lui-button,
96
+ button.lui-button {
97
+ display: flex;
98
+ align-items: center;
99
+
100
+ span.LuiIcon {
101
+ margin-left: auto;
102
+ margin-right: auto;
103
+ }
104
+ }
105
+ }
106
+
107
+ .WindowPanel-header-title {
108
+ display: flex;
109
+ align-items: center;
110
+ white-space: nowrap;
111
+ }
112
+
113
+ .WindowPanel-header-title-icon {
114
+ fill: lui.$fuscous !important;
115
+ margin-right: 8px;
116
+ }
117
+
118
+ .WindowPanel-content {
119
+ flex: 1;
120
+ overflow: auto;
121
+ display: flex;
122
+ flex-direction: column;
123
+ }
@@ -3,7 +3,8 @@ import './PanelBlue.scss';
3
3
  import '@linzjs/lui/dist/scss/base.scss';
4
4
 
5
5
  import clsx from 'clsx';
6
- import { PropsWithChildren, ReactElement, useContext, useEffect, useRef, useState } from 'react';
6
+ import { NumberSize } from 're-resizable';
7
+ import { PropsWithChildren, ReactElement, useCallback, useContext, useEffect, useRef, useState } from 'react';
7
8
  import { createPortal } from 'react-dom';
8
9
 
9
10
  import { useConstFunction } from '../common';
@@ -14,14 +15,20 @@ import { PopoutWindow } from './PopoutWindow';
14
15
  import { PanelProps } from './types/PanelProps';
15
16
  import { useRestoreStateFrom } from './usePanelStateHandler';
16
17
 
18
+ const defaultInitialSize = { width: 320, height: 200 };
19
+ const nullOpFunction = () => {};
20
+
17
21
  export const Panel = (props: PanelProps): ReactElement => {
18
22
  const panelRef = useRef<HTMLDivElement>(null);
19
- const { title, size = { width: 320, height: 200 }, className, children, onClose } = props;
23
+ const { title, size = defaultInitialSize, className, children, onClose } = props;
20
24
 
21
- const { dockElements } = useContext(PanelsContext);
25
+ const { dockElements, nextStackPosition } = useContext(PanelsContext);
22
26
  const { panelPoppedOut, uniqueId, setTitle, dockId, docked } = useContext(PanelInstanceContext);
23
27
 
24
- const onCloseConstFn = useConstFunction(onClose ?? (() => {}));
28
+ const savedState = useRestoreStateFrom({ uniqueId, panelPoppedOut: false });
29
+
30
+ // The function has to be const as the panel must no re-render as that would cause popout windows to close
31
+ const onCloseConstFn = useConstFunction(onClose ?? nullOpFunction);
25
32
 
26
33
  useEffect(() => {
27
34
  return () => {
@@ -43,10 +50,6 @@ export const Panel = (props: PanelProps): ReactElement => {
43
50
  }
44
51
  }, [title]);
45
52
 
46
- const { nextStackPosition } = useContext(PanelsContext);
47
-
48
- const savedState = useRestoreStateFrom({ uniqueId, panelPoppedOut: false });
49
-
50
53
  const [panelPosition, setPanelPosition] = useState(() => {
51
54
  if (savedState?.panelPosition) {
52
55
  return savedState.panelPosition;
@@ -66,7 +69,7 @@ export const Panel = (props: PanelProps): ReactElement => {
66
69
  return nextStackPosition();
67
70
  });
68
71
 
69
- const [panelSize, setPanelSize] = useState(() => {
72
+ const [panelSize, setPanelSize] = useState<NumberSize>(() => {
70
73
  if (savedState?.panelSize) {
71
74
  return savedState.panelSize;
72
75
  }
@@ -74,6 +77,18 @@ export const Panel = (props: PanelProps): ReactElement => {
74
77
  return size ?? { width: 320, height: 200 };
75
78
  });
76
79
 
80
+ const setInitialPanelSize = useCallback(
81
+ (size: NumberSize) => {
82
+ // If panel was already sized from state, then don't resize
83
+ if (savedState?.panelSize) {
84
+ return;
85
+ }
86
+
87
+ setPanelSize(size);
88
+ },
89
+ [savedState?.panelSize],
90
+ );
91
+
77
92
  const dockElement = docked && dockId && dockElements[dockId];
78
93
 
79
94
  return (
@@ -108,6 +123,7 @@ export const Panel = (props: PanelProps): ReactElement => {
108
123
  setPanelPosition={setPanelPosition}
109
124
  panelSize={panelSize}
110
125
  setPanelSize={setPanelSize}
126
+ setInitialPanelSize={setInitialPanelSize}
111
127
  >
112
128
  {children}
113
129
  </PopinWindow>
@@ -1,18 +1,18 @@
1
- @use "@linzjs/lui/dist/scss/Core" as lui;
2
-
3
- .WindowPanel-blue.WindowPanel-header, .WindowPanel-blue .WindowPanel-header {
4
- background: linear-gradient(270deg,#007198,#00425b 100%);
5
- color: #fff;
6
-
7
- svg * {
8
- fill: #fff;
9
- }
10
- }
11
-
12
- .WindowPanel-blue .LuiTab {
13
- color: lui.$iceberg
14
- }
15
-
16
- .WindowPanel-blue .LuiTab.LuiTab--active {
17
- color: lui.$downy
18
- }
1
+ @use "@linzjs/lui/dist/scss/Core" as lui;
2
+
3
+ .WindowPanel-blue.WindowPanel-header, .WindowPanel-blue .WindowPanel-header {
4
+ background: linear-gradient(270deg,#007198,#00425b 100%);
5
+ color: #fff;
6
+
7
+ svg * {
8
+ fill: #fff;
9
+ }
10
+ }
11
+
12
+ .WindowPanel-blue .LuiTab {
13
+ color: lui.$iceberg
14
+ }
15
+
16
+ .WindowPanel-blue .LuiTab.LuiTab--active {
17
+ color: lui.$downy
18
+ }
@@ -4,6 +4,7 @@ import { PanelSize } from './types';
4
4
 
5
5
  export interface PanelContextType {
6
6
  resizePanel: (size: Partial<PanelSize>) => void;
7
+ initialResizePanel: (size: Partial<PanelSize>) => void;
7
8
  resizeable: boolean;
8
9
  }
9
10
 
@@ -16,5 +17,6 @@ const NoContextError = () => {
16
17
  */
17
18
  export const PanelContext = createContext<PanelContextType>({
18
19
  resizePanel: NoContextError,
20
+ initialResizePanel: NoContextError,
19
21
  resizeable: true,
20
22
  });
@@ -1,5 +1,5 @@
1
1
  import clsx from 'clsx';
2
- import { Dispatch, useCallback, useContext, useEffect, useRef } from 'react';
2
+ import { Dispatch, ReactNode, useCallback, useContext, useEffect, useRef } from 'react';
3
3
  import { Rnd } from 'react-rnd';
4
4
 
5
5
  import { PanelContext } from './PanelContext';
@@ -23,12 +23,14 @@ export function PopinWindow({
23
23
  setPanelPosition,
24
24
  panelSize,
25
25
  setPanelSize,
26
+ setInitialPanelSize,
26
27
  }: PanelProps & {
27
28
  panelPosition: PanelPosition;
28
29
  setPanelPosition: Dispatch<PanelPosition>;
29
30
  panelSize: PanelSize;
30
31
  setPanelSize: Dispatch<PanelSize>;
31
- }): JSX.Element {
32
+ setInitialPanelSize: Dispatch<PanelSize>;
33
+ }): ReactNode {
32
34
  const panelRef = useRef<Rnd>(null);
33
35
 
34
36
  const { bounds, zIndex, bringPanelToFront, uniqueId } = useContext(PanelInstanceContext);
@@ -51,12 +53,25 @@ export function PopinWindow({
51
53
  return;
52
54
  }, [centerWindow, position, resizeable]);
53
55
 
54
- const resizePanel = (newPanelSize: Partial<PanelSize>) => {
55
- const newSize = { ...panelSize, ...newPanelSize };
56
- if (newSize.width !== panelSize.width || newSize.height !== panelSize.height) {
57
- setPanelSize(newSize);
58
- }
59
- };
56
+ const resizePanel = useCallback(
57
+ (newPanelSize: Partial<PanelSize>) => {
58
+ const newSize = { ...panelSize, ...newPanelSize };
59
+ if (newSize.width !== panelSize.width || newSize.height !== panelSize.height) {
60
+ setPanelSize(newSize);
61
+ }
62
+ },
63
+ [panelSize, setPanelSize],
64
+ );
65
+
66
+ const initialResizePanel = useCallback(
67
+ (newPanelSize: Partial<PanelSize>) => {
68
+ const newSize = { ...panelSize, ...newPanelSize };
69
+ if (newSize.width !== panelSize.width || newSize.height !== panelSize.height) {
70
+ setInitialPanelSize(newSize);
71
+ }
72
+ },
73
+ [panelSize, setInitialPanelSize],
74
+ );
60
75
 
61
76
  const saveStateIn = useSaveStateIn({ uniqueId });
62
77
 
@@ -68,7 +83,7 @@ export function PopinWindow({
68
83
  }, [panelPosition, panelSize, saveStateIn]);
69
84
 
70
85
  return (
71
- <PanelContext.Provider value={{ resizePanel, resizeable }}>
86
+ <PanelContext.Provider value={{ resizePanel, initialResizePanel, resizeable }}>
72
87
  {modal && (
73
88
  <div
74
89
  style={{
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "popout"
14
14
  ],
15
15
  "main": "./dist/index.ts",
16
- "version": "5.5.0",
16
+ "version": "5.6.0",
17
17
  "peerDependencies": {
18
18
  "@linzjs/lui": ">=21",
19
19
  "lodash-es": ">=4",