@linzjs/windows 1.5.0 → 1.5.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.
@@ -34,6 +34,10 @@ export const Modal = ({ className, children }: PropsWithChildren<ModalProps>): R
34
34
  className={clsx("linzjs-windows-dialog", className)}
35
35
  ref={dialogRef}
36
36
  onClick={(e) => e.target === e.currentTarget && close()}
37
+ onCancel={(e) => {
38
+ e.preventDefault();
39
+ close();
40
+ }}
37
41
  >
38
42
  {children}
39
43
  </dialog>
@@ -6,7 +6,7 @@ import { ModalInstanceContext } from "./ModalInstanceContext";
6
6
  import React, { Fragment, ReactNode } from "react";
7
7
  import { MutableRefObject, ReactElement, useCallback, useState } from "react";
8
8
  import { createPortal } from "react-dom";
9
- import { v4 as uuid } from "uuid";
9
+ import { v4 as makeUuid } from "uuid";
10
10
 
11
11
  export interface ModalInstance {
12
12
  uuid: string;
@@ -72,14 +72,14 @@ export const ModalContextProvider = ({ children }: { children?: ReactNode | unde
72
72
  */
73
73
  const showModal = useCallback(
74
74
  async (ownerRef: MutableRefObject<HTMLElement | null>, Component: ComponentType, args: any): Promise<any> => {
75
- let componentInstance: ReactElement | undefined;
75
+ const uuid = makeUuid();
76
76
  const promise = new Promise((resolve) => {
77
77
  try {
78
78
  // If there are any exceptions the modal won't show
79
- setModals([
79
+ setModals((modals) => [
80
80
  ...modals,
81
81
  {
82
- uuid: uuid(),
82
+ uuid,
83
83
  ownerElement: ownerRef.current ?? document.body,
84
84
  componentInstance: <Component {...args} resolve={resolve} close={() => resolve(undefined)} />,
85
85
  resolve,
@@ -95,11 +95,11 @@ export const ModalContextProvider = ({ children }: { children?: ReactNode | unde
95
95
  const result = await promise;
96
96
 
97
97
  // Close modal
98
- setModals(modals.filter((e) => e.componentInstance !== componentInstance));
98
+ setModals((modals) => modals.filter((e) => e.uuid !== uuid));
99
99
 
100
100
  return result;
101
101
  },
102
- [modals],
102
+ [],
103
103
  );
104
104
 
105
105
  const modalHasView = useCallback(
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "popout"
14
14
  ],
15
15
  "main": "./dist/index.ts",
16
- "version": "1.5.0",
16
+ "version": "1.5.2",
17
17
  "peerDependencies": {
18
18
  "@linzjs/lui": "^17",
19
19
  "lodash-es": ">=4",