@helloworldqq/react-modal 1.0.1 → 1.0.3
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/hook/index.d.ts.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -26
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +57 -26
- package/dist/index.modern.js.map +1 -1
- package/dist/provider/index.d.ts +14 -0
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +21 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/package.json +5 -2
package/dist/hook/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/hook/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAG/B,oBAAY,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEtF,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,GAAG,EAAE,OAAO,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACpC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAED,eAAO,MAAM,aAAa;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/hook/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAG/B,oBAAY,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEtF,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,GAAG,EAAE,OAAO,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACpC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAED,eAAO,MAAM,aAAa;;;;;;;uBAgEc,OAAO;;;CAiC9C,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,16 @@ declare type ModalComponent = React.FunctionComponent<any> | React.ComponentType
|
|
|
3
3
|
export declare type ReactHookModalProviderProps = {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
modals: Record<string, ModalComponent>;
|
|
6
|
+
/**
|
|
7
|
+
* Strategy for rendering modals:
|
|
8
|
+
* - 'eager': Mount all modals upfront (default, backward compatible)
|
|
9
|
+
* - 'lazy': Only mount modals that have been opened at least once
|
|
10
|
+
*
|
|
11
|
+
* Use 'lazy' if you have 50+ modals for better performance.
|
|
12
|
+
*/
|
|
13
|
+
renderStrategy?: 'eager' | 'lazy';
|
|
6
14
|
};
|
|
7
|
-
export declare const ReactHookModalProvider: ({ children, modals }: ReactHookModalProviderProps) => React.JSX.Element;
|
|
15
|
+
export declare const ReactHookModalProvider: ({ children, modals, renderStrategy }: ReactHookModalProviderProps) => React.JSX.Element;
|
|
8
16
|
export * from './hook';
|
|
9
17
|
export * from './provider';
|
|
10
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,aAAK,cAAc,GAAG,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;AAE7E,oBAAY,2BAA2B,GAAG;IACxC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,aAAK,cAAc,GAAG,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;AAE7E,oBAAY,2BAA2B,GAAG;IACxC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACtC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,sBAAsB,yCAIhC,2BAA2B,sBAO7B,CAAA;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,8 @@ var closeModal = function closeModal(tag) {
|
|
|
42
42
|
var _extends4;
|
|
43
43
|
return {
|
|
44
44
|
modalTags: _extends({}, state.modalTags, (_extends4 = {}, _extends4[tag] = {
|
|
45
|
-
input: false
|
|
45
|
+
input: false,
|
|
46
|
+
output: undefined
|
|
46
47
|
}, _extends4))
|
|
47
48
|
};
|
|
48
49
|
});
|
|
@@ -88,38 +89,64 @@ var useModalActions = function useModalActions(actionCallback) {
|
|
|
88
89
|
};
|
|
89
90
|
|
|
90
91
|
var ModalWrapper = React.memo(function ModalWrapper(_ref) {
|
|
91
|
-
var modals = _ref.modals
|
|
92
|
+
var modals = _ref.modals,
|
|
93
|
+
_ref$renderStrategy = _ref.renderStrategy,
|
|
94
|
+
renderStrategy = _ref$renderStrategy === void 0 ? 'eager' : _ref$renderStrategy;
|
|
92
95
|
var modalTags = useModalStore(function (state) {
|
|
93
96
|
return state.modalTags;
|
|
94
97
|
});
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
var allModals = React.useMemo(function () {
|
|
99
|
+
if (renderStrategy === 'lazy') {
|
|
100
|
+
return Object.keys(modalTags).map(function (tag) {
|
|
101
|
+
var Modal = modals[tag];
|
|
102
|
+
if (!Modal) {
|
|
103
|
+
console.warn("[ModalWrapper] Modal \"" + tag + "\" not found in modals registry");
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
return React__default.createElement(Modal, {
|
|
108
|
+
key: tag
|
|
109
|
+
});
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error("[ModalWrapper] Error rendering modal \"" + tag + "\":", error);
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
105
114
|
});
|
|
115
|
+
}
|
|
116
|
+
return Object.entries(modals).map(function (_ref2) {
|
|
117
|
+
var tag = _ref2[0],
|
|
118
|
+
Modal = _ref2[1];
|
|
119
|
+
try {
|
|
120
|
+
return React__default.createElement(Modal, {
|
|
121
|
+
key: tag
|
|
122
|
+
});
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error("[ModalWrapper] Error rendering modal \"" + tag + "\":", error);
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
106
127
|
});
|
|
107
|
-
}, [modals,
|
|
108
|
-
return React__default.createElement(React__default.Fragment, null,
|
|
128
|
+
}, [renderStrategy === 'lazy' ? modalTags : modals, modals, renderStrategy]);
|
|
129
|
+
return React__default.createElement(React__default.Fragment, null, allModals);
|
|
109
130
|
});
|
|
110
131
|
|
|
111
132
|
var useDisclosure = function useDisclosure(disclosureHook) {
|
|
112
133
|
var tag = disclosureHook.tag;
|
|
113
134
|
var disclosureHookRef = React.useRef(disclosureHook);
|
|
114
135
|
disclosureHookRef.current = disclosureHook;
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
136
|
+
var inputSelector = React.useMemo(function () {
|
|
137
|
+
return function (state) {
|
|
138
|
+
var _state$modalTags$tag;
|
|
139
|
+
return (_state$modalTags$tag = state.modalTags[tag]) === null || _state$modalTags$tag === void 0 ? void 0 : _state$modalTags$tag.input;
|
|
140
|
+
};
|
|
141
|
+
}, [tag]);
|
|
142
|
+
var outputSelector = React.useMemo(function () {
|
|
143
|
+
return function (state) {
|
|
144
|
+
var _state$modalTags$tag2;
|
|
145
|
+
return (_state$modalTags$tag2 = state.modalTags[tag]) === null || _state$modalTags$tag2 === void 0 ? void 0 : _state$modalTags$tag2.output;
|
|
146
|
+
};
|
|
147
|
+
}, [tag]);
|
|
148
|
+
var inputState = useModalStore(inputSelector);
|
|
149
|
+
var outputState = useModalStore(outputSelector);
|
|
123
150
|
var clearDisclosureTag = useModalActions(function (actions) {
|
|
124
151
|
return actions.clearModalTag;
|
|
125
152
|
});
|
|
@@ -178,9 +205,10 @@ var useDisclosure = function useDisclosure(disclosureHook) {
|
|
|
178
205
|
}, [tag, clearDisclosureTag]);
|
|
179
206
|
React.useEffect(function () {
|
|
180
207
|
if (outputState) {
|
|
181
|
-
|
|
208
|
+
var _disclosureHookRef$cu1, _disclosureHookRef$cu10;
|
|
209
|
+
(_disclosureHookRef$cu1 = disclosureHookRef.current) === null || _disclosureHookRef$cu1 === void 0 ? void 0 : (_disclosureHookRef$cu10 = _disclosureHookRef$cu1.onOk) === null || _disclosureHookRef$cu10 === void 0 ? void 0 : _disclosureHookRef$cu10.call(_disclosureHookRef$cu1, outputState);
|
|
182
210
|
}
|
|
183
|
-
}, [outputState
|
|
211
|
+
}, [outputState]);
|
|
184
212
|
return {
|
|
185
213
|
isOpen: !!inputState,
|
|
186
214
|
input: typeof inputState === 'boolean' ? undefined : inputState,
|
|
@@ -196,9 +224,12 @@ var useDisclosure = function useDisclosure(disclosureHook) {
|
|
|
196
224
|
|
|
197
225
|
var ReactHookModalProvider = function ReactHookModalProvider(_ref) {
|
|
198
226
|
var children = _ref.children,
|
|
199
|
-
modals = _ref.modals
|
|
227
|
+
modals = _ref.modals,
|
|
228
|
+
_ref$renderStrategy = _ref.renderStrategy,
|
|
229
|
+
renderStrategy = _ref$renderStrategy === void 0 ? 'eager' : _ref$renderStrategy;
|
|
200
230
|
return React.createElement(React.Fragment, null, React.createElement(ModalWrapper, {
|
|
201
|
-
modals: modals
|
|
231
|
+
modals: modals,
|
|
232
|
+
renderStrategy: renderStrategy
|
|
202
233
|
}), children);
|
|
203
234
|
};
|
|
204
235
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/store/index.ts","../src/provider/index.tsx","../src/hook/index.ts","../src/index.tsx"],"sourcesContent":["import { Store, useStore } from \"@tanstack/react-store\";\n\n// You can instantiate the store outside of React components too!\n\nimport { Any } from '../hook'\n\nexport type State = {\n modalTags: {\n [tag: string]: {\n input?: Any\n output?: Any\n }\n }\n}\n\nexport type Action = {\n openModal: (tag: string, input?: Any) => void\n okModal: (tag: string, output?: Any) => void\n closeModal: (tag: string) => void\n toggleModal: (tag: string) => void\n clearModalTag: (tag: string) => void\n clearAllModalTags: () => void\n}\nexport const store = new Store<State>({\n modalTags: {}\n});\n\n\nconst openModal = (tag: string, input?: Any) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n input: input ?? true // Default to true if no input is provided\n }\n }\n }))\n}\nconst okModal = (tag: string, output?: Any) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n output\n }\n }\n }))\n}\nconst closeModal = (tag: string) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: { input: false }\n }\n }))\n}\nconst toggleModal = (tag: string) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n input: !state.modalTags[tag]?.input\n }\n }\n }))\n}\nconst clearModalTag = (tag: string) => {\n store.setState((state) => {\n const newModalTags = { ...state.modalTags };\n delete newModalTags[tag];\n return { modalTags: newModalTags };\n })\n}\nconst clearAllModalTags = () => {\n store.setState(() => ({ modalTags: {} }))\n}\n\nexport const useModalStore = <T>(\n stateCallback: (state: State) => T,\n): T => {\n return useStore(store, stateCallback)\n}\n\nexport const useModalActions = <T>(\n actionCallback: (action: Action) => T\n): T => {\n return actionCallback(\n {\n openModal,\n okModal,\n closeModal,\n toggleModal,\n clearModalTag,\n clearAllModalTags\n }\n )\n}","import React, { useMemo, memo } from 'react'\nimport { useModalStore, State } from '../store'\n\ntype ModalComponent = React.FunctionComponent<any> | React.ComponentType<any>\n\nexport interface ModalWrapperProps {\n modals: Record<string, ModalComponent>\n}\n\nexport const ModalWrapper = memo(function ModalWrapper({\n modals\n}: ModalWrapperProps) {\n const modalTags = useModalStore((state: State) => state.modalTags)\n \n const modalOpened = useMemo(() => {\n return Object.entries(modals)\n .filter(([tag]) => !!modalTags[tag]?.input)\n .map(([tag, Modal]) => <Modal key={tag} />)\n }, [modals, modalTags])\n \n return <React.Fragment>{modalOpened}</React.Fragment>\n})\n","import { useEffect, useCallback, useRef } from 'react'\nimport { TagType } from './tag'\nimport { useModalStore, useModalActions, store } from '../store'\n\nexport type Any = string | number | boolean | object | undefined | Record<string, any>\n\nexport interface DisclosureHookProps<O> {\n tag: TagType\n isOpen?: boolean\n onOpen?: () => void\n onClose?: () => void\n onToggle?: () => void\n onChange?: (isOpen: boolean) => void\n onOk?: (output?: O) => void\n onCancel?: () => void\n}\n\nexport const useDisclosure = <Input = Any, Output = Any>(\n disclosureHook: DisclosureHookProps<Output>\n) => {\n const tag = disclosureHook.tag\n \n // Use refs to store callbacks to avoid stale closures\n const disclosureHookRef = useRef(disclosureHook)\n disclosureHookRef.current = disclosureHook\n\n const inputState = useModalStore(\n (state) => state.modalTags[tag]?.input\n ) as Input\n const outputState = useModalStore(\n (state) => state.modalTags[tag]?.output\n ) as Output\n const clearDisclosureTag = useModalActions(\n (actions) => actions.clearModalTag\n )\n\n const onOpenAction = useModalActions((actions) => actions.openModal)\n const okAction = useModalActions((actions) => actions.okModal)\n const onCloseAction = useModalActions((actions) => actions.closeModal)\n const onToggleAction = useModalActions((actions) => actions.toggleModal)\n\n const updateInput = useCallback((input?: Input) => {\n // If input is a function, call it and set the result as input\n let processedInput = input\n if (processedInput && typeof processedInput == 'object' && 'preventDefault' in processedInput) {\n processedInput = undefined\n }\n onOpenAction(tag, processedInput as Any)\n }, [tag, onOpenAction])\n\n const onOpen = useCallback((input?: Input) => {\n updateInput(input)\n disclosureHookRef.current?.onOpen?.()\n }, [updateInput])\n\n const onClose = useCallback(() => {\n onCloseAction(tag)\n disclosureHookRef.current?.onClose?.()\n }, [tag, onCloseAction])\n\n const onToggle = useCallback(() => {\n onToggleAction(tag)\n disclosureHookRef.current?.onToggle?.()\n }, [tag, onToggleAction])\n\n const onOk = useCallback((output?: Output) => {\n disclosureHookRef.current?.onOk?.(output)\n okAction(tag, output as Any)\n }, [tag, okAction])\n\n const onChange = useCallback((isOpen: boolean) => {\n if (isOpen) {\n onOpen()\n } else {\n onClose()\n }\n disclosureHookRef.current?.onChange?.(isOpen)\n }, [onOpen, onClose])\n\n useEffect(() => {\n return () => {\n clearDisclosureTag(tag)\n }\n }, [tag, clearDisclosureTag])\n\n useEffect(() => {\n if (outputState) {\n onOk(outputState as Output)\n }\n }, [outputState, onOk])\n\n return {\n isOpen: !!inputState,\n input: typeof inputState === 'boolean' ? undefined : inputState,\n onOpen,\n onClose,\n onToggle,\n onOk,\n onChange,\n updateInput,\n store\n }\n}\n","import * as React from 'react'\nimport { ModalWrapper } from './provider'\n\ntype ModalComponent = React.FunctionComponent<any> | React.ComponentType<any>\n\nexport type ReactHookModalProviderProps = {\n children: React.ReactNode\n modals: Record<string, ModalComponent>\n}\n\nexport const ReactHookModalProvider = ({\n children,\n modals\n}: ReactHookModalProviderProps) => {\n return (\n <React.Fragment>\n <ModalWrapper modals={modals} />\n {children}\n </React.Fragment>\n )\n}\n\nexport * from './hook'\nexport * from './provider'\n"],"names":["store","Store","modalTags","openModal","tag","input","setState","state","_extends2","_extends","okModal","output","_extends3","closeModal","_extends4","toggleModal","_state$modalTags$tag","_extends5","clearModalTag","newModalTags","clearAllModalTags","useModalStore","stateCallback","useStore","useModalActions","actionCallback","ModalWrapper","memo","_ref","modals","modalOpened","useMemo","Object","entries","filter","_ref2","_modalTags$tag","map","_ref3","Modal","React","key","Fragment","useDisclosure","disclosureHook","disclosureHookRef","useRef","current","inputState","outputState","_state$modalTags$tag2","clearDisclosureTag","actions","onOpenAction","okAction","onCloseAction","onToggleAction","updateInput","useCallback","processedInput","undefined","onOpen","_disclosureHookRef$cu","_disclosureHookRef$cu2","call","onClose","_disclosureHookRef$cu3","_disclosureHookRef$cu4","onToggle","_disclosureHookRef$cu5","_disclosureHookRef$cu6","onOk","_disclosureHookRef$cu7","_disclosureHookRef$cu8","onChange","isOpen","_disclosureHookRef$cu9","_disclosureHookRef$cu0","useEffect","ReactHookModalProvider","children"],"mappings":";;;;;;;;;;;;;;;;AAuBO,IAAMA,KAAK,GAAG,IAAIC,gBAAK,CAAQ;EACpCC,SAAS,EAAE;CACZ,CAAC;AAG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AAW,EAAE;MACfsB,IAAI,CAACtB,WAAqB,CAAC;;GAE9B,EAAE,CAACA,WAAW,EAAEsB,IAAI,CAAC,CAAC;EAEvB,OAAO;IACLI,MAAM,EAAE,CAAC,CAAC3B,UAAU;IACpB3C,KAAK,EAAE,OAAO2C,UAAU,KAAK,SAAS,GAAGY,SAAS,GAAGZ,UAAU;IAC/Da,MAAM,EAANA,MAAM;IACNI,OAAO,EAAPA,OAAO;IACPG,QAAQ,EAARA,QAAQ;IACRG,IAAI,EAAJA,IAAI;IACJG,QAAQ,EAARA,QAAQ;IACRjB,WAAW,EAAXA,WAAW;IACXzD,KAAK,EAALA;GACD;AACH,CAAC;;IC5FY+E,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAAnD,IAAA;MACjCoD,QAAQ,GAAApD,IAAA,CAARoD,QAAQ;IACRnD,MAAM,GAAAD,IAAA,CAANC,MAAM;EAEN,OACEW,oBAACA,cAAc,QACbA,oBAACd,YAAY;IAACG,MAAM,EAAEA;IAAU,EAC/BmD,QAAQ,CACM;AAErB,CAAC;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/store/index.ts","../src/provider/index.tsx","../src/hook/index.ts","../src/index.tsx"],"sourcesContent":["import { Store, useStore } from \"@tanstack/react-store\";\n\n// You can instantiate the store outside of React components too!\n\nimport { Any } from '../hook'\n\nexport type State = {\n modalTags: {\n [tag: string]: {\n input?: Any\n output?: Any\n }\n }\n}\n\nexport type Action = {\n openModal: (tag: string, input?: Any) => void\n okModal: (tag: string, output?: Any) => void\n closeModal: (tag: string) => void\n toggleModal: (tag: string) => void\n clearModalTag: (tag: string) => void\n clearAllModalTags: () => void\n}\nexport const store = new Store<State>({\n modalTags: {}\n});\n\n\nconst openModal = (tag: string, input?: Any) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n input: input ?? true // Default to true if no input is provided\n }\n }\n }))\n}\nconst okModal = (tag: string, output?: Any) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n output\n }\n }\n }))\n}\nconst closeModal = (tag: string) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: { input: false, output: undefined }\n }\n }))\n}\nconst toggleModal = (tag: string) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n input: !state.modalTags[tag]?.input\n }\n }\n }))\n}\nconst clearModalTag = (tag: string) => {\n store.setState((state) => {\n const newModalTags = { ...state.modalTags };\n delete newModalTags[tag];\n return { modalTags: newModalTags };\n })\n}\nconst clearAllModalTags = () => {\n store.setState(() => ({ modalTags: {} }))\n}\n\nexport const useModalStore = <T>(\n stateCallback: (state: State) => T,\n): T => {\n return useStore(store, stateCallback)\n}\n\nexport const useModalActions = <T>(\n actionCallback: (action: Action) => T\n): T => {\n return actionCallback(\n {\n openModal,\n okModal,\n closeModal,\n toggleModal,\n clearModalTag,\n clearAllModalTags\n }\n )\n}","import React, { useMemo, memo } from 'react'\nimport { useModalStore, State } from '../store'\n\ntype ModalComponent = React.FunctionComponent<any> | React.ComponentType<any>\n\nexport interface ModalWrapperProps {\n modals: Record<string, ModalComponent>\n /**\n * Strategy for rendering modals:\n * - 'eager': Mount all modals upfront (default, backward compatible)\n * - 'lazy': Only mount modals that have been opened at least once\n * \n * Performance comparison:\n * - 10 modals: Both strategies are fine\n * - 50 modals: Lazy recommended (~200ms faster initial render)\n * - 100+ modals: Lazy strongly recommended (~500ms+ faster initial render)\n * - 1000 modals: Lazy is mandatory (~10s faster initial render, ~100MB less memory)\n * \n * Trade-off: With lazy mode, first modal open has ~50-100ms delay for mounting.\n */\n renderStrategy?: 'eager' | 'lazy'\n}\n\nexport const ModalWrapper = memo(function ModalWrapper({\n modals,\n renderStrategy = 'eager'\n}: ModalWrapperProps) {\n const modalTags = useModalStore((state: State) => state.modalTags)\n\n const allModals = useMemo(() => {\n if (renderStrategy === 'lazy') {\n // LAZY MODE: Chỉ render modals đã được mở ít nhất 1 lần\n // Significantly faster for apps with many modals!\n return Object.keys(modalTags).map((tag) => {\n const Modal = modals[tag]\n if (!Modal) {\n console.warn(`[ModalWrapper] Modal \"${tag}\" not found in modals registry`)\n return null\n }\n\n try {\n return <Modal key={tag} />\n } catch (error) {\n console.error(`[ModalWrapper] Error rendering modal \"${tag}\":`, error)\n return null\n }\n })\n }\n\n // EAGER MODE: Render tất cả modals ngay từ đầu (backward compatible)\n // Modal components tự control hiển thị qua isOpen prop\n return Object.entries(modals).map(([tag, Modal]) => {\n try {\n return <Modal key={tag} />\n } catch (error) {\n console.error(`[ModalWrapper] Error rendering modal \"${tag}\":`, error)\n return null\n }\n })\n }, [renderStrategy === 'lazy' ? modalTags : modals, modals, renderStrategy])\n\n return <React.Fragment>{allModals}</React.Fragment>\n})\n","import { useEffect, useCallback, useRef, useMemo } from 'react'\nimport { TagType } from './tag'\nimport { useModalStore, useModalActions, store } from '../store'\n\nexport type Any = string | number | boolean | object | undefined | Record<string, any>\n\nexport interface DisclosureHookProps<O> {\n tag: TagType\n isOpen?: boolean\n onOpen?: () => void\n onClose?: () => void\n onToggle?: () => void\n onChange?: (isOpen: boolean) => void\n onOk?: (output?: O) => void\n onCancel?: () => void\n}\n\nexport const useDisclosure = <Input = Any, Output = Any>(\n disclosureHook: DisclosureHookProps<Output>\n) => {\n const tag = disclosureHook.tag\n\n // Use refs to store callbacks to avoid stale closures\n const disclosureHookRef = useRef(disclosureHook)\n disclosureHookRef.current = disclosureHook\n\n // ⚡ Selective Subscription: Memoize selectors để TanStack Store\n // chỉ trigger re-render khi state của MODAL NÀY thay đổi\n // Không re-render khi modal khác thay đổi state\n const inputSelector = useMemo(\n () => (state: { modalTags: Record<string, { input?: Any; output?: Any }> }) =>\n state.modalTags[tag]?.input,\n [tag]\n )\n\n const outputSelector = useMemo(\n () => (state: { modalTags: Record<string, { input?: Any; output?: Any }> }) =>\n state.modalTags[tag]?.output,\n [tag]\n )\n\n const inputState = useModalStore(inputSelector) as Input\n const outputState = useModalStore(outputSelector) as Output\n const clearDisclosureTag = useModalActions(\n (actions) => actions.clearModalTag\n )\n\n const onOpenAction = useModalActions((actions) => actions.openModal)\n const okAction = useModalActions((actions) => actions.okModal)\n const onCloseAction = useModalActions((actions) => actions.closeModal)\n const onToggleAction = useModalActions((actions) => actions.toggleModal)\n\n const updateInput = useCallback((input?: Input) => {\n // If input is a function, call it and set the result as input\n let processedInput = input\n if (processedInput && typeof processedInput == 'object' && 'preventDefault' in processedInput) {\n processedInput = undefined\n }\n onOpenAction(tag, processedInput as Any)\n }, [tag, onOpenAction])\n\n const onOpen = useCallback((input?: Input) => {\n updateInput(input)\n disclosureHookRef.current?.onOpen?.()\n }, [updateInput])\n\n const onClose = useCallback(() => {\n onCloseAction(tag)\n disclosureHookRef.current?.onClose?.()\n }, [tag, onCloseAction])\n\n const onToggle = useCallback(() => {\n onToggleAction(tag)\n disclosureHookRef.current?.onToggle?.()\n }, [tag, onToggleAction])\n\n const onOk = useCallback((output?: Output) => {\n disclosureHookRef.current?.onOk?.(output)\n okAction(tag, output as Any)\n }, [tag, okAction])\n\n const onChange = useCallback((isOpen: boolean) => {\n if (isOpen) {\n onOpen()\n } else {\n onClose()\n }\n disclosureHookRef.current?.onChange?.(isOpen)\n }, [onOpen, onClose])\n\n useEffect(() => {\n return () => {\n clearDisclosureTag(tag)\n }\n }, [tag, clearDisclosureTag])\n\n useEffect(() => {\n if (outputState) {\n // Use ref instead of direct callback to avoid infinite loop\n disclosureHookRef.current?.onOk?.(outputState as Output)\n }\n }, [outputState])\n\n return {\n isOpen: !!inputState,\n input: typeof inputState === 'boolean' ? undefined : inputState,\n onOpen,\n onClose,\n onToggle,\n onOk,\n onChange,\n updateInput,\n store\n }\n}\n","import * as React from 'react'\nimport { ModalWrapper } from './provider'\n\ntype ModalComponent = React.FunctionComponent<any> | React.ComponentType<any>\n\nexport type ReactHookModalProviderProps = {\n children: React.ReactNode\n modals: Record<string, ModalComponent>\n /**\n * Strategy for rendering modals:\n * - 'eager': Mount all modals upfront (default, backward compatible)\n * - 'lazy': Only mount modals that have been opened at least once\n * \n * Use 'lazy' if you have 50+ modals for better performance.\n */\n renderStrategy?: 'eager' | 'lazy'\n}\n\nexport const ReactHookModalProvider = ({\n children,\n modals,\n renderStrategy = 'eager'\n}: ReactHookModalProviderProps) => {\n return (\n <React.Fragment>\n <ModalWrapper modals={modals} renderStrategy={renderStrategy} />\n {children}\n </React.Fragment>\n )\n}\n\nexport * from './hook'\nexport * from './provider'\n"],"names":["store","Store","modalTags","openModal","tag","input","setState","state","_extends2","_extends","okModal","output","_extends3","closeModal","_extends4","undefined","toggleModal","_state$modalTags$tag","_extends5","clearModalTag","newModalTags","clearAllModalTags","useModalStore","stateCallback","useStore","useModalActions","actionCallback","ModalWrapper","memo","_ref","modals","_ref$renderStrategy","renderStrategy","allModals","useMemo","Object","keys","map","Modal","console","warn","React","key","error","entries","_ref2","Fragment","useDisclosure","disclosureHook","disclosureHookRef","useRef","current","inputSelector","outputSelector","_state$modalTags$tag2","inputState","outputState","clearDisclosureTag","actions","onOpenAction","okAction","onCloseAction","onToggleAction","updateInput","useCallback","processedInput","onOpen","_disclosureHookRef$cu","_disclosureHookRef$cu2","call","onClose","_disclosureHookRef$cu3","_disclosureHookRef$cu4","onToggle","_disclosureHookRef$cu5","_disclosureHookRef$cu6","onOk","_disclosureHookRef$cu7","_disclosureHookRef$cu8","onChange","isOpen","_disclosureHookRef$cu9","_disclosureHookRef$cu0","useEffect","_disclosureHookRef$cu1","_disclosureHookRef$cu10","ReactHookModalProvider","children"],"mappings":";;;;;;;;;;;;;;;;AAuBO,IAAMA,KAAK,GAAG,IAAIC,gBAAK,CAAQ;EACpCC,SAAS,EAAE;CACZ,CAAC;AAGF,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAIC,GAAW,EAAEC,KAAW;EACzCL,KAAK,CAACM,QAAQ,CAAC,UAACC,KAAK;IAAA,IAAAC,SA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GACD;AACH,CAAC;;IChGYsF,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAAzD,IAAA;MACjC0D,QAAQ,GAAA1D,IAAA,CAAR0D,QAAQ;IACRzD,MAAM,GAAAD,IAAA,CAANC,MAAM;IAAAC,mBAAA,GAAAF,IAAA,CACNG,cAAc;IAAdA,cAAc,GAAAD,mBAAA,cAAG,OAAO,GAAAA,mBAAA;EAExB,OACEU,oBAACA,cAAc,QACbA,oBAACd,YAAY;IAACG,MAAM,EAAEA,MAAM;IAAEE,cAAc,EAAEA;IAAkB,EAC/DuD,QAAQ,CACM;AAErB,CAAC;;;;;;"}
|
package/dist/index.modern.js
CHANGED
|
@@ -39,7 +39,8 @@ var closeModal = function closeModal(tag) {
|
|
|
39
39
|
var _extends4;
|
|
40
40
|
return {
|
|
41
41
|
modalTags: _extends({}, state.modalTags, (_extends4 = {}, _extends4[tag] = {
|
|
42
|
-
input: false
|
|
42
|
+
input: false,
|
|
43
|
+
output: undefined
|
|
43
44
|
}, _extends4))
|
|
44
45
|
};
|
|
45
46
|
});
|
|
@@ -85,38 +86,64 @@ var useModalActions = function useModalActions(actionCallback) {
|
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
var ModalWrapper = memo(function ModalWrapper(_ref) {
|
|
88
|
-
var modals = _ref.modals
|
|
89
|
+
var modals = _ref.modals,
|
|
90
|
+
_ref$renderStrategy = _ref.renderStrategy,
|
|
91
|
+
renderStrategy = _ref$renderStrategy === void 0 ? 'eager' : _ref$renderStrategy;
|
|
89
92
|
var modalTags = useModalStore(function (state) {
|
|
90
93
|
return state.modalTags;
|
|
91
94
|
});
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
var allModals = useMemo(function () {
|
|
96
|
+
if (renderStrategy === 'lazy') {
|
|
97
|
+
return Object.keys(modalTags).map(function (tag) {
|
|
98
|
+
var Modal = modals[tag];
|
|
99
|
+
if (!Modal) {
|
|
100
|
+
console.warn("[ModalWrapper] Modal \"" + tag + "\" not found in modals registry");
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
return React__default.createElement(Modal, {
|
|
105
|
+
key: tag
|
|
106
|
+
});
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error("[ModalWrapper] Error rendering modal \"" + tag + "\":", error);
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
102
111
|
});
|
|
112
|
+
}
|
|
113
|
+
return Object.entries(modals).map(function (_ref2) {
|
|
114
|
+
var tag = _ref2[0],
|
|
115
|
+
Modal = _ref2[1];
|
|
116
|
+
try {
|
|
117
|
+
return React__default.createElement(Modal, {
|
|
118
|
+
key: tag
|
|
119
|
+
});
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error("[ModalWrapper] Error rendering modal \"" + tag + "\":", error);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
103
124
|
});
|
|
104
|
-
}, [modals,
|
|
105
|
-
return React__default.createElement(React__default.Fragment, null,
|
|
125
|
+
}, [renderStrategy === 'lazy' ? modalTags : modals, modals, renderStrategy]);
|
|
126
|
+
return React__default.createElement(React__default.Fragment, null, allModals);
|
|
106
127
|
});
|
|
107
128
|
|
|
108
129
|
var useDisclosure = function useDisclosure(disclosureHook) {
|
|
109
130
|
var tag = disclosureHook.tag;
|
|
110
131
|
var disclosureHookRef = useRef(disclosureHook);
|
|
111
132
|
disclosureHookRef.current = disclosureHook;
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
133
|
+
var inputSelector = useMemo(function () {
|
|
134
|
+
return function (state) {
|
|
135
|
+
var _state$modalTags$tag;
|
|
136
|
+
return (_state$modalTags$tag = state.modalTags[tag]) === null || _state$modalTags$tag === void 0 ? void 0 : _state$modalTags$tag.input;
|
|
137
|
+
};
|
|
138
|
+
}, [tag]);
|
|
139
|
+
var outputSelector = useMemo(function () {
|
|
140
|
+
return function (state) {
|
|
141
|
+
var _state$modalTags$tag2;
|
|
142
|
+
return (_state$modalTags$tag2 = state.modalTags[tag]) === null || _state$modalTags$tag2 === void 0 ? void 0 : _state$modalTags$tag2.output;
|
|
143
|
+
};
|
|
144
|
+
}, [tag]);
|
|
145
|
+
var inputState = useModalStore(inputSelector);
|
|
146
|
+
var outputState = useModalStore(outputSelector);
|
|
120
147
|
var clearDisclosureTag = useModalActions(function (actions) {
|
|
121
148
|
return actions.clearModalTag;
|
|
122
149
|
});
|
|
@@ -175,9 +202,10 @@ var useDisclosure = function useDisclosure(disclosureHook) {
|
|
|
175
202
|
}, [tag, clearDisclosureTag]);
|
|
176
203
|
useEffect(function () {
|
|
177
204
|
if (outputState) {
|
|
178
|
-
|
|
205
|
+
var _disclosureHookRef$cu1, _disclosureHookRef$cu10;
|
|
206
|
+
(_disclosureHookRef$cu1 = disclosureHookRef.current) === null || _disclosureHookRef$cu1 === void 0 ? void 0 : (_disclosureHookRef$cu10 = _disclosureHookRef$cu1.onOk) === null || _disclosureHookRef$cu10 === void 0 ? void 0 : _disclosureHookRef$cu10.call(_disclosureHookRef$cu1, outputState);
|
|
179
207
|
}
|
|
180
|
-
}, [outputState
|
|
208
|
+
}, [outputState]);
|
|
181
209
|
return {
|
|
182
210
|
isOpen: !!inputState,
|
|
183
211
|
input: typeof inputState === 'boolean' ? undefined : inputState,
|
|
@@ -193,9 +221,12 @@ var useDisclosure = function useDisclosure(disclosureHook) {
|
|
|
193
221
|
|
|
194
222
|
var ReactHookModalProvider = function ReactHookModalProvider(_ref) {
|
|
195
223
|
var children = _ref.children,
|
|
196
|
-
modals = _ref.modals
|
|
224
|
+
modals = _ref.modals,
|
|
225
|
+
_ref$renderStrategy = _ref.renderStrategy,
|
|
226
|
+
renderStrategy = _ref$renderStrategy === void 0 ? 'eager' : _ref$renderStrategy;
|
|
197
227
|
return createElement(Fragment, null, createElement(ModalWrapper, {
|
|
198
|
-
modals: modals
|
|
228
|
+
modals: modals,
|
|
229
|
+
renderStrategy: renderStrategy
|
|
199
230
|
}), children);
|
|
200
231
|
};
|
|
201
232
|
|
package/dist/index.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/store/index.ts","../src/provider/index.tsx","../src/hook/index.ts","../src/index.tsx"],"sourcesContent":["import { Store, useStore } from \"@tanstack/react-store\";\n\n// You can instantiate the store outside of React components too!\n\nimport { Any } from '../hook'\n\nexport type State = {\n modalTags: {\n [tag: string]: {\n input?: Any\n output?: Any\n }\n }\n}\n\nexport type Action = {\n openModal: (tag: string, input?: Any) => void\n okModal: (tag: string, output?: Any) => void\n closeModal: (tag: string) => void\n toggleModal: (tag: string) => void\n clearModalTag: (tag: string) => void\n clearAllModalTags: () => void\n}\nexport const store = new Store<State>({\n modalTags: {}\n});\n\n\nconst openModal = (tag: string, input?: Any) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n input: input ?? true // Default to true if no input is provided\n }\n }\n }))\n}\nconst okModal = (tag: string, output?: Any) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n output\n }\n }\n }))\n}\nconst closeModal = (tag: string) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: { input: false }\n }\n }))\n}\nconst toggleModal = (tag: string) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n input: !state.modalTags[tag]?.input\n }\n }\n }))\n}\nconst clearModalTag = (tag: string) => {\n store.setState((state) => {\n const newModalTags = { ...state.modalTags };\n delete newModalTags[tag];\n return { modalTags: newModalTags };\n })\n}\nconst clearAllModalTags = () => {\n store.setState(() => ({ modalTags: {} }))\n}\n\nexport const useModalStore = <T>(\n stateCallback: (state: State) => T,\n): T => {\n return useStore(store, stateCallback)\n}\n\nexport const useModalActions = <T>(\n actionCallback: (action: Action) => T\n): T => {\n return actionCallback(\n {\n openModal,\n okModal,\n closeModal,\n toggleModal,\n clearModalTag,\n clearAllModalTags\n }\n )\n}","import React, { useMemo, memo } from 'react'\nimport { useModalStore, State } from '../store'\n\ntype ModalComponent = React.FunctionComponent<any> | React.ComponentType<any>\n\nexport interface ModalWrapperProps {\n modals: Record<string, ModalComponent>\n}\n\nexport const ModalWrapper = memo(function ModalWrapper({\n modals\n}: ModalWrapperProps) {\n const modalTags = useModalStore((state: State) => state.modalTags)\n \n const modalOpened = useMemo(() => {\n return Object.entries(modals)\n .filter(([tag]) => !!modalTags[tag]?.input)\n .map(([tag, Modal]) => <Modal key={tag} />)\n }, [modals, modalTags])\n \n return <React.Fragment>{modalOpened}</React.Fragment>\n})\n","import { useEffect, useCallback, useRef } from 'react'\nimport { TagType } from './tag'\nimport { useModalStore, useModalActions, store } from '../store'\n\nexport type Any = string | number | boolean | object | undefined | Record<string, any>\n\nexport interface DisclosureHookProps<O> {\n tag: TagType\n isOpen?: boolean\n onOpen?: () => void\n onClose?: () => void\n onToggle?: () => void\n onChange?: (isOpen: boolean) => void\n onOk?: (output?: O) => void\n onCancel?: () => void\n}\n\nexport const useDisclosure = <Input = Any, Output = Any>(\n disclosureHook: DisclosureHookProps<Output>\n) => {\n const tag = disclosureHook.tag\n \n // Use refs to store callbacks to avoid stale closures\n const disclosureHookRef = useRef(disclosureHook)\n disclosureHookRef.current = disclosureHook\n\n const inputState = useModalStore(\n (state) => state.modalTags[tag]?.input\n ) as Input\n const outputState = useModalStore(\n (state) => state.modalTags[tag]?.output\n ) as Output\n const clearDisclosureTag = useModalActions(\n (actions) => actions.clearModalTag\n )\n\n const onOpenAction = useModalActions((actions) => actions.openModal)\n const okAction = useModalActions((actions) => actions.okModal)\n const onCloseAction = useModalActions((actions) => actions.closeModal)\n const onToggleAction = useModalActions((actions) => actions.toggleModal)\n\n const updateInput = useCallback((input?: Input) => {\n // If input is a function, call it and set the result as input\n let processedInput = input\n if (processedInput && typeof processedInput == 'object' && 'preventDefault' in processedInput) {\n processedInput = undefined\n }\n onOpenAction(tag, processedInput as Any)\n }, [tag, onOpenAction])\n\n const onOpen = useCallback((input?: Input) => {\n updateInput(input)\n disclosureHookRef.current?.onOpen?.()\n }, [updateInput])\n\n const onClose = useCallback(() => {\n onCloseAction(tag)\n disclosureHookRef.current?.onClose?.()\n }, [tag, onCloseAction])\n\n const onToggle = useCallback(() => {\n onToggleAction(tag)\n disclosureHookRef.current?.onToggle?.()\n }, [tag, onToggleAction])\n\n const onOk = useCallback((output?: Output) => {\n disclosureHookRef.current?.onOk?.(output)\n okAction(tag, output as Any)\n }, [tag, okAction])\n\n const onChange = useCallback((isOpen: boolean) => {\n if (isOpen) {\n onOpen()\n } else {\n onClose()\n }\n disclosureHookRef.current?.onChange?.(isOpen)\n }, [onOpen, onClose])\n\n useEffect(() => {\n return () => {\n clearDisclosureTag(tag)\n }\n }, [tag, clearDisclosureTag])\n\n useEffect(() => {\n if (outputState) {\n onOk(outputState as Output)\n }\n }, [outputState, onOk])\n\n return {\n isOpen: !!inputState,\n input: typeof inputState === 'boolean' ? undefined : inputState,\n onOpen,\n onClose,\n onToggle,\n onOk,\n onChange,\n updateInput,\n store\n }\n}\n","import * as React from 'react'\nimport { ModalWrapper } from './provider'\n\ntype ModalComponent = React.FunctionComponent<any> | React.ComponentType<any>\n\nexport type ReactHookModalProviderProps = {\n children: React.ReactNode\n modals: Record<string, ModalComponent>\n}\n\nexport const ReactHookModalProvider = ({\n children,\n modals\n}: ReactHookModalProviderProps) => {\n return (\n <React.Fragment>\n <ModalWrapper modals={modals} />\n {children}\n </React.Fragment>\n )\n}\n\nexport * from './hook'\nexport * from './provider'\n"],"names":["store","Store","modalTags","openModal","tag","input","setState","state","_extends2","_extends","okModal","output","_extends3","closeModal","_extends4","toggleModal","_state$modalTags$tag","_extends5","clearModalTag","newModalTags","clearAllModalTags","useModalStore","stateCallback","useStore","useModalActions","actionCallback","ModalWrapper","memo","_ref","modals","modalOpened","useMemo","Object","entries","filter","_ref2","_modalTags$tag","map","_ref3","Modal","React","key","Fragment","useDisclosure","disclosureHook","disclosureHookRef","useRef","current","inputState","outputState","_state$modalTags$tag2","clearDisclosureTag","actions","onOpenAction","okAction","onCloseAction","onToggleAction","updateInput","useCallback","processedInput","undefined","onOpen","_disclosureHookRef$cu","_disclosureHookRef$cu2","call","onClose","_disclosureHookRef$cu3","_disclosureHookRef$cu4","onToggle","_disclosureHookRef$cu5","_disclosureHookRef$cu6","onOk","_disclosureHookRef$cu7","_disclosureHookRef$cu8","onChange","isOpen","_disclosureHookRef$cu9","_disclosureHookRef$cu0","useEffect","ReactHookModalProvider","children"],"mappings":";;;;;;;;;;;;;AAuBO,IAAMA,KAAK,GAAG,IAAIC,KAAK,CAAQ;EACpCC,SAAS,EAAE;CACZ,CAAC;AAGF,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAIC,GAAW,EAAEC,KAAW;EACzCL,KAAK,CAACM,QAAQ,CAAC,UAACC,KAAK;IAAA,IAAAC,SAAA;IAAA,OAAM;MACzBN,SAAS,EAAAO,QAAA,KACJF,KAAK,CAACL,SAAS,GAAAM,SAAA,OAAAA,SAAA,CACjBJ,GAAG,IAAAK,QAAA,KACCF,KAAK,CAACL,SAAS,CAACE,GAAG,CAAC;QACvBC,KAAK,EAAEA,KAAK,WAALA,KAAK,GAAI;UAAIG,SAAA;KAGzB;GAAC,CAAC;AACL,CAAC;AACD,IAAME,OAAO,GAAG,SAAVA,OAAOA,CAAIN,GAAW,EAAEO,MAAY;EACxCX,KAAK,CAACM,QAAQ,CAAC,UAACC,KAAK;IAAA,IAAAK,SAAA;IAAA,OAAM;MACzBV,SAAS,EAAAO,QAAA,KACJF,KAAK,CAACL,SAAS,GAAAU,SAAA,OAAAA,SAAA,CACjBR,GAAG,IAAAK,QAAA,KACCF,KAAK,CAACL,SAAS,CAACE,GAAG,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"}
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/store/index.ts","../src/provider/index.tsx","../src/hook/index.ts","../src/index.tsx"],"sourcesContent":["import { Store, useStore } from \"@tanstack/react-store\";\n\n// You can instantiate the store outside of React components too!\n\nimport { Any } from '../hook'\n\nexport type State = {\n modalTags: {\n [tag: string]: {\n input?: Any\n output?: Any\n }\n }\n}\n\nexport type Action = {\n openModal: (tag: string, input?: Any) => void\n okModal: (tag: string, output?: Any) => void\n closeModal: (tag: string) => void\n toggleModal: (tag: string) => void\n clearModalTag: (tag: string) => void\n clearAllModalTags: () => void\n}\nexport const store = new Store<State>({\n modalTags: {}\n});\n\n\nconst openModal = (tag: string, input?: Any) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n input: input ?? true // Default to true if no input is provided\n }\n }\n }))\n}\nconst okModal = (tag: string, output?: Any) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n output\n }\n }\n }))\n}\nconst closeModal = (tag: string) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: { input: false, output: undefined }\n }\n }))\n}\nconst toggleModal = (tag: string) => {\n store.setState((state) => ({\n modalTags: {\n ...state.modalTags,\n [tag]: {\n ...state.modalTags[tag],\n input: !state.modalTags[tag]?.input\n }\n }\n }))\n}\nconst clearModalTag = (tag: string) => {\n store.setState((state) => {\n const newModalTags = { ...state.modalTags };\n delete newModalTags[tag];\n return { modalTags: newModalTags };\n })\n}\nconst clearAllModalTags = () => {\n store.setState(() => ({ modalTags: {} }))\n}\n\nexport const useModalStore = <T>(\n stateCallback: (state: State) => T,\n): T => {\n return useStore(store, stateCallback)\n}\n\nexport const useModalActions = <T>(\n actionCallback: (action: Action) => T\n): T => {\n return actionCallback(\n {\n openModal,\n okModal,\n closeModal,\n toggleModal,\n clearModalTag,\n clearAllModalTags\n }\n )\n}","import React, { useMemo, memo } from 'react'\nimport { useModalStore, State } from '../store'\n\ntype ModalComponent = React.FunctionComponent<any> | React.ComponentType<any>\n\nexport interface ModalWrapperProps {\n modals: Record<string, ModalComponent>\n /**\n * Strategy for rendering modals:\n * - 'eager': Mount all modals upfront (default, backward compatible)\n * - 'lazy': Only mount modals that have been opened at least once\n * \n * Performance comparison:\n * - 10 modals: Both strategies are fine\n * - 50 modals: Lazy recommended (~200ms faster initial render)\n * - 100+ modals: Lazy strongly recommended (~500ms+ faster initial render)\n * - 1000 modals: Lazy is mandatory (~10s faster initial render, ~100MB less memory)\n * \n * Trade-off: With lazy mode, first modal open has ~50-100ms delay for mounting.\n */\n renderStrategy?: 'eager' | 'lazy'\n}\n\nexport const ModalWrapper = memo(function ModalWrapper({\n modals,\n renderStrategy = 'eager'\n}: ModalWrapperProps) {\n const modalTags = useModalStore((state: State) => state.modalTags)\n\n const allModals = useMemo(() => {\n if (renderStrategy === 'lazy') {\n // LAZY MODE: Chỉ render modals đã được mở ít nhất 1 lần\n // Significantly faster for apps with many modals!\n return Object.keys(modalTags).map((tag) => {\n const Modal = modals[tag]\n if (!Modal) {\n console.warn(`[ModalWrapper] Modal \"${tag}\" not found in modals registry`)\n return null\n }\n\n try {\n return <Modal key={tag} />\n } catch (error) {\n console.error(`[ModalWrapper] Error rendering modal \"${tag}\":`, error)\n return null\n }\n })\n }\n\n // EAGER MODE: Render tất cả modals ngay từ đầu (backward compatible)\n // Modal components tự control hiển thị qua isOpen prop\n return Object.entries(modals).map(([tag, Modal]) => {\n try {\n return <Modal key={tag} />\n } catch (error) {\n console.error(`[ModalWrapper] Error rendering modal \"${tag}\":`, error)\n return null\n }\n })\n }, [renderStrategy === 'lazy' ? modalTags : modals, modals, renderStrategy])\n\n return <React.Fragment>{allModals}</React.Fragment>\n})\n","import { useEffect, useCallback, useRef, useMemo } from 'react'\nimport { TagType } from './tag'\nimport { useModalStore, useModalActions, store } from '../store'\n\nexport type Any = string | number | boolean | object | undefined | Record<string, any>\n\nexport interface DisclosureHookProps<O> {\n tag: TagType\n isOpen?: boolean\n onOpen?: () => void\n onClose?: () => void\n onToggle?: () => void\n onChange?: (isOpen: boolean) => void\n onOk?: (output?: O) => void\n onCancel?: () => void\n}\n\nexport const useDisclosure = <Input = Any, Output = Any>(\n disclosureHook: DisclosureHookProps<Output>\n) => {\n const tag = disclosureHook.tag\n\n // Use refs to store callbacks to avoid stale closures\n const disclosureHookRef = useRef(disclosureHook)\n disclosureHookRef.current = disclosureHook\n\n // ⚡ Selective Subscription: Memoize selectors để TanStack Store\n // chỉ trigger re-render khi state của MODAL NÀY thay đổi\n // Không re-render khi modal khác thay đổi state\n const inputSelector = useMemo(\n () => (state: { modalTags: Record<string, { input?: Any; output?: Any }> }) =>\n state.modalTags[tag]?.input,\n [tag]\n )\n\n const outputSelector = useMemo(\n () => (state: { modalTags: Record<string, { input?: Any; output?: Any }> }) =>\n state.modalTags[tag]?.output,\n [tag]\n )\n\n const inputState = useModalStore(inputSelector) as Input\n const outputState = useModalStore(outputSelector) as Output\n const clearDisclosureTag = useModalActions(\n (actions) => actions.clearModalTag\n )\n\n const onOpenAction = useModalActions((actions) => actions.openModal)\n const okAction = useModalActions((actions) => actions.okModal)\n const onCloseAction = useModalActions((actions) => actions.closeModal)\n const onToggleAction = useModalActions((actions) => actions.toggleModal)\n\n const updateInput = useCallback((input?: Input) => {\n // If input is a function, call it and set the result as input\n let processedInput = input\n if (processedInput && typeof processedInput == 'object' && 'preventDefault' in processedInput) {\n processedInput = undefined\n }\n onOpenAction(tag, processedInput as Any)\n }, [tag, onOpenAction])\n\n const onOpen = useCallback((input?: Input) => {\n updateInput(input)\n disclosureHookRef.current?.onOpen?.()\n }, [updateInput])\n\n const onClose = useCallback(() => {\n onCloseAction(tag)\n disclosureHookRef.current?.onClose?.()\n }, [tag, onCloseAction])\n\n const onToggle = useCallback(() => {\n onToggleAction(tag)\n disclosureHookRef.current?.onToggle?.()\n }, [tag, onToggleAction])\n\n const onOk = useCallback((output?: Output) => {\n disclosureHookRef.current?.onOk?.(output)\n okAction(tag, output as Any)\n }, [tag, okAction])\n\n const onChange = useCallback((isOpen: boolean) => {\n if (isOpen) {\n onOpen()\n } else {\n onClose()\n }\n disclosureHookRef.current?.onChange?.(isOpen)\n }, [onOpen, onClose])\n\n useEffect(() => {\n return () => {\n clearDisclosureTag(tag)\n }\n }, [tag, clearDisclosureTag])\n\n useEffect(() => {\n if (outputState) {\n // Use ref instead of direct callback to avoid infinite loop\n disclosureHookRef.current?.onOk?.(outputState as Output)\n }\n }, [outputState])\n\n return {\n isOpen: !!inputState,\n input: typeof inputState === 'boolean' ? undefined : inputState,\n onOpen,\n onClose,\n onToggle,\n onOk,\n onChange,\n updateInput,\n store\n }\n}\n","import * as React from 'react'\nimport { ModalWrapper } from './provider'\n\ntype ModalComponent = React.FunctionComponent<any> | React.ComponentType<any>\n\nexport type ReactHookModalProviderProps = {\n children: React.ReactNode\n modals: Record<string, ModalComponent>\n /**\n * Strategy for rendering modals:\n * - 'eager': Mount all modals upfront (default, backward compatible)\n * - 'lazy': Only mount modals that have been opened at least once\n * \n * Use 'lazy' if you have 50+ modals for better performance.\n */\n renderStrategy?: 'eager' | 'lazy'\n}\n\nexport const ReactHookModalProvider = ({\n children,\n modals,\n renderStrategy = 'eager'\n}: ReactHookModalProviderProps) => {\n return (\n <React.Fragment>\n <ModalWrapper modals={modals} renderStrategy={renderStrategy} />\n {children}\n </React.Fragment>\n )\n}\n\nexport * from './hook'\nexport * from './provider'\n"],"names":["store","Store","modalTags","openModal","tag","input","setState","state","_extends2","_extends","okModal","output","_extends3","closeModal","_extends4","undefined","toggleModal","_state$modalTags$tag","_extends5","clearModalTag","newModalTags","clearAllModalTags","useModalStore","stateCallback","useStore","useModalActions","actionCallback","ModalWrapper","memo","_ref","modals","_ref$renderStrategy","renderStrategy","allModals","useMemo","Object","keys","map","Modal","console","warn","React","key","error","entries","_ref2","Fragment","useDisclosure","disclosureHook","disclosureHookRef","useRef","current","inputSelector","outputSelector","_state$modalTags$tag2","inputState","outputState","clearDisclosureTag","actions","onOpenAction","okAction","onCloseAction","onToggleAction","updateInput","useCallback","processedInput","onOpen","_disclosureHookRef$cu","_disclosureHookRef$cu2","call","onClose","_disclosureHookRef$cu3","_disclosureHookRef$cu4","onToggle","_disclosureHookRef$cu5","_disclosureHookRef$cu6","onOk","_disclosureHookRef$cu7","_disclosureHookRef$cu8","onChange","isOpen","_disclosureHookRef$cu9","_disclosureHookRef$cu0","useEffect","_disclosureHookRef$cu1","_disclosureHookRef$cu10","ReactHookModalProvider","children"],"mappings":";;;;;;;;;;;;;AAuBO,IAAMA,KAAK,GAAG,IAAIC,KAAK,CAAQ;EACpCC,SAAS,EAAE;CACZ,CAAC;AAGF,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAIC,GAAW,EAAEC,KAAW;EACzCL,KAAK,CAACM,QAAQ,CAAC,UAACC,KAAK;IAAA,IAAAC,SAAA;IAAA,OAAM;MACzBN,SAAS,EAAAO,QAAA,KACJF,KAAK,CAACL,SAAS,GAAAM,SAAA,OAAAA,SAAA,CACjBJ,GAAG,IAAAK,QAAA,KACCF,KAAK,CAACL,SAAS,CAACE,GAAG,CAAC;QACvBC,KAAK,EAAEA,KAAK,WAALA,KAAK,GAAI;UAAIG,SAAA;KAGzB;GAAC,CAAC;AACL,CAAC;AACD,IAAME,OAAO,GAAG,SAAVA,OAAOA,CAAIN,GAAW,EAAEO,MAAY;EACxCX,KAAK,CAACM,QAAQ,CAAC,UAACC,KAAK;IAAA,IAAAK,SAAA;IAAA,OAAM;MACzBV,SAAS,EAAAO,QAAA,KACJF,KAAK,CAACL,SAAS,GAAAU,SAAA,OAAAA,SAAA,CACjBR,GAAG,IAAAK,QAAA,KACCF,KAAK,CAACL,SAAS,CAACE,GAAG,CAAC;QACvBO,MAAM,EAANA;UAAMC,SAAA;KAGX;GAAC,CAAC;AACL,CAAC;AACD,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAIT,GAAW;EAC7BJ,KAAK,C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,sBAAA,EAAAC,uBAAA;MAEf,CAAAD,sBAAA,GAAAnC,iBAAiB,CAACE,OAAO,cAAAiC,sBAAA,wBAAAC,uBAAA,GAAzBD,sBAAA,CAA2BR,IAAI,cAAAS,uBAAA,uBAA/BA,uBAAA,CAAAhB,IAAA,CAAAe,sBAAA,EAAkC5B,WAAqB,CAAC;;GAE3D,EAAE,CAACA,WAAW,CAAC,CAAC;EAEjB,OAAO;IACLwB,MAAM,EAAE,CAAC,CAACzB,UAAU;IACpBlD,KAAK,EAAE,OAAOkD,UAAU,KAAK,SAAS,GAAGxC,SAAS,GAAGwC,UAAU;IAC/DW,MAAM,EAANA,MAAM;IACNI,OAAO,EAAPA,OAAO;IACPG,QAAQ,EAARA,QAAQ;IACRG,IAAI,EAAJA,IAAI;IACJG,QAAQ,EAARA,QAAQ;IACRhB,WAAW,EAAXA,WAAW;IACX/D,KAAK,EAALA;GACD;AACH,CAAC;;IChGYsF,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAAzD,IAAA;MACjC0D,QAAQ,GAAA1D,IAAA,CAAR0D,QAAQ;IACRzD,MAAM,GAAAD,IAAA,CAANC,MAAM;IAAAC,mBAAA,GAAAF,IAAA,CACNG,cAAc;IAAdA,cAAc,GAAAD,mBAAA,cAAG,OAAO,GAAAA,mBAAA;EAExB,OACEU,cAACA,QAAc,QACbA,cAACd,YAAY;IAACG,MAAM,EAAEA,MAAM;IAAEE,cAAc,EAAEA;IAAkB,EAC/DuD,QAAQ,CACM;AAErB,CAAC;;;;"}
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -2,6 +2,20 @@ import React from 'react';
|
|
|
2
2
|
declare type ModalComponent = React.FunctionComponent<any> | React.ComponentType<any>;
|
|
3
3
|
export interface ModalWrapperProps {
|
|
4
4
|
modals: Record<string, ModalComponent>;
|
|
5
|
+
/**
|
|
6
|
+
* Strategy for rendering modals:
|
|
7
|
+
* - 'eager': Mount all modals upfront (default, backward compatible)
|
|
8
|
+
* - 'lazy': Only mount modals that have been opened at least once
|
|
9
|
+
*
|
|
10
|
+
* Performance comparison:
|
|
11
|
+
* - 10 modals: Both strategies are fine
|
|
12
|
+
* - 50 modals: Lazy recommended (~200ms faster initial render)
|
|
13
|
+
* - 100+ modals: Lazy strongly recommended (~500ms+ faster initial render)
|
|
14
|
+
* - 1000 modals: Lazy is mandatory (~10s faster initial render, ~100MB less memory)
|
|
15
|
+
*
|
|
16
|
+
* Trade-off: With lazy mode, first modal open has ~50-100ms delay for mounting.
|
|
17
|
+
*/
|
|
18
|
+
renderStrategy?: 'eager' | 'lazy';
|
|
5
19
|
}
|
|
6
20
|
export declare const ModalWrapper: React.NamedExoticComponent<ModalWrapperProps>;
|
|
7
21
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/provider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAA;AAG5C,aAAK,cAAc,GAAG,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;AAE7E,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/provider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAA;AAG5C,aAAK,cAAc,GAAG,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;AAE7E,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACtC;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CAClC;AAED,eAAO,MAAM,YAAY,+CAuCvB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
2
|
+
export interface LoggerConfig {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
level: LogLevel;
|
|
5
|
+
prefix: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const logger: {
|
|
8
|
+
configure: (newConfig: Partial<LoggerConfig>) => void;
|
|
9
|
+
getConfig: () => {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
level: LogLevel;
|
|
12
|
+
prefix: string;
|
|
13
|
+
};
|
|
14
|
+
debug: (message: string, ...args: any[]) => void;
|
|
15
|
+
info: (message: string, ...args: any[]) => void;
|
|
16
|
+
warn: (message: string, ...args: any[]) => void;
|
|
17
|
+
error: (message: string, ...args: any[]) => void;
|
|
18
|
+
group: (label: string) => void;
|
|
19
|
+
groupEnd: () => void;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/utils/logger.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;AAEnE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAuBD,eAAO,MAAM,MAAM;2BACM,OAAO,CAAC,YAAY,CAAC;;iBA3BnC,OAAO;eACT,QAAQ;gBACP,MAAM;;qBA+BG,MAAM,WAAW,GAAG,EAAE;oBAMvB,MAAM,WAAW,GAAG,EAAE;oBAMtB,MAAM,WAAW,GAAG,EAAE;qBAMrB,MAAM,WAAW,GAAG,EAAE;mBAMxB,MAAM;;CAWtB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helloworldqq/react-modal",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "React hook disclosure modal - A powerful and flexible React hook library for managing modals",
|
|
5
5
|
"author": "helloworldqq",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
+
"@babel/core": "^7.28.5",
|
|
52
|
+
"@babel/plugin-proposal-unicode-property-regex": "^7.18.6",
|
|
53
|
+
"@babel/plugin-transform-unicode-property-regex": "^7.27.1",
|
|
51
54
|
"@testing-library/jest-dom": "^6.4.2",
|
|
52
55
|
"@testing-library/react": "^14.2.1",
|
|
53
56
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -79,4 +82,4 @@
|
|
|
79
82
|
"@tanstack/react-store": "^0.7.3"
|
|
80
83
|
},
|
|
81
84
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
82
|
-
}
|
|
85
|
+
}
|