Releases: JWo1F/modal.react.js
Releases · JWo1F/modal.react.js
Version 2.1.0
New features
- The
useBlockModalfunction 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()));- The
createModal().checkInterlocksfunction 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
Version 2.0.0
What's Changed
- Bump typescript from 4.9.5 to 5.0.2 by @dependabot in #24
- Bump esbuild from 0.17.11 to 0.17.14 by @dependabot in #25
- Bump @typescript-eslint/eslint-plugin from 5.54.1 to 5.57.0 by @dependabot in #26
- Bump rollup from 3.19.1 to 3.20.2 by @dependabot in #28
- Bump @typescript-eslint/parser from 5.54.1 to 5.57.0 by @dependabot in #27
- Version 2.0.0 by @JWo1F in #39
New Contributors
- @dependabot made their first contribution in #24
- @JWo1F made their first contribution in #39
Full Changelog: v1.7.1...v2.0.0
Version v2.0.0-beta3
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
Bump version
Version 1.7.1
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
Full Changelog: v1.6.1...v1.7.0
Version 1.6.1
Full Changelog: v1.6.0...v1.6.1
1.6.0
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