@bigbinary/neeto-commons-frontend 4.6.2 → 4.6.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/cjs/configs/babel.js +0 -1
- package/cjs/initializers/axiosInitializer/index.js +5 -7
- package/cjs/initializers/axiosInitializer/index.js.map +1 -1
- package/cjs/initializers/i18n.js +3 -3
- package/cjs/initializers/i18n.js.map +1 -1
- package/cjs/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js +2 -2
- package/cjs/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js.map +1 -1
- package/cjs/react-utils/PrivateRoute/PrivateRoute.js +2 -3
- package/cjs/react-utils/PrivateRoute/PrivateRoute.js.map +1 -1
- package/cjs/react-utils/metaClick/metaClick.js +2 -3
- package/cjs/react-utils/metaClick/metaClick.js.map +1 -1
- package/cjs/react-utils/useBreakpoints/index.js +2 -3
- package/cjs/react-utils/useBreakpoints/index.js.map +1 -1
- package/cjs/react-utils/useDisplayErrorPage/useDisplayErrorPage.js +2 -3
- package/cjs/react-utils/useDisplayErrorPage/useDisplayErrorPage.js.map +1 -1
- package/cjs/react-utils/useLocalStorage/useLocalStorage.js +2 -2
- package/cjs/react-utils/useLocalStorage/useLocalStorage.js.map +1 -1
- package/cjs/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js +4 -4
- package/cjs/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js.map +1 -1
- package/cjs/react-utils/usePersistedQuery/usePersistedQuery.js +3 -3
- package/cjs/react-utils/usePersistedQuery/usePersistedQuery.js.map +1 -1
- package/cjs/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js +8 -11
- package/cjs/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js.map +1 -1
- package/cjs/react-utils/useRestoreScrollPosition/useRestoreScrollPosition.js +8 -10
- package/cjs/react-utils/useRestoreScrollPosition/useRestoreScrollPosition.js.map +1 -1
- package/cjs/react-utils/withImmutableActions/withImmutableActions.js +3 -5
- package/cjs/react-utils/withImmutableActions/withImmutableActions.js.map +1 -1
- package/cjs/utils/axios.js +2 -2
- package/cjs/utils/axios.js.map +1 -1
- package/cjs/utils/buildNestedAttributesPayload.js +2 -2
- package/cjs/utils/buildNestedAttributesPayload.js.map +1 -1
- package/cjs/utils/general.js +7 -12
- package/cjs/utils/general.js.map +1 -1
- package/configs/babel.js +0 -1
- package/initializers/axiosInitializer/index.js +5 -7
- package/initializers/axiosInitializer/index.js.map +1 -1
- package/initializers/i18n.js +3 -3
- package/initializers/i18n.js.map +1 -1
- package/package.json +1 -1
- package/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js +2 -2
- package/react-utils/HoneybadgerErrorBoundary/FallbackComponent.js.map +1 -1
- package/react-utils/PrivateRoute/PrivateRoute.js +2 -3
- package/react-utils/PrivateRoute/PrivateRoute.js.map +1 -1
- package/react-utils/metaClick/metaClick.js +2 -2
- package/react-utils/metaClick/metaClick.js.map +1 -1
- package/react-utils/useBreakpoints/index.js +2 -2
- package/react-utils/useBreakpoints/index.js.map +1 -1
- package/react-utils/useDisplayErrorPage/useDisplayErrorPage.js +2 -2
- package/react-utils/useDisplayErrorPage/useDisplayErrorPage.js.map +1 -1
- package/react-utils/useLocalStorage/useLocalStorage.js +2 -2
- package/react-utils/useLocalStorage/useLocalStorage.js.map +1 -1
- package/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js +4 -4
- package/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js.map +1 -1
- package/react-utils/usePersistedQuery/usePersistedQuery.js +3 -3
- package/react-utils/usePersistedQuery/usePersistedQuery.js.map +1 -1
- package/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js +8 -11
- package/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js.map +1 -1
- package/react-utils/useRestoreScrollPosition/useRestoreScrollPosition.js +8 -10
- package/react-utils/useRestoreScrollPosition/useRestoreScrollPosition.js.map +1 -1
- package/react-utils/withImmutableActions/withImmutableActions.js +3 -4
- package/react-utils/withImmutableActions/withImmutableActions.js.map +1 -1
- package/utils/axios.js +2 -2
- package/utils/axios.js.map +1 -1
- package/utils/buildNestedAttributesPayload.js +2 -2
- package/utils/buildNestedAttributesPayload.js.map +1 -1
- package/utils/general.js +7 -12
- package/utils/general.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["axios","i18next","isNotEmpty","keysToCamelCase","matches","serializeKeysToSnakeCase","Toastr","toast","useErrorDisplayStore","resetAuthTokens","setParamsSerializer","HEADERS_KEYS","MAXIMUM_OFFLINE_DURATION","checkOnlineInterval","requestErrorToasts","shouldNot","skip","_typeof","shouldShowToastr","response","notice","noticeCode","setAuthHeaders","_document$querySelect","defaults","headers","_defineProperty","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config","_response$config$show","showToastr","requestUrl","url","requestMethod","method","toastIdKey","concat","errorToastId","dismiss","_dissoc","showThumbsUpToastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","t","dismissToastInterval","setInterval","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref3$show422ErrorToa","show422ErrorToastr","_ref3$url","_ref3$method","_ref4","message","code","toastrContent","skippedStatusCodes","includes","isCancel","globalProps","railsEnv","getUrlPathName","URL","_unused","handle404ErrorResponse","_error$config4","_error$response4","_ref5","_ref5$show404ErrorPag","show404ErrorPage","_ref5$show403ErrorPag","show403ErrorPage","_error$request","fullUrl","request","responseURL","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","_evolve","_omit","transformDataToSnakeCase","_request$transformReq","transformRequestCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer"],"sources":["../../../src/initializers/axiosInitializer/index.js"],"sourcesContent":["import axios from \"axios\";\nimport i18next from \"i18next\";\nimport {\n isNotEmpty,\n keysToCamelCase,\n matches,\n serializeKeysToSnakeCase,\n} from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { dissoc, evolve, omit } from \"ramda\";\nimport { toast } from \"react-toastify\";\nimport { useErrorDisplayStore } from \"react-utils/useDisplayErrorPage\";\nimport { resetAuthTokens } from \"utils/axios\";\n\nimport setParamsSerializer from \"./paramsSerializer\";\n\nimport { HEADERS_KEYS, MAXIMUM_OFFLINE_DURATION } from \"../constants\";\n\nlet checkOnlineInterval = null;\nlet requestErrorToasts = {};\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n (typeof response === \"string\" && isNotEmpty(response)) ||\n (typeof response === \"object\" && (response?.notice || response?.noticeCode));\n\nconst setAuthHeaders = () => {\n // @ts-ignore\n axios.defaults.headers = {\n [HEADERS_KEYS.accept]: \"application/json\",\n [HEADERS_KEYS.contentType]: \"application/json\",\n [HEADERS_KEYS.xCsrfToken]: document\n .querySelector('[name=\"csrf-token\"]')\n ?.getAttribute(\"content\"),\n };\n};\n\n// pipe function from ramda doesn't accept array of functions.\n// We can't use spread operator too. So this is a workaround.\nconst createPipe = functions => data =>\n functions.reduce((acc, fn) => fn(acc), data);\n\nconst transformResponseKeysToCamelCase = response => {\n const { transformResponseCase = true } = response.config;\n\n if (response.data && transformResponseCase) {\n response.data = keysToCamelCase(response.data);\n }\n\n return response;\n};\n\nconst transformErrorKeysToCamelCase = error => {\n const { transformResponseCase = true } = error.config ?? {};\n\n if (error.response?.data && transformResponseCase) {\n error.response.data = keysToCamelCase(error.response.data);\n }\n\n return error;\n};\n\nconst showSuccessToastr = response => {\n const {\n showToastr = true,\n url: requestUrl,\n method: requestMethod,\n } = response.config;\n if (!showToastr) return response;\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) {\n toast.dismiss(errorToastId);\n requestErrorToasts = dissoc(toastIdKey, requestErrorToasts);\n }\n\n if (matches({ showThumbsUpToastr: true }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (matches({ noticeCode: \"thumbs_up\" }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (shouldShowToastr(response.data)) {\n Toastr.success(response.data);\n }\n\n return response;\n};\n\nconst pullDataFromResponse = response => {\n const { includeMetadataInResponse = false } = response.config;\n\n return includeMetadataInResponse ? response : response.data;\n};\n\nconst buildSuccessResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformResponseKeysToCamelCase);\n\n if (!skip?.showToastr) interceptors.push(showSuccessToastr);\n\n if (!skip?.pullDataFromResponse) interceptors.push(pullDataFromResponse);\n\n return createPipe(interceptors);\n};\n\nconst handleUnauthorizedErrorResponse = error => {\n if (error.response?.status !== 401) return error;\n\n resetAuthTokens();\n\n const { redirectOnError = true } = error.config ?? {};\n if (redirectOnError) {\n setTimeout(() => {\n const redirectTo =\n window.location.pathname === \"/login\"\n ? \"/login\"\n : `/login?redirect_uri=${encodeURIComponent(window.location.href)}`;\n\n // eslint-disable-next-line xss/no-location-href-assign\n window.location.href = redirectTo;\n }, 300);\n }\n\n return error;\n};\n\nconst isOnline = () => window.navigator.onLine;\n\nconst showOfflineToastr = () => {\n const toastId = Toastr.error(\n i18next.t(\"neetoCommons.toastr.error.networkError\")\n );\n\n if (toastId) {\n const dismissToastInterval = setInterval(() => {\n if (!isOnline()) return;\n\n toast.dismiss(toastId);\n clearInterval(dismissToastInterval);\n checkOnlineInterval = null;\n }, 1000);\n }\n};\n\nconst handleNetworkError = error => {\n if (checkOnlineInterval) return error;\n\n const startTime = Date.now();\n\n checkOnlineInterval = setInterval(() => {\n const elapsedTime = Date.now() - startTime;\n\n if (isOnline()) {\n clearInterval(checkOnlineInterval);\n checkOnlineInterval = null;\n } else if (elapsedTime >= MAXIMUM_OFFLINE_DURATION) {\n clearInterval(checkOnlineInterval);\n showOfflineToastr();\n }\n }, 1000);\n\n return error;\n};\n\nconst showErrorToastr = error => {\n const {\n showToastr = true,\n show422ErrorToastr = true,\n url: requestUrl = \"\",\n method: requestMethod = \"\",\n } = error.config ?? {};\n const { status } = error.response ?? {};\n\n if (!showToastr) return error;\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n let shouldShowToastr = false,\n toastrContent = error;\n\n const skippedStatusCodes = [403, 404, 520, 422];\n if (!skippedStatusCodes.includes(status) && !axios.isCancel(error)) {\n // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.\n // We handle cloudflare error differently for production and other environments.\n shouldShowToastr = true;\n }\n\n if (status === 422 && show422ErrorToastr) shouldShowToastr = true;\n\n if (status === 520) {\n shouldShowToastr = true;\n if (globalProps.railsEnv === \"production\") {\n toastrContent = i18next.t(\"generic.error\");\n }\n }\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) toast.dismiss(errorToastId);\n\n if (shouldShowToastr) {\n if (errorToastId) {\n // if there's an existing toastr with the same message, the onClose callback in the neetoUI which\n // removes the toastr from the unique list will be fired only after the toast is completely removed\n // from the UI. If there's no delay, the new toastr will be considered as duplicate and ignored.\n setTimeout(() => {\n requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }, 1200);\n } else requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }\n\n return error;\n};\n\nconst getUrlPathName = url => {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\nconst handle404ErrorResponse = error => {\n const { show404ErrorPage = true, show403ErrorPage = true } =\n error.config ?? {};\n\n const status = error.response?.status;\n if (\n (status === 404 && show404ErrorPage) ||\n (status === 403 && show403ErrorPage)\n ) {\n const fullUrl = error.request?.responseURL || error.config.url;\n useErrorDisplayStore.setState({\n showErrorPage: true,\n statusCode: status,\n failedApiUrl: fullUrl,\n failedApiPath: getUrlPathName(fullUrl),\n });\n }\n\n return error;\n};\n\nconst buildErrorResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformErrorKeysToCamelCase);\n\n if (!skip?.show404ErrorPage) interceptors.push(handle404ErrorResponse);\n\n if (!skip?.logoutOn401) interceptors.push(handleUnauthorizedErrorResponse);\n\n if (!skip?.showToastr) interceptors.push(showErrorToastr);\n\n interceptors.push(Promise.reject.bind(Promise));\n\n return createPipe(interceptors);\n};\n\nconst cleanupCredentialsForCrossOrigin = request => {\n if (!request.url.includes(\"://\")) return request;\n\n if (request.url.includes(window.location.hostname)) return request;\n\n return evolve({ headers: omit([HEADERS_KEYS.xCsrfToken]) })(request);\n};\n\nconst transformDataToSnakeCase = request => {\n const { transformRequestCase = true } = request;\n\n if (!transformRequestCase) return request;\n\n return evolve(\n { data: serializeKeysToSnakeCase, params: serializeKeysToSnakeCase },\n request\n );\n};\n\nconst addRequestInterceptors = skip => {\n if (!skip?.cleanCredentialsForCrossOrigin) {\n axios.interceptors.request.use(cleanupCredentialsForCrossOrigin);\n }\n\n if (!skip?.transformCase) {\n axios.interceptors.request.use(transformDataToSnakeCase);\n }\n};\n\nconst addResponseInterceptors = skip => {\n axios.interceptors.response.use(\n buildSuccessResponseHandler(skip),\n buildErrorResponseHandler(skip)\n );\n};\n\nconst registerIntercepts = skip => {\n if (shouldNot(skip?.request)) addRequestInterceptors(skip?.request);\n\n if (shouldNot(skip?.response)) addResponseInterceptors(skip?.response);\n};\n\nexport default function initializeAxios(skip) {\n if (!skip?.baseURL) axios.defaults.baseURL = \"/\";\n\n if (!skip?.authHeaders) setAuthHeaders();\n\n if (!skip?.paramsSerializer) setParamsSerializer();\n\n if (shouldNot(skip?.interceptors)) registerIntercepts(skip?.interceptors);\n}\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,SAAS;AAC7B,SACEC,UAAU,EACVC,eAAe,EACfC,OAAO,EACPC,wBAAwB;AACP,OAAAC,MAAA;AAGnB,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,oBAAoB;AAC7B,SAASC,eAAe;AAExB,OAAOC,mBAAmB;AAE1B,SAASC,YAAY,EAAEC,wBAAwB;AAE/C,IAAIC,mBAAmB,GAAG,IAAI;AAC9B,IAAIC,kBAAkB,GAAG,CAAC,CAAC;AAE3B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,IAAI;EAAA,OAAIC,OAAA,CAAOD,IAAI,MAAK,QAAQ,IAAI,CAACA,IAAI;AAAA;AAE3D,IAAME,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAGC,QAAQ;EAAA,OAC9B,OAAOA,QAAQ,KAAK,QAAQ,IAAIjB,UAAU,CAACiB,QAAQ,CAAC,IACpDF,OAAA,CAAOE,QAAQ,MAAK,QAAQ,KAAK,CAAAA,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEC,MAAM,MAAID,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,UAAU,EAAE;AAAA;AAE9E,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAA,EAAS;EAAA,IAAAC,qBAAA;EAC3B;EACAvB,KAAK,CAACwB,QAAQ,CAACC,OAAO,GAAAC,eAAA,CAAAA,eAAA,CAAAA,eAAA,KACnBf,YAAY,CAACgB,MAAM,EAAG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C5C,IAAI,EAACA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE8I,OAAO,GAAE9J,KAAK,CAACwB,QAAQ,CAACsI,OAAO,GAAG,GAAG;EAEhD,IAAI,EAAC9I,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE+I,WAAW,GAAEzI,cAAc,CAAC,CAAC;EAExC,IAAI,EAACN,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEgJ,gBAAgB,GAAEtJ,mBAAmB,CAAC,CAAC;EAElD,IAAIK,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEsD,YAAY,CAAC,EAAEsF,kBAAkB,CAAC5I,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEsD,YAAY,CAAC;AAC3E","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["axios","i18next","isNotEmpty","keysToCamelCase","matches","serializeKeysToSnakeCase","Toastr","dissoc","evolve","omit","toast","useErrorDisplayStore","resetAuthTokens","setParamsSerializer","HEADERS_KEYS","MAXIMUM_OFFLINE_DURATION","checkOnlineInterval","requestErrorToasts","shouldNot","skip","_typeof","shouldShowToastr","response","notice","noticeCode","setAuthHeaders","_document$querySelect","defaults","headers","_defineProperty","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config","_response$config$show","showToastr","requestUrl","url","requestMethod","method","toastIdKey","concat","errorToastId","dismiss","showThumbsUpToastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","t","dismissToastInterval","setInterval","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref3$show422ErrorToa","show422ErrorToastr","_ref3$url","_ref3$method","_ref4","message","code","toastrContent","skippedStatusCodes","includes","isCancel","globalProps","railsEnv","getUrlPathName","URL","_unused","handle404ErrorResponse","_error$config4","_error$response4","_ref5","_ref5$show404ErrorPag","show404ErrorPage","_ref5$show403ErrorPag","show403ErrorPage","_error$request","fullUrl","request","responseURL","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","transformDataToSnakeCase","_request$transformReq","transformRequestCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer"],"sources":["../../../src/initializers/axiosInitializer/index.js"],"sourcesContent":["import axios from \"axios\";\nimport i18next from \"i18next\";\nimport {\n isNotEmpty,\n keysToCamelCase,\n matches,\n serializeKeysToSnakeCase,\n} from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { dissoc, evolve, omit } from \"ramda\";\nimport { toast } from \"react-toastify\";\nimport { useErrorDisplayStore } from \"react-utils/useDisplayErrorPage\";\nimport { resetAuthTokens } from \"utils/axios\";\n\nimport setParamsSerializer from \"./paramsSerializer\";\n\nimport { HEADERS_KEYS, MAXIMUM_OFFLINE_DURATION } from \"../constants\";\n\nlet checkOnlineInterval = null;\nlet requestErrorToasts = {};\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n (typeof response === \"string\" && isNotEmpty(response)) ||\n (typeof response === \"object\" && (response?.notice || response?.noticeCode));\n\nconst setAuthHeaders = () => {\n // @ts-ignore\n axios.defaults.headers = {\n [HEADERS_KEYS.accept]: \"application/json\",\n [HEADERS_KEYS.contentType]: \"application/json\",\n [HEADERS_KEYS.xCsrfToken]: document\n .querySelector('[name=\"csrf-token\"]')\n ?.getAttribute(\"content\"),\n };\n};\n\n// pipe function from ramda doesn't accept array of functions.\n// We can't use spread operator too. So this is a workaround.\nconst createPipe = functions => data =>\n functions.reduce((acc, fn) => fn(acc), data);\n\nconst transformResponseKeysToCamelCase = response => {\n const { transformResponseCase = true } = response.config;\n\n if (response.data && transformResponseCase) {\n response.data = keysToCamelCase(response.data);\n }\n\n return response;\n};\n\nconst transformErrorKeysToCamelCase = error => {\n const { transformResponseCase = true } = error.config ?? {};\n\n if (error.response?.data && transformResponseCase) {\n error.response.data = keysToCamelCase(error.response.data);\n }\n\n return error;\n};\n\nconst showSuccessToastr = response => {\n const {\n showToastr = true,\n url: requestUrl,\n method: requestMethod,\n } = response.config;\n if (!showToastr) return response;\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) {\n toast.dismiss(errorToastId);\n requestErrorToasts = dissoc(toastIdKey, requestErrorToasts);\n }\n\n if (matches({ showThumbsUpToastr: true }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (matches({ noticeCode: \"thumbs_up\" }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (shouldShowToastr(response.data)) {\n Toastr.success(response.data);\n }\n\n return response;\n};\n\nconst pullDataFromResponse = response => {\n const { includeMetadataInResponse = false } = response.config;\n\n return includeMetadataInResponse ? response : response.data;\n};\n\nconst buildSuccessResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformResponseKeysToCamelCase);\n\n if (!skip?.showToastr) interceptors.push(showSuccessToastr);\n\n if (!skip?.pullDataFromResponse) interceptors.push(pullDataFromResponse);\n\n return createPipe(interceptors);\n};\n\nconst handleUnauthorizedErrorResponse = error => {\n if (error.response?.status !== 401) return error;\n\n resetAuthTokens();\n\n const { redirectOnError = true } = error.config ?? {};\n if (redirectOnError) {\n setTimeout(() => {\n const redirectTo =\n window.location.pathname === \"/login\"\n ? \"/login\"\n : `/login?redirect_uri=${encodeURIComponent(window.location.href)}`;\n\n // eslint-disable-next-line xss/no-location-href-assign\n window.location.href = redirectTo;\n }, 300);\n }\n\n return error;\n};\n\nconst isOnline = () => window.navigator.onLine;\n\nconst showOfflineToastr = () => {\n const toastId = Toastr.error(\n i18next.t(\"neetoCommons.toastr.error.networkError\")\n );\n\n if (toastId) {\n const dismissToastInterval = setInterval(() => {\n if (!isOnline()) return;\n\n toast.dismiss(toastId);\n clearInterval(dismissToastInterval);\n checkOnlineInterval = null;\n }, 1000);\n }\n};\n\nconst handleNetworkError = error => {\n if (checkOnlineInterval) return error;\n\n const startTime = Date.now();\n\n checkOnlineInterval = setInterval(() => {\n const elapsedTime = Date.now() - startTime;\n\n if (isOnline()) {\n clearInterval(checkOnlineInterval);\n checkOnlineInterval = null;\n } else if (elapsedTime >= MAXIMUM_OFFLINE_DURATION) {\n clearInterval(checkOnlineInterval);\n showOfflineToastr();\n }\n }, 1000);\n\n return error;\n};\n\nconst showErrorToastr = error => {\n const {\n showToastr = true,\n show422ErrorToastr = true,\n url: requestUrl = \"\",\n method: requestMethod = \"\",\n } = error.config ?? {};\n const { status } = error.response ?? {};\n\n if (!showToastr) return error;\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n let shouldShowToastr = false,\n toastrContent = error;\n\n const skippedStatusCodes = [403, 404, 520, 422];\n if (!skippedStatusCodes.includes(status) && !axios.isCancel(error)) {\n // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.\n // We handle cloudflare error differently for production and other environments.\n shouldShowToastr = true;\n }\n\n if (status === 422 && show422ErrorToastr) shouldShowToastr = true;\n\n if (status === 520) {\n shouldShowToastr = true;\n if (globalProps.railsEnv === \"production\") {\n toastrContent = i18next.t(\"generic.error\");\n }\n }\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) toast.dismiss(errorToastId);\n\n if (shouldShowToastr) {\n if (errorToastId) {\n // if there's an existing toastr with the same message, the onClose callback in the neetoUI which\n // removes the toastr from the unique list will be fired only after the toast is completely removed\n // from the UI. If there's no delay, the new toastr will be considered as duplicate and ignored.\n setTimeout(() => {\n requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }, 1200);\n } else requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }\n\n return error;\n};\n\nconst getUrlPathName = url => {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\nconst handle404ErrorResponse = error => {\n const { show404ErrorPage = true, show403ErrorPage = true } =\n error.config ?? {};\n\n const status = error.response?.status;\n if (\n (status === 404 && show404ErrorPage) ||\n (status === 403 && show403ErrorPage)\n ) {\n const fullUrl = error.request?.responseURL || error.config.url;\n useErrorDisplayStore.setState({\n showErrorPage: true,\n statusCode: status,\n failedApiUrl: fullUrl,\n failedApiPath: getUrlPathName(fullUrl),\n });\n }\n\n return error;\n};\n\nconst buildErrorResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformErrorKeysToCamelCase);\n\n if (!skip?.show404ErrorPage) interceptors.push(handle404ErrorResponse);\n\n if (!skip?.logoutOn401) interceptors.push(handleUnauthorizedErrorResponse);\n\n if (!skip?.showToastr) interceptors.push(showErrorToastr);\n\n interceptors.push(Promise.reject.bind(Promise));\n\n return createPipe(interceptors);\n};\n\nconst cleanupCredentialsForCrossOrigin = request => {\n if (!request.url.includes(\"://\")) return request;\n\n if (request.url.includes(window.location.hostname)) return request;\n\n return evolve({ headers: omit([HEADERS_KEYS.xCsrfToken]) })(request);\n};\n\nconst transformDataToSnakeCase = request => {\n const { transformRequestCase = true } = request;\n\n if (!transformRequestCase) return request;\n\n return evolve(\n { data: serializeKeysToSnakeCase, params: serializeKeysToSnakeCase },\n request\n );\n};\n\nconst addRequestInterceptors = skip => {\n if (!skip?.cleanCredentialsForCrossOrigin) {\n axios.interceptors.request.use(cleanupCredentialsForCrossOrigin);\n }\n\n if (!skip?.transformCase) {\n axios.interceptors.request.use(transformDataToSnakeCase);\n }\n};\n\nconst addResponseInterceptors = skip => {\n axios.interceptors.response.use(\n buildSuccessResponseHandler(skip),\n buildErrorResponseHandler(skip)\n );\n};\n\nconst registerIntercepts = skip => {\n if (shouldNot(skip?.request)) addRequestInterceptors(skip?.request);\n\n if (shouldNot(skip?.response)) addResponseInterceptors(skip?.response);\n};\n\nexport default function initializeAxios(skip) {\n if (!skip?.baseURL) axios.defaults.baseURL = \"/\";\n\n if (!skip?.authHeaders) setAuthHeaders();\n\n if (!skip?.paramsSerializer) setParamsSerializer();\n\n if (shouldNot(skip?.interceptors)) registerIntercepts(skip?.interceptors);\n}\n"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,SAAS;AAC7B,SACEC,UAAU,EACVC,eAAe,EACfC,OAAO,EACPC,wBAAwB;AACP,OAAAC,MAAA;AAEnB,SAASC,MAAM,EAAEC,MAAM,EAAEC,IAAI,QAAQ,OAAO;AAC5C,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,oBAAoB;AAC7B,SAASC,eAAe;AAExB,OAAOC,mBAAmB;AAE1B,SAASC,YAAY,EAAEC,wBAAwB;AAE/C,IAAIC,mBAAmB,GAAG,IAAI;AAC9B,IAAIC,kBAAkB,GAAG,CAAC,CAAC;AAE3B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,IAAI;EAAA,OAAIC,OAAA,CAAOD,IAAI,MAAK,QAAQ,IAAI,CAACA,IAAI;AAAA;AAE3D,IAAME,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAGC,QAAQ;EAAA,OAC9B,OAAOA,QAAQ,KAAK,QAAQ,IAAIpB,UAAU,CAACoB,QAAQ,CAAC,IACpDF,OAAA,CAAOE,QAAQ,MAAK,QAAQ,KAAK,CAAAA,QAAQ,aAARA,QAA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sBAAsB,CAACrI,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEmH,OAAO,CAAC;EAEnE,IAAIpH,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,QAAQ,CAAC,EAAEqI,uBAAuB,CAACxI,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,QAAQ,CAAC;AACxE,CAAC;AAED,eAAe,SAASuI,eAAeA,CAAC1I,IAAI,EAAE;EAC5C,IAAI,EAACA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE2I,OAAO,GAAE9J,KAAK,CAAC2B,QAAQ,CAACmI,OAAO,GAAG,GAAG;EAEhD,IAAI,EAAC3I,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE4I,WAAW,GAAEtI,cAAc,CAAC,CAAC;EAExC,IAAI,EAACN,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE6I,gBAAgB,GAAEnJ,mBAAmB,CAAC,CAAC;EAElD,IAAIK,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEqD,YAAY,CAAC,EAAEoF,kBAAkB,CAACzI,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEqD,YAAY,CAAC;AAC3E","ignoreList":[]}
|
package/initializers/i18n.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _mergeDeepLeft from "ramda/es/mergeDeepLeft";
|
|
2
1
|
import i18n from "i18next";
|
|
3
2
|
import LanguageDetector from "i18next-browser-languagedetector";
|
|
3
|
+
import { mergeDeepLeft } from "ramda";
|
|
4
4
|
import { initReactI18next } from "react-i18next";
|
|
5
5
|
import { LIST_FORMATS } from "./constants";
|
|
6
6
|
import { listFormatter, lowerCaseDynamicTextFormatter } from "./utils/customFormatters";
|
|
@@ -19,7 +19,7 @@ var initializeI18n = function initializeI18n(hostTranslations) {
|
|
|
19
19
|
translation: commonsEn
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
var resources = [hostTranslations, commonsTranslations, packageTranslations].reduce(
|
|
22
|
+
var resources = [hostTranslations, commonsTranslations, packageTranslations].reduce(mergeDeepLeft);
|
|
23
23
|
var defaultTaxonomyKeys = Object.keys(resources.en.translation.taxonomyDefaultLabels || {});
|
|
24
24
|
var defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(function (key) {
|
|
25
25
|
return [key, {
|
|
@@ -28,7 +28,7 @@ var initializeI18n = function initializeI18n(hostTranslations) {
|
|
|
28
28
|
}];
|
|
29
29
|
}));
|
|
30
30
|
var hostTaxonomies = ((_window$globalProps = window.globalProps) === null || _window$globalProps === void 0 ? void 0 : _window$globalProps.taxonomies) || {};
|
|
31
|
-
taxonomies = replaceNullValuesWithGetter(
|
|
31
|
+
taxonomies = replaceNullValuesWithGetter(mergeDeepLeft(hostTaxonomies, defaultTaxonomies));
|
|
32
32
|
i18n.use(LanguageDetector).use(initReactI18next).use(sentenceCaseProcessor).init({
|
|
33
33
|
resources: resources,
|
|
34
34
|
fallbackLng: "en",
|
package/initializers/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":["i18n","LanguageDetector","initReactI18next","LIST_FORMATS","listFormatter","lowerCaseDynamicTextFormatter","sentenceCaseProcessor","replaceNullValuesWithGetter","commonsEn","taxonomies","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","require","commonsTranslations","en","translation","resources","reduce","
|
|
1
|
+
{"version":3,"file":"i18n.js","names":["i18n","LanguageDetector","mergeDeepLeft","initReactI18next","LIST_FORMATS","listFormatter","lowerCaseDynamicTextFormatter","sentenceCaseProcessor","replaceNullValuesWithGetter","commonsEn","taxonomies","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","require","commonsTranslations","en","translation","resources","reduce","defaultTaxonomyKeys","Object","keys","taxonomyDefaultLabels","defaultTaxonomies","fromEntries","map","key","singular","plural","hostTaxonomies","window","globalProps","use","init","fallbackLng","interpolation","defaultVariables","escapeValue","skipOnVariables","alwaysFormat","format","value","lng","options","newValue","includes","postProcess","name","detection","order","caches","lookupQuerystring","lookupCookie"],"sources":["../../src/initializers/i18n.js"],"sourcesContent":["import i18n from \"i18next\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { initReactI18next } from \"react-i18next\";\n\nimport { LIST_FORMATS } from \"./constants\";\nimport {\n listFormatter,\n lowerCaseDynamicTextFormatter,\n} from \"./utils/customFormatters\";\nimport { sentenceCaseProcessor } from \"./utils/customPostProcessors\";\nimport { replaceNullValuesWithGetter } from \"./utils/utils\";\n\nimport commonsEn from \"../translations/en.json\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet taxonomies = {};\n\nconst initializeI18n = hostTranslations => {\n // eslint-disable-next-line no-undef\n const packageTranslations = preval.require(\n \"../configs/scripts/getPkgTranslations.js\"\n );\n\n const commonsTranslations = { en: { translation: commonsEn } };\n\n const resources = [\n hostTranslations,\n commonsTranslations,\n packageTranslations,\n ].reduce(mergeDeepLeft);\n\n const defaultTaxonomyKeys = Object.keys(\n resources.en.translation.taxonomyDefaultLabels || {}\n );\n\n const defaultTaxonomies = Object.fromEntries(\n defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }])\n );\n\n const hostTaxonomies = window.globalProps?.taxonomies || {};\n\n taxonomies = replaceNullValuesWithGetter(\n mergeDeepLeft(hostTaxonomies, defaultTaxonomies)\n );\n\n i18n\n .use(LanguageDetector)\n .use(initReactI18next)\n .use(sentenceCaseProcessor)\n .init({\n resources,\n fallbackLng: \"en\",\n interpolation: {\n defaultVariables: { taxonomies },\n escapeValue: false,\n skipOnVariables: false,\n alwaysFormat: true,\n format: (value, format, lng, options) => {\n let newValue = value;\n\n if (LIST_FORMATS.includes(format)) {\n newValue = listFormatter({ value: newValue, format, lng, options });\n\n return newValue;\n }\n\n return lowerCaseDynamicTextFormatter(newValue, format);\n },\n },\n postProcess: [sentenceCaseProcessor.name],\n detection: {\n order: [\"querystring\", \"cookie\", \"navigator\", \"path\"],\n caches: [\"cookie\"],\n lookupQuerystring: \"lang\",\n lookupCookie: \"lang\",\n },\n });\n};\n\nexport { taxonomies };\n\nexport default initializeI18n;\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,SAAS;AAC1B,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,aAAa,QAAQ,OAAO;AACrC,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,SAASC,YAAY;AACrB,SACEC,aAAa,EACbC,6BAA6B;AAE/B,SAASC,qBAAqB;AAC9B,SAASC,2BAA2B;AAEpC,OAAOC,SAAS;;AAEhB;AACA,IAAIC,UAAU,GAAG,CAAC,CAAC;AAEnB,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,gBAAgB,EAAI;EAAA,IAAAC,mBAAA;EACzC;EACA,IAAMC,mBAAmB,GAAGC,MAAM,CAACC,OAAO,CACxC,0CACF,CAAC;EAED,IAAMC,mBAAmB,GAAG;IAAEC,EAAE,EAAE;MAAEC,WAAW,EAAEV;IAAU;EAAE,CAAC;EAE9D,IAAMW,SAAS,GAAG,CAChBR,gBAAgB,EAChBK,mBAAmB,EACnBH,mBAAmB,CACpB,CAACO,MAAM,CAACnB,aAAa,CAAC;EAEvB,IAAMoB,mBAAmB,GAAGC,MAAM,CAACC,IAAI,CACrCJ,SAAS,CAACF,EAAE,CAACC,WAAW,CAACM,qBAAqB,IAAI,CAAC,CACrD,CAAC;EAED,IAAMC,iBAAiB,GAAGH,MAAM,CAACI,WAAW,CAC1CL,mBAAmB,CAACM,GAAG,CAAC,UAAAC,GAAG;IAAA,OAAI,CAACA,GAAG,EAAE;MAAEC,QAAQ,EAAE,IAAI;MAAEC,MAAM,EAAE;IAAK,CAAC,CAAC;EAAA,EACxE,CAAC;EAED,IAAMC,cAAc,GAAG,EAAAnB,mBAAA,GAAAoB,MAAM,CAACC,WAAW,cAAArB,mBAAA,uBAAlBA,mBAAA,CAAoBH,UAAU,KAA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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.3",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _isNil from "ramda/es/isNil";
|
|
3
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
4
|
import React from "react";
|
|
@@ -38,6 +37,7 @@ FallbackComponentImage.defaultProps = {
|
|
|
38
37
|
import { sanitize } from "dompurify";
|
|
39
38
|
import Button from "@bigbinary/neetoui/Button";
|
|
40
39
|
import Typography from "@bigbinary/neetoui/Typography";
|
|
40
|
+
import { isNil } from "ramda";
|
|
41
41
|
import { Trans, useTranslation } from "react-i18next";
|
|
42
42
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
43
43
|
var FallbackComponent = function FallbackComponent() {
|
|
@@ -46,7 +46,7 @@ var FallbackComponent = function FallbackComponent() {
|
|
|
46
46
|
useEffect(function () {
|
|
47
47
|
var listener = function listener(e) {
|
|
48
48
|
var _e$target;
|
|
49
|
-
if (
|
|
49
|
+
if (isNil(e.state)) return;
|
|
50
50
|
window.location.href = sanitize((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.location.href);
|
|
51
51
|
};
|
|
52
52
|
window.addEventListener("popstate", listener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FallbackComponent.js","names":["useEffect","FallbackComponentImage","props","_jsxs","_objectSpread","children","_jsx","d","fill","defaultProps","width","height","viewBox","xmlns","sanitize","Button","Typography","Trans","useTranslation","jsx","jsxs","FallbackComponent","_useTranslation","t","listener","e","_e$target","
|
|
1
|
+
{"version":3,"file":"FallbackComponent.js","names":["useEffect","FallbackComponentImage","props","_jsxs","_objectSpread","children","_jsx","d","fill","defaultProps","width","height","viewBox","xmlns","sanitize","Button","Typography","isNil","Trans","useTranslation","jsx","jsxs","FallbackComponent","_useTranslation","t","listener","e","_e$target","state","window","location","href","target","addEventListener","removeEventListener","className","component","style","weight","i18nKey","components","reloading","onClick","reload","contactus","_window$NeetoChat","_window$NeetoChat$con","_window$NeetoChat2","_window$NeetoChat2$co","NeetoChat","contextualHelp","maximizeWidget","openWidget"],"sources":["../../../src/react-utils/HoneybadgerErrorBoundary/FallbackComponent.jsx"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport FallbackComponentImage from \"assets/images/fallback-component.svg\";\nimport { sanitize } from \"dompurify\";\nimport { Button, Typography } from \"neetoui\";\nimport { isNil } from \"ramda\";\nimport { Trans, useTranslation } from \"react-i18next\";\n\nconst FallbackComponent = () => {\n const { t } = useTranslation();\n\n useEffect(() => {\n const listener = e => {\n if (isNil(e.state)) return;\n window.location.href = sanitize(e.target?.location.href);\n };\n window.addEventListener(\"popstate\", listener);\n\n return () => window.removeEventListener(\"popstate\", listener);\n }, []);\n\n return (\n <div className=\"flex h-screen w-full flex-row items-start justify-start\">\n <div className=\"m-auto text-center\">\n <div className=\"m-auto mb-8 flex items-center justify-center\">\n <FallbackComponentImage />\n </div>\n <Typography\n className=\"mb-4\"\n component=\"h2\"\n style=\"h2\"\n weight=\"semibold\"\n >\n {t(\"neetoCommons.fallbackComponent.somethingWentWrong\")}\n </Typography>\n <Typography\n className=\"neeto-ui-text-gray-600 mb-8\"\n component=\"p\"\n style=\"body1\"\n weight=\"normal\"\n >\n <Trans\n i18nKey=\"neetoCommons.fallbackComponent.description\"\n components={{\n reloading: (\n <Button style=\"link\" onClick={() => window.location.reload()} />\n ),\n contactus: (\n <Button\n style=\"link\"\n onClick={() => {\n window.NeetoChat?.contextualHelp?.maximizeWidget();\n window.NeetoChat?.contextualHelp?.openWidget();\n }}\n />\n ),\n }}\n />\n </Typography>\n </div>\n </div>\n );\n};\n\nexport default FallbackComponent;\n"],"mappings":";;;;AAAA,SAASA,SAAS,QAAQ,OAAO;AAAC,IAE3BC,sBAAsB,YAAtBA,sBAAsBA,CAAAC,KAAA;EAAA,oBAAAC,KAAA,QAAAC,aAAA,CAAAA,aAAA,KAAAF,KAAA;IAAAG,QAAA,gBAAAC,IAAA;MAAAC,CAAA;MAAAC,IAAA;IAAA,iBAAAF,IAAA;MAAAC,CAAA;MAAAC,IAAA;IAAA,iBAAAF,IAAA;MAAAC,CAAA;MAAAC,IAAA;IAAA,iBAAAF,IAAA;MAAAC,CAAA;MAAAC,IAAA;IAAA,iBAAAF,IAAA;MAAAC,CAAA;MAAAC,IAAA;IAAA,iBAAAF,IAAA;MAAAC,CAAA;MAAAC,IAAA;IAAA;EAAA;AAAA;AAAtBP,sBAAsB,CAAAQ,YAAA;EAAAC,KAAA;EAAAC,MAAA;EAAAC,OAAA;EAAAJ,IAAA;EAAA;EAAAK,KAAA;AAAA;AAC7B,SAASC,QAAQ,QAAQ,WAAW;AAAC,OAAAC,MAAA;AAAA,OAAAC,UAAA;AAErC,SAASC,KAAK,QAAQ,OAAO;AAC7B,SAASC,KAAK,EAAEC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAd,IAAA,EA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,IAAA,CAACY,KAAK;UACJqB,OAAO,EAAC,4CAA4C;UACpDC,UAAU,EAAE;YACVC,SAAS,eACPnC,IAAA,CAACS,MAAM;cAACsB,KAAK,EAAC,MAAM;cAACK,OAAO,EAAE,SAATA,OAAOA,CAAA;gBAAA,OAAQb,MAAM,CAACC,QAAQ,CAACa,MAAM,CAAC,CAAC;cAAA;YAAC,CAAE,CAChE;YACDC,SAAS,eACPtC,IAAA,CAACS,MAAM;cACLsB,KAAK,EAAC,MAAM;cACZK,OAAO,EAAE,SAATA,OAAOA,CAAA,EAAQ;gBAAA,IAAAG,iBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA;gBACb,CAAAH,iBAAA,GAAAhB,MAAM,CAACoB,SAAS,cAAAJ,iBAAA,wBAAAC,qBAAA,GAAhBD,iBAAA,CAAkBK,cAAc,cAAAJ,qBAAA,uBAAhCA,qBAAA,CAAkCK,cAAc,CAAC,CAAC;gBAClD,CAAAJ,kBAAA,GAAAlB,MAAM,CAACoB,SAAS,cAAAF,kBAAA,wBAAAC,qBAAA,GAAhBD,kBAAA,CAAkBG,cAAc,cAAAF,qBAAA,uBAAhCA,qBAAA,CAAkCI,UAAU,CAAC,CAAC;cAChD;YAAE,CACH;UAEL;QAAE,CACH;MAAC,CACQ,CAAC;IAAA,CACV;EAAC,CACH,CAAC;AAEV,CAAC;AAED,eAAe9B,iBAAiB","ignoreList":[]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _ from "ramda/es/__";
|
|
3
|
-
import _includes from "ramda/es/includes";
|
|
4
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
3
|
var _excluded = ["condition", "redirectRoute", "errorPage", "permissions"];
|
|
6
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
6
|
import ErrorPage from "@bigbinary/neeto-molecules/ErrorPage";
|
|
7
|
+
import { __, includes } from "ramda";
|
|
9
8
|
import { Redirect, Route } from "react-router-dom";
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
10
|
var PrivateRoute = function PrivateRoute(_ref) {
|
|
@@ -20,7 +19,7 @@ var PrivateRoute = function PrivateRoute(_ref) {
|
|
|
20
19
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
20
|
if (condition) {
|
|
22
21
|
if (permissions) {
|
|
23
|
-
return globalProps.permissions.some(
|
|
22
|
+
return globalProps.permissions.some(includes(__, permissions)) ? /*#__PURE__*/_jsx(Route, _objectSpread({}, props)) : errorPage || /*#__PURE__*/_jsx(ErrorPage, {
|
|
24
23
|
status: 403
|
|
25
24
|
});
|
|
26
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateRoute.js","names":["ErrorPage","Redirect","Route","jsx","_jsx","PrivateRoute","_ref","_ref$condition","condition","globalProps","authenticated","_ref$redirectRoute","redirectRoute","undefined","_ref$errorPage","errorPage","_ref$permissions","permissions","props","_objectWithoutProperties","_excluded","some","
|
|
1
|
+
{"version":3,"file":"PrivateRoute.js","names":["ErrorPage","__","includes","Redirect","Route","jsx","_jsx","PrivateRoute","_ref","_ref$condition","condition","globalProps","authenticated","_ref$redirectRoute","redirectRoute","undefined","_ref$errorPage","errorPage","_ref$permissions","permissions","props","_objectWithoutProperties","_excluded","some","_objectSpread","status","to","pathname"],"sources":["../../../src/react-utils/PrivateRoute/PrivateRoute.jsx"],"sourcesContent":["import ErrorPage from \"neetomolecules/ErrorPage\";\nimport { __, includes } from \"ramda\";\nimport { Redirect, Route } from \"react-router-dom\";\n\nconst PrivateRoute = ({\n condition = globalProps.authenticated,\n redirectRoute = undefined,\n errorPage = undefined,\n permissions = undefined,\n ...props\n}) => {\n if (condition) {\n if (permissions) {\n return globalProps.permissions.some(includes(__, permissions)) ? (\n <Route {...props} />\n ) : (\n errorPage || <ErrorPage status={403} />\n );\n }\n\n return <Route {...props} />;\n }\n\n if (redirectRoute) {\n return <Redirect to={{ pathname: redirectRoute }} />;\n }\n\n return errorPage || <ErrorPage status={403} />;\n};\n\nexport default PrivateRoute;\n"],"mappings":";;;;;AAAA,OAAOA,SAAS;AAChB,SAASC,EAAE,EAAEC,QAAQ,QAAQ,OAAO;AACpC,SAASC,QAAQ,EAAEC,KAAK,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnD,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAMZ;EAAA,IAAAC,cAAA,GAAAD,IAAA,CALJE,SAAS;IAATA,SAAS,GAAAD,cAAA,cAAGE,WAAW,CAACC,aAAa,GAAAH,cAAA;IAAAI,kBAAA,GAAAL,IAAA,CACrCM,aAAa;IAAbA,aAAa,GAAAD,kBAAA,cAAGE,SAAS,GAAAF,kBAAA;IAAAG,cAAA,GAAAR,IAAA,CACzBS,SAAS;IAATA,SAAS,GAAAD,cAAA,cAAGD,SAAS,GAAAC,cAAA;IAAAE,gBAAA,GAAAV,IAAA,CACrBW,WAAW;IAAXA,WAAW,GAAAD,gBAAA,cAAGH,SAAS,GAAAG,gBAAA;IACpBE,KAAK,GAAAC,wBAAA,CAAAb,IAAA,EAAAc,SAAA;EAER,IAAIZ,SAAS,EAAE;IACb,IAAIS,WAAW,EAAE;MACf,OAAOR,WAAW,CAACQ,WAAW,CAACI,IAAI,CAACrB,QAAQ,CAACD,EAAE,EAAEkB,WAAW,CAAC,CAAC,gBAC5Db,IAAA,CAACF,KAAK,EAAAoB,aAAA,KAAKJ,KAAK,CAAG,CAAC,GAEpBH,SAAS,iBAAIX,IAAA,CAACN,SAAS;QAACyB,MAAM,EAAE;MAAI,CAAE,CACvC;IACH;IAEA,oBAAOnB,IAAA,CAACF,KAAK,EAAAoB,aAAA,KAAKJ,KAAK,CAAG,CAAC;EAC7B;EAEA,IAAIN,aAAa,EAAE;IACjB,oBAAOR,IAAA,CAACH,QAAQ;MAACuB,EAAE,EAAE;QAAEC,QAAQ,EAAEb;MAAc;IAAE,CAAE,CAAC;EACtD;EAEA,OAAOG,SAAS,iBAAIX,IAAA,CAACN,SAAS;IAACyB,MAAM,EAAE;EAAI,CAAE,CAAC;AAChD,CAAC;AAED,eAAelB,YAAY","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export var handleMetaClick =
|
|
1
|
+
import { curry } from "ramda";
|
|
2
|
+
export var handleMetaClick = curry(function (history, params, event) {
|
|
3
3
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
4
4
|
if (isMetaKeyPressed(event)) {
|
|
5
5
|
return window.open(params.pathname || params, "_blank");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metaClick.js","names":["
|
|
1
|
+
{"version":3,"file":"metaClick.js","names":["curry","handleMetaClick","history","params","event","options","arguments","length","undefined","isMetaKeyPressed","window","open","pathname","_options$isHistoryRep","isHistoryReplace","historyMethod","replace","push","ctrlKey","metaKey"],"sources":["../../../src/react-utils/metaClick/metaClick.js"],"sourcesContent":["import { curry } from \"ramda\";\n\nexport const handleMetaClick = curry((history, params, event, options = {}) => {\n if (isMetaKeyPressed(event)) {\n return window.open(params.pathname || params, \"_blank\");\n }\n\n const { isHistoryReplace = false } = options;\n const historyMethod = isHistoryReplace ? history.replace : history.push;\n\n return historyMethod(params);\n});\n\nexport const isMetaKeyPressed = event => !!(event?.ctrlKey || event?.metaKey);\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,OAAO;AAE7B,OAAO,IAAMC,eAAe,GAAGD,KAAK,CAAC,UAACE,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAmB;EAAA,IAAjBC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACxE,IAAIG,gBAAgB,CAACL,KAAK,CAAC,EAAE;IAC3B,OAAOM,MAAM,CAACC,IAAI,CAACR,MAAM,CAACS,QAAQ,IAAIT,MAAM,EAAE,QAAQ,CAAC;EACzD;EAEA,IAAAU,qBAAA,GAAqCR,OAAO,CAApCS,gBAAgB;IAAhBA,gBAAgB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;EAChC,IAAME,aAAa,GAAGD,gBAAgB,GAAGZ,OAAO,CAACc,OAAO,GAAGd,OAAO,CAACe,IAAI;EAEvE,OAAOF,aAAa,CAACZ,MAAM,CAAC;AAC9B,CAAC,CAAC;AAEF,OAAO,IAAMM,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAGL,KAAK;EAAA,OAAI,CAAC,EAAEA,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEc,OAAO,IAAId,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEe,OAAO,CAAC;AAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _equals from "ramda/es/equals";
|
|
2
1
|
import { useSyncExternalStore } from "react";
|
|
2
|
+
import { equals } from "ramda";
|
|
3
3
|
import { getCurrentSize, subscribe } from "./utils";
|
|
4
4
|
var useBreakpoints = function useBreakpoints(breakpointOverrides) {
|
|
5
5
|
var getSnapshot = function getSnapshot() {
|
|
@@ -8,7 +8,7 @@ var useBreakpoints = function useBreakpoints(breakpointOverrides) {
|
|
|
8
8
|
var currentSize = useSyncExternalStore(subscribe, getSnapshot);
|
|
9
9
|
return {
|
|
10
10
|
currentSize: currentSize,
|
|
11
|
-
isSize:
|
|
11
|
+
isSize: equals(currentSize)
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
export default useBreakpoints;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useSyncExternalStore","getCurrentSize","subscribe","useBreakpoints","breakpointOverrides","getSnapshot","window","currentSize","isSize"
|
|
1
|
+
{"version":3,"file":"index.js","names":["useSyncExternalStore","equals","getCurrentSize","subscribe","useBreakpoints","breakpointOverrides","getSnapshot","window","currentSize","isSize"],"sources":["../../../src/react-utils/useBreakpoints/index.js"],"sourcesContent":["import { useSyncExternalStore } from \"react\";\n\nimport { equals } from \"ramda\";\n\nimport { getCurrentSize, subscribe } from \"./utils\";\n\nconst useBreakpoints = breakpointOverrides => {\n const getSnapshot = () => getCurrentSize(window, breakpointOverrides);\n const currentSize = useSyncExternalStore(subscribe, getSnapshot);\n\n return { currentSize, isSize: equals(currentSize) };\n};\n\nexport default useBreakpoints;\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,OAAO;AAE5C,SAASC,MAAM,QAAQ,OAAO;AAE9B,SAASC,cAAc,EAAEC,SAAS;AAElC,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,mBAAmB,EAAI;EAC5C,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAA;IAAA,OAASJ,cAAc,CAACK,MAAM,EAAEF,mBAAmB,CAAC;EAAA;EACrE,IAAMG,WAAW,GAAGR,oBAAoB,CAACG,SAAS,EAAEG,WAAW,CAAC;EAEhE,OAAO;IAAEE,WAAW,EAAXA,WAAW;IAAEC,MAAM,EAAER,MAAM,CAACO,WAAW;EAAE,CAAC;AACrD,CAAC;AAED,eAAeJ,cAAc","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { prop } from "ramda";
|
|
2
2
|
import { create } from "zustand";
|
|
3
3
|
var useDisplayErrorPage = function useDisplayErrorPage() {
|
|
4
|
-
return useErrorDisplayStore(
|
|
4
|
+
return useErrorDisplayStore(prop("showErrorPage"));
|
|
5
5
|
};
|
|
6
6
|
export var useErrorDisplayStore = create(function () {
|
|
7
7
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDisplayErrorPage.js","names":["create","useDisplayErrorPage","useErrorDisplayStore","
|
|
1
|
+
{"version":3,"file":"useDisplayErrorPage.js","names":["prop","create","useDisplayErrorPage","useErrorDisplayStore","showErrorPage","statusCode","failedApiUrl","failedApiPath"],"sources":["../../../src/react-utils/useDisplayErrorPage/useDisplayErrorPage.js"],"sourcesContent":["import { prop } from \"ramda\";\nimport { create } from \"zustand\";\n\nconst useDisplayErrorPage = () => useErrorDisplayStore(prop(\"showErrorPage\"));\n\nexport const useErrorDisplayStore = create(() => ({\n showErrorPage: false,\n statusCode: 404,\n failedApiUrl: \"\",\n failedApiPath: \"\",\n}));\n\nexport default useDisplayErrorPage;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SAASC,MAAM,QAAQ,SAAS;AAEhC,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAA;EAAA,OAASC,oBAAoB,CAACH,IAAI,CAAC,eAAe,CAAC,CAAC;AAAA;AAE7E,OAAO,IAAMG,oBAAoB,GAAGF,MAAM,CAAC;EAAA,OAAO;IAChDG,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,GAAG;IACfC,YAAY,EAAE,EAAE;IAChBC,aAAa,EAAE;EACjB,CAAC;AAAA,CAAC,CAAC;AAEH,eAAeL,mBAAmB","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import _isNil from "ramda/es/isNil";
|
|
2
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
2
|
/* eslint-disable @bigbinary/neeto/no-local-storage */
|
|
4
3
|
|
|
5
4
|
import { useState } from "react";
|
|
5
|
+
import { isNil } from "ramda";
|
|
6
6
|
import { removeFromLocalStorage, setToLocalStorage } from "../../utils";
|
|
7
7
|
var getStorageValue = function getStorageValue(key, defaultValue) {
|
|
8
8
|
try {
|
|
@@ -23,7 +23,7 @@ var useLocalStorage = function useLocalStorage(key, defaultValue) {
|
|
|
23
23
|
var setValue = function setValue(value) {
|
|
24
24
|
return setStoredValue(function (prevStoredValue) {
|
|
25
25
|
var newValue = typeof value === "function" ? value(prevStoredValue) : value;
|
|
26
|
-
if (
|
|
26
|
+
if (isNil(newValue)) {
|
|
27
27
|
removeFromLocalStorage(key);
|
|
28
28
|
} else {
|
|
29
29
|
setToLocalStorage(key, newValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorage.js","names":["useState","removeFromLocalStorage","setToLocalStorage","getStorageValue","key","defaultValue","storedValue","localStorage","getItem","JSON","parse","error","logger","useLocalStorage","_useState","_useState2","_slicedToArray","setStoredValue","setValue","value","prevStoredValue","newValue"
|
|
1
|
+
{"version":3,"file":"useLocalStorage.js","names":["useState","isNil","removeFromLocalStorage","setToLocalStorage","getStorageValue","key","defaultValue","storedValue","localStorage","getItem","JSON","parse","error","logger","useLocalStorage","_useState","_useState2","_slicedToArray","setStoredValue","setValue","value","prevStoredValue","newValue"],"sources":["../../../src/react-utils/useLocalStorage/useLocalStorage.js"],"sourcesContent":["/* eslint-disable @bigbinary/neeto/no-local-storage */\n\nimport { useState } from \"react\";\n\nimport { isNil } from \"ramda\";\nimport { removeFromLocalStorage, setToLocalStorage } from \"utils\";\n\nconst getStorageValue = (key, defaultValue) => {\n try {\n const storedValue = localStorage.getItem(key);\n\n return storedValue ? JSON.parse(storedValue) : defaultValue;\n } catch (error) {\n logger.error(error);\n\n return defaultValue;\n }\n};\n\nconst useLocalStorage = (key, defaultValue) => {\n const [storedValue, setStoredValue] = useState(() =>\n getStorageValue(key, defaultValue)\n );\n\n const setValue = value =>\n setStoredValue(prevStoredValue => {\n const newValue =\n typeof value === \"function\" ? value(prevStoredValue) : value;\n\n if (isNil(newValue)) {\n removeFromLocalStorage(key);\n } else {\n setToLocalStorage(key, newValue);\n }\n\n return newValue;\n });\n\n return [storedValue, setValue];\n};\n\nexport default useLocalStorage;\n"],"mappings":";AAAA;;AAEA,SAASA,QAAQ,QAAQ,OAAO;AAEhC,SAASC,KAAK,QAAQ,OAAO;AAC7B,SAASC,sBAAsB,EAAEC,iBAAiB;AAElD,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,GAAG,EAAEC,YAAY,EAAK;EAC7C,IAAI;IACF,IAAMC,WAAW,GAAGC,YAAY,CAACC,OAAO,CAACJ,GAAG,CAAC;IAE7C,OAAOE,WAAW,GAAGG,IAAI,CAACC,KAAK,CAACJ,WAAW,CAAC,GAAGD,YAAY;EAC7D,CAAC,CAAC,OAAOM,KAAK,EAAE;IACdC,MAAM,CAACD,KAAK,CAACA,KAAK,CAAC;IAEnB,OAAON,YAAY;EACrB;AACF,CAAC;AAED,IAAMQ,eAAe,GAAG,SAAlBA,eAAeA,CAAIT,GAAG,EAAEC,YAAY,EAAK;EAC7C,IAAAS,SAAA,GAAsCf,QAAQ,CAAC;MAAA,OAC7CI,eAAe,CAACC,GAAG,EAAEC,YAAY,CAAC;IAAA,CACpC,CAAC;IAAAU,UAAA,GAAAC,cAAA,CAAAF,SAAA;IAFMR,WAAW,GAAAS,UAAA;IAAEE,cAAc,GAAAF,UAAA;EAIlC,IAAMG,QAAQ,GAAG,SAAXA,QAAQA,CAAGC,KAAK;IAAA,OACpBF,cAAc,CAAC,UAAAG,eAAe,EAAI;MAChC,IAAMC,QAAQ,GACZ,OAAOF,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACC,eAAe,CAAC,GAAGD,KAAK;MAE9D,IAAInB,KAAK,CAACqB,QAAQ,CAAC,EAAE;QACnBpB,sBAAsB,CAACG,GAAG,CAAC;MAC7B,CAAC,MAAM;QACLF,iBAAiB,CAACE,GAAG,EAAEiB,QAAQ,CAAC;MAClC;MAEA,OAAOA,QAAQ;IACjB,CAAC,CAAC;EAAA;EAEJ,OAAO,CAACf,WAAW,EAAEY,QAAQ,CAAC;AAChC,CAAC;AAED,eAAeL,eAAe","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _type from "ramda/es/type";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
3
|
var _excluded = ["keysToInvalidate"],
|
|
@@ -6,6 +5,7 @@ var _excluded = ["keysToInvalidate"],
|
|
|
6
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
7
|
import { useQueryClient, useMutation } from "@tanstack/react-query";
|
|
8
|
+
import { type } from "ramda";
|
|
9
9
|
var useMutationWithInvalidation = function useMutationWithInvalidation(mutationFn, _ref) {
|
|
10
10
|
var keysToInvalidate = _ref.keysToInvalidate,
|
|
11
11
|
options = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -16,10 +16,10 @@ var useMutationWithInvalidation = function useMutationWithInvalidation(mutationF
|
|
|
16
16
|
mutationFn: mutationFn,
|
|
17
17
|
onSuccess: function onSuccess(data, variables, context) {
|
|
18
18
|
keysToInvalidate.forEach(function (key) {
|
|
19
|
-
var result =
|
|
20
|
-
if (
|
|
19
|
+
var result = type(key) === "Function" ? key(data, variables, context) : key;
|
|
20
|
+
if (type(result) === "Object") {
|
|
21
21
|
queryClient.invalidateQueries(result);
|
|
22
|
-
} else if (
|
|
22
|
+
} else if (type(result) === "String") {
|
|
23
23
|
queryClient.invalidateQueries({
|
|
24
24
|
queryKey: [result]
|
|
25
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutationWithInvalidation.js","names":["useQueryClient","useMutation","useMutationWithInvalidation","mutationFn","_ref","keysToInvalidate","options","_objectWithoutProperties","_excluded","queryClient","onSuccess","otherOptions","_excluded2","_objectSpread","data","variables","context","forEach","key","result","
|
|
1
|
+
{"version":3,"file":"useMutationWithInvalidation.js","names":["useQueryClient","useMutation","type","useMutationWithInvalidation","mutationFn","_ref","keysToInvalidate","options","_objectWithoutProperties","_excluded","queryClient","onSuccess","otherOptions","_excluded2","_objectSpread","data","variables","context","forEach","key","result","invalidateQueries","queryKey"],"sources":["../../../src/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js"],"sourcesContent":["import { useQueryClient, useMutation } from \"@tanstack/react-query\";\nimport { type } from \"ramda\";\n\nconst useMutationWithInvalidation = (\n mutationFn,\n { keysToInvalidate, ...options }\n) => {\n const queryClient = useQueryClient();\n const { onSuccess, ...otherOptions } = options;\n\n return useMutation({\n mutationFn,\n onSuccess: (data, variables, context) => {\n keysToInvalidate.forEach(key => {\n const result =\n type(key) === \"Function\" ? key(data, variables, context) : key;\n\n if (type(result) === \"Object\") {\n queryClient.invalidateQueries(result);\n } else if (type(result) === \"String\") {\n queryClient.invalidateQueries({ queryKey: [result] });\n } else {\n queryClient.invalidateQueries({ queryKey: result });\n }\n });\n\n onSuccess?.(data, variables, context);\n },\n\n ...otherOptions,\n });\n};\n\nexport default useMutationWithInvalidation;\n"],"mappings":";;;;;;AAAA,SAASA,cAAc,EAAEC,WAAW,QAAQ,uBAAuB;AACnE,SAASC,IAAI,QAAQ,OAAO;AAE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
1
|
-
import _isNil from "ramda/es/isNil";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
4
|
import { useEffect } from "react";
|
|
6
5
|
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { isNil } from "ramda";
|
|
7
7
|
import { QUERY_CACHE_NAME_SPACE } from "../constants";
|
|
8
8
|
import { getFromLocalStorage, setToLocalStorage } from "../../utils/general";
|
|
9
9
|
var localStorageQueryCache = {
|
|
@@ -25,8 +25,8 @@ var localStorageQueryCache = {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
var isOutdated = function isOutdated(localCache, staleTime) {
|
|
28
|
-
if (
|
|
29
|
-
if (
|
|
28
|
+
if (isNil(localCache)) return true;
|
|
29
|
+
if (isNil(staleTime)) return false;
|
|
30
30
|
return localCache.modifiedAt <= Date.now() - staleTime;
|
|
31
31
|
};
|
|
32
32
|
var usePersistedQuery = function usePersistedQuery(queryKey, fetch, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePersistedQuery.js","names":["useEffect","useQuery","QUERY_CACHE_NAME_SPACE","getFromLocalStorage","setToLocalStorage","localStorageQueryCache","set","key","data","cache","getAll","newCache","_objectSpread","_defineProperty","modifiedAt","Date","now","get","isOutdated","localCache","staleTime","
|
|
1
|
+
{"version":3,"file":"usePersistedQuery.js","names":["useEffect","useQuery","isNil","QUERY_CACHE_NAME_SPACE","getFromLocalStorage","setToLocalStorage","localStorageQueryCache","set","key","data","cache","getAll","newCache","_objectSpread","_defineProperty","modifiedAt","Date","now","get","isOutdated","localCache","staleTime","usePersistedQuery","queryKey","fetch","options","queryResult","queryFn","isSuccess","isFreshLoading","isLoading","getCache"],"sources":["../../../src/react-utils/usePersistedQuery/usePersistedQuery.js"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { isNil } from \"ramda\";\nimport { QUERY_CACHE_NAME_SPACE } from \"react-utils/constants\";\nimport { getFromLocalStorage, setToLocalStorage } from \"utils/general\";\n\nconst localStorageQueryCache = {\n set: (key, data) => {\n const cache = localStorageQueryCache.getAll();\n const newCache = { ...cache, [key]: { data, modifiedAt: Date.now() } };\n setToLocalStorage(QUERY_CACHE_NAME_SPACE, newCache);\n },\n getAll: () => {\n const cache = getFromLocalStorage(QUERY_CACHE_NAME_SPACE);\n if (!cache) return {};\n\n return cache;\n },\n get: key => localStorageQueryCache.getAll()[key],\n};\n\nconst isOutdated = (localCache, staleTime) => {\n if (isNil(localCache)) return true;\n\n if (isNil(staleTime)) return false;\n\n return localCache.modifiedAt <= Date.now() - staleTime;\n};\n\nconst usePersistedQuery = (queryKey, fetch, options) => {\n const queryResult = useQuery({\n queryKey,\n queryFn: fetch,\n ...options,\n });\n const localCache = localStorageQueryCache.get(queryKey);\n\n useEffect(() => {\n if (!queryResult.isSuccess) return;\n localStorageQueryCache.set(queryKey, queryResult.data);\n }, [queryKey, queryResult.data, queryResult.isSuccess]);\n\n if (isOutdated(localCache, options?.staleTime)) {\n return { ...queryResult, isFreshLoading: queryResult.isLoading };\n }\n\n return {\n ...queryResult,\n data: queryResult.data || localCache.data,\n isFreshLoading: false,\n };\n};\n\nusePersistedQuery.getCache = localStorageQueryCache.get;\n\nexport default usePersistedQuery;\n"],"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AAO,EAAK;EACtD,IAAMC,WAAW,GAAGzB,QAAQ,CAAAY,aAAA;IAC1BU,QAAQ,EAARA,QAAQ;IACRI,OAAO,EAAEH;EAAK,GACXC,OAAO,CACX,CAAC;EACF,IAAML,UAAU,GAAGd,sBAAsB,CAACY,GAAG,CAACK,QAAQ,CAAC;EAEvDvB,SAAS,CAAC,YAAM;IACd,IAAI,CAAC0B,WAAW,CAACE,SAAS,EAAE;IAC5BtB,sBAAsB,CAACC,GAAG,CAACgB,QAAQ,EAAEG,WAAW,CAACjB,IAAI,CAAC;EACxD,CAAC,EAAE,CAACc,QAAQ,EAAEG,WAAW,CAACjB,IAAI,EAAEiB,WAAW,CAACE,SAAS,CAAC,CAAC;EAEvD,IAAIT,UAAU,CAACC,UAAU,EAAEK,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEJ,SAAS,CAAC,EAAE;IAC9C,OAAAR,aAAA,CAAAA,aAAA,KAAYa,WAAW;MAAEG,cAAc,EAAEH,WAAW,CAACI;IAAS;EAChE;EAEA,OAAAjB,aAAA,CAAAA,aAAA,KACKa,WAAW;IACdjB,IAAI,EAAEiB,WAAW,CAACjB,IAAI,IAAIW,UAAU,CAACX,IAAI;IACzCoB,cAAc,EAAE;EAAK;AAEzB,CAAC;AAEDP,iBAAiB,CAACS,QAAQ,GAAGzB,sBAAsB,CAACY,GAAG;AAEvD,eAAeI,iBAAiB","ignoreList":[]}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import _pick from "ramda/es/pick";
|
|
2
|
-
import _prop from "ramda/es/prop";
|
|
3
|
-
import _dissoc from "ramda/es/dissoc";
|
|
4
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
import _mergeDeepLeft from "ramda/es/mergeDeepLeft";
|
|
6
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
4
|
import { useEffect } from "react";
|
|
5
|
+
import { mergeDeepLeft, pick, prop, dissoc } from "ramda";
|
|
9
6
|
import { STORAGE_KEY } from "../constants";
|
|
10
7
|
import withImmutableActions from "../withImmutableActions";
|
|
11
8
|
import { getFromLocalStorage, setToLocalStorage } from "../../utils/general";
|
|
@@ -23,14 +20,14 @@ var useCheckpointStore = create(withImmutableActions(function (set) {
|
|
|
23
20
|
return {
|
|
24
21
|
checkpoints: {},
|
|
25
22
|
setCheckpoint: function setCheckpoint(key, path) {
|
|
26
|
-
return set(
|
|
23
|
+
return set(mergeDeepLeft({
|
|
27
24
|
checkpoints: _defineProperty({}, key, path)
|
|
28
25
|
}));
|
|
29
26
|
},
|
|
30
27
|
removeCheckpoint: function removeCheckpoint(key) {
|
|
31
28
|
return set(function (state) {
|
|
32
29
|
return {
|
|
33
|
-
checkpoints:
|
|
30
|
+
checkpoints: dissoc(key, state.checkpoints)
|
|
34
31
|
};
|
|
35
32
|
});
|
|
36
33
|
}
|
|
@@ -39,7 +36,7 @@ var useCheckpointStore = create(withImmutableActions(function (set) {
|
|
|
39
36
|
var useRegisterNavigationCheckpoint = function useRegisterNavigationCheckpoint(key) {
|
|
40
37
|
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.pathname + window.location.search;
|
|
41
38
|
var persistInLocalStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
42
|
-
var setCheckpoint = useCheckpointStore(
|
|
39
|
+
var setCheckpoint = useCheckpointStore(prop("setCheckpoint"));
|
|
43
40
|
useEffect(function () {
|
|
44
41
|
setCheckpoint(key, path);
|
|
45
42
|
if (persistInLocalStorage) {
|
|
@@ -53,18 +50,18 @@ export var useNavigationCheckpoints = function useNavigationCheckpoints() {
|
|
|
53
50
|
keys[_key] = arguments[_key];
|
|
54
51
|
}
|
|
55
52
|
var getCheckpoints = useCheckpointStore(function (store) {
|
|
56
|
-
return
|
|
53
|
+
return pick(keys, store.checkpoints);
|
|
57
54
|
}, shallow);
|
|
58
55
|
var localStorageData = getLocalStorageData();
|
|
59
|
-
var localStorageCheckpoints =
|
|
56
|
+
var localStorageCheckpoints = pick(keys, localStorageData);
|
|
60
57
|
return _objectSpread(_objectSpread({}, getCheckpoints), localStorageCheckpoints);
|
|
61
58
|
};
|
|
62
59
|
export var useRemoveNavigationCheckpoint = function useRemoveNavigationCheckpoint() {
|
|
63
|
-
var removeCheckpoint = useCheckpointStore(
|
|
60
|
+
var removeCheckpoint = useCheckpointStore(prop("removeCheckpoint"));
|
|
64
61
|
return function (key) {
|
|
65
62
|
removeCheckpoint(key);
|
|
66
63
|
var localStorageData = getLocalStorageData();
|
|
67
|
-
setLocalStorageData(
|
|
64
|
+
setLocalStorageData(dissoc(key, localStorageData));
|
|
68
65
|
};
|
|
69
66
|
};
|
|
70
67
|
export default useRegisterNavigationCheckpoint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRegisterNavigationCheckpoint.js","names":["useEffect","STORAGE_KEY","withImmutableActions","getFromLocalStorage","setToLocalStorage","create","shallow","getLocalStorageData","setLocalStorageData","data","useCheckpointStore","set","checkpoints","setCheckpoint","key","path","
|
|
1
|
+
{"version":3,"file":"useRegisterNavigationCheckpoint.js","names":["useEffect","mergeDeepLeft","pick","prop","dissoc","STORAGE_KEY","withImmutableActions","getFromLocalStorage","setToLocalStorage","create","shallow","getLocalStorageData","setLocalStorageData","data","useCheckpointStore","set","checkpoints","setCheckpoint","key","path","_defineProperty","removeCheckpoint","state","useRegisterNavigationCheckpoint","arguments","length","undefined","window","location","pathname","search","persistInLocalStorage","localStorageData","_objectSpread","useNavigationCheckpoints","_len","keys","Array","_key","getCheckpoints","store","localStorageCheckpoints","useRemoveNavigationCheckpoint"],"sources":["../../../src/react-utils/useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { mergeDeepLeft, pick, prop, dissoc } from \"ramda\";\nimport { STORAGE_KEY } from \"react-utils/constants\";\nimport withImmutableActions from \"react-utils/withImmutableActions\";\nimport { getFromLocalStorage, setToLocalStorage } from \"utils/general\";\nimport { create } from \"zustand\";\nimport { shallow } from \"zustand/shallow\";\n\nconst getLocalStorageData = () => getFromLocalStorage(STORAGE_KEY) || {};\n\nconst setLocalStorageData = data => setToLocalStorage(STORAGE_KEY, data);\n\n/** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\nconst useCheckpointStore = create(\n withImmutableActions(set => ({\n checkpoints: {},\n setCheckpoint: (key, path) =>\n set(mergeDeepLeft({ checkpoints: { [key]: path } })),\n removeCheckpoint: key =>\n set(state => ({ checkpoints: dissoc(key, state.checkpoints) })),\n }))\n);\n\nconst useRegisterNavigationCheckpoint = (\n key,\n path = window.location.pathname + window.location.search,\n persistInLocalStorage = false\n) => {\n const setCheckpoint = useCheckpointStore(prop(\"setCheckpoint\"));\n\n useEffect(() => {\n setCheckpoint(key, path);\n if (persistInLocalStorage) {\n const localStorageData = getLocalStorageData();\n setLocalStorageData({ ...localStorageData, [key]: path });\n }\n }, [key, path, persistInLocalStorage]);\n};\n\nexport const useNavigationCheckpoints = (...keys) => {\n const getCheckpoints = useCheckpointStore(\n store => pick(keys, store.checkpoints),\n shallow\n );\n\n const localStorageData = getLocalStorageData();\n const localStorageCheckpoints = pick(keys, localStorageData);\n\n return { ...getCheckpoints, ...localStorageCheckpoints };\n};\n\nexport const useRemoveNavigationCheckpoint = () => {\n const removeCheckpoint = useCheckpointStore(prop(\"removeCheckpoint\"));\n\n return key => {\n removeCheckpoint(key);\n const localStorageData = getLocalStorageData();\n setLocalStorageData(dissoc(key, localStorageData));\n };\n};\n\nexport default useRegisterNavigationCheckpoint;\n"],"mappings":";;;AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,aAAa,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,QAAQ,OAAO;AACzD,SAASC,WAAW;AACpB,OAAOC,oBAAoB;AAC3B,SAASC,mBAAmB,EAAEC,iBAAiB;AAC/C,SAASC,MAAM,QAAQ,SAAS;AAChC,SAASC,OAAO,QAAQ,iBAAiB;AAEzC,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAA;EAAA,OAASJ,mBAAmB,CAACF,WAAW,CAAC,IAAI,CAAC,CAAC;AAAA;AAExE,IAAMO,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAGC,IAAI;EAAA,OAAIL,iBAAiB,CAACH,WAAW,EAAEQ,IAAI,CAAC;AAAA;;AAExE;AACA,IAAMC,kBAAkB,GAAGL,MAAM,CAC/BH,oBAAoB,CAAC,UAAAS,GAAG;EAAA,OAAK;IAC3BC,WAAW,EAAE,CAAC,CAAC;IACfC,aAAa,EAAE,SAAfA,aAAaA,CAAGC,GAAG,EAAEC,IAAI;MAAA,OACvBJ,GAAG,CAACd,aAAa,CAAC;QAAEe,WAAW,EAAAI,eAAA,KAAKF,GAAG,EAAGC,IAAI;MAAG,CAAC,CAAC,CAAC;IAAA;IACtDE,gBAAgB,EAAE,SAAlBA,gBAAgBA,CAAEH,GAAG;MAAA,OACnBH,GAAG,CAAC,UAAAO,KAAK;QAAA,OAAK;UAAEN,WAAW,EAAEZ,MAAM,CAACc,GAAG,EAAEI,KAAK,CAACN,WAAW;QAAE,CAAC;MAAA,CAAC,CAAC;IAAA;EACnE,CAAC;AAAA,CAAC,CACJ,CAAC;AAED,IAAMO,+BAA+B,GAAG,SAAlCA,+BAA+BA,CACnCL,GAAG,EAGA;EA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