@gen-epix/ui-client-common 4.4.1 → 4.4.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.
- package/README.md +7 -7
- package/dist/_chunks/QueryClientProvider.js +1 -1
- package/dist/_chunks/QueryClientProvider.js.map +1 -1
- package/dist/_chunks/Table.js +1 -1
- package/dist/_chunks/Table.js.map +1 -1
- package/dist/_chunks/middleware.js +1 -1
- package/dist/_chunks/middleware.js.map +1 -1
- package/dist/_chunks/react.js +1 -1
- package/dist/_chunks/react.js.map +1 -1
- package/dist/_chunks/useColumnsMenu.js +2 -2
- package/dist/_chunks/useColumnsMenu.js.map +1 -1
- package/dist/_chunks/useMutation.js +1 -1
- package/dist/_chunks/useMutation.js.map +1 -1
- package/dist/_chunks/useQueryMemo.js +4 -4
- package/dist/_chunks/useQueryMemo.js.map +1 -1
- package/dist/_chunks/vanilla.js +1 -1
- package/dist/_chunks/vanilla.js.map +1 -1
- package/dist/_chunks/yup.js +2 -2
- package/dist/_chunks/yup.js.map +1 -1
- package/package.json +11 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.
|
|
1
|
+
//#region ../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.1_use-sync-external-store@1.7.0_react@19.3.1_/node_modules/zustand/esm/middleware.mjs
|
|
2
2
|
function e(e, t) {
|
|
3
3
|
let n;
|
|
4
4
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","names":["createJSONStorage","storage","getStorage","parse","str2","options","str","name","newValue","toThenable","result","fn","input","onFulfilled","onRejected","persist","state","currentState","persistedState","baseOptions","hasHydrated","hydrationVersion","hydrationListeners","finishHydrationListeners","config","args","set","get","api","setItem","savedSetState","replace","configResult","stateFromStorage","hydrate","currentVersion","cb","postRehydrationCallback","deserializedStorageValue","migration","migrated","migratedState","migrationResult","e","newOptions"],"sources":["../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.0_use-sync-external-store@1.7.0_react@19.3.0_/node_modules/zustand/esm/middleware.mjs"],"sourcesContent":["const reduxImpl = (reducer, initial) => (set, _get, api) => {\n api.dispatch = (action) => {\n set((state) => reducer(state, action), false, action);\n return action;\n };\n api.dispatchFromDevtools = true;\n return { dispatch: (...args) => api.dispatch(...args), ...initial };\n};\nconst redux = reduxImpl;\n\nconst shouldDispatchFromDevtools = (api) => !!api.dispatchFromDevtools && typeof api.dispatch === \"function\";\nconst trackedConnections = /* @__PURE__ */ new Map();\nconst getTrackedConnectionState = (name) => {\n const api = trackedConnections.get(name);\n if (!api) return {};\n return Object.fromEntries(\n Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])\n );\n};\nconst extractConnectionInformation = (store, extensionConnector, options) => {\n if (store === void 0) {\n return {\n type: \"untracked\",\n connection: extensionConnector.connect(options)\n };\n }\n const existingConnection = trackedConnections.get(options.name);\n if (existingConnection) {\n return { type: \"tracked\", store, ...existingConnection };\n }\n const newConnection = {\n connection: extensionConnector.connect(options),\n stores: {}\n };\n trackedConnections.set(options.name, newConnection);\n return { type: \"tracked\", store, ...newConnection };\n};\nconst removeStoreFromTrackedConnections = (name, store) => {\n if (store === void 0) return;\n const connectionInfo = trackedConnections.get(name);\n if (!connectionInfo) return;\n delete connectionInfo.stores[store];\n if (Object.keys(connectionInfo.stores).length === 0) {\n trackedConnections.delete(name);\n }\n};\nconst v8StackLineRe = /^at (?:new |async )?(.+?) \\(/;\nconst geckoStackLineRe = /^([^@]+)@/;\nfunction findCallerName(stack) {\n var _a, _b, _c;\n if (!stack) return void 0;\n const traceLines = stack.split(\"\\n\");\n const apiSetStateLineIndex = traceLines.findIndex(\n (traceLine) => traceLine.includes(\"api.setState\")\n );\n if (apiSetStateLineIndex < 0) return void 0;\n const callerLine = ((_a = traceLines[apiSetStateLineIndex + 1]) == null ? void 0 : _a.trim()) || \"\";\n return ((_b = v8StackLineRe.exec(callerLine)) == null ? void 0 : _b[1]) || ((_c = geckoStackLineRe.exec(callerLine)) == null ? void 0 : _c[1]);\n}\nconst devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {\n const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;\n let extensionConnector;\n try {\n extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") && window.__REDUX_DEVTOOLS_EXTENSION__;\n } catch (e) {\n }\n if (!extensionConnector) {\n return fn(set, get, api);\n }\n const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);\n let isRecording = true;\n api.setState = ((state, replace, nameOrAction) => {\n const r = set(state, replace);\n if (!isRecording) return r;\n const action = nameOrAction === void 0 ? {\n type: anonymousActionType || findCallerName(new Error().stack) || \"anonymous\"\n } : typeof nameOrAction === \"string\" ? { type: nameOrAction } : nameOrAction;\n if (store === void 0) {\n connection == null ? void 0 : connection.send(action, get());\n return r;\n }\n connection == null ? void 0 : connection.send(\n {\n ...action,\n type: `${store}/${action.type}`\n },\n {\n ...getTrackedConnectionState(options.name),\n [store]: api.getState()\n }\n );\n return r;\n });\n api.devtools = {\n cleanup: () => {\n if (connection && typeof connection.unsubscribe === \"function\") {\n connection.unsubscribe();\n }\n removeStoreFromTrackedConnections(options.name, store);\n }\n };\n const setStateFromDevtools = (...a) => {\n const originalIsRecording = isRecording;\n isRecording = false;\n set(...a);\n isRecording = originalIsRecording;\n };\n const initialState = fn(api.setState, get, api);\n if (connectionInformation.type === \"untracked\") {\n connection == null ? void 0 : connection.init(initialState);\n } else {\n connectionInformation.stores[connectionInformation.store] = api;\n connection == null ? void 0 : connection.init(\n Object.fromEntries(\n Object.entries(connectionInformation.stores).map(([key, store2]) => [\n key,\n key === connectionInformation.store ? initialState : store2.getState()\n ])\n )\n );\n }\n if (shouldDispatchFromDevtools(api)) {\n let didWarnAboutReservedActionType = false;\n const originalDispatch = api.dispatch;\n api.dispatch = (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" && args[0].type === \"__setState\" && !didWarnAboutReservedActionType) {\n console.warn(\n '[zustand devtools middleware] \"__setState\" action type is reserved to set state from the devtools. Avoid using it.'\n );\n didWarnAboutReservedActionType = true;\n }\n originalDispatch(...args);\n };\n }\n connection.subscribe((message) => {\n var _a;\n switch (message.type) {\n case \"ACTION\":\n if (typeof message.payload !== \"string\") {\n console.error(\n \"[zustand devtools middleware] Unsupported action format\"\n );\n return;\n }\n return parseJsonThen(\n message.payload,\n (action) => {\n if (action.type === \"__setState\") {\n if (store === void 0) {\n setStateFromDevtools(action.state);\n return;\n }\n if (Object.keys(action.state).length !== 1) {\n console.error(\n `\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n `\n );\n }\n const stateFromDevtools = action.state[store];\n if (stateFromDevtools === void 0 || stateFromDevtools === null) {\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {\n setStateFromDevtools(stateFromDevtools);\n }\n return;\n }\n if (shouldDispatchFromDevtools(api)) {\n api.dispatch(action);\n }\n }\n );\n case \"DISPATCH\":\n switch (message.payload.type) {\n case \"RESET\":\n setStateFromDevtools(initialState);\n if (store === void 0) {\n return connection == null ? void 0 : connection.init(api.getState());\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"COMMIT\":\n if (store === void 0) {\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"ROLLBACK\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n setStateFromDevtools(state[store]);\n connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n });\n case \"JUMP_TO_STATE\":\n case \"JUMP_TO_ACTION\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {\n setStateFromDevtools(state[store]);\n }\n });\n case \"IMPORT_STATE\": {\n const { nextLiftedState } = message.payload;\n const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;\n if (!lastComputedState) return;\n if (store === void 0) {\n setStateFromDevtools(lastComputedState);\n } else {\n setStateFromDevtools(lastComputedState[store]);\n }\n connection == null ? void 0 : connection.send(\n null,\n // FIXME no-any\n nextLiftedState\n );\n return;\n }\n case \"PAUSE_RECORDING\":\n return isRecording = !isRecording;\n }\n return;\n }\n });\n return initialState;\n};\nconst devtools = devtoolsImpl;\nconst parseJsonThen = (stringified, fn) => {\n let parsed;\n try {\n parsed = JSON.parse(stringified);\n } catch (e) {\n console.error(\n \"[zustand devtools middleware] Could not parse the received json\",\n e\n );\n }\n if (parsed !== void 0) fn(parsed);\n};\n\nconst subscribeWithSelectorImpl = (fn) => (set, get, api) => {\n const origSubscribe = api.subscribe;\n api.subscribe = ((selector, optListener, options) => {\n let listener = selector;\n if (optListener) {\n const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;\n let currentSlice = selector(api.getState());\n listener = (state) => {\n const nextSlice = selector(state);\n if (!equalityFn(currentSlice, nextSlice)) {\n const previousSlice = currentSlice;\n optListener(currentSlice = nextSlice, previousSlice);\n }\n };\n if (options == null ? void 0 : options.fireImmediately) {\n optListener(currentSlice, currentSlice);\n }\n }\n return origSubscribe(listener);\n });\n const initialState = fn(set, get, api);\n return initialState;\n};\nconst subscribeWithSelector = subscribeWithSelectorImpl;\n\nfunction combine(initialState, create) {\n return (...args) => Object.assign({}, initialState, create(...args));\n}\n\nfunction createJSONStorage(getStorage, options) {\n let storage;\n try {\n storage = getStorage();\n } catch (e) {\n return;\n }\n const persistStorage = {\n getItem: (name) => {\n var _a;\n const parse = (str2) => {\n if (str2 === null) {\n return null;\n }\n return JSON.parse(str2, options == null ? void 0 : options.reviver);\n };\n const str = (_a = storage.getItem(name)) != null ? _a : null;\n if (str instanceof Promise) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),\n removeItem: (name) => storage.removeItem(name)\n };\n return persistStorage;\n}\nconst toThenable = (fn) => (input) => {\n try {\n const result = fn(input);\n if (result instanceof Promise) {\n return result;\n }\n return {\n then(onFulfilled) {\n return toThenable(onFulfilled)(result);\n },\n catch(_onRejected) {\n return this;\n }\n };\n } catch (e) {\n return {\n then(_onFulfilled) {\n return this;\n },\n catch(onRejected) {\n return toThenable(onRejected)(e);\n }\n };\n }\n};\nconst persistImpl = (config, baseOptions) => (set, get, api) => {\n let options = {\n storage: createJSONStorage(() => window.localStorage),\n partialize: (state) => state,\n version: 0,\n merge: (persistedState, currentState) => ({\n ...currentState,\n ...persistedState\n }),\n ...baseOptions\n };\n let hasHydrated = false;\n let hydrationVersion = 0;\n const hydrationListeners = /* @__PURE__ */ new Set();\n const finishHydrationListeners = /* @__PURE__ */ new Set();\n let storage = options.storage;\n if (!storage) {\n return config(\n (...args) => {\n console.warn(\n `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`\n );\n set(...args);\n },\n get,\n api\n );\n }\n const setItem = () => {\n const state = options.partialize({ ...get() });\n return storage.setItem(options.name, {\n state,\n version: options.version\n });\n };\n const savedSetState = api.setState;\n api.setState = (state, replace) => {\n savedSetState(state, replace);\n return setItem();\n };\n const configResult = config(\n (...args) => {\n set(...args);\n return setItem();\n },\n get,\n api\n );\n api.getInitialState = () => configResult;\n let stateFromStorage;\n const hydrate = () => {\n var _a, _b;\n if (!storage) return;\n const currentVersion = ++hydrationVersion;\n hasHydrated = false;\n hydrationListeners.forEach((cb) => {\n var _a2;\n return cb((_a2 = get()) != null ? _a2 : configResult);\n });\n const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;\n return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {\n if (deserializedStorageValue) {\n if (typeof deserializedStorageValue.version === \"number\" && deserializedStorageValue.version !== options.version) {\n if (options.migrate) {\n const migration = options.migrate(\n deserializedStorageValue.state,\n deserializedStorageValue.version\n );\n if (migration instanceof Promise) {\n return migration.then((result) => [true, result]);\n }\n return [true, migration];\n }\n console.error(\n `State loaded from storage couldn't be migrated since no migrate function was provided`\n );\n } else {\n return [false, deserializedStorageValue.state];\n }\n }\n return [false, void 0];\n }).then((migrationResult) => {\n var _a2;\n if (currentVersion !== hydrationVersion) {\n return;\n }\n const [migrated, migratedState] = migrationResult;\n stateFromStorage = options.merge(\n migratedState,\n (_a2 = get()) != null ? _a2 : configResult\n );\n set(stateFromStorage, true);\n if (migrated) {\n return setItem();\n }\n }).then(() => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);\n stateFromStorage = get();\n hasHydrated = true;\n finishHydrationListeners.forEach((cb) => cb(stateFromStorage));\n }).catch((e) => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);\n });\n };\n api.persist = {\n setOptions: (newOptions) => {\n options = {\n ...options,\n ...newOptions\n };\n if (newOptions.storage) {\n storage = newOptions.storage;\n }\n },\n clearStorage: () => {\n ++hydrationVersion;\n storage == null ? void 0 : storage.removeItem(options.name);\n },\n getOptions: () => options,\n rehydrate: () => hydrate(),\n hasHydrated: () => hasHydrated,\n onHydrate: (cb) => {\n hydrationListeners.add(cb);\n return () => {\n hydrationListeners.delete(cb);\n };\n },\n onFinishHydration: (cb) => {\n finishHydrationListeners.add(cb);\n return () => {\n finishHydrationListeners.delete(cb);\n };\n }\n };\n if (!options.skipHydration) {\n hydrate();\n }\n return stateFromStorage || configResult;\n};\nconst persist = persistImpl;\n\nfunction ssrSafe(config, isSSR = typeof window === \"undefined\") {\n return (set, get, api) => {\n if (!isSSR) {\n return config(set, get, api);\n }\n const ssrSet = () => {\n throw new Error(\"Cannot set state of Zustand store in SSR\");\n };\n api.setState = ssrSet;\n return config(ssrSet, get, api);\n };\n}\n\nexport { combine, createJSONStorage, devtools, persist, redux, subscribeWithSelector, ssrSafe as unstable_ssrSafe };\n"],"ignoreList":[0],"mappings":";AAqRA,SAASA,EAAkB,GAAY,GAAS;CAC9C,IAAIC;CACJ,IAAI;EACF,IAAUC,EAAW;CACvB,QAAY;EACV;CACF;CAmBA,OAAO;EAjBL,UAAU,MAAS;GAEjB,IAAMC,KAAS,MACTC,MAAS,OACJ,OAEF,KAAK,MAAMA,GAAMC,GAAmC,OAAO,GAE9DC,IAAYL,EAAQ,QAAQM,CAAI,KAAkB;GAIxD,OAHID,aAAe,UACVA,EAAI,KAAKH,CAAK,IAEhBA,EAAMG,CAAG;EAClB;EACA,UAAU,GAAM,MAAaL,EAAQ,QAAQM,GAAM,KAAK,UAAUC,GAAUH,GAAmC,QAAQ,CAAC;EACxH,aAAa,MAASJ,EAAQ,WAAWM,CAAI;CAE3B;AACtB;AACA,IAAME,KAAc,OAAQ,MAAU;CACpC,IAAI;EACF,IAAMC,IAASC,EAAGC,CAAK;EAIvB,OAHIF,aAAkB,UACbA,IAEF;GACL,KAAK,GAAa;IAChB,OAAOD,EAAWI,CAAW,CAAC,CAACH,CAAM;GACvC;GACA,MAAM,GAAa;IACjB,OAAO;GACT;EACF;CACF,SAAS,GAAG;EACV,OAAO;GACL,KAAK,GAAc;IACjB,OAAO;GACT;GACA,MAAM,GAAY;IAChB,OAAOD,EAAWK,CAAU,CAAC,CAAC,CAAC;GACjC;EACF;CACF;AACF,GAkJMC,KAjJe,GAAQ,OAAiB,GAAK,GAAK,MAAQ;CAC9D,IAAIV,IAAU;EACZ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6B,EAAQ,GAEHD,KAAoBD;AAC7B"}
|
|
1
|
+
{"version":3,"file":"middleware.js","names":["createJSONStorage","storage","getStorage","parse","str2","options","str","name","newValue","toThenable","result","fn","input","onFulfilled","onRejected","persist","state","currentState","persistedState","baseOptions","hasHydrated","hydrationVersion","hydrationListeners","finishHydrationListeners","config","args","set","get","api","setItem","savedSetState","replace","configResult","stateFromStorage","hydrate","currentVersion","cb","postRehydrationCallback","deserializedStorageValue","migration","migrated","migratedState","migrationResult","e","newOptions"],"sources":["../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.1_use-sync-external-store@1.7.0_react@19.3.1_/node_modules/zustand/esm/middleware.mjs"],"sourcesContent":["const reduxImpl = (reducer, initial) => (set, _get, api) => {\n api.dispatch = (action) => {\n set((state) => reducer(state, action), false, action);\n return action;\n };\n api.dispatchFromDevtools = true;\n return { dispatch: (...args) => api.dispatch(...args), ...initial };\n};\nconst redux = reduxImpl;\n\nconst shouldDispatchFromDevtools = (api) => !!api.dispatchFromDevtools && typeof api.dispatch === \"function\";\nconst trackedConnections = /* @__PURE__ */ new Map();\nconst getTrackedConnectionState = (name) => {\n const api = trackedConnections.get(name);\n if (!api) return {};\n return Object.fromEntries(\n Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])\n );\n};\nconst extractConnectionInformation = (store, extensionConnector, options) => {\n if (store === void 0) {\n return {\n type: \"untracked\",\n connection: extensionConnector.connect(options)\n };\n }\n const existingConnection = trackedConnections.get(options.name);\n if (existingConnection) {\n return { type: \"tracked\", store, ...existingConnection };\n }\n const newConnection = {\n connection: extensionConnector.connect(options),\n stores: {}\n };\n trackedConnections.set(options.name, newConnection);\n return { type: \"tracked\", store, ...newConnection };\n};\nconst removeStoreFromTrackedConnections = (name, store) => {\n if (store === void 0) return;\n const connectionInfo = trackedConnections.get(name);\n if (!connectionInfo) return;\n delete connectionInfo.stores[store];\n if (Object.keys(connectionInfo.stores).length === 0) {\n trackedConnections.delete(name);\n }\n};\nconst v8StackLineRe = /^at (?:new |async )?(.+?) \\(/;\nconst geckoStackLineRe = /^([^@]+)@/;\nfunction findCallerName(stack) {\n var _a, _b, _c;\n if (!stack) return void 0;\n const traceLines = stack.split(\"\\n\");\n const apiSetStateLineIndex = traceLines.findIndex(\n (traceLine) => traceLine.includes(\"api.setState\")\n );\n if (apiSetStateLineIndex < 0) return void 0;\n const callerLine = ((_a = traceLines[apiSetStateLineIndex + 1]) == null ? void 0 : _a.trim()) || \"\";\n return ((_b = v8StackLineRe.exec(callerLine)) == null ? void 0 : _b[1]) || ((_c = geckoStackLineRe.exec(callerLine)) == null ? void 0 : _c[1]);\n}\nconst devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {\n const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;\n let extensionConnector;\n try {\n extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") && window.__REDUX_DEVTOOLS_EXTENSION__;\n } catch (e) {\n }\n if (!extensionConnector) {\n return fn(set, get, api);\n }\n const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);\n let isRecording = true;\n api.setState = ((state, replace, nameOrAction) => {\n const r = set(state, replace);\n if (!isRecording) return r;\n const action = nameOrAction === void 0 ? {\n type: anonymousActionType || findCallerName(new Error().stack) || \"anonymous\"\n } : typeof nameOrAction === \"string\" ? { type: nameOrAction } : nameOrAction;\n if (store === void 0) {\n connection == null ? void 0 : connection.send(action, get());\n return r;\n }\n connection == null ? void 0 : connection.send(\n {\n ...action,\n type: `${store}/${action.type}`\n },\n {\n ...getTrackedConnectionState(options.name),\n [store]: api.getState()\n }\n );\n return r;\n });\n api.devtools = {\n cleanup: () => {\n if (connection && typeof connection.unsubscribe === \"function\") {\n connection.unsubscribe();\n }\n removeStoreFromTrackedConnections(options.name, store);\n }\n };\n const setStateFromDevtools = (...a) => {\n const originalIsRecording = isRecording;\n isRecording = false;\n set(...a);\n isRecording = originalIsRecording;\n };\n const initialState = fn(api.setState, get, api);\n if (connectionInformation.type === \"untracked\") {\n connection == null ? void 0 : connection.init(initialState);\n } else {\n connectionInformation.stores[connectionInformation.store] = api;\n connection == null ? void 0 : connection.init(\n Object.fromEntries(\n Object.entries(connectionInformation.stores).map(([key, store2]) => [\n key,\n key === connectionInformation.store ? initialState : store2.getState()\n ])\n )\n );\n }\n if (shouldDispatchFromDevtools(api)) {\n let didWarnAboutReservedActionType = false;\n const originalDispatch = api.dispatch;\n api.dispatch = (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" && args[0].type === \"__setState\" && !didWarnAboutReservedActionType) {\n console.warn(\n '[zustand devtools middleware] \"__setState\" action type is reserved to set state from the devtools. Avoid using it.'\n );\n didWarnAboutReservedActionType = true;\n }\n originalDispatch(...args);\n };\n }\n connection.subscribe((message) => {\n var _a;\n switch (message.type) {\n case \"ACTION\":\n if (typeof message.payload !== \"string\") {\n console.error(\n \"[zustand devtools middleware] Unsupported action format\"\n );\n return;\n }\n return parseJsonThen(\n message.payload,\n (action) => {\n if (action.type === \"__setState\") {\n if (store === void 0) {\n setStateFromDevtools(action.state);\n return;\n }\n if (Object.keys(action.state).length !== 1) {\n console.error(\n `\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n `\n );\n }\n const stateFromDevtools = action.state[store];\n if (stateFromDevtools === void 0 || stateFromDevtools === null) {\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {\n setStateFromDevtools(stateFromDevtools);\n }\n return;\n }\n if (shouldDispatchFromDevtools(api)) {\n api.dispatch(action);\n }\n }\n );\n case \"DISPATCH\":\n switch (message.payload.type) {\n case \"RESET\":\n setStateFromDevtools(initialState);\n if (store === void 0) {\n return connection == null ? void 0 : connection.init(api.getState());\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"COMMIT\":\n if (store === void 0) {\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"ROLLBACK\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n setStateFromDevtools(state[store]);\n connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n });\n case \"JUMP_TO_STATE\":\n case \"JUMP_TO_ACTION\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {\n setStateFromDevtools(state[store]);\n }\n });\n case \"IMPORT_STATE\": {\n const { nextLiftedState } = message.payload;\n const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;\n if (!lastComputedState) return;\n if (store === void 0) {\n setStateFromDevtools(lastComputedState);\n } else {\n setStateFromDevtools(lastComputedState[store]);\n }\n connection == null ? void 0 : connection.send(\n null,\n // FIXME no-any\n nextLiftedState\n );\n return;\n }\n case \"PAUSE_RECORDING\":\n return isRecording = !isRecording;\n }\n return;\n }\n });\n return initialState;\n};\nconst devtools = devtoolsImpl;\nconst parseJsonThen = (stringified, fn) => {\n let parsed;\n try {\n parsed = JSON.parse(stringified);\n } catch (e) {\n console.error(\n \"[zustand devtools middleware] Could not parse the received json\",\n e\n );\n }\n if (parsed !== void 0) fn(parsed);\n};\n\nconst subscribeWithSelectorImpl = (fn) => (set, get, api) => {\n const origSubscribe = api.subscribe;\n api.subscribe = ((selector, optListener, options) => {\n let listener = selector;\n if (optListener) {\n const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;\n let currentSlice = selector(api.getState());\n listener = (state) => {\n const nextSlice = selector(state);\n if (!equalityFn(currentSlice, nextSlice)) {\n const previousSlice = currentSlice;\n optListener(currentSlice = nextSlice, previousSlice);\n }\n };\n if (options == null ? void 0 : options.fireImmediately) {\n optListener(currentSlice, currentSlice);\n }\n }\n return origSubscribe(listener);\n });\n const initialState = fn(set, get, api);\n return initialState;\n};\nconst subscribeWithSelector = subscribeWithSelectorImpl;\n\nfunction combine(initialState, create) {\n return (...args) => Object.assign({}, initialState, create(...args));\n}\n\nfunction createJSONStorage(getStorage, options) {\n let storage;\n try {\n storage = getStorage();\n } catch (e) {\n return;\n }\n const persistStorage = {\n getItem: (name) => {\n var _a;\n const parse = (str2) => {\n if (str2 === null) {\n return null;\n }\n return JSON.parse(str2, options == null ? void 0 : options.reviver);\n };\n const str = (_a = storage.getItem(name)) != null ? _a : null;\n if (str instanceof Promise) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),\n removeItem: (name) => storage.removeItem(name)\n };\n return persistStorage;\n}\nconst toThenable = (fn) => (input) => {\n try {\n const result = fn(input);\n if (result instanceof Promise) {\n return result;\n }\n return {\n then(onFulfilled) {\n return toThenable(onFulfilled)(result);\n },\n catch(_onRejected) {\n return this;\n }\n };\n } catch (e) {\n return {\n then(_onFulfilled) {\n return this;\n },\n catch(onRejected) {\n return toThenable(onRejected)(e);\n }\n };\n }\n};\nconst persistImpl = (config, baseOptions) => (set, get, api) => {\n let options = {\n storage: createJSONStorage(() => window.localStorage),\n partialize: (state) => state,\n version: 0,\n merge: (persistedState, currentState) => ({\n ...currentState,\n ...persistedState\n }),\n ...baseOptions\n };\n let hasHydrated = false;\n let hydrationVersion = 0;\n const hydrationListeners = /* @__PURE__ */ new Set();\n const finishHydrationListeners = /* @__PURE__ */ new Set();\n let storage = options.storage;\n if (!storage) {\n return config(\n (...args) => {\n console.warn(\n `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`\n );\n set(...args);\n },\n get,\n api\n );\n }\n const setItem = () => {\n const state = options.partialize({ ...get() });\n return storage.setItem(options.name, {\n state,\n version: options.version\n });\n };\n const savedSetState = api.setState;\n api.setState = (state, replace) => {\n savedSetState(state, replace);\n return setItem();\n };\n const configResult = config(\n (...args) => {\n set(...args);\n return setItem();\n },\n get,\n api\n );\n api.getInitialState = () => configResult;\n let stateFromStorage;\n const hydrate = () => {\n var _a, _b;\n if (!storage) return;\n const currentVersion = ++hydrationVersion;\n hasHydrated = false;\n hydrationListeners.forEach((cb) => {\n var _a2;\n return cb((_a2 = get()) != null ? _a2 : configResult);\n });\n const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;\n return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {\n if (deserializedStorageValue) {\n if (typeof deserializedStorageValue.version === \"number\" && deserializedStorageValue.version !== options.version) {\n if (options.migrate) {\n const migration = options.migrate(\n deserializedStorageValue.state,\n deserializedStorageValue.version\n );\n if (migration instanceof Promise) {\n return migration.then((result) => [true, result]);\n }\n return [true, migration];\n }\n console.error(\n `State loaded from storage couldn't be migrated since no migrate function was provided`\n );\n } else {\n return [false, deserializedStorageValue.state];\n }\n }\n return [false, void 0];\n }).then((migrationResult) => {\n var _a2;\n if (currentVersion !== hydrationVersion) {\n return;\n }\n const [migrated, migratedState] = migrationResult;\n stateFromStorage = options.merge(\n migratedState,\n (_a2 = get()) != null ? _a2 : configResult\n );\n set(stateFromStorage, true);\n if (migrated) {\n return setItem();\n }\n }).then(() => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);\n stateFromStorage = get();\n hasHydrated = true;\n finishHydrationListeners.forEach((cb) => cb(stateFromStorage));\n }).catch((e) => {\n if (currentVersion !== hydrationVersion) {\n return;\n }\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);\n });\n };\n api.persist = {\n setOptions: (newOptions) => {\n options = {\n ...options,\n ...newOptions\n };\n if (newOptions.storage) {\n storage = newOptions.storage;\n }\n },\n clearStorage: () => {\n ++hydrationVersion;\n storage == null ? void 0 : storage.removeItem(options.name);\n },\n getOptions: () => options,\n rehydrate: () => hydrate(),\n hasHydrated: () => hasHydrated,\n onHydrate: (cb) => {\n hydrationListeners.add(cb);\n return () => {\n hydrationListeners.delete(cb);\n };\n },\n onFinishHydration: (cb) => {\n finishHydrationListeners.add(cb);\n return () => {\n finishHydrationListeners.delete(cb);\n };\n }\n };\n if (!options.skipHydration) {\n hydrate();\n }\n return stateFromStorage || configResult;\n};\nconst persist = persistImpl;\n\nfunction ssrSafe(config, isSSR = typeof window === \"undefined\") {\n return (set, get, api) => {\n if (!isSSR) {\n return config(set, get, api);\n }\n const ssrSet = () => {\n throw new Error(\"Cannot set state of Zustand store in SSR\");\n };\n api.setState = ssrSet;\n return config(ssrSet, get, api);\n };\n}\n\nexport { combine, createJSONStorage, devtools, persist, redux, subscribeWithSelector, ssrSafe as unstable_ssrSafe };\n"],"ignoreList":[0],"mappings":";AAqRA,SAASA,EAAkB,GAAY,GAAS;CAC9C,IAAIC;CACJ,IAAI;EACF,IAAUC,EAAW;CACvB,QAAY;EACV;CACF;CAmBA,OAAO;EAjBL,UAAU,MAAS;GAEjB,IAAMC,KAAS,MACTC,MAAS,OACJ,OAEF,KAAK,MAAMA,GAAMC,GAAmC,OAAO,GAE9DC,IAAYL,EAAQ,QAAQM,CAAI,KAAkB;GAIxD,OAHID,aAAe,UACVA,EAAI,KAAKH,CAAK,IAEhBA,EAAMG,CAAG;EAClB;EACA,UAAU,GAAM,MAAaL,EAAQ,QAAQM,GAAM,KAAK,UAAUC,GAAUH,GAAmC,QAAQ,CAAC;EACxH,aAAa,MAASJ,EAAQ,WAAWM,CAAI;CAE3B;AACtB;AACA,IAAME,KAAc,OAAQ,MAAU;CACpC,IAAI;EACF,IAAMC,IAASC,EAAGC,CAAK;EAIvB,OAHIF,aAAkB,UACbA,IAEF;GACL,KAAK,GAAa;IAChB,OAAOD,EAAWI,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AAEvB,GACFpB,GAAmC,WAAWI,EAAQ,IAAI;EAC5D;EACA,kBAAkBA;EAClB,iBAAiB6B,EAAQ;EACzB,mBAAmBd;EACnB,YAAY,OACVE,EAAmB,IAAIc,CAAE,SACZ;GACX,EAAmB,OAAOA,CAAE;EAC9B;EAEF,oBAAoB,OAClBb,EAAyB,IAAIa,CAAE,SAClB;GACX,EAAyB,OAAOA,CAAE;EACpC;CAEJ,GACK/B,EAAQ,iBACX6B,EAAQ,GAEHD,KAAoBD;AAC7B"}
|
package/dist/_chunks/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e from "react";
|
|
2
|
-
//#region ../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.
|
|
2
|
+
//#region ../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.1_use-sync-external-store@1.7.0_react@19.3.1_/node_modules/zustand/esm/react.mjs
|
|
3
3
|
var t = (e) => e;
|
|
4
4
|
function n(n, r = t) {
|
|
5
5
|
let i = e.useSyncExternalStore(n.subscribe, e.useCallback(() => r(n.getState()), [n, r]), e.useCallback(() => r(n.getInitialState()), [n, r]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","names":["React","identity","arg","useStore","slice","api","selector"],"sources":["../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.
|
|
1
|
+
{"version":3,"file":"react.js","names":["React","identity","arg","useStore","slice","api","selector"],"sources":["../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.1_use-sync-external-store@1.7.0_react@19.3.1_/node_modules/zustand/esm/react.mjs"],"sourcesContent":["import React from 'react';\nimport { createStore } from 'zustand/vanilla';\n\nconst identity = (arg) => arg;\nfunction useStore(api, selector = identity) {\n const slice = React.useSyncExternalStore(\n api.subscribe,\n React.useCallback(() => selector(api.getState()), [api, selector]),\n React.useCallback(() => selector(api.getInitialState()), [api, selector])\n );\n React.useDebugValue(slice);\n return slice;\n}\nconst createImpl = (createState) => {\n const api = createStore(createState);\n const useBoundStore = (selector) => useStore(api, selector);\n Object.assign(useBoundStore, api);\n return useBoundStore;\n};\nconst create = ((createState) => createState ? createImpl(createState) : createImpl);\n\nexport { create, useStore };\n"],"ignoreList":[0],"mappings":";;AAGA,IAAMC,KAAY,MAAQC;AAC1B,SAASC,EAAS,GAAK,IAAWF,GAAU;CAC1C,IAAMG,IAAQJ,EAAM,qBAClBK,EAAI,WACJL,EAAM,kBAAkBM,EAASD,EAAI,SAAS,CAAC,GAAG,CAACA,GAAKC,CAAQ,CAAC,GACjEN,EAAM,kBAAkBM,EAASD,EAAI,gBAAgB,CAAC,GAAG,CAACA,GAAKC,CAAQ,CAAC,CAC1E;CAEA,OADAN,EAAM,cAAcI,CAAK,GAClBA;AACT"}
|
|
@@ -9,7 +9,7 @@ import u from "@mui/icons-material/CheckBoxOutlined";
|
|
|
9
9
|
import d from "@mui/icons-material/CheckBoxOutlineBlankOutlined";
|
|
10
10
|
import f from "@mui/icons-material/ToggleOffOutlined";
|
|
11
11
|
import p from "@mui/icons-material/ToggleOnOutlined";
|
|
12
|
-
//#region ../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.
|
|
12
|
+
//#region ../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.1_use-sync-external-store@1.7.0_react@19.3.1_/node_modules/zustand/esm/vanilla/shallow.mjs
|
|
13
13
|
var m = (e) => Symbol.iterator in e, h = (e) => "entries" in e, g = (e, t) => {
|
|
14
14
|
let n = e instanceof Map ? e : new Map(e.entries()), r = t instanceof Map ? t : new Map(t.entries());
|
|
15
15
|
if (n.size !== r.size) return !1;
|
|
@@ -27,7 +27,7 @@ function v(e, t) {
|
|
|
27
27
|
return Object.is(e, t) ? !0 : typeof e != "object" || !e || typeof t != "object" || !t || Object.getPrototypeOf(e) !== Object.getPrototypeOf(t) ? !1 : m(e) && m(t) ? h(e) && h(t) ? g(e, t) : _(e, t) : g({ entries: () => Object.entries(e) }, { entries: () => Object.entries(t) });
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
|
-
//#region ../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.
|
|
30
|
+
//#region ../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.1_use-sync-external-store@1.7.0_react@19.3.1_/node_modules/zustand/esm/react/shallow.mjs
|
|
31
31
|
function y(e) {
|
|
32
32
|
let t = i.useRef(void 0);
|
|
33
33
|
return (n) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useColumnsMenu.js","names":["TableUtil","produce","useTableStoreContext","React","IndeterminateCheckBoxIcon","CheckBoxOutlinedIcon","CheckBoxOutlineBlankOutlinedIcon","ToggleOffOutlinedIcon","ToggleOnOutlinedIcon","isIterable","obj","hasIterableEntries","value","compareEntries","mapA","valueA","mapB","valueB","key","compareIterables","iteratorA","iteratorB","nextA","nextB","shallow","useShallow","prev","next","selector","state","useColumnsMenu","tableStore","emitTableEvent","useStore","tableColumns","dataContext","visibleColumnIds","c","columnDimensions","isCondensed","sortedData","useTranslation","isCondensingSupported","useMemo","onColumnsEditorMenuItemClick","useCallback","hasCellData","toggleItem","newVisibleColumnIds","draft","columnId","toggleDimension","areAllVisible","dimensionColumnIds","onHideColumnsWithoutDataClick","onIsCondensedMenuItemClick","items","jsx","x","columnDimension","areSomeVisible","checked","column","t"],"sources":["../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.0_use-sync-external-store@1.7.0_react@19.3.0_/node_modules/zustand/esm/vanilla/shallow.mjs","../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.0_use-sync-external-store@1.7.0_react@19.3.0_/node_modules/zustand/esm/react/shallow.mjs","../../src/hooks/useColumnsMenu/useColumnsMenu.tsx"],"sourcesContent":["const isIterable = (obj) => Symbol.iterator in obj;\nconst hasIterableEntries = (value) => (\n // HACK: avoid checking entries type\n \"entries\" in value\n);\nconst compareEntries = (valueA, valueB) => {\n const mapA = valueA instanceof Map ? valueA : new Map(valueA.entries());\n const mapB = valueB instanceof Map ? valueB : new Map(valueB.entries());\n if (mapA.size !== mapB.size) {\n return false;\n }\n for (const [key, value] of mapA) {\n if (!mapB.has(key) || !Object.is(value, mapB.get(key))) {\n return false;\n }\n }\n return true;\n};\nconst compareIterables = (valueA, valueB) => {\n const iteratorA = valueA[Symbol.iterator]();\n const iteratorB = valueB[Symbol.iterator]();\n let nextA = iteratorA.next();\n let nextB = iteratorB.next();\n while (!nextA.done && !nextB.done) {\n if (!Object.is(nextA.value, nextB.value)) {\n return false;\n }\n nextA = iteratorA.next();\n nextB = iteratorB.next();\n }\n return !!nextA.done && !!nextB.done;\n};\nfunction shallow(valueA, valueB) {\n if (Object.is(valueA, valueB)) {\n return true;\n }\n if (typeof valueA !== \"object\" || valueA === null || typeof valueB !== \"object\" || valueB === null) {\n return false;\n }\n if (Object.getPrototypeOf(valueA) !== Object.getPrototypeOf(valueB)) {\n return false;\n }\n if (isIterable(valueA) && isIterable(valueB)) {\n if (hasIterableEntries(valueA) && hasIterableEntries(valueB)) {\n return compareEntries(valueA, valueB);\n }\n return compareIterables(valueA, valueB);\n }\n return compareEntries(\n { entries: () => Object.entries(valueA) },\n { entries: () => Object.entries(valueB) }\n );\n}\n\nexport { shallow };\n","import React from 'react';\nimport { shallow } from 'zustand/vanilla/shallow';\n\nfunction useShallow(selector) {\n const prev = React.useRef(void 0);\n return (state) => {\n const next = selector(state);\n return shallow(prev.current, next) ? prev.current : prev.current = next;\n };\n}\n\nexport { useShallow };\n","import { produce } from 'immer';\nimport { useStore } from 'zustand';\nimport { useShallow } from 'zustand/shallow';\nimport CheckBoxOutlinedIcon from '@mui/icons-material/CheckBoxOutlined';\nimport CheckBoxOutlineBlankOutlinedIcon from '@mui/icons-material/CheckBoxOutlineBlankOutlined';\nimport ToggleOffOutlinedIcon from '@mui/icons-material/ToggleOffOutlined';\nimport ToggleOnOutlinedIcon from '@mui/icons-material/ToggleOnOutlined';\nimport IndeterminateCheckBoxIcon from '@mui/icons-material/IndeterminateCheckBox';\nimport {\n useCallback,\n useMemo,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport type { MenuItemData } from '@gen-epix/ui-core-components/models/nested-menu.models';\n\nimport type { HasCellDataFn } from '../../models/table.models';\nimport { useTableStoreContext } from '../../stores/tableStore';\nimport { TableUtil } from '../../utils/TableUtil';\n\n\nexport type UseColumnsMenuProps<TRowData, TDataContext = null> = {\n readonly hasCellData?: HasCellDataFn<TRowData, TDataContext>;\n};\n\nexport const useColumnsMenu = <TRowData, TDataContext = null>({ hasCellData }: UseColumnsMenuProps<TRowData, TDataContext>): MenuItemData => {\n const tableStore = useTableStoreContext<TRowData, TDataContext>();\n const emitTableEvent = useStore(tableStore, useShallow((state) => state.emitEvent));\n const tableColumns = useStore(tableStore, useShallow((state) => state.columns));\n const dataContext = useStore(tableStore, useShallow((state) => state.dataContext));\n const visibleColumnIds = useStore(tableStore, useShallow((state) => state.getCurrentColumnVisualSettings().filter(c => c.isVisible).map(c => c.id)));\n const columnDimensions = useStore(tableStore, useShallow((state) => state.columnDimensions));\n const isCondensed = useStore(tableStore, useShallow((state) => state.isCondensed));\n const sortedData = useStore(tableStore, useShallow((state) => state.sortedData));\n const { t } = useTranslation();\n\n const isCondensingSupported = useMemo(() => {\n return tableColumns.some(c => c.cellColorGetter);\n }, [tableColumns]);\n\n const onColumnsEditorMenuItemClick = useCallback(() => {\n emitTableEvent('openColumnsEditorDialog', hasCellData);\n }, [emitTableEvent, hasCellData]);\n\n const toggleItem = useCallback((columnId: string): void => {\n const newVisibleColumnIds = produce(visibleColumnIds, (draft) => {\n if (draft.includes(columnId)) {\n return draft.filter(c => c !== columnId);\n }\n draft.push(columnId);\n return draft;\n });\n emitTableEvent('columnVisibilityChange', newVisibleColumnIds);\n }, [emitTableEvent, visibleColumnIds]);\n\n const toggleDimension = useCallback((dimensionColumnIds: string[]): void => {\n const areAllVisible = dimensionColumnIds.every(columnId => visibleColumnIds.includes(columnId));\n const newVisibleColumnIds = produce(visibleColumnIds, (draft) => {\n if (areAllVisible) {\n return draft.filter(c => !dimensionColumnIds.includes(c));\n }\n dimensionColumnIds.forEach((columnId) => {\n if (!draft.includes(columnId)) {\n draft.push(columnId);\n }\n });\n return draft;\n });\n emitTableEvent('columnVisibilityChange', newVisibleColumnIds);\n }, [emitTableEvent, visibleColumnIds]);\n\n const onHideColumnsWithoutDataClick = useCallback(() => {\n emitTableEvent('columnVisibilityChange', TableUtil.getColumnIdsWithData<TRowData, TDataContext>({\n dataContext,\n hasCellData,\n sortedData,\n tableColumns,\n visibleColumnIds,\n }));\n\n }, [emitTableEvent, hasCellData, sortedData, tableColumns, visibleColumnIds, dataContext]);\n\n const onIsCondensedMenuItemClick = useCallback(() => {\n emitTableEvent('condensedChange', !isCondensed);\n }, [emitTableEvent, isCondensed]);\n\n const menuItemData: MenuItemData = useMemo(() => {\n const items: MenuItemData[] = [\n isCondensingSupported ? {\n autoCloseDisabled: true,\n callback: () => onIsCondensedMenuItemClick(),\n checked: isCondensed ? 'true' : 'false',\n divider: true,\n label: t`Condensed`,\n rightIcon: isCondensed ? <ToggleOnOutlinedIcon /> : <ToggleOffOutlinedIcon />,\n } : undefined,\n {\n callback: () => onColumnsEditorMenuItemClick(),\n divider: true,\n label: t`Change order / visibility`,\n },\n {\n autoCloseDisabled: true,\n callback: () => emitTableEvent('reset'),\n label: t`Reset`,\n },\n {\n autoCloseDisabled: true,\n callback: () => {\n emitTableEvent('columnVisibilityChange', [...tableColumns.map(c => c.id)]);\n },\n label: t`Show all`,\n },\n {\n autoCloseDisabled: true,\n callback: () => {\n emitTableEvent('columnVisibilityChange', [...tableColumns.filter(c => c.frozen).map(c => c.id)]);\n },\n label: t`Hide all`,\n },\n {\n autoCloseDisabled: true,\n callback: () => onHideColumnsWithoutDataClick(),\n divider: true,\n label: t`Hide columns without data`,\n },\n ].filter(x => x) as MenuItemData[];\n\n if (columnDimensions) {\n columnDimensions.forEach((columnDimension) => {\n const areAllVisible = columnDimension.columnIds.every(columnId => visibleColumnIds.includes(columnId));\n const areSomeVisible = columnDimension.columnIds.some(columnId => visibleColumnIds.includes(columnId));\n items.push({\n autoCloseDisabled: true,\n callback: () => toggleDimension(columnDimension.columnIds),\n // eslint-disable-next-line no-nested-ternary\n checked: areAllVisible ? 'true' : areSomeVisible ? 'mixed' : 'false',\n items: columnDimension.columnIds.map((columnId) => {\n const checked = visibleColumnIds.includes(columnId);\n return {\n autoCloseDisabled: true,\n callback: () => toggleItem(columnId),\n checked: checked ? 'true' : 'false',\n label: tableColumns.find(c => c.id === columnId)?.headerName ?? '',\n rightIcon: checked ? <CheckBoxOutlinedIcon /> : <CheckBoxOutlineBlankOutlinedIcon />,\n };\n }),\n label: columnDimension.label,\n // eslint-disable-next-line no-nested-ternary\n rightIcon: areAllVisible ? <CheckBoxOutlinedIcon /> : areSomeVisible ? <IndeterminateCheckBoxIcon /> : <CheckBoxOutlineBlankOutlinedIcon />,\n });\n });\n } else {\n tableColumns.filter(c => !c.frozen).forEach((column) => {\n const checked = visibleColumnIds.includes(column.id);\n items.push({\n autoCloseDisabled: true,\n callback: () => toggleItem(column.id),\n checked: checked ? 'true' : 'false',\n label: column.headerName,\n rightIcon: checked ? <CheckBoxOutlinedIcon /> : <CheckBoxOutlineBlankOutlinedIcon />,\n });\n });\n }\n\n return {\n items,\n label: t`Columns`,\n };\n }, [isCondensed, isCondensingSupported, t, columnDimensions, onIsCondensedMenuItemClick, onColumnsEditorMenuItemClick, emitTableEvent, tableColumns, onHideColumnsWithoutDataClick, visibleColumnIds, toggleDimension, toggleItem]);\n\n return menuItemData;\n};\n"],"ignoreList":[0,1],"mappings":";;;;;;;;;;;;AAAA,IAAMS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AAqBL,EAAVI,IAAWxD,IAA2BC,GAA5B,CAAuB,CAAuC;GACrF,CAAC;EACH,CAAC,GAGI;GACL;GACA,OAAO,CAAC;EACV;CACF,GAAG;EAACiC;EAAaG;EAAuBqB;EAAGzB;EAAkBiB;EAA4BX;EAA8BZ;EAAgBE;EAAcoB;EAA+BlB;EAAkBe;EAAiBJ;CAAU,CAE1N;AACT"}
|
|
1
|
+
{"version":3,"file":"useColumnsMenu.js","names":["TableUtil","produce","useTableStoreContext","React","IndeterminateCheckBoxIcon","CheckBoxOutlinedIcon","CheckBoxOutlineBlankOutlinedIcon","ToggleOffOutlinedIcon","ToggleOnOutlinedIcon","isIterable","obj","hasIterableEntries","value","compareEntries","mapA","valueA","mapB","valueB","key","compareIterables","iteratorA","iteratorB","nextA","nextB","shallow","useShallow","prev","next","selector","state","useColumnsMenu","tableStore","emitTableEvent","useStore","tableColumns","dataContext","visibleColumnIds","c","columnDimensions","isCondensed","sortedData","useTranslation","isCondensingSupported","useMemo","onColumnsEditorMenuItemClick","useCallback","hasCellData","toggleItem","newVisibleColumnIds","draft","columnId","toggleDimension","areAllVisible","dimensionColumnIds","onHideColumnsWithoutDataClick","onIsCondensedMenuItemClick","items","jsx","x","columnDimension","areSomeVisible","checked","column","t"],"sources":["../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.1_use-sync-external-store@1.7.0_react@19.3.1_/node_modules/zustand/esm/vanilla/shallow.mjs","../../../../node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.1_use-sync-external-store@1.7.0_react@19.3.1_/node_modules/zustand/esm/react/shallow.mjs","../../src/hooks/useColumnsMenu/useColumnsMenu.tsx"],"sourcesContent":["const isIterable = (obj) => Symbol.iterator in obj;\nconst hasIterableEntries = (value) => (\n // HACK: avoid checking entries type\n \"entries\" in value\n);\nconst compareEntries = (valueA, valueB) => {\n const mapA = valueA instanceof Map ? valueA : new Map(valueA.entries());\n const mapB = valueB instanceof Map ? valueB : new Map(valueB.entries());\n if (mapA.size !== mapB.size) {\n return false;\n }\n for (const [key, value] of mapA) {\n if (!mapB.has(key) || !Object.is(value, mapB.get(key))) {\n return false;\n }\n }\n return true;\n};\nconst compareIterables = (valueA, valueB) => {\n const iteratorA = valueA[Symbol.iterator]();\n const iteratorB = valueB[Symbol.iterator]();\n let nextA = iteratorA.next();\n let nextB = iteratorB.next();\n while (!nextA.done && !nextB.done) {\n if (!Object.is(nextA.value, nextB.value)) {\n return false;\n }\n nextA = iteratorA.next();\n nextB = iteratorB.next();\n }\n return !!nextA.done && !!nextB.done;\n};\nfunction shallow(valueA, valueB) {\n if (Object.is(valueA, valueB)) {\n return true;\n }\n if (typeof valueA !== \"object\" || valueA === null || typeof valueB !== \"object\" || valueB === null) {\n return false;\n }\n if (Object.getPrototypeOf(valueA) !== Object.getPrototypeOf(valueB)) {\n return false;\n }\n if (isIterable(valueA) && isIterable(valueB)) {\n if (hasIterableEntries(valueA) && hasIterableEntries(valueB)) {\n return compareEntries(valueA, valueB);\n }\n return compareIterables(valueA, valueB);\n }\n return compareEntries(\n { entries: () => Object.entries(valueA) },\n { entries: () => Object.entries(valueB) }\n );\n}\n\nexport { shallow };\n","import React from 'react';\nimport { shallow } from 'zustand/vanilla/shallow';\n\nfunction useShallow(selector) {\n const prev = React.useRef(void 0);\n return (state) => {\n const next = selector(state);\n return shallow(prev.current, next) ? prev.current : prev.current = next;\n };\n}\n\nexport { useShallow };\n","import { produce } from 'immer';\nimport { useStore } from 'zustand';\nimport { useShallow } from 'zustand/shallow';\nimport CheckBoxOutlinedIcon from '@mui/icons-material/CheckBoxOutlined';\nimport CheckBoxOutlineBlankOutlinedIcon from '@mui/icons-material/CheckBoxOutlineBlankOutlined';\nimport ToggleOffOutlinedIcon from '@mui/icons-material/ToggleOffOutlined';\nimport ToggleOnOutlinedIcon from '@mui/icons-material/ToggleOnOutlined';\nimport IndeterminateCheckBoxIcon from '@mui/icons-material/IndeterminateCheckBox';\nimport {\n useCallback,\n useMemo,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport type { MenuItemData } from '@gen-epix/ui-core-components/models/nested-menu.models';\n\nimport type { HasCellDataFn } from '../../models/table.models';\nimport { useTableStoreContext } from '../../stores/tableStore';\nimport { TableUtil } from '../../utils/TableUtil';\n\n\nexport type UseColumnsMenuProps<TRowData, TDataContext = null> = {\n readonly hasCellData?: HasCellDataFn<TRowData, TDataContext>;\n};\n\nexport const useColumnsMenu = <TRowData, TDataContext = null>({ hasCellData }: UseColumnsMenuProps<TRowData, TDataContext>): MenuItemData => {\n const tableStore = useTableStoreContext<TRowData, TDataContext>();\n const emitTableEvent = useStore(tableStore, useShallow((state) => state.emitEvent));\n const tableColumns = useStore(tableStore, useShallow((state) => state.columns));\n const dataContext = useStore(tableStore, useShallow((state) => state.dataContext));\n const visibleColumnIds = useStore(tableStore, useShallow((state) => state.getCurrentColumnVisualSettings().filter(c => c.isVisible).map(c => c.id)));\n const columnDimensions = useStore(tableStore, useShallow((state) => state.columnDimensions));\n const isCondensed = useStore(tableStore, useShallow((state) => state.isCondensed));\n const sortedData = useStore(tableStore, useShallow((state) => state.sortedData));\n const { t } = useTranslation();\n\n const isCondensingSupported = useMemo(() => {\n return tableColumns.some(c => c.cellColorGetter);\n }, [tableColumns]);\n\n const onColumnsEditorMenuItemClick = useCallback(() => {\n emitTableEvent('openColumnsEditorDialog', hasCellData);\n }, [emitTableEvent, hasCellData]);\n\n const toggleItem = useCallback((columnId: string): void => {\n const newVisibleColumnIds = produce(visibleColumnIds, (draft) => {\n if (draft.includes(columnId)) {\n return draft.filter(c => c !== columnId);\n }\n draft.push(columnId);\n return draft;\n });\n emitTableEvent('columnVisibilityChange', newVisibleColumnIds);\n }, [emitTableEvent, visibleColumnIds]);\n\n const toggleDimension = useCallback((dimensionColumnIds: string[]): void => {\n const areAllVisible = dimensionColumnIds.every(columnId => visibleColumnIds.includes(columnId));\n const newVisibleColumnIds = produce(visibleColumnIds, (draft) => {\n if (areAllVisible) {\n return draft.filter(c => !dimensionColumnIds.includes(c));\n }\n dimensionColumnIds.forEach((columnId) => {\n if (!draft.includes(columnId)) {\n draft.push(columnId);\n }\n });\n return draft;\n });\n emitTableEvent('columnVisibilityChange', newVisibleColumnIds);\n }, [emitTableEvent, visibleColumnIds]);\n\n const onHideColumnsWithoutDataClick = useCallback(() => {\n emitTableEvent('columnVisibilityChange', TableUtil.getColumnIdsWithData<TRowData, TDataContext>({\n dataContext,\n hasCellData,\n sortedData,\n tableColumns,\n visibleColumnIds,\n }));\n\n }, [emitTableEvent, hasCellData, sortedData, tableColumns, visibleColumnIds, dataContext]);\n\n const onIsCondensedMenuItemClick = useCallback(() => {\n emitTableEvent('condensedChange', !isCondensed);\n }, [emitTableEvent, isCondensed]);\n\n const menuItemData: MenuItemData = useMemo(() => {\n const items: MenuItemData[] = [\n isCondensingSupported ? {\n autoCloseDisabled: true,\n callback: () => onIsCondensedMenuItemClick(),\n checked: isCondensed ? 'true' : 'false',\n divider: true,\n label: t`Condensed`,\n rightIcon: isCondensed ? <ToggleOnOutlinedIcon /> : <ToggleOffOutlinedIcon />,\n } : undefined,\n {\n callback: () => onColumnsEditorMenuItemClick(),\n divider: true,\n label: t`Change order / visibility`,\n },\n {\n autoCloseDisabled: true,\n callback: () => emitTableEvent('reset'),\n label: t`Reset`,\n },\n {\n autoCloseDisabled: true,\n callback: () => {\n emitTableEvent('columnVisibilityChange', [...tableColumns.map(c => c.id)]);\n },\n label: t`Show all`,\n },\n {\n autoCloseDisabled: true,\n callback: () => {\n emitTableEvent('columnVisibilityChange', [...tableColumns.filter(c => c.frozen).map(c => c.id)]);\n },\n label: t`Hide all`,\n },\n {\n autoCloseDisabled: true,\n callback: () => onHideColumnsWithoutDataClick(),\n divider: true,\n label: t`Hide columns without data`,\n },\n ].filter(x => x) as MenuItemData[];\n\n if (columnDimensions) {\n columnDimensions.forEach((columnDimension) => {\n const areAllVisible = columnDimension.columnIds.every(columnId => visibleColumnIds.includes(columnId));\n const areSomeVisible = columnDimension.columnIds.some(columnId => visibleColumnIds.includes(columnId));\n items.push({\n autoCloseDisabled: true,\n callback: () => toggleDimension(columnDimension.columnIds),\n // eslint-disable-next-line no-nested-ternary\n checked: areAllVisible ? 'true' : areSomeVisible ? 'mixed' : 'false',\n items: columnDimension.columnIds.map((columnId) => {\n const checked = visibleColumnIds.includes(columnId);\n return {\n autoCloseDisabled: true,\n callback: () => toggleItem(columnId),\n checked: checked ? 'true' : 'false',\n label: tableColumns.find(c => c.id === columnId)?.headerName ?? '',\n rightIcon: checked ? <CheckBoxOutlinedIcon /> : <CheckBoxOutlineBlankOutlinedIcon />,\n };\n }),\n label: columnDimension.label,\n // eslint-disable-next-line no-nested-ternary\n rightIcon: areAllVisible ? <CheckBoxOutlinedIcon /> : areSomeVisible ? <IndeterminateCheckBoxIcon /> : <CheckBoxOutlineBlankOutlinedIcon />,\n });\n });\n } else {\n tableColumns.filter(c => !c.frozen).forEach((column) => {\n const checked = visibleColumnIds.includes(column.id);\n items.push({\n autoCloseDisabled: true,\n callback: () => toggleItem(column.id),\n checked: checked ? 'true' : 'false',\n label: column.headerName,\n rightIcon: checked ? <CheckBoxOutlinedIcon /> : <CheckBoxOutlineBlankOutlinedIcon />,\n });\n });\n }\n\n return {\n items,\n label: t`Columns`,\n };\n }, [isCondensed, isCondensingSupported, t, columnDimensions, onIsCondensedMenuItemClick, onColumnsEditorMenuItemClick, emitTableEvent, tableColumns, onHideColumnsWithoutDataClick, visibleColumnIds, toggleDimension, toggleItem]);\n\n return menuItemData;\n};\n"],"ignoreList":[0,1],"mappings":";;;;;;;;;;;;AAAA,IAAMS,KAAc,MAAQ,OAAO,YAAYC,GACzCC,KAAsB,MAE1B,aAAaC,GAETC,KAAkB,GAAQ,MAAW;CACzC,IAAMC,IAAOC,aAAkB,MAAMA,IAAS,IAAI,IAAIA,EAAO,QAAQ,CAAC,GAChEC,IAAOC,aAAkB,MAAMA,IAAS,IAAI,IAAIA,EA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AAkBe;EAAiBJ;CAAU,CAE1N;AACT"}
|
|
@@ -92,7 +92,7 @@ var l = class extends r {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
//#endregion
|
|
95
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.
|
|
95
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.1/node_modules/@tanstack/react-query/build/modern/useMutation.js
|
|
96
96
|
function u(e, n) {
|
|
97
97
|
let r = t(n), [i] = c.useState(() => new l(r, e));
|
|
98
98
|
c.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutation.js","names":["React","getDefaultState","useQueryClient","shallowEqualObjects","Subscribable","hashKey","noop","shouldThrowError","React$1","MutationObserver","#client","client","options","#updateResult","prevOptions","#currentMutation","#notify","action","#currentResult","#mutateOptions","variables","state","mutateOptions","onMutateResult","context","useMutation","queryClient","observer","result","notifyManager","onStoreChange","mutate","args"],"sources":["../../../../node_modules/.pnpm/@tanstack+query-core@5.104.2/node_modules/@tanstack/query-core/build/modern/mutationObserver.js","../../../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.0/node_modules/@tanstack/react-query/build/modern/useMutation.js"],"sourcesContent":["import { hashKey, shallowEqualObjects } from \"./utils.js\";\nimport { Subscribable } from \"./subscribable.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { getDefaultState } from \"./mutation.js\";\n//#region src/mutationObserver.ts\n/**\n* Observes a single mutation and derives a `MutationObserverResult` from it.\n* A framework hook like `useMutation` creates one `MutationObserver` per hook\n* call, keeps it stable across re-renders, calls `setOptions` when the options\n* passed to the hook change, subscribes to it to re-render on updates, and\n* reads `getCurrentResult()` for the value to return. Calling `mutate()`\n* builds a new underlying `Mutation` in the `MutationCache` and executes it.\n* @example\n* ```ts\n* const observer = new MutationObserver(queryClient, {\n* mutationFn: (variables: { title: string }) => addPost(variables),\n* })\n* ```\n*/\nvar MutationObserver = class extends Subscribable {\n\t#client;\n\t#currentResult = void 0;\n\t#currentMutation;\n\t#mutateOptions;\n\tconstructor(client, options) {\n\t\tsuper();\n\t\tthis.#client = client;\n\t\tthis.setOptions(options);\n\t\tthis.bindMethods();\n\t\tthis.#updateResult();\n\t}\n\t/**\n\t* Binds the methods of the result (`mutate` and `reset`) to the observer, so they keep working when\n\t* destructured from it.\n\t*/\n\tbindMethods() {\n\t\tthis.mutate = this.mutate.bind(this);\n\t\tthis.reset = this.reset.bind(this);\n\t}\n\t/**\n\t* Updates the observer's options.\n\t*\n\t* If the new `mutationKey` differs from the previous one (and both were\n\t* defined), the observer is reset, detaching it from the mutation it was\n\t* observing. Otherwise, if the currently observed mutation is still\n\t* `pending`, its options are updated in place as well.\n\t* @param options - The new mutation observer options. They are defaulted with {@link\n\t* QueryClient#defaultMutationOptions} before being applied.\n\t* @example\n\t* ```ts\n\t* observer.setOptions({\n\t* mutationFn: (variables: { title: string }) => addPost(variables),\n\t* onSuccess: (data) => console.log(data),\n\t* })\n\t* ```\n\t*/\n\tsetOptions(options) {\n\t\tconst prevOptions = this.options;\n\t\tthis.options = this.#client.defaultMutationOptions(options);\n\t\tif (!shallowEqualObjects(this.options, prevOptions)) this.#client.getMutationCache().notify({\n\t\t\ttype: \"observerOptionsUpdated\",\n\t\t\tmutation: this.#currentMutation,\n\t\t\tobserver: this\n\t\t});\n\t\tif (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();\n\t\telse if (this.#currentMutation?.state.status === \"pending\") this.#currentMutation.setOptions(this.options);\n\t}\n\tonSubscribe() {\n\t\tif (this.listeners.size === 1 && this.#currentMutation) {\n\t\t\tthis.#currentMutation.addObserver(this);\n\t\t\tthis.#updateResult();\n\t\t}\n\t}\n\tonUnsubscribe() {\n\t\tif (!this.hasListeners()) this.#currentMutation?.removeObserver(this);\n\t}\n\t/**\n\t* Updates the observer's result when the observed mutation changes, and notifies its listeners.\n\t* @internal\n\t* @param action - The action that updated the observed mutation, passed on to the observer's\n\t* callbacks.\n\t*/\n\tonMutationUpdate(action) {\n\t\tthis.#updateResult();\n\t\tthis.#notify(action);\n\t}\n\t/**\n\t* Returns the observer's current result, derived from the observed\n\t* mutation's state (or the default, `idle` state if no mutation has been\n\t* built yet, e.g. before the first `mutate()` call or after `reset()`).\n\t* @returns The observer's latest result.\n\t*/\n\tgetCurrentResult() {\n\t\treturn this.#currentResult;\n\t}\n\t/**\n\t* Detaches the observer from the mutation it is currently observing (if\n\t* any) and resets the observed result back to its default, `idle` state.\n\t*\n\t* This does not cancel an in-flight mutation; the mutation itself keeps\n\t* running to completion and its own callbacks still fire, but this\n\t* observer stops reflecting its state and a subsequent `mutate()` call\n\t* will build a brand new mutation.\n\t* @see {@link MutationObserver#mutate}\n\t* @example\n\t* ```ts\n\t* observer.reset()\n\t* ```\n\t*/\n\treset() {\n\t\tthis.#currentMutation?.removeObserver(this);\n\t\tthis.#currentMutation = void 0;\n\t\tthis.#updateResult();\n\t\tthis.#notify();\n\t}\n\t/**\n\t* Builds a new `Mutation` in the `MutationCache` using the observer's\n\t* current options, detaches this observer from any previously observed\n\t* mutation, attaches it to the new one, and executes it with the given\n\t* variables.\n\t*\n\t* The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are\n\t* invoked once the mutation settles, in addition to any callbacks defined\n\t* on the observer's own options.\n\t* @param variables - The variables passed to the `mutationFn`.\n\t* @param options - Per-call `onSuccess`, `onError`, and `onSettled` callbacks.\n\t* @returns A promise that resolves with the mutation's data, or rejects with its error.\n\t* @example\n\t* ```ts\n\t* await observer.mutate(\n\t* { title: 'New post' },\n\t* { onSuccess: (data) => console.log(data) },\n\t* )\n\t* ```\n\t*/\n\tmutate(variables, options) {\n\t\tthis.#mutateOptions = options;\n\t\tthis.#currentMutation?.removeObserver(this);\n\t\tthis.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);\n\t\tthis.#currentMutation.addObserver(this);\n\t\treturn this.#currentMutation.execute(variables);\n\t}\n\t#updateResult() {\n\t\tconst state = this.#currentMutation?.state ?? getDefaultState();\n\t\tthis.#currentResult = {\n\t\t\t...state,\n\t\t\tisPending: state.status === \"pending\",\n\t\t\tisSuccess: state.status === \"success\",\n\t\t\tisError: state.status === \"error\",\n\t\t\tisIdle: state.status === \"idle\",\n\t\t\tmutate: this.mutate,\n\t\t\treset: this.reset\n\t\t};\n\t}\n\t#notify(action) {\n\t\tnotifyManager.batch(() => {\n\t\t\tconst mutateOptions = this.#mutateOptions;\n\t\t\tif (mutateOptions && this.hasListeners()) {\n\t\t\t\tconst variables = this.#currentResult.variables;\n\t\t\t\tconst onMutateResult = this.#currentResult.context;\n\t\t\t\tconst context = {\n\t\t\t\t\tclient: this.#client,\n\t\t\t\t\tmeta: this.options.meta,\n\t\t\t\t\tmutationKey: this.options.mutationKey\n\t\t\t\t};\n\t\t\t\tif (action?.type === \"success\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t} else if (action?.type === \"error\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onError?.(action.error, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.listeners.forEach((listener) => {\n\t\t\t\tlistener(this.#currentResult);\n\t\t\t});\n\t\t});\n\t}\n};\n//#endregion\nexport { MutationObserver };\n\n//# sourceMappingURL=mutationObserver.js.map","\"use client\";\nimport { useQueryClient } from \"./QueryClientProvider.js\";\nimport * as React from \"react\";\nimport { MutationObserver, noop, notifyManager, shouldThrowError } from \"@tanstack/query-core\";\n//#region src/useMutation.ts\n/**\n* Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.\n* `useMutation` is the hook for that.\n* @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.\n* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n* be used.\n* @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n* argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n* mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call callbacks\n* fire only for the latest call you've made, and only while the component is still mounted — unmounting before\n* the mutation settles removes the subscription and prevents them from firing.\n* @throws {Error} The mutation error, when `throwOnError` is `true` or returns `true` for it, so that it is\n* thrown to the nearest error boundary.\n* @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look\n* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).\n* @example\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* return (\n* <button\n* onClick={() =>\n* addMutation.mutate('Item', {\n* onError: (error) => console.error('Failed to add item:', error),\n* })\n* }\n* >\n* Add\n* </button>\n* )\n* }\n* ```\n* @example\n* Rendering the mutation's own state, rather than just firing it off:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* return (\n* <div>\n* {addMutation.isPending ? (\n* 'Adding todo...'\n* ) : (\n* <>\n* {addMutation.isError ? (\n* <div>An error occurred: {addMutation.error.message}</div>\n* ) : null}\n* <button onClick={() => addMutation.mutate('Item')}>Add</button>\n* </>\n* )}\n* </div>\n* )\n* }\n* ```\n* @example\n* Optimistic update via `onMutate`, rolling back on `onError`:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onMutate: async (newTodo) => {\n* await queryClient.cancelQueries({ queryKey: ['todos'] })\n* const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n*\n* queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n* ...(old ?? []),\n* newTodo,\n* ])\n*\n* // Passed to `onError` as `onMutateResult` if the mutation fails.\n* return { previousTodos }\n* },\n* onError: (_err, _newTodo, onMutateResult) => {\n* queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n* },\n* onSettled: () => {\n* queryClient.invalidateQueries({ queryKey: ['todos'] })\n* },\n* })\n*\n* return (\n* <button onClick={() => addMutation.mutate('Item')}>Add</button>\n* )\n* }\n* ```\n* @example\n* Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n* promise per call instead, so you can wait for all of them when they succeed:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodos() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* async function handleAddAll(todos: Array<string>) {\n* try {\n* await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n* } catch (error) {\n* console.error('Failed to add todos:', error)\n* }\n* }\n*\n* return (\n* <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n* Add all\n* </button>\n* )\n* }\n* ```\n* @example\n* If some of the mutations above can fail independently of the others, and you want to know which ones\n* did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n* `Promise.allSettled`:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodos() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* async function handleAddAll(todos: Array<string>) {\n* const addResults = await Promise.allSettled(\n* todos.map((todo) => addMutation.mutateAsync(todo)),\n* )\n*\n* addResults.forEach((addResult, index) => {\n* if (addResult.status === 'rejected') {\n* console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n* }\n* })\n* }\n*\n* return (\n* <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n* Add all\n* </button>\n* )\n* }\n* ```\n*/\nfunction useMutation(options, queryClient) {\n\tconst client = useQueryClient(queryClient);\n\tconst [observer] = React.useState(() => new MutationObserver(client, options));\n\tReact.useEffect(() => {\n\t\tobserver.setOptions(options);\n\t}, [observer, options]);\n\tconst result = React.useSyncExternalStore(React.useCallback((onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult());\n\tconst mutate = React.useCallback((...args) => {\n\t\tobserver.mutate(args[0], args[1]).catch(noop);\n\t}, [observer]);\n\tif (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) throw result.error;\n\treturn {\n\t\t...result,\n\t\tmutate,\n\t\tmutateAsync: result.mutate\n\t};\n}\n//#endregion\nexport { useMutation };\n\n//# sourceMappingURL=useMutation.js.map"],"ignoreList":[0,1],"mappings":";;;;;AAmBA,IAAIS,IAAmB,cAAcL,EAAa;CACjD;CACA,KAAiB,KAAK;CACtB;CACA;CACA,YAAY,GAAQ,GAAS;EAK5B,AAJA,MAAM,GACN,KAAKM,KAAUC,GACf,KAAK,W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C,CAACC,KAAY3B,EAAM,eAAe,IAAIS,EAAiBE,GAAQC,CAAO,CAAC;CAC7E,EAAM,gBAAgB;EACrB,EAAS,WAAWA,CAAO;CAC5B,GAAG,CAACe,GAAUf,CAAO,CAAC;CACtB,IAAMgB,IAAS5B,EAAM,qBAAqBA,EAAM,aAAa,MAAkB2B,EAAS,UAAUE,EAAc,WAAWC,CAAa,CAAC,GAAG,CAACH,CAAQ,CAAC,SAASA,EAAS,iBAAiB,SAASA,EAAS,iBAAiB,CAAC,GACvNI,IAAS/B,EAAM,aAAa,GAAGgC,MAAS;EAC7C,EAAS,OAAOA,EAAK,IAAIA,EAAK,EAAE,CAAC,CAAC,MAAM1B,CAAI;CAC7C,GAAG,CAACqB,CAAQ,CAAC;CACb,IAAIC,EAAO,SAASrB,EAAiBoB,EAAS,QAAQ,cAAc,CAACC,EAAO,KAAK,CAAC,GAAG,MAAMA,EAAO;CAClG,OAAO;EACN,GAAGA;EACH;EACA,aAAaA,EAAO;CACrB;AACD"}
|
|
1
|
+
{"version":3,"file":"useMutation.js","names":["React","getDefaultState","useQueryClient","shallowEqualObjects","Subscribable","hashKey","noop","shouldThrowError","React$1","MutationObserver","#client","client","options","#updateResult","prevOptions","#currentMutation","#notify","action","#currentResult","#mutateOptions","variables","state","mutateOptions","onMutateResult","context","useMutation","queryClient","observer","result","notifyManager","onStoreChange","mutate","args"],"sources":["../../../../node_modules/.pnpm/@tanstack+query-core@5.104.2/node_modules/@tanstack/query-core/build/modern/mutationObserver.js","../../../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.1/node_modules/@tanstack/react-query/build/modern/useMutation.js"],"sourcesContent":["import { hashKey, shallowEqualObjects } from \"./utils.js\";\nimport { Subscribable } from \"./subscribable.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { getDefaultState } from \"./mutation.js\";\n//#region src/mutationObserver.ts\n/**\n* Observes a single mutation and derives a `MutationObserverResult` from it.\n* A framework hook like `useMutation` creates one `MutationObserver` per hook\n* call, keeps it stable across re-renders, calls `setOptions` when the options\n* passed to the hook change, subscribes to it to re-render on updates, and\n* reads `getCurrentResult()` for the value to return. Calling `mutate()`\n* builds a new underlying `Mutation` in the `MutationCache` and executes it.\n* @example\n* ```ts\n* const observer = new MutationObserver(queryClient, {\n* mutationFn: (variables: { title: string }) => addPost(variables),\n* })\n* ```\n*/\nvar MutationObserver = class extends Subscribable {\n\t#client;\n\t#currentResult = void 0;\n\t#currentMutation;\n\t#mutateOptions;\n\tconstructor(client, options) {\n\t\tsuper();\n\t\tthis.#client = client;\n\t\tthis.setOptions(options);\n\t\tthis.bindMethods();\n\t\tthis.#updateResult();\n\t}\n\t/**\n\t* Binds the methods of the result (`mutate` and `reset`) to the observer, so they keep working when\n\t* destructured from it.\n\t*/\n\tbindMethods() {\n\t\tthis.mutate = this.mutate.bind(this);\n\t\tthis.reset = this.reset.bind(this);\n\t}\n\t/**\n\t* Updates the observer's options.\n\t*\n\t* If the new `mutationKey` differs from the previous one (and both were\n\t* defined), the observer is reset, detaching it from the mutation it was\n\t* observing. Otherwise, if the currently observed mutation is still\n\t* `pending`, its options are updated in place as well.\n\t* @param options - The new mutation observer options. They are defaulted with {@link\n\t* QueryClient#defaultMutationOptions} before being applied.\n\t* @example\n\t* ```ts\n\t* observer.setOptions({\n\t* mutationFn: (variables: { title: string }) => addPost(variables),\n\t* onSuccess: (data) => console.log(data),\n\t* })\n\t* ```\n\t*/\n\tsetOptions(options) {\n\t\tconst prevOptions = this.options;\n\t\tthis.options = this.#client.defaultMutationOptions(options);\n\t\tif (!shallowEqualObjects(this.options, prevOptions)) this.#client.getMutationCache().notify({\n\t\t\ttype: \"observerOptionsUpdated\",\n\t\t\tmutation: this.#currentMutation,\n\t\t\tobserver: this\n\t\t});\n\t\tif (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();\n\t\telse if (this.#currentMutation?.state.status === \"pending\") this.#currentMutation.setOptions(this.options);\n\t}\n\tonSubscribe() {\n\t\tif (this.listeners.size === 1 && this.#currentMutation) {\n\t\t\tthis.#currentMutation.addObserver(this);\n\t\t\tthis.#updateResult();\n\t\t}\n\t}\n\tonUnsubscribe() {\n\t\tif (!this.hasListeners()) this.#currentMutation?.removeObserver(this);\n\t}\n\t/**\n\t* Updates the observer's result when the observed mutation changes, and notifies its listeners.\n\t* @internal\n\t* @param action - The action that updated the observed mutation, passed on to the observer's\n\t* callbacks.\n\t*/\n\tonMutationUpdate(action) {\n\t\tthis.#updateResult();\n\t\tthis.#notify(action);\n\t}\n\t/**\n\t* Returns the observer's current result, derived from the observed\n\t* mutation's state (or the default, `idle` state if no mutation has been\n\t* built yet, e.g. before the first `mutate()` call or after `reset()`).\n\t* @returns The observer's latest result.\n\t*/\n\tgetCurrentResult() {\n\t\treturn this.#currentResult;\n\t}\n\t/**\n\t* Detaches the observer from the mutation it is currently observing (if\n\t* any) and resets the observed result back to its default, `idle` state.\n\t*\n\t* This does not cancel an in-flight mutation; the mutation itself keeps\n\t* running to completion and its own callbacks still fire, but this\n\t* observer stops reflecting its state and a subsequent `mutate()` call\n\t* will build a brand new mutation.\n\t* @see {@link MutationObserver#mutate}\n\t* @example\n\t* ```ts\n\t* observer.reset()\n\t* ```\n\t*/\n\treset() {\n\t\tthis.#currentMutation?.removeObserver(this);\n\t\tthis.#currentMutation = void 0;\n\t\tthis.#updateResult();\n\t\tthis.#notify();\n\t}\n\t/**\n\t* Builds a new `Mutation` in the `MutationCache` using the observer's\n\t* current options, detaches this observer from any previously observed\n\t* mutation, attaches it to the new one, and executes it with the given\n\t* variables.\n\t*\n\t* The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are\n\t* invoked once the mutation settles, in addition to any callbacks defined\n\t* on the observer's own options.\n\t* @param variables - The variables passed to the `mutationFn`.\n\t* @param options - Per-call `onSuccess`, `onError`, and `onSettled` callbacks.\n\t* @returns A promise that resolves with the mutation's data, or rejects with its error.\n\t* @example\n\t* ```ts\n\t* await observer.mutate(\n\t* { title: 'New post' },\n\t* { onSuccess: (data) => console.log(data) },\n\t* )\n\t* ```\n\t*/\n\tmutate(variables, options) {\n\t\tthis.#mutateOptions = options;\n\t\tthis.#currentMutation?.removeObserver(this);\n\t\tthis.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);\n\t\tthis.#currentMutation.addObserver(this);\n\t\treturn this.#currentMutation.execute(variables);\n\t}\n\t#updateResult() {\n\t\tconst state = this.#currentMutation?.state ?? getDefaultState();\n\t\tthis.#currentResult = {\n\t\t\t...state,\n\t\t\tisPending: state.status === \"pending\",\n\t\t\tisSuccess: state.status === \"success\",\n\t\t\tisError: state.status === \"error\",\n\t\t\tisIdle: state.status === \"idle\",\n\t\t\tmutate: this.mutate,\n\t\t\treset: this.reset\n\t\t};\n\t}\n\t#notify(action) {\n\t\tnotifyManager.batch(() => {\n\t\t\tconst mutateOptions = this.#mutateOptions;\n\t\t\tif (mutateOptions && this.hasListeners()) {\n\t\t\t\tconst variables = this.#currentResult.variables;\n\t\t\t\tconst onMutateResult = this.#currentResult.context;\n\t\t\t\tconst context = {\n\t\t\t\t\tclient: this.#client,\n\t\t\t\t\tmeta: this.options.meta,\n\t\t\t\t\tmutationKey: this.options.mutationKey\n\t\t\t\t};\n\t\t\t\tif (action?.type === \"success\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t} else if (action?.type === \"error\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onError?.(action.error, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.listeners.forEach((listener) => {\n\t\t\t\tlistener(this.#currentResult);\n\t\t\t});\n\t\t});\n\t}\n};\n//#endregion\nexport { MutationObserver };\n\n//# sourceMappingURL=mutationObserver.js.map","\"use client\";\nimport { useQueryClient } from \"./QueryClientProvider.js\";\nimport * as React from \"react\";\nimport { MutationObserver, noop, notifyManager, shouldThrowError } from \"@tanstack/query-core\";\n//#region src/useMutation.ts\n/**\n* Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.\n* `useMutation` is the hook for that.\n* @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.\n* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n* be used.\n* @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n* argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n* mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call callbacks\n* fire only for the latest call you've made, and only while the component is still mounted — unmounting before\n* the mutation settles removes the subscription and prevents them from firing.\n* @throws {Error} The mutation error, when `throwOnError` is `true` or returns `true` for it, so that it is\n* thrown to the nearest error boundary.\n* @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look\n* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).\n* @example\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* return (\n* <button\n* onClick={() =>\n* addMutation.mutate('Item', {\n* onError: (error) => console.error('Failed to add item:', error),\n* })\n* }\n* >\n* Add\n* </button>\n* )\n* }\n* ```\n* @example\n* Rendering the mutation's own state, rather than just firing it off:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* return (\n* <div>\n* {addMutation.isPending ? (\n* 'Adding todo...'\n* ) : (\n* <>\n* {addMutation.isError ? (\n* <div>An error occurred: {addMutation.error.message}</div>\n* ) : null}\n* <button onClick={() => addMutation.mutate('Item')}>Add</button>\n* </>\n* )}\n* </div>\n* )\n* }\n* ```\n* @example\n* Optimistic update via `onMutate`, rolling back on `onError`:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onMutate: async (newTodo) => {\n* await queryClient.cancelQueries({ queryKey: ['todos'] })\n* const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n*\n* queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n* ...(old ?? []),\n* newTodo,\n* ])\n*\n* // Passed to `onError` as `onMutateResult` if the mutation fails.\n* return { previousTodos }\n* },\n* onError: (_err, _newTodo, onMutateResult) => {\n* queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n* },\n* onSettled: () => {\n* queryClient.invalidateQueries({ queryKey: ['todos'] })\n* },\n* })\n*\n* return (\n* <button onClick={() => addMutation.mutate('Item')}>Add</button>\n* )\n* }\n* ```\n* @example\n* Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n* promise per call instead, so you can wait for all of them when they succeed:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodos() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* async function handleAddAll(todos: Array<string>) {\n* try {\n* await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n* } catch (error) {\n* console.error('Failed to add todos:', error)\n* }\n* }\n*\n* return (\n* <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n* Add all\n* </button>\n* )\n* }\n* ```\n* @example\n* If some of the mutations above can fail independently of the others, and you want to know which ones\n* did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n* `Promise.allSettled`:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodos() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* async function handleAddAll(todos: Array<string>) {\n* const addResults = await Promise.allSettled(\n* todos.map((todo) => addMutation.mutateAsync(todo)),\n* )\n*\n* addResults.forEach((addResult, index) => {\n* if (addResult.status === 'rejected') {\n* console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n* }\n* })\n* }\n*\n* return (\n* <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n* Add all\n* </button>\n* )\n* }\n* ```\n*/\nfunction useMutation(options, queryClient) {\n\tconst client = useQueryClient(queryClient);\n\tconst [observer] = React.useState(() => new MutationObserver(client, options));\n\tReact.useEffect(() => {\n\t\tobserver.setOptions(options);\n\t}, [observer, options]);\n\tconst result = React.useSyncExternalStore(React.useCallback((onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult());\n\tconst mutate = React.useCallback((...args) => {\n\t\tobserver.mutate(args[0], args[1]).catch(noop);\n\t}, [observer]);\n\tif (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) throw result.error;\n\treturn {\n\t\t...result,\n\t\tmutate,\n\t\tmutateAsync: result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AWG,GAAgBC,CAAO;KACnF,SAAS,GAAG;MACX,QAAQ,OAAO,CAAC;KACjB;IACD;GACD;GACA,KAAK,UAAU,SAAS,MAAa;IACpC,EAAS,KAAKN,EAAc;GAC7B,CAAC;EACF,CAAC;CACF;AACD;;;ACrBA,SAASO,EAAY,GAAS,GAAa;CAC1C,IAAMd,IAAST,EAAewB,CAAW,GACnC,CAACC,KAAY3B,EAAM,eAAe,IAAIS,EAAiBE,GAAQC,CAAO,CAAC;CAC7E,EAAM,gBAAgB;EACrB,EAAS,WAAWA,CAAO;CAC5B,GAAG,CAACe,GAAUf,CAAO,CAAC;CACtB,IAAMgB,IAAS5B,EAAM,qBAAqBA,EAAM,aAAa,MAAkB2B,EAAS,UAAUE,EAAc,WAAWC,CAAa,CAAC,GAAG,CAACH,CAAQ,CAAC,SAASA,EAAS,iBAAiB,SAASA,EAAS,iBAAiB,CAAC,GACvNI,IAAS/B,EAAM,aAAa,GAAGgC,MAAS;EAC7C,EAAS,OAAOA,EAAK,IAAIA,EAAK,EAAE,CAAC,CAAC,MAAM1B,CAAI;CAC7C,GAAG,CAACqB,CAAQ,CAAC;CACb,IAAIC,EAAO,SAASrB,EAAiBoB,EAAS,QAAQ,cAAc,CAACC,EAAO,KAAK,CAAC,GAAG,MAAMA,EAAO;CAClG,OAAO;EACN,GAAGA;EACH;EACA,aAAaA,EAAO;CACrB;AACD"}
|
|
@@ -232,11 +232,11 @@ function x(e, t) {
|
|
|
232
232
|
return p(t.enabled, e) !== !1 && e.isStaleByTime(p(t.staleTime, e));
|
|
233
233
|
}
|
|
234
234
|
//#endregion
|
|
235
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.
|
|
235
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.1/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
|
|
236
236
|
var S = m.createContext(!1), C = () => m.useContext(S);
|
|
237
237
|
S.Provider;
|
|
238
238
|
//#endregion
|
|
239
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.
|
|
239
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.1/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
|
|
240
240
|
function w() {
|
|
241
241
|
let e = !1;
|
|
242
242
|
return {
|
|
@@ -265,7 +265,7 @@ var T = m.createContext(w()), E = () => m.useContext(T), D = (e, t, n) => {
|
|
|
265
265
|
n.clearReset();
|
|
266
266
|
});
|
|
267
267
|
//#endregion
|
|
268
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.
|
|
268
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.1/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
|
|
269
269
|
function N(t, n, r) {
|
|
270
270
|
if (process.env.NODE_ENV !== "production" && (typeof t != "object" || Array.isArray(t))) throw Error("Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object");
|
|
271
271
|
let a = C(), o = E(), c = e(r), l = c.defaultQueryOptions(t), u = c.getQueryCache().get(l.queryHash);
|
|
@@ -289,7 +289,7 @@ function N(t, n, r) {
|
|
|
289
289
|
return l.notifyOnChangeProps ? p : f.trackResult(p);
|
|
290
290
|
}
|
|
291
291
|
//#endregion
|
|
292
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.
|
|
292
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-query@5.104.2_react@19.3.1/node_modules/@tanstack/react-query/build/modern/useQuery.js
|
|
293
293
|
function P(e, t) {
|
|
294
294
|
return N(e, g, t);
|
|
295
295
|
}
|