Skip to content

Releases: JWo1F/modal.react.js

Version 2.1.0

08 Jun 13:19

Choose a tag to compare

New features

  1. The useBlockModal function is now available. You can block any modal window by calling this function:
useBlockModal({
  skip: false,
  checker: async () => Boolean(await asyncStaff())
});

// or short version:
useBlockModal(async () => Boolean(await asyncStaff()));
  1. The createModal().checkInterlocks function is now available. You can check if the modal window is locked by calling this function:
const modal = createModal();

// you cannot use await here, because otherwise the code will freeze waiting
// for the exit from the modal window, which will never happen until all blockers are removed.
const result = modal.show(<Element />);

const isLocked = await modal.checkInterlocks();

// but you can change the modal window without waiting to unlock it:
await modal.show(<Element2 />);

Version 2.0.1

11 Apr 09:32
ba7488d

Choose a tag to compare

What's Changed

Full Changelog: v2.0.0...v2.0.1

Version 2.0.0

11 Apr 08:41
a5911c8

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.7.1...v2.0.0

Version v2.0.0-beta3

08 Apr 10:14

Choose a tag to compare

Version v2.0.0-beta3 Pre-release
Pre-release
feat(utils): add ShowFn type to createModal

The ShowFn type is added to createModal in order to provide a more
flexible way of rendering content in modals. The showModal function
is updated to accept either a ReactNode or a ShowFn as its second
argument. This allows for more complex rendering logic to be included
in modals.

Version v2.0.0-beta2

08 Apr 09:43

Choose a tag to compare

Version v2.0.0-beta2 Pre-release
Pre-release
Bump version

Version 1.7.1

27 Jan 07:56

Choose a tag to compare

In this release, the createArea function has been rewritten, which now works correctly and does not cause errors with a very fast unmount of the modal window.

Full Changelog: v1.7.0...v1.7.1

Version 1.7

20 Dec 20:24

Choose a tag to compare

Full Changelog: v1.6.1...v1.7.0

Version 1.6.1

19 Dec 22:37

Choose a tag to compare

Full Changelog: v1.6.0...v1.6.1

1.6.0

08 Dec 13:15

Choose a tag to compare

createModal feature

You can now create entire sequences of modal windows thanks to the new createModal function. Call it and get a Handler to control your modal window.

export interface Handler {
  // close modal window with animation
  close: () => Promise<void>;

  // show node as your modal window (will replace current window w/o animation)
  show: (node: ReactNode) => void;

  // request modal window to get answer (like in `showModal` function)
  request: <T extends any>(input: Input<T>) => Promise<T>;
}

Example Usage:

const area = createArea();
const modal = createModal(area);

// Instant display of your node as a modal window
modal.show(<YourComponent />);

// Change props without re-mounting:
modal.show(<YourComponent disabled />);

// Change whole component with re-mounting:
modal.show(<YourAnotherComponent />);

// Close your modal window with animation:
await modal.close();

// Request modal window to get the answer:
const data = await modal.request<string>((res, rej) => (
  <RequestComponent
    onClose={(count) => res(count)}
    onError={() => rej('Unexpected error')}
  />
));

// You should close your modal window after show/request:
modal.close();

There is showModal change. Now it's just a syntax sugar for:

const showModal = async <T = void>(area: AreaHolder, input: Input<T>) => {
  const modal = createModal(area);

  try {
    return await modal.request(input);
  } finally {
    await modal.close();
  }
};

Full Changelog: v1.5.2...v1.6.0

1.5.2

29 Nov 09:23

Choose a tag to compare

Move dependencies to dev dependencies