Skip to content

Commit

Permalink
Merge pull request #1022 from TouK/dev
Browse files Browse the repository at this point in the history
release
  • Loading branch information
JulianWielga authored Dec 28, 2023
2 parents f1771a7 + e1516eb commit 04dfefb
Show file tree
Hide file tree
Showing 18 changed files with 1,942 additions and 2,393 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [1.7.1-beta.1](https://github.com/touk/nk-windows/compare/v1.7.0...v1.7.1-beta.1) (2023-12-28)


### Bug Fixes

* replace window data ([0ee38b4](https://github.com/touk/nk-windows/commit/0ee38b4b361a615cd8e2214edf32ad1c8631ddeb))

## [1.7.1-beta.1](https://github.com/touk/nk-windows/compare/v1.7.0...v1.7.1-beta.1) (2023-12-28)


### Bug Fixes

* replace window data ([468cc69](https://github.com/touk/nk-windows/commit/468cc69e8de5d54401c17e661b4db90846373cb4))

# [1.7.0](https://github.com/touk/nk-windows/compare/v1.6.1...v1.7.0) (2023-10-20)


Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions cypress/e2e/demo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ context("WM", () => {
it("should maximize/restore window", () => {
cy.contains("with title").click();
cy.get("[data-testid='window-frame']").should("be.visible").as("window");
cy.get("@window").contains("scroll to bottom").should("be.enabled");
cy.document().matchImage({ screenshotConfig });
cy.get("@window").contains("with title").dblclick();
cy.document().matchImage({ screenshotConfig });
cy.get("button[name='zoom']").click();
cy.document().matchImage({ screenshotConfig });
cy.get("@window").contains("close all").click();
});

it("should prevent window from going offscreen", () => {
Expand Down
4,220 changes: 1,875 additions & 2,345 deletions package-lock.json

Large diffs are not rendered by default.

80 changes: 40 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@touk/window-manager",
"version": "1.7.0",
"version": "1.7.1-beta.1",
"types": "./cjs/index.d.ts",
"main": "./cjs/index.js",
"module": "./esm/index.js",
Expand Down Expand Up @@ -46,77 +46,77 @@
"url": "https://github.com/touk/nk-windows.git"
},
"devDependencies": {
"@babel/core": "7.23.2",
"@babel/preset-env": "7.23.2",
"@babel/preset-react": "7.22.15",
"@babel/preset-typescript": "7.23.2",
"@babel/core": "7.23.6",
"@babel/preset-env": "7.23.6",
"@babel/preset-react": "7.23.3",
"@babel/preset-typescript": "7.23.3",
"@cypress/browserify-preprocessor": "3.0.2",
"@cypress/code-coverage": "3.12.4",
"@cypress/code-coverage": "3.12.15",
"@frsource/cypress-plugin-visual-regression-diff": "3.3.10",
"@loadable/component": "5.15.3",
"@loadable/component": "5.16.3",
"@rollup/plugin-commonjs": "25.0.7",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "0.4.4",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/commit-analyzer": "11.0.0",
"@semantic-release/commit-analyzer": "11.1.0",
"@semantic-release/git": "10.0.1",
"@semantic-release/github": "9.2.1",
"@semantic-release/npm": "11.0.0",
"@semantic-release/release-notes-generator": "12.0.0",
"@storybook/addon-coverage": "0.0.9",
"@storybook/addon-essentials": "7.5.1",
"@storybook/addon-interactions": "7.5.1",
"@storybook/addon-links": "7.5.1",
"@storybook/addon-onboarding": "1.0.8",
"@storybook/addons": "7.5.1",
"@storybook/blocks": "7.5.1",
"@storybook/react": "7.5.1",
"@semantic-release/github": "9.2.6",
"@semantic-release/npm": "11.0.2",
"@semantic-release/release-notes-generator": "12.1.0",
"@storybook/addon-coverage": "1.0.0",
"@storybook/addon-essentials": "7.6.6",
"@storybook/addon-interactions": "7.6.6",
"@storybook/addon-links": "7.6.6",
"@storybook/addon-onboarding": "1.0.10",
"@storybook/addons": "7.6.6",
"@storybook/blocks": "7.6.6",
"@storybook/react": "7.6.6",
"@storybook/react-docgen-typescript-plugin": "1.0.1",
"@storybook/react-webpack5": "7.5.1",
"@storybook/react-webpack5": "7.6.6",
"@storybook/storybook-deployer": "2.8.16",
"@storybook/testing-library": "0.2.2",
"@svgr/rollup": "8.1.0",
"@svgr/webpack": "8.1.0",
"@testing-library/jest-dom": "6.1.4",
"@testing-library/jest-dom": "6.1.6",
"@testing-library/react": "12.1.5",
"@types/jest": "29.5.6",
"@types/lodash": "4.14.200",
"@types/node": "20.8.7",
"@types/jest": "29.5.11",
"@types/lodash": "4.14.202",
"@types/node": "20.10.5",
"@types/react": "18.2.31",
"@typescript-eslint/eslint-plugin": "6.8.0",
"@typescript-eslint/parser": "6.8.0",
"@typescript-eslint/eslint-plugin": "6.16.0",
"@typescript-eslint/parser": "6.16.0",
"babel-loader": "9.1.3",
"babel-plugin-istanbul": "6.1.1",
"cypress": "13.3.2",
"eslint": "8.51.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-jest": "27.4.2",
"eslint-plugin-prettier": "5.0.1",
"cypress": "13.6.2",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "27.6.0",
"eslint-plugin-prettier": "5.1.2",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-storybook": "0.6.15",
"istanbul-merge": "2.0.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"patch-package": "8.0.0",
"prettier": "3.0.3",
"prettier": "3.1.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"rimraf": "5.0.5",
"rollup": "4.1.4",
"rollup": "4.9.1",
"rollup-plugin-node-externals": "6.1.2",
"rollup-plugin-typescript2": "0.36.0",
"semantic-release": "22.0.5",
"start-server-and-test": "2.0.1",
"storybook": "7.5.1",
"semantic-release": "22.0.12",
"start-server-and-test": "2.0.3",
"storybook": "7.6.6",
"ts-jest": "29.1.1",
"typescript": "5.2.2",
"ua-parser-js": "1.0.36",
"typescript": "5.3.3",
"ua-parser-js": "1.0.37",
"webpack": "5.89.0"
},
"dependencies": {
"@emotion/css": "11.11.2",
"@emotion/react": "11.11.1",
"@emotion/react": "11.11.3",
"@juggle/resize-observer": "3.4.0",
"color-alpha": "1.1.3",
"lodash": "4.17.21",
Expand All @@ -126,7 +126,7 @@
"react-inspector": "6.0.2",
"react-rnd": "10.4.1",
"react-transition-group": "4.4.5",
"reselect": "4.1.8",
"reselect": "5.0.1",
"rooks": "7.14.1"
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/demo/DebugButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function DebugButtons({ currentId }: { currentId?: WindowId }): JSX.Eleme
{ title: "lazy loaded content", kind: DemoWindowKind.lazy },
{ title: "initial size", kind: DemoWindowKind.lazy, width: 700, height: 700 },
{ title: "minimal size (overflow fixed)", kind: DemoWindowKind.danger, width: 7000, height: 7000 },
{ title: `fixed id`, id: "fixed", parent: null },
],
[],
);
Expand Down
2 changes: 1 addition & 1 deletion src/store/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ThunkAction } from "./reducerWithThunk";

export type Action =
| { type: "CLEAR_WINDOWS" }
| { type: "OPEN_WINDOW"; windowData: WindowType<any, any> }
| { type: "OPEN_WINDOW"; windowData: WindowType }
| { type: "CLOSE_WINDOW"; id: WindowId }
| { type: "FOCUS_WINDOW"; id: WindowId };

Expand Down
4 changes: 2 additions & 2 deletions src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export function openWindow<Kind extends number | string = any, Meta = never>({
export function closeWindow(id: string = null): WMAction {
return async (dispatch, getState) => {
const state = getState();
dispatch({ type: "CLOSE_WINDOW", id });
await Promise.all(
getWindows(state)
.filter(({ parent }) => parent === id)
.filter((w) => w.parent === id && w.id !== id && w.id !== w.parent)
.map(({ id }) => dispatch(closeWindow(id))),
);
return await dispatch({ type: "CLOSE_WINDOW", id });
};
}
12 changes: 7 additions & 5 deletions src/store/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ export function withoutId<T extends { id: I }, I = string>(arr: T[], id: T["id"]
return arr.filter((el) => id !== el.id);
}

const windows: Reducer<WindowType<any, any>[], Action> = (windows = [], action) => {
const windows: Reducer<WindowType[], Action> = (windows = [], action) => {
switch (action.type) {
case "CLEAR_WINDOWS":
return [];
case "OPEN_WINDOW":
const existingWindow = windows.find((w) => w.id === action.windowData.id);
if (existingWindow) {
return windows.map((window) => (window === existingWindow ? action.windowData : window));
}
return [...windows, action.windowData];
case "CLOSE_WINDOW":
return withoutId(windows, action.id);
Expand All @@ -26,13 +30,11 @@ const order: Reducer<WindowId[], Action> = (state = [], action) => {
case "CLEAR_WINDOWS":
return [];
case "OPEN_WINDOW":
return uniq([action.windowData.id, ...state]);
return state.includes(action.windowData.id) ? state : uniq([action.windowData.id, ...state]);
case "CLOSE_WINDOW":
return without(state, action.id);
case "FOCUS_WINDOW":
if (action.id !== state[0]) {
return uniq([action.id, ...state]);
}
return action.id !== state[0] ? uniq([action.id, ...state]) : state;
default:
return state;
}
Expand Down

0 comments on commit 04dfefb

Please sign in to comment.