@lerx/promise-modal 0.2.6 → 0.2.7

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.
package/dist/index.cjs CHANGED
@@ -419,30 +419,34 @@ const FallbackForegroundFrame = react.forwardRef(({ id, onChangeOrder, children
419
419
 
420
420
  const ConfigurationContext = react.createContext({});
421
421
 
422
- const ConfigurationContextProvider = react.memo(({ ForegroundComponent, BackgroundComponent, TitleComponent, SubtitleComponent, ContentComponent, FooterComponent, options, children, }) => {
423
- const value = react.useMemo(() => ({
422
+ const DEFAULT_OPTIONS = {
423
+ duration: DEFAULT_ANIMATION_DURATION,
424
+ backdrop: DEFAULT_BACKDROP_COLOR,
425
+ closeOnBackdropClick: true,
426
+ manualDestroy: false,
427
+ };
428
+ const ConfigurationContextProvider = react.memo(({ ForegroundComponent, BackgroundComponent, TitleComponent, SubtitleComponent, ContentComponent, FooterComponent, options: inputOptions, children, }) => {
429
+ const memoized = hook.useMemorize({
424
430
  BackgroundComponent,
425
431
  ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,
426
432
  TitleComponent: TitleComponent || FallbackTitle,
427
433
  SubtitleComponent: SubtitleComponent || FallbackSubtitle,
428
434
  ContentComponent: react.memo(ContentComponent || FallbackContent),
429
435
  FooterComponent: react.memo(FooterComponent || FallbackFooter),
436
+ });
437
+ const options = hook.useSnapshot(inputOptions);
438
+ const value = react.useMemo(() => ({
439
+ ForegroundComponent: memoized.ForegroundComponent,
440
+ BackgroundComponent: memoized.BackgroundComponent,
441
+ TitleComponent: memoized.TitleComponent,
442
+ SubtitleComponent: memoized.SubtitleComponent,
443
+ ContentComponent: memoized.ContentComponent,
444
+ FooterComponent: memoized.FooterComponent,
430
445
  options: {
431
- duration: DEFAULT_ANIMATION_DURATION,
432
- backdrop: DEFAULT_BACKDROP_COLOR,
433
- closeOnBackdropClick: true,
434
- manualDestroy: false,
446
+ ...DEFAULT_OPTIONS,
435
447
  ...options,
436
448
  },
437
- }), [
438
- ForegroundComponent,
439
- BackgroundComponent,
440
- ContentComponent,
441
- FooterComponent,
442
- SubtitleComponent,
443
- TitleComponent,
444
- options,
445
- ]);
449
+ }), [memoized, options]);
446
450
  return (jsxRuntime.jsx(ConfigurationContext.Provider, { value: value, children: children }));
447
451
  });
448
452
 
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { createContext, useContext, useMemo, forwardRef, memo, useRef, useState, useLayoutEffect, useCallback, Fragment, useEffect, useImperativeHandle } from 'react';
3
3
  import { convertMsFromDuration } from '@winglet/common-utils/convert';
4
- import { useReference, useOnMountLayout, useHandle, useVersion, useOnMount } from '@winglet/react-utils/hook';
4
+ import { useMemorize, useSnapshot, useReference, useOnMountLayout, useHandle, useVersion, useOnMount } from '@winglet/react-utils/hook';
5
5
  import { polynomialHash } from '@winglet/common-utils/hash';
6
6
  import { getRandomString, counterFactory } from '@winglet/common-utils/lib';
7
7
  import { styleManagerFactory, destroyScope } from '@winglet/style-utils/style-manager';
@@ -417,30 +417,34 @@ const FallbackForegroundFrame = forwardRef(({ id, onChangeOrder, children }, ref
417
417
 
418
418
  const ConfigurationContext = createContext({});
419
419
 
420
- const ConfigurationContextProvider = memo(({ ForegroundComponent, BackgroundComponent, TitleComponent, SubtitleComponent, ContentComponent, FooterComponent, options, children, }) => {
421
- const value = useMemo(() => ({
420
+ const DEFAULT_OPTIONS = {
421
+ duration: DEFAULT_ANIMATION_DURATION,
422
+ backdrop: DEFAULT_BACKDROP_COLOR,
423
+ closeOnBackdropClick: true,
424
+ manualDestroy: false,
425
+ };
426
+ const ConfigurationContextProvider = memo(({ ForegroundComponent, BackgroundComponent, TitleComponent, SubtitleComponent, ContentComponent, FooterComponent, options: inputOptions, children, }) => {
427
+ const memoized = useMemorize({
422
428
  BackgroundComponent,
423
429
  ForegroundComponent: ForegroundComponent || FallbackForegroundFrame,
424
430
  TitleComponent: TitleComponent || FallbackTitle,
425
431
  SubtitleComponent: SubtitleComponent || FallbackSubtitle,
426
432
  ContentComponent: memo(ContentComponent || FallbackContent),
427
433
  FooterComponent: memo(FooterComponent || FallbackFooter),
434
+ });
435
+ const options = useSnapshot(inputOptions);
436
+ const value = useMemo(() => ({
437
+ ForegroundComponent: memoized.ForegroundComponent,
438
+ BackgroundComponent: memoized.BackgroundComponent,
439
+ TitleComponent: memoized.TitleComponent,
440
+ SubtitleComponent: memoized.SubtitleComponent,
441
+ ContentComponent: memoized.ContentComponent,
442
+ FooterComponent: memoized.FooterComponent,
428
443
  options: {
429
- duration: DEFAULT_ANIMATION_DURATION,
430
- backdrop: DEFAULT_BACKDROP_COLOR,
431
- closeOnBackdropClick: true,
432
- manualDestroy: false,
444
+ ...DEFAULT_OPTIONS,
433
445
  ...options,
434
446
  },
435
- }), [
436
- ForegroundComponent,
437
- BackgroundComponent,
438
- ContentComponent,
439
- FooterComponent,
440
- SubtitleComponent,
441
- TitleComponent,
442
- options,
443
- ]);
447
+ }), [memoized, options]);
444
448
  return (jsx(ConfigurationContext.Provider, { value: value, children: children }));
445
449
  });
446
450
 
@@ -19,4 +19,4 @@ export interface ConfigurationContextProviderProps {
19
19
  closeOnBackdropClick?: boolean;
20
20
  };
21
21
  }
22
- export declare const ConfigurationContextProvider: import("react").MemoExoticComponent<({ ForegroundComponent, BackgroundComponent, TitleComponent, SubtitleComponent, ContentComponent, FooterComponent, options, children, }: PropsWithChildren<ConfigurationContextProviderProps>) => import("react/jsx-runtime").JSX.Element>;
22
+ export declare const ConfigurationContextProvider: import("react").MemoExoticComponent<({ ForegroundComponent, BackgroundComponent, TitleComponent, SubtitleComponent, ContentComponent, FooterComponent, options: inputOptions, children, }: PropsWithChildren<ConfigurationContextProviderProps>) => import("react/jsx-runtime").JSX.Element>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lerx/promise-modal",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Universal React modal utility that can be used outside React components with promise-based results for alert, confirm, and prompt modals",
5
5
  "keywords": [
6
6
  "react",
@@ -66,11 +66,11 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@winglet/common-utils": "^0.2.2",
69
- "@winglet/react-utils": "^0.2.4",
69
+ "@winglet/react-utils": "^0.2.6",
70
70
  "@winglet/style-utils": "^0.2.2"
71
71
  },
72
72
  "devDependencies": {
73
- "@chromatic-com/storybook": "^3.2.6",
73
+ "@chromatic-com/storybook": "^4.0.1",
74
74
  "@rollup/plugin-commonjs": "^28.0.1",
75
75
  "@rollup/plugin-node-resolve": "^15.3.0",
76
76
  "@rollup/plugin-terser": "^0.4.4",
@@ -78,12 +78,8 @@
78
78
  "@size-limit/preset-app": "^11.1.6",
79
79
  "@size-limit/preset-big-lib": "^11.1.6",
80
80
  "@size-limit/preset-small-lib": "^11.1.6",
81
- "@storybook/addon-essentials": "^8.6.14",
82
- "@storybook/addon-interactions": "^8.6.14",
83
- "@storybook/blocks": "^8.6.14",
84
- "@storybook/react": "^8.6.14",
85
- "@storybook/react-vite": "^8.6.14",
86
- "@storybook/test": "^8.6.14",
81
+ "@storybook/addon-docs": "^9.0.14",
82
+ "@storybook/react-vite": "^9.0.14",
87
83
  "@testing-library/dom": "^10.4.0",
88
84
  "@testing-library/jest-dom": "^6.6.3",
89
85
  "@testing-library/react": "^16.1.0",
@@ -102,7 +98,7 @@
102
98
  "rollup-plugin-peer-deps-external": "^2.2.4",
103
99
  "rollup-plugin-visualizer": "^5.12.0",
104
100
  "size-limit": "^11.2.0",
105
- "storybook": "^8.6.14",
101
+ "storybook": "^9.0.14",
106
102
  "tsc-alias": "^1.8.16",
107
103
  "typescript": "^5.7.2",
108
104
  "vite": "^6.3.5",