@erpsquad/common 1.8.102 → 1.8.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index/index.esm10.js +3 -3
- package/dist/_virtual/index/index.esm11.js +4 -2
- package/dist/_virtual/index/index.esm11.js.map +1 -1
- package/dist/_virtual/index/index.esm2.js +2 -4
- package/dist/_virtual/index/index.esm2.js.map +1 -1
- package/dist/_virtual/index/index.esm3.js +3 -3
- package/dist/_virtual/index/index.esm4.js +3 -3
- package/dist/_virtual/index/index.esm5.js +3 -3
- package/dist/_virtual/index/index.esm6.js +3 -3
- package/dist/_virtual/index/index.esm7.js +3 -3
- package/dist/_virtual/index/index.esm8.js +3 -3
- package/dist/_virtual/index/index.esm9.js +3 -3
- package/dist/_virtual/index/index10.js +1 -1
- package/dist/_virtual/index/index11.js +1 -1
- package/dist/_virtual/index/index2.js +1 -1
- package/dist/_virtual/index/index3.js +1 -1
- package/dist/_virtual/index/index4.js +1 -1
- package/dist/_virtual/index/index5.js +1 -1
- package/dist/_virtual/index/index6.js +1 -1
- package/dist/_virtual/index/index7.js +1 -1
- package/dist/_virtual/index/index8.js +1 -1
- package/dist/_virtual/index/index9.js +1 -1
- package/dist/api-client/api.inventory/api/index.esm.js +95 -30
- package/dist/api-client/api.inventory/api/index.esm.js.map +1 -1
- package/dist/api-client/api.inventory/api/index.js +1 -1
- package/dist/api-client/api.inventory/api/index.js.map +1 -1
- package/dist/api-client/api.inventory/api-types.d.ts +930 -425
- package/dist/api-client/api.inventory/api.d.ts +14 -10
- package/dist/api-client/api.rbac/api/index.esm2.js +218 -0
- package/dist/api-client/api.rbac/api/index.esm2.js.map +1 -1
- package/dist/api-client/api.rbac/api/index2.js +1 -1
- package/dist/api-client/api.rbac/api/index2.js.map +1 -1
- package/dist/components/filter/components/delete-group/index.esm.js +1 -0
- package/dist/components/filter/components/delete-group/index.esm.js.map +1 -1
- package/dist/components/filter/components/delete-group/index.js +1 -1
- package/dist/components/filter/components/delete-group/index.js.map +1 -1
- package/dist/components/listing/listing/index.esm.js +2 -2
- package/dist/components/listing/listing/index.esm.js.map +1 -1
- package/dist/components/listing/listing/index.js +5 -5
- package/dist/components/listing/listing/index.js.map +1 -1
- package/dist/components/providers/ERPUIProvider/index.esm.js +0 -6
- package/dist/components/providers/ERPUIProvider/index.esm.js.map +1 -1
- package/dist/components/providers/ERPUIProvider/index.js +1 -2
- package/dist/components/providers/ERPUIProvider/index.js.map +1 -1
- package/dist/components/uom-field-wrapper/uom-field-wrapper/index.esm.js.map +1 -1
- package/dist/components/uom-field-wrapper/uom-field-wrapper/index.js.map +1 -1
- package/dist/hooks/index.esm.js +4 -4
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/use-translations/index.esm.js +1 -2
- package/dist/hooks/use-translations/index.esm.js.map +1 -1
- package/dist/hooks/use-translations/index.js +1 -1
- package/dist/hooks/use-translations/index.js.map +1 -1
- package/dist/hooks/useDataFetcher/index.esm.js +2 -3
- package/dist/hooks/useDataFetcher/index.esm.js.map +1 -1
- package/dist/hooks/useDataFetcher/index.js +1 -1
- package/dist/hooks/useDataFetcher/index.js.map +1 -1
- package/dist/hooks/useDataFetcher.d.ts +2 -2
- package/dist/index.esm.js +69 -69
- package/dist/index.js +1 -1
- package/dist/node_modules/@asseinfo/react-kanban/dist/index/index.esm.js +1 -1
- package/dist/node_modules/@asseinfo/react-kanban/dist/index/index.js +1 -1
- package/dist/node_modules/@asseinfo/react-kanban/dist/index/index.js.map +1 -1
- package/dist/node_modules/@mui/icons-material/utils/createSvgIcon/index.esm.js +1 -1
- package/dist/node_modules/@mui/icons-material/utils/createSvgIcon/index.js +1 -1
- package/dist/node_modules/@mui/system/colorManipulator/index.esm.js +2 -2
- package/dist/node_modules/@mui/system/colorManipulator/index.js +1 -1
- package/dist/node_modules/@mui/system/colorManipulator/index.js.map +1 -1
- package/dist/node_modules/@mui/system/createStyled/index.esm.js +6 -6
- package/dist/node_modules/@mui/system/createStyled/index.js +1 -1
- package/dist/node_modules/@mui/system/useThemeWithoutDefault/index.esm.js +1 -1
- package/dist/node_modules/@mui/system/useThemeWithoutDefault/index.js +1 -1
- package/dist/src/api-client/api.inventory/api.d.ts +14 -10
- package/dist/src/hooks/useDataFetcher.d.ts +2 -2
- package/dist/src/utils/api.d.ts +18 -8
- package/dist/style.css +65 -65
- package/dist/utils/api/index.esm.js +45 -22
- package/dist/utils/api/index.esm.js.map +1 -1
- package/dist/utils/api/index.js +1 -1
- package/dist/utils/api/index.js.map +1 -1
- package/dist/utils/api.d.ts +18 -8
- package/dist/utils/common-utility/index.esm.js +13 -7
- package/dist/utils/common-utility/index.esm.js.map +1 -1
- package/dist/utils/common-utility/index.js +5 -5
- package/dist/utils/common-utility/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../../src/components/providers/ERPUIProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode, Suspense } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { SnackbarProvider } from 'notistack';\nimport { BrowserRouter } from 'react-router-dom';\nimport { createLibraryStore, ApiClientConfig } from '../../redux';\nimport { createLightTheme, createDarkTheme, Color } from '../../theme';\nimport { AuthProvider } from '../../contexts/AuthContext';\nimport { LanguageProvider } from '../../contexts/languageContext';\nimport { PageProvider } from '../../contexts/page-context';\nimport { PermissionsProvider } from '../../contexts/permission-context';\nimport MUIThemeWrapper from '../../theme/themeWrapper';\nimport Loader from '../loader';\nimport useAppTranslations from '../../hooks/use-translations';\nimport '../../utils/i18n';\nimport { initializeApiConfig, ApiConfig } from '../../utils/api-config';\nimport { initializeApiBaseUrls } from '../../utils/api';\n\n// Context for library configuration\ninterface ERPUIContextValue {\n useRedux: boolean;\n apiClient?: ApiClientConfig;\n theme?: any;\n themeMode: 'light' | 'dark';\n direction: 'ltr' | 'rtl';\n primaryColor?: Color;\n}\n\nconst ERPUIContext = createContext<ERPUIContextValue>({\n useRedux: false,\n themeMode: 'light',\n direction: 'ltr',\n});\n\nexport const useERPUI = () => useContext(ERPUIContext);\n\n// Provider props interface\ninterface ERPUIProviderProps {\n children: ReactNode;\n\n // Redux configuration\n useRedux?: boolean;\n reduxStore?: any;\n apiClient?: ApiClientConfig;\n additionalReducers?: Record<string, any>;\n\n // Theme configuration\n theme?: any;\n themeMode?: 'light' | 'dark';\n primaryColor?: Color;\n direction?: 'ltr' | 'rtl';\n\n // Context providers configuration\n enableAuth?: boolean;\n enableLanguage?: boolean;\n enablePages?: boolean;\n enablePermissions?: boolean;\n enableRouter?: boolean;\n enableSnackbar?: boolean;\n\n // Other configuration\n enableCssBaseline?: boolean;\n snackbarConfig?: {\n maxSnack?: number;\n anchorOrigin?: {\n vertical: 'top' | 'bottom';\n horizontal: 'left' | 'center' | 'right';\n };\n autoHideDuration?: number;\n };\n\n // API configuration\n apiConfig?: ApiConfig;\n}\n\nexport const ERPUIProvider: React.FC<ERPUIProviderProps> = ({\n children,\n\n // Redux props\n useRedux = false,\n reduxStore,\n apiClient,\n additionalReducers = {},\n\n // Theme props\n theme: customTheme,\n themeMode = 'light',\n primaryColor,\n direction = 'ltr',\n\n // Context providers configuration\n enableAuth = true,\n enableLanguage = true,\n enablePages = true,\n enablePermissions = true,\n enableRouter = false, // Default false since consuming app usually provides router\n enableSnackbar = true,\n\n // Other props\n enableCssBaseline = true,\n snackbarConfig = {\n maxSnack: 3,\n anchorOrigin: { vertical: 'top', horizontal: 'right' },\n autoHideDuration: 5000,\n },\n\n // API configuration\n apiConfig: providedApiConfig,\n}) => {\n\n // Initialize API configuration synchronously before first render\n // This prevents \"API configuration not initialized\" errors when components\n // try to use the API during initial render\n const isInitialized = React.useRef(false);\n\n if (providedApiConfig && !isInitialized.current) {\n try {\n initializeApiConfig(providedApiConfig);\n initializeApiBaseUrls();\n isInitialized.current = true;\n } catch (error) {\n console.error('Failed to initialize API configuration:', error);\n }\n }\n const { isLoading } = useAppTranslations();\n if (isLoading) {\n
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../src/components/providers/ERPUIProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode, Suspense } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { SnackbarProvider } from 'notistack';\nimport { BrowserRouter } from 'react-router-dom';\nimport { createLibraryStore, ApiClientConfig } from '../../redux';\nimport { createLightTheme, createDarkTheme, Color } from '../../theme';\nimport { AuthProvider } from '../../contexts/AuthContext';\nimport { LanguageProvider } from '../../contexts/languageContext';\nimport { PageProvider } from '../../contexts/page-context';\nimport { PermissionsProvider } from '../../contexts/permission-context';\nimport MUIThemeWrapper from '../../theme/themeWrapper';\nimport Loader from '../loader';\nimport useAppTranslations from '../../hooks/use-translations';\nimport '../../utils/i18n';\nimport { initializeApiConfig, ApiConfig } from '../../utils/api-config';\nimport { initializeApiBaseUrls } from '../../utils/api';\n\n// Context for library configuration\ninterface ERPUIContextValue {\n useRedux: boolean;\n apiClient?: ApiClientConfig;\n theme?: any;\n themeMode: 'light' | 'dark';\n direction: 'ltr' | 'rtl';\n primaryColor?: Color;\n}\n\nconst ERPUIContext = createContext<ERPUIContextValue>({\n useRedux: false,\n themeMode: 'light',\n direction: 'ltr',\n});\n\nexport const useERPUI = () => useContext(ERPUIContext);\n\n// Provider props interface\ninterface ERPUIProviderProps {\n children: ReactNode;\n\n // Redux configuration\n useRedux?: boolean;\n reduxStore?: any;\n apiClient?: ApiClientConfig;\n additionalReducers?: Record<string, any>;\n\n // Theme configuration\n theme?: any;\n themeMode?: 'light' | 'dark';\n primaryColor?: Color;\n direction?: 'ltr' | 'rtl';\n\n // Context providers configuration\n enableAuth?: boolean;\n enableLanguage?: boolean;\n enablePages?: boolean;\n enablePermissions?: boolean;\n enableRouter?: boolean;\n enableSnackbar?: boolean;\n\n // Other configuration\n enableCssBaseline?: boolean;\n snackbarConfig?: {\n maxSnack?: number;\n anchorOrigin?: {\n vertical: 'top' | 'bottom';\n horizontal: 'left' | 'center' | 'right';\n };\n autoHideDuration?: number;\n };\n\n // API configuration\n apiConfig?: ApiConfig;\n}\n\nexport const ERPUIProvider: React.FC<ERPUIProviderProps> = ({\n children,\n\n // Redux props\n useRedux = false,\n reduxStore,\n apiClient,\n additionalReducers = {},\n\n // Theme props\n theme: customTheme,\n themeMode = 'light',\n primaryColor,\n direction = 'ltr',\n\n // Context providers configuration\n enableAuth = true,\n enableLanguage = true,\n enablePages = true,\n enablePermissions = true,\n enableRouter = false, // Default false since consuming app usually provides router\n enableSnackbar = true,\n\n // Other props\n enableCssBaseline = true,\n snackbarConfig = {\n maxSnack: 3,\n anchorOrigin: { vertical: 'top', horizontal: 'right' },\n autoHideDuration: 5000,\n },\n\n // API configuration\n apiConfig: providedApiConfig,\n}) => {\n\n // Initialize API configuration synchronously before first render\n // This prevents \"API configuration not initialized\" errors when components\n // try to use the API during initial render\n const isInitialized = React.useRef(false);\n\n if (providedApiConfig && !isInitialized.current) {\n try {\n initializeApiConfig(providedApiConfig);\n initializeApiBaseUrls();\n isInitialized.current = true;\n } catch (error) {\n console.error('Failed to initialize API configuration:', error);\n }\n }\n // const { isLoading } = useAppTranslations();\n // if (isLoading) {\n // return <Loader />;\n // }\n // Create or use provided Redux store\n const store = React.useMemo(() => {\n if (!useRedux) return null;\n\n if (reduxStore) {\n return reduxStore;\n }\n\n return createLibraryStore(additionalReducers, apiClient);\n }, [useRedux, reduxStore, additionalReducers, apiClient]);\n\n // Create theme\n const theme = React.useMemo(() => {\n if (customTheme) {\n return customTheme;\n }\n\n const themeCreator = themeMode === 'dark' ? createDarkTheme : createLightTheme;\n const { theme: generatedTheme } = themeCreator(primaryColor, direction);\n return generatedTheme;\n }, [customTheme, themeMode, primaryColor, direction]);\n\n // Context value\n const contextValue: ERPUIContextValue = {\n useRedux,\n apiClient,\n theme,\n themeMode,\n direction,\n primaryColor,\n };\n\n // Build provider tree from inside out\n let content = (\n <ERPUIContext.Provider value={contextValue}>\n {/* <ThemeProvider theme={theme}>\n {enableCssBaseline && <CssBaseline />} */}\n {/* <Suspense fallback={<Loader />}> */}\n <MUIThemeWrapper theme={theme} enableCssBaseline={enableCssBaseline}>\n {children}\n </MUIThemeWrapper>\n {/* </Suspense> */}\n {/* </ThemeProvider> */}\n </ERPUIContext.Provider>\n );\n\n // Wrap with snackbar provider if enabled\n if (enableSnackbar) {\n content = (\n <SnackbarProvider {...snackbarConfig}>\n {content}\n </SnackbarProvider>\n );\n }\n\n // Wrap with page provider if enabled\n if (enablePages) {\n content = (\n <PageProvider>\n {content}\n </PageProvider>\n );\n }\n\n // Wrap with permissions provider if enabled\n if (enablePermissions) {\n content = (\n <PermissionsProvider>\n {content}\n </PermissionsProvider>\n );\n }\n\n // Wrap with language provider if enabled\n if (enableLanguage) {\n content = (\n <LanguageProvider>\n {content}\n </LanguageProvider>\n );\n }\n\n // Wrap with auth provider if enabled\n if (enableAuth) {\n content = (\n <AuthProvider>\n {content}\n </AuthProvider>\n );\n }\n\n // Wrap with router if enabled\n if (enableRouter) {\n content = (\n <BrowserRouter>\n {content}\n </BrowserRouter>\n );\n }\n\n // Wrap with Redux provider if enabled\n if (useRedux && store) {\n content = (\n <ReduxProvider store={store}>\n {content}\n </ReduxProvider>\n );\n }\n\n return content;\n};\n\nexport default ERPUIProvider;"],"names":["React","ReduxProvider"],"mappings":";;;;;;;;;;;;;;AA6BA,MAAM,eAAe,cAAiC;AAAA,EACpD,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AACb,CAAC;AAEM,MAAM,WAAW,MAAM,WAAW,YAAY;AAyC9C,MAAM,gBAA8C,CAAC;AAAA,EAC1D;AAAA;AAAA,EAGA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,qBAAqB,CAAA;AAAA;AAAA,EAGrB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ;AAAA,EACA,YAAY;AAAA;AAAA,EAGZ,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,eAAe;AAAA;AAAA,EACf,iBAAiB;AAAA;AAAA,EAGjB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,IACf,UAAU;AAAA,IACV,cAAc,EAAE,UAAU,OAAO,YAAY,QAAA;AAAA,IAC7C,kBAAkB;AAAA,EAAA;AAAA;AAAA,EAIpB,WAAW;AACb,MAAM;AAKJ,QAAM,gBAAgBA,eAAM,OAAO,KAAK;AAExC,MAAI,qBAAqB,CAAC,cAAc,SAAS;AAC/C,QAAI;AACF,0BAAoB,iBAAiB;AACrC,4BAAA;AACA,oBAAc,UAAU;AAAA,IAC1B,SAAS,OAAO;AACd,cAAQ,MAAM,2CAA2C,KAAK;AAAA,IAChE;AAAA,EACF;AAMA,QAAM,QAAQA,eAAM,QAAQ,MAAM;AAChC,QAAI,CAAC,SAAU,QAAO;AAEtB,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAEA,WAAO,mBAAmB,oBAAoB,SAAS;AAAA,EACzD,GAAG,CAAC,UAAU,YAAY,oBAAoB,SAAS,CAAC;AAGxD,QAAM,QAAQA,eAAM,QAAQ,MAAM;AAChC,QAAI,aAAa;AACf,aAAO;AAAA,IACT;AAEA,UAAM,eAAe,cAAc,SAAS,kBAAkB;AAC9D,UAAM,EAAE,OAAO,eAAA,IAAmB,aAAa,cAAc,SAAS;AACtE,WAAO;AAAA,EACT,GAAG,CAAC,aAAa,WAAW,cAAc,SAAS,CAAC;AAGpD,QAAM,eAAkC;AAAA,IACtC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAIF,MAAI,UACF,oBAAC,aAAa,UAAb,EAAsB,OAAO,cAI5B,UAAA,oBAAC,iBAAA,EAAgB,OAAc,mBAC5B,SAAA,CACH,GAGF;AAIF,MAAI,gBAAgB;AAClB,cACE,oBAAC,kBAAA,EAAkB,GAAG,gBACnB,UAAA,SACH;AAAA,EAEJ;AAGA,MAAI,aAAa;AACf,cACE,oBAAC,gBACE,UAAA,QAAA,CACH;AAAA,EAEJ;AAGA,MAAI,mBAAmB;AACrB,cACE,oBAAC,uBACE,UAAA,QAAA,CACH;AAAA,EAEJ;AAGA,MAAI,gBAAgB;AAClB,cACE,oBAAC,oBACE,UAAA,QAAA,CACH;AAAA,EAEJ;AAGA,MAAI,YAAY;AACd,cACE,oBAAC,gBACE,UAAA,QAAA,CACH;AAAA,EAEJ;AAGA,MAAI,cAAc;AAChB,cACE,oBAAC,iBACE,UAAA,QAAA,CACH;AAAA,EAEJ;AAGA,MAAI,YAAY,OAAO;AACrB,cACE,oBAACC,UAAA,EAAc,OACZ,UAAA,SACH;AAAA,EAEJ;AAEA,SAAO;AACT;"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),
|
|
2
|
-
return e.jsx(l.Loader,{});const E=g.default.useMemo(()=>p?q||m.createLibraryStore(b,P):null,[p,q,b,P]),I=g.default.useMemo(()=>{if(v)return v;const e="dark"===C?j.createDarkTheme:j.createLightTheme,{theme:r}=e(k,R);return r},[v,C,k,R]),O={useRedux:p,apiClient:P,theme:I,themeMode:C,direction:R,primaryColor:k};let w=/* @__PURE__ */e.jsx(f.Provider,{value:O,children:/* @__PURE__ */e.jsx(d.default,{theme:I,enableCssBaseline:z,children:r})});return B&&(w=/* @__PURE__ */e.jsx(t.SnackbarProvider,{...T,children:w})),L&&(w=/* @__PURE__ */e.jsx(a.PageProvider,{children:w})),M&&(w=/* @__PURE__ */e.jsx(u.PermissionsProvider,{children:w})),A&&(w=/* @__PURE__ */e.jsx(o.LanguageProvider,{children:w})),y&&(w=/* @__PURE__ */e.jsx(s.AuthProvider,{children:w})),S&&(w=/* @__PURE__ */e.jsx(n.BrowserRouter,{children:w})),p&&E&&(w=/* @__PURE__ */e.jsx(i.Provider,{store:E,children:w})),w};exports.ERPUIProvider=q,exports.default=q,exports.useERPUI=()=>r.useContext(f);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("react-redux"),i=require("../../../node_modules/notistack/notistack.esm/index.js"),n=require("react-router-dom"),s=require("../../../contexts/AuthContext/index.js"),a=require("../../../contexts/languageContext/index.js"),o=require("../../../contexts/page-context/index.js"),u=require("../../../contexts/permission-context/index.js"),d=require("../../../theme/themeWrapper/index.js"),l=require("../../../utils/api-config/index.js"),c=require("../../../utils/api/index.js"),x=require("../../../redux/store/index.js"),h=require("../../../theme/theme-impl/index.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var j=/* @__PURE__ */m(r);const p=r.createContext({useRedux:!1,themeMode:"light",direction:"ltr"}),g=({children:r,useRedux:m=!1,reduxStore:g,apiClient:f,additionalReducers:P={},theme:b,themeMode:q="light",primaryColor:v,direction:C="ltr",enableAuth:R=!0,enableLanguage:k=!0,enablePages:y=!0,enablePermissions:M=!0,enableRouter:A=!1,enableSnackbar:S=!0,enableCssBaseline:B=!0,snackbarConfig:L={maxSnack:3,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:5e3},apiConfig:z})=>{const U=j.default.useRef(!1);if(z&&!U.current)try{l.initializeApiConfig(z),c.initializeApiBaseUrls(),U.current=!0}catch(O){}const _=j.default.useMemo(()=>m?g||x.createLibraryStore(P,f):null,[m,g,P,f]),D=j.default.useMemo(()=>{if(b)return b;const e="dark"===q?h.createDarkTheme:h.createLightTheme,{theme:r}=e(v,C);return r},[b,q,v,C]),E={useRedux:m,apiClient:f,theme:D,themeMode:q,direction:C,primaryColor:v};let I=/* @__PURE__ */e.jsx(p.Provider,{value:E,children:/* @__PURE__ */e.jsx(d.default,{theme:D,enableCssBaseline:B,children:r})});return S&&(I=/* @__PURE__ */e.jsx(i.SnackbarProvider,{...L,children:I})),y&&(I=/* @__PURE__ */e.jsx(o.PageProvider,{children:I})),M&&(I=/* @__PURE__ */e.jsx(u.PermissionsProvider,{children:I})),k&&(I=/* @__PURE__ */e.jsx(a.LanguageProvider,{children:I})),R&&(I=/* @__PURE__ */e.jsx(s.AuthProvider,{children:I})),A&&(I=/* @__PURE__ */e.jsx(n.BrowserRouter,{children:I})),m&&_&&(I=/* @__PURE__ */e.jsx(t.Provider,{store:_,children:I})),I};exports.ERPUIProvider=g,exports.default=g,exports.useERPUI=()=>r.useContext(p);
|
|
3
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/providers/ERPUIProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode, Suspense } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { SnackbarProvider } from 'notistack';\nimport { BrowserRouter } from 'react-router-dom';\nimport { createLibraryStore, ApiClientConfig } from '../../redux';\nimport { createLightTheme, createDarkTheme, Color } from '../../theme';\nimport { AuthProvider } from '../../contexts/AuthContext';\nimport { LanguageProvider } from '../../contexts/languageContext';\nimport { PageProvider } from '../../contexts/page-context';\nimport { PermissionsProvider } from '../../contexts/permission-context';\nimport MUIThemeWrapper from '../../theme/themeWrapper';\nimport Loader from '../loader';\nimport useAppTranslations from '../../hooks/use-translations';\nimport '../../utils/i18n';\nimport { initializeApiConfig, ApiConfig } from '../../utils/api-config';\nimport { initializeApiBaseUrls } from '../../utils/api';\n\n// Context for library configuration\ninterface ERPUIContextValue {\n useRedux: boolean;\n apiClient?: ApiClientConfig;\n theme?: any;\n themeMode: 'light' | 'dark';\n direction: 'ltr' | 'rtl';\n primaryColor?: Color;\n}\n\nconst ERPUIContext = createContext<ERPUIContextValue>({\n useRedux: false,\n themeMode: 'light',\n direction: 'ltr',\n});\n\nexport const useERPUI = () => useContext(ERPUIContext);\n\n// Provider props interface\ninterface ERPUIProviderProps {\n children: ReactNode;\n\n // Redux configuration\n useRedux?: boolean;\n reduxStore?: any;\n apiClient?: ApiClientConfig;\n additionalReducers?: Record<string, any>;\n\n // Theme configuration\n theme?: any;\n themeMode?: 'light' | 'dark';\n primaryColor?: Color;\n direction?: 'ltr' | 'rtl';\n\n // Context providers configuration\n enableAuth?: boolean;\n enableLanguage?: boolean;\n enablePages?: boolean;\n enablePermissions?: boolean;\n enableRouter?: boolean;\n enableSnackbar?: boolean;\n\n // Other configuration\n enableCssBaseline?: boolean;\n snackbarConfig?: {\n maxSnack?: number;\n anchorOrigin?: {\n vertical: 'top' | 'bottom';\n horizontal: 'left' | 'center' | 'right';\n };\n autoHideDuration?: number;\n };\n\n // API configuration\n apiConfig?: ApiConfig;\n}\n\nexport const ERPUIProvider: React.FC<ERPUIProviderProps> = ({\n children,\n\n // Redux props\n useRedux = false,\n reduxStore,\n apiClient,\n additionalReducers = {},\n\n // Theme props\n theme: customTheme,\n themeMode = 'light',\n primaryColor,\n direction = 'ltr',\n\n // Context providers configuration\n enableAuth = true,\n enableLanguage = true,\n enablePages = true,\n enablePermissions = true,\n enableRouter = false, // Default false since consuming app usually provides router\n enableSnackbar = true,\n\n // Other props\n enableCssBaseline = true,\n snackbarConfig = {\n maxSnack: 3,\n anchorOrigin: { vertical: 'top', horizontal: 'right' },\n autoHideDuration: 5000,\n },\n\n // API configuration\n apiConfig: providedApiConfig,\n}) => {\n\n // Initialize API configuration synchronously before first render\n // This prevents \"API configuration not initialized\" errors when components\n // try to use the API during initial render\n const isInitialized = React.useRef(false);\n\n if (providedApiConfig && !isInitialized.current) {\n try {\n initializeApiConfig(providedApiConfig);\n initializeApiBaseUrls();\n isInitialized.current = true;\n } catch (error) {\n console.error('Failed to initialize API configuration:', error);\n }\n }\n const { isLoading } = useAppTranslations();\n if (isLoading) {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/providers/ERPUIProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode, Suspense } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { SnackbarProvider } from 'notistack';\nimport { BrowserRouter } from 'react-router-dom';\nimport { createLibraryStore, ApiClientConfig } from '../../redux';\nimport { createLightTheme, createDarkTheme, Color } from '../../theme';\nimport { AuthProvider } from '../../contexts/AuthContext';\nimport { LanguageProvider } from '../../contexts/languageContext';\nimport { PageProvider } from '../../contexts/page-context';\nimport { PermissionsProvider } from '../../contexts/permission-context';\nimport MUIThemeWrapper from '../../theme/themeWrapper';\nimport Loader from '../loader';\nimport useAppTranslations from '../../hooks/use-translations';\nimport '../../utils/i18n';\nimport { initializeApiConfig, ApiConfig } from '../../utils/api-config';\nimport { initializeApiBaseUrls } from '../../utils/api';\n\n// Context for library configuration\ninterface ERPUIContextValue {\n useRedux: boolean;\n apiClient?: ApiClientConfig;\n theme?: any;\n themeMode: 'light' | 'dark';\n direction: 'ltr' | 'rtl';\n primaryColor?: Color;\n}\n\nconst ERPUIContext = createContext<ERPUIContextValue>({\n useRedux: false,\n themeMode: 'light',\n direction: 'ltr',\n});\n\nexport const useERPUI = () => useContext(ERPUIContext);\n\n// Provider props interface\ninterface ERPUIProviderProps {\n children: ReactNode;\n\n // Redux configuration\n useRedux?: boolean;\n reduxStore?: any;\n apiClient?: ApiClientConfig;\n additionalReducers?: Record<string, any>;\n\n // Theme configuration\n theme?: any;\n themeMode?: 'light' | 'dark';\n primaryColor?: Color;\n direction?: 'ltr' | 'rtl';\n\n // Context providers configuration\n enableAuth?: boolean;\n enableLanguage?: boolean;\n enablePages?: boolean;\n enablePermissions?: boolean;\n enableRouter?: boolean;\n enableSnackbar?: boolean;\n\n // Other configuration\n enableCssBaseline?: boolean;\n snackbarConfig?: {\n maxSnack?: number;\n anchorOrigin?: {\n vertical: 'top' | 'bottom';\n horizontal: 'left' | 'center' | 'right';\n };\n autoHideDuration?: number;\n };\n\n // API configuration\n apiConfig?: ApiConfig;\n}\n\nexport const ERPUIProvider: React.FC<ERPUIProviderProps> = ({\n children,\n\n // Redux props\n useRedux = false,\n reduxStore,\n apiClient,\n additionalReducers = {},\n\n // Theme props\n theme: customTheme,\n themeMode = 'light',\n primaryColor,\n direction = 'ltr',\n\n // Context providers configuration\n enableAuth = true,\n enableLanguage = true,\n enablePages = true,\n enablePermissions = true,\n enableRouter = false, // Default false since consuming app usually provides router\n enableSnackbar = true,\n\n // Other props\n enableCssBaseline = true,\n snackbarConfig = {\n maxSnack: 3,\n anchorOrigin: { vertical: 'top', horizontal: 'right' },\n autoHideDuration: 5000,\n },\n\n // API configuration\n apiConfig: providedApiConfig,\n}) => {\n\n // Initialize API configuration synchronously before first render\n // This prevents \"API configuration not initialized\" errors when components\n // try to use the API during initial render\n const isInitialized = React.useRef(false);\n\n if (providedApiConfig && !isInitialized.current) {\n try {\n initializeApiConfig(providedApiConfig);\n initializeApiBaseUrls();\n isInitialized.current = true;\n } catch (error) {\n console.error('Failed to initialize API configuration:', error);\n }\n }\n // const { isLoading } = useAppTranslations();\n // if (isLoading) {\n // return <Loader />;\n // }\n // Create or use provided Redux store\n const store = React.useMemo(() => {\n if (!useRedux) return null;\n\n if (reduxStore) {\n return reduxStore;\n }\n\n return createLibraryStore(additionalReducers, apiClient);\n }, [useRedux, reduxStore, additionalReducers, apiClient]);\n\n // Create theme\n const theme = React.useMemo(() => {\n if (customTheme) {\n return customTheme;\n }\n\n const themeCreator = themeMode === 'dark' ? createDarkTheme : createLightTheme;\n const { theme: generatedTheme } = themeCreator(primaryColor, direction);\n return generatedTheme;\n }, [customTheme, themeMode, primaryColor, direction]);\n\n // Context value\n const contextValue: ERPUIContextValue = {\n useRedux,\n apiClient,\n theme,\n themeMode,\n direction,\n primaryColor,\n };\n\n // Build provider tree from inside out\n let content = (\n <ERPUIContext.Provider value={contextValue}>\n {/* <ThemeProvider theme={theme}>\n {enableCssBaseline && <CssBaseline />} */}\n {/* <Suspense fallback={<Loader />}> */}\n <MUIThemeWrapper theme={theme} enableCssBaseline={enableCssBaseline}>\n {children}\n </MUIThemeWrapper>\n {/* </Suspense> */}\n {/* </ThemeProvider> */}\n </ERPUIContext.Provider>\n );\n\n // Wrap with snackbar provider if enabled\n if (enableSnackbar) {\n content = (\n <SnackbarProvider {...snackbarConfig}>\n {content}\n </SnackbarProvider>\n );\n }\n\n // Wrap with page provider if enabled\n if (enablePages) {\n content = (\n <PageProvider>\n {content}\n </PageProvider>\n );\n }\n\n // Wrap with permissions provider if enabled\n if (enablePermissions) {\n content = (\n <PermissionsProvider>\n {content}\n </PermissionsProvider>\n );\n }\n\n // Wrap with language provider if enabled\n if (enableLanguage) {\n content = (\n <LanguageProvider>\n {content}\n </LanguageProvider>\n );\n }\n\n // Wrap with auth provider if enabled\n if (enableAuth) {\n content = (\n <AuthProvider>\n {content}\n </AuthProvider>\n );\n }\n\n // Wrap with router if enabled\n if (enableRouter) {\n content = (\n <BrowserRouter>\n {content}\n </BrowserRouter>\n );\n }\n\n // Wrap with Redux provider if enabled\n if (useRedux && store) {\n content = (\n <ReduxProvider store={store}>\n {content}\n </ReduxProvider>\n );\n }\n\n return content;\n};\n\nexport default ERPUIProvider;"],"names":["ERPUIContext","createContext","useRedux","themeMode","direction","ERPUIProvider","children","reduxStore","apiClient","additionalReducers","theme","customTheme","primaryColor","enableAuth","enableLanguage","enablePages","enablePermissions","enableRouter","enableSnackbar","enableCssBaseline","snackbarConfig","maxSnack","anchorOrigin","vertical","horizontal","autoHideDuration","apiConfig","providedApiConfig","isInitialized","React","useRef","current","initializeApiConfig","initializeApiBaseUrls","error","store","useMemo","createLibraryStore","themeCreator","createDarkTheme","createLightTheme","generatedTheme","contextValue","content","jsx","Provider","value","MUIThemeWrapper","SnackbarProvider","PageProvider","PermissionsProvider","LanguageProvider","AuthProvider","BrowserRouter","ReduxProvider","useContext"],"mappings":"yxBA6BA,MAAMA,EAAeC,EAAAA,cAAiC,CACpDC,UAAU,EACVC,UAAW,QACXC,UAAW,QA4CAC,EAA8C,EACzDC,WAGAJ,YAAW,EACXK,aACAC,YACAC,qBAAqB,CAAA,EAGrBC,MAAOC,EACPR,YAAY,QACZS,eACAR,YAAY,MAGZS,cAAa,EACbC,kBAAiB,EACjBC,eAAc,EACdC,qBAAoB,EACpBC,gBAAe,EACfC,kBAAiB,EAGjBC,qBAAoB,EACpBC,iBAAiB,CACfC,SAAU,EACVC,aAAc,CAAEC,SAAU,MAAOC,WAAY,SAC7CC,iBAAkB,KAIpBC,UAAWC,MAMX,MAAMC,EAAgBC,EAAAA,QAAMC,QAAO,GAEnC,GAAIH,IAAsBC,EAAcG,QACtC,IACEC,EAAAA,oBAAoBL,GACpBM,0BACAL,EAAcG,SAAU,CAC1B,OAASG,GAET,CAOF,MAAMC,EAAQN,UAAMO,QAAQ,IACrBlC,EAEDK,GAIG8B,EAAAA,mBAAmB5B,EAAoBD,GANxB,KAOrB,CAACN,EAAUK,EAAYE,EAAoBD,IAGxCE,EAAQmB,UAAMO,QAAQ,KAC1B,GAAIzB,EACF,OAAOA,EAGT,MAAM2B,EAA6B,SAAdnC,EAAuBoC,EAAAA,gBAAkBC,EAAAA,kBACtD9B,MAAO+B,GAAmBH,EAAa1B,EAAcR,GAC7D,OAAOqC,GACN,CAAC9B,EAAaR,EAAWS,EAAcR,IAGpCsC,EAAkC,CACtCxC,WACAM,YACAE,QACAP,YACAC,YACAQ,gBAIF,IAAI+B,iBACFC,EAAAA,IAAC5C,EAAa6C,SAAb,CAAsBC,MAAOJ,EAI5BpC,0BAAAsC,IAACG,EAAAA,QAAA,CAAgBrC,QAAcS,oBAC5Bb,eAsEP,OA9DIY,IACFyB,iBACEC,EAAAA,IAACI,mBAAA,IAAqB5B,EACnBd,SAAAqC,KAMH5B,IACF4B,mBACEC,IAACK,EAAAA,cACE3C,SAAAqC,KAMH3B,IACF2B,mBACEC,IAACM,EAAAA,qBACE5C,SAAAqC,KAMH7B,IACF6B,mBACEC,IAACO,EAAAA,kBACE7C,SAAAqC,KAMH9B,IACF8B,mBACEC,IAACQ,EAAAA,cACE9C,SAAAqC,KAMH1B,IACF0B,mBACEC,IAACS,EAAAA,eACE/C,SAAAqC,KAMHzC,GAAYiC,IACdQ,iBACEC,EAAAA,IAACU,EAAAA,SAAA,CAAAnB,MAAcA,EACZ7B,SAAAqC,KAKAA,8DA3Me,IAAMY,EAAAA,WAAWvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../../src/components/uom-field-wrapper/uom-field-wrapper.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState, useMemo } from 'react';\nimport DynamicSearchSelect from '../form-control/form-builder/form-builder-element/dynamic-select';\nimport { useUomFieldUpdater } from '../../hooks/useUomFieldUpdater';\nimport { useFormContext } from 'react-hook-form';\n\ninterface UomFieldWrapperProps {\n label: string;\n name?: string;\n placeholder?: string;\n fieldArrayName?: string;\n required?: boolean;\n is_loading?: boolean;\n disabled?: boolean;\n selectedItem: any;\n selectedUom?: any;\n fieldMapping?: Record<string, string>;\n customeFilter?: Record<string, any>;\n getSelectedData?: (data: any, name: string) => void;\n fieldPrefix?: string;\n setValue?: any;\n control?: any;\n isConversationFactor?: boolean;\n}\n\nconst UomFieldWrapper: React.FC<UomFieldWrapperProps> = ({\n label,\n name = 'uom_id',\n placeholder,\n fieldArrayName,\n required = false,\n is_loading = false,\n disabled = false,\n selectedItem,\n fieldMapping = {\n 'total_on_hand_quantity': 'on_hand_quantity',\n 'total_available_quantity': 'available_quantity',\n 'total_committed_quantity': 'committed_quantity',\n },\n customeFilter,\n getSelectedData,\n fieldPrefix,\n setValue,\n control,\n isConversationFactor = true\n}) => {\n // const selectedUom = useMemo(() => getValues(`${fieldArrayName}.${name}`), [getValues(`${fieldArrayName}.${name}`)])\n\n const [uomDetails, setUomDetails] = useState<any>(null);\n const formContext = useFormContext()\n const {\n control: contextControl,\n setValue: contextSetValue,\n } = formContext || {};\n\n const effectiveFieldPrefix = fieldPrefix !== undefined ? fieldPrefix : fieldArrayName || '';\n const finalFieldMapping = useMemo(() => fieldMapping
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../src/components/uom-field-wrapper/uom-field-wrapper.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState, useMemo } from 'react';\nimport DynamicSearchSelect from '../form-control/form-builder/form-builder-element/dynamic-select';\nimport { useUomFieldUpdater } from '../../hooks/useUomFieldUpdater';\nimport { useFormContext } from 'react-hook-form';\n\ninterface UomFieldWrapperProps {\n label: string;\n name?: string;\n placeholder?: string;\n fieldArrayName?: string;\n required?: boolean;\n is_loading?: boolean;\n disabled?: boolean;\n selectedItem: any;\n selectedUom?: any;\n fieldMapping?: Record<string, string>;\n customeFilter?: Record<string, any>;\n getSelectedData?: (data: any, name: string) => void;\n fieldPrefix?: string;\n setValue?: any;\n control?: any;\n isConversationFactor?: boolean;\n}\n\nconst UomFieldWrapper: React.FC<UomFieldWrapperProps> = ({\n label,\n name = 'uom_id',\n placeholder,\n fieldArrayName,\n required = false,\n is_loading = false,\n disabled = false,\n selectedItem,\n fieldMapping = {\n 'total_on_hand_quantity': 'on_hand_quantity',\n 'total_available_quantity': 'available_quantity',\n 'total_committed_quantity': 'committed_quantity',\n },\n customeFilter,\n getSelectedData,\n fieldPrefix,\n setValue,\n control,\n isConversationFactor = true\n}) => {\n // const selectedUom = useMemo(() => getValues(`${fieldArrayName}.${name}`), [getValues(`${fieldArrayName}.${name}`)])\n\n const [uomDetails, setUomDetails] = useState<any>(null);\n const formContext = useFormContext()\n const {\n control: contextControl,\n setValue: contextSetValue,\n } = formContext || {};\n\n const effectiveFieldPrefix = fieldPrefix !== undefined ? fieldPrefix : fieldArrayName || '';\n const finalFieldMapping = useMemo(() => fieldMapping,\n //eslint-disable-next-line\n [JSON.stringify(fieldMapping)]);\n\n const handleUomChange = useUomFieldUpdater({\n fieldMapping: finalFieldMapping,\n sourceData: selectedItem,\n conversation_factor: uomDetails?.conversation_factor,\n fieldPrefix: effectiveFieldPrefix,\n setValue: setValue || contextSetValue,\n control: control || contextControl,\n // shouldUpdate: !!selectedUom\n });\n\n useEffect(() => {\n if (!isConversationFactor) return;\n handleUomChange();\n // eslint-disable-next-line\n }, [handleUomChange, isConversationFactor]);\n\n const handleUomSelect = (data: any, name: string) => {\n setUomDetails(data);\n getSelectedData?.(data, name);\n };\n\n const effectiveCustomeFilter = customeFilter || {\n '&template_id.eq': selectedItem?.unit_of_measurement || 0\n };\n\n return (\n <DynamicSearchSelect\n label={label}\n name={name}\n placeholder={placeholder || ''}\n fieldArrayName={fieldArrayName || ''}\n formControl={control}\n required={required}\n is_loading={is_loading}\n disabled={disabled}\n apiType='uom'\n customeFilter={effectiveCustomeFilter}\n getSelectedData={handleUomSelect}\n />\n );\n};\n\nexport default UomFieldWrapper;\n"],"names":["name"],"mappings":";;;;;AAyBA,MAAM,kBAAkD,CAAC;AAAA,EACrD;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,aAAa;AAAA,EACb,WAAW;AAAA,EACX;AAAA,EACA,eAAe;AAAA,IACX,0BAA0B;AAAA,IAC1B,4BAA4B;AAAA,IAC5B,4BAA4B;AAAA,EAAA;AAAA,EAEhC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,uBAAuB;AAC3B,MAAM;AAGF,QAAM,CAAC,YAAY,aAAa,IAAI,SAAc,IAAI;AACtD,QAAM,cAAc,eAAA;AACpB,QAAM;AAAA,IAEF,UAAU;AAAA,EAAA,IACV,eAAe,CAAA;AAEnB,QAAM,uBAAuB,gBAAgB,SAAY,cAAc,kBAAkB;AACzF,QAAM,oBAAoB;AAAA,IAAQ,MAAM;AAAA;AAAA,IAEpC,CAAC,KAAK,UAAU,YAAY,CAAC;AAAA,EAAA;AAEjC,QAAM,kBAAkB,mBAAmB;AAAA,IACvC,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,qBAAqB,yCAAY;AAAA,IACjC,aAAa;AAAA,IACb,UAAU,YAAY;AAAA,EAG1B,CAAC;AAED,YAAU,MAAM;AACZ,QAAI,CAAC,qBAAsB;AAC3B,oBAAA;AAAA,EAEJ,GAAG,CAAC,iBAAiB,oBAAoB,CAAC;AAE1C,QAAM,kBAAkB,CAAC,MAAWA,UAAiB;AACjD,kBAAc,IAAI;AAClB,uDAAkB,MAAMA;AAAAA,EAC5B;AAEA,QAAM,yBAAyB,iBAAiB;AAAA,IAC5C,oBAAmB,6CAAc,wBAAuB;AAAA,EAAA;AAG5D,SACI;AAAA,IAAC;AAAA,IAAA;AAAA,MACG;AAAA,MACA;AAAA,MACA,aAAa,eAAe;AAAA,MAC5B,gBAAgB,kBAAkB;AAAA,MAClC,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAQ;AAAA,MACR,eAAe;AAAA,MACf,iBAAiB;AAAA,IAAA;AAAA,EAAA;AAG7B;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/uom-field-wrapper/uom-field-wrapper.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState, useMemo } from 'react';\nimport DynamicSearchSelect from '../form-control/form-builder/form-builder-element/dynamic-select';\nimport { useUomFieldUpdater } from '../../hooks/useUomFieldUpdater';\nimport { useFormContext } from 'react-hook-form';\n\ninterface UomFieldWrapperProps {\n label: string;\n name?: string;\n placeholder?: string;\n fieldArrayName?: string;\n required?: boolean;\n is_loading?: boolean;\n disabled?: boolean;\n selectedItem: any;\n selectedUom?: any;\n fieldMapping?: Record<string, string>;\n customeFilter?: Record<string, any>;\n getSelectedData?: (data: any, name: string) => void;\n fieldPrefix?: string;\n setValue?: any;\n control?: any;\n isConversationFactor?: boolean;\n}\n\nconst UomFieldWrapper: React.FC<UomFieldWrapperProps> = ({\n label,\n name = 'uom_id',\n placeholder,\n fieldArrayName,\n required = false,\n is_loading = false,\n disabled = false,\n selectedItem,\n fieldMapping = {\n 'total_on_hand_quantity': 'on_hand_quantity',\n 'total_available_quantity': 'available_quantity',\n 'total_committed_quantity': 'committed_quantity',\n },\n customeFilter,\n getSelectedData,\n fieldPrefix,\n setValue,\n control,\n isConversationFactor = true\n}) => {\n // const selectedUom = useMemo(() => getValues(`${fieldArrayName}.${name}`), [getValues(`${fieldArrayName}.${name}`)])\n\n const [uomDetails, setUomDetails] = useState<any>(null);\n const formContext = useFormContext()\n const {\n control: contextControl,\n setValue: contextSetValue,\n } = formContext || {};\n\n const effectiveFieldPrefix = fieldPrefix !== undefined ? fieldPrefix : fieldArrayName || '';\n const finalFieldMapping = useMemo(() => fieldMapping
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/uom-field-wrapper/uom-field-wrapper.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState, useMemo } from 'react';\nimport DynamicSearchSelect from '../form-control/form-builder/form-builder-element/dynamic-select';\nimport { useUomFieldUpdater } from '../../hooks/useUomFieldUpdater';\nimport { useFormContext } from 'react-hook-form';\n\ninterface UomFieldWrapperProps {\n label: string;\n name?: string;\n placeholder?: string;\n fieldArrayName?: string;\n required?: boolean;\n is_loading?: boolean;\n disabled?: boolean;\n selectedItem: any;\n selectedUom?: any;\n fieldMapping?: Record<string, string>;\n customeFilter?: Record<string, any>;\n getSelectedData?: (data: any, name: string) => void;\n fieldPrefix?: string;\n setValue?: any;\n control?: any;\n isConversationFactor?: boolean;\n}\n\nconst UomFieldWrapper: React.FC<UomFieldWrapperProps> = ({\n label,\n name = 'uom_id',\n placeholder,\n fieldArrayName,\n required = false,\n is_loading = false,\n disabled = false,\n selectedItem,\n fieldMapping = {\n 'total_on_hand_quantity': 'on_hand_quantity',\n 'total_available_quantity': 'available_quantity',\n 'total_committed_quantity': 'committed_quantity',\n },\n customeFilter,\n getSelectedData,\n fieldPrefix,\n setValue,\n control,\n isConversationFactor = true\n}) => {\n // const selectedUom = useMemo(() => getValues(`${fieldArrayName}.${name}`), [getValues(`${fieldArrayName}.${name}`)])\n\n const [uomDetails, setUomDetails] = useState<any>(null);\n const formContext = useFormContext()\n const {\n control: contextControl,\n setValue: contextSetValue,\n } = formContext || {};\n\n const effectiveFieldPrefix = fieldPrefix !== undefined ? fieldPrefix : fieldArrayName || '';\n const finalFieldMapping = useMemo(() => fieldMapping,\n //eslint-disable-next-line\n [JSON.stringify(fieldMapping)]);\n\n const handleUomChange = useUomFieldUpdater({\n fieldMapping: finalFieldMapping,\n sourceData: selectedItem,\n conversation_factor: uomDetails?.conversation_factor,\n fieldPrefix: effectiveFieldPrefix,\n setValue: setValue || contextSetValue,\n control: control || contextControl,\n // shouldUpdate: !!selectedUom\n });\n\n useEffect(() => {\n if (!isConversationFactor) return;\n handleUomChange();\n // eslint-disable-next-line\n }, [handleUomChange, isConversationFactor]);\n\n const handleUomSelect = (data: any, name: string) => {\n setUomDetails(data);\n getSelectedData?.(data, name);\n };\n\n const effectiveCustomeFilter = customeFilter || {\n '&template_id.eq': selectedItem?.unit_of_measurement || 0\n };\n\n return (\n <DynamicSearchSelect\n label={label}\n name={name}\n placeholder={placeholder || ''}\n fieldArrayName={fieldArrayName || ''}\n formControl={control}\n required={required}\n is_loading={is_loading}\n disabled={disabled}\n apiType='uom'\n customeFilter={effectiveCustomeFilter}\n getSelectedData={handleUomSelect}\n />\n );\n};\n\nexport default UomFieldWrapper;\n"],"names":["label","name","placeholder","fieldArrayName","required","is_loading","disabled","selectedItem","fieldMapping","total_on_hand_quantity","total_available_quantity","total_committed_quantity","customeFilter","getSelectedData","fieldPrefix","setValue","control","isConversationFactor","uomDetails","setUomDetails","useState","formContext","useFormContext","contextSetValue","effectiveFieldPrefix","finalFieldMapping","useMemo","JSON","stringify","handleUomChange","useUomFieldUpdater","sourceData","conversation_factor","useEffect","effectiveCustomeFilter","unit_of_measurement","jsx","DynamicSearchSelect","formControl","apiType","data"],"mappings":"yTAyBwD,EACpDA,QACAC,OAAO,SACPC,cACAC,iBACAC,YAAW,EACXC,cAAa,EACbC,YAAW,EACXC,eACAC,eAAe,CACXC,uBAA0B,mBAC1BC,yBAA4B,qBAC5BC,yBAA4B,sBAEhCC,gBACAC,kBACAC,cACAC,WACAC,UACAC,wBAAuB,MAIvB,MAAOC,EAAYC,GAAiBC,EAAAA,SAAc,MAC5CC,EAAcC,EAAAA,kBAGhBP,SAAUQ,GACVF,GAAe,CAAA,EAEbG,OAAuC,IAAhBV,EAA4BA,EAAcX,GAAkB,GACnFsB,EAAoBC,EAAAA,QAAQ,IAAMlB,EAEpC,CAACmB,KAAKC,UAAUpB,KAEdqB,EAAkBC,EAAAA,mBAAmB,CACvCtB,aAAciB,EACdM,WAAYxB,EACZyB,oBAAqB,MAAAd,OAAA,EAAAA,EAAYc,oBACjClB,YAAaU,EACbT,SAAUA,GAAYQ,IAK1BU,EAAAA,UAAU,KACDhB,GACLY,KAED,CAACA,EAAiBZ,IAErB,MAKMiB,EAAyBtB,GAAiB,CAC5C,yBAAmBL,WAAc4B,sBAAuB;AAG5D,OACIC,EAAAA,IAACC,EAAAA,QAAA,CACGrC,QACAC,OACAC,YAAaA,GAAe,GAC5BC,eAAgBA,GAAkB,GAClCmC,YAAatB,EACbZ,WACAC,aACAC,WACAiC,QAAQ,MACR3B,cAAesB,EACfrB,gBArBgB,CAAC2B,EAAWvC,KAChCkB,EAAcqB,GACd,MAAA3B,GAAAA,EAAkB2B,EAAMvC"}
|
package/dist/hooks/index.esm.js
CHANGED
|
@@ -6,13 +6,13 @@ import { usePermissions } from "./use-permissions/index.esm.js";
|
|
|
6
6
|
import { useAppTranslations } from "./use-translations/index.esm.js";
|
|
7
7
|
import { useAuth } from "./useAuth/index.esm.js";
|
|
8
8
|
import { useNameSkuUniquenessCheck } from "./useCheckSkuAndName/index.esm.js";
|
|
9
|
-
import {
|
|
9
|
+
import { default as default3 } from "./useDataFetcher/index.esm.js";
|
|
10
10
|
import { useLanguage } from "./useLangauge/index.esm.js";
|
|
11
11
|
import { useLanguageFallback, useLanguageState } from "./useLanguageFallback/index.esm.js";
|
|
12
12
|
import { useLocationFilter, useMultipleLocationFilters } from "./useLocationFilter/index.esm.js";
|
|
13
13
|
import { useReduxIntegration } from "./useReduxIntegration/index.esm.js";
|
|
14
14
|
import { apiHelper } from "./apiHelper/index.esm.js";
|
|
15
|
-
import { default as
|
|
15
|
+
import { default as default4 } from "./useApi/index.esm.js";
|
|
16
16
|
export {
|
|
17
17
|
apiHelper,
|
|
18
18
|
apiType,
|
|
@@ -27,10 +27,10 @@ export {
|
|
|
27
27
|
recursiveSort,
|
|
28
28
|
removeExtraKeys,
|
|
29
29
|
sortData,
|
|
30
|
-
|
|
30
|
+
default4 as useApi,
|
|
31
31
|
useAppTranslations,
|
|
32
32
|
useAuth,
|
|
33
|
-
useDataFetcher,
|
|
33
|
+
default3 as useDataFetcher,
|
|
34
34
|
default2 as useDeepMemo,
|
|
35
35
|
useLanguage,
|
|
36
36
|
useLanguageFallback,
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./common/index.js"),s=require("./use-deep-memo/index.js"),r=require("./use-material-calculations/index.js"),t=require("./use-pages/index.js"),a=require("./use-permissions/index.js"),u=require("./use-translations/index.js"),i=require("./useAuth/index.js"),o=require("./useCheckSkuAndName/index.js"),p=require("./useDataFetcher/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./common/index.js"),s=require("./use-deep-memo/index.js"),r=require("./use-material-calculations/index.js"),t=require("./use-pages/index.js"),a=require("./use-permissions/index.js"),u=require("./use-translations/index.js"),i=require("./useAuth/index.js"),o=require("./useCheckSkuAndName/index.js"),p=require("./useDataFetcher/index.js"),l=require("./useLangauge/index.js"),n=require("./useLanguageFallback/index.js"),x=require("./useLocationFilter/index.js"),d=require("./useReduxIntegration/index.js"),c=require("./apiHelper/index.js"),m=require("./useApi/index.js");exports.apiType=e.apiType,exports.capitalizeWords=e.capitalizeWords,exports.convertEmptyToNull=e.convertEmptyToNull,exports.defaultUserCurrency=e.defaultUserCurrency,exports.formatNumber=e.formatNumber,exports.formatTime=e.formatTime,exports.formateDate=e.formateDate,exports.recursiveSort=e.recursiveSort,exports.removeExtraKeys=e.removeExtraKeys,exports.sortData=e.sortData,exports.valueWithCurrency=e.valueWithCurrency,exports.useDeepMemo=s.default,exports.getAvailableSteelTypes=r.getAvailableSteelTypes,exports.getAvailableTubeTypes=r.getAvailableTubeTypes,exports.useMaterialCalculations=r.useMaterialCalculations,exports.validateFormValues=r.validateFormValues,exports.usePages=t.usePages,exports.usePermissions=a.usePermissions,exports.useAppTranslations=u.useAppTranslations,exports.useAuth=i.useAuth,exports.useNameSkuUniquenessCheck=o.useNameSkuUniquenessCheck,exports.useDataFetcher=p.default,exports.useLanguage=l.useLanguage,exports.useLanguageFallback=n.useLanguageFallback,exports.useLanguageState=n.useLanguageState,exports.useLocationFilter=x.useLocationFilter,exports.useMultipleLocationFilters=x.useMultipleLocationFilters,exports.useReduxIntegration=d.useReduxIntegration,exports.apiHelper=c.apiHelper,exports.useApi=m.default;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
|
-
import { useLocation } from "react-router-dom";
|
|
3
2
|
import { useTranslation } from "react-i18next";
|
|
4
3
|
import { loadModuleTranslations } from "../../utils/translations/index.esm.js";
|
|
5
4
|
import modules from "../../constants/modules/index.esm.js";
|
|
@@ -8,7 +7,7 @@ let globalIsLoading = false;
|
|
|
8
7
|
let globalInitialLoad = true;
|
|
9
8
|
const useAppTranslations = () => {
|
|
10
9
|
const [isLoading, setIsLoading] = useState(globalInitialLoad);
|
|
11
|
-
const location =
|
|
10
|
+
const location = window.location;
|
|
12
11
|
const { t } = useTranslation();
|
|
13
12
|
useEffect(() => {
|
|
14
13
|
const erpModules = modules(t);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../src/hooks/use-translations.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/hooks/use-translations.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n// import { useLocation } from 'react-router-dom'\nimport { useTranslation } from 'react-i18next'\nimport { loadModuleTranslations } from '../utils/translations'\nimport modules from '../constants/modules'\n\n// Global state to prevent duplicate calls across all hook instances\nlet globalLastLoadedModules = ''\nlet globalIsLoading = false\nlet globalInitialLoad = true\n\nexport const useAppTranslations = () => {\n\tconst [isLoading, setIsLoading] = useState(globalInitialLoad)\n\tconst location = window.location\n\tconst { t } = useTranslation()\n\n\tuseEffect(() => {\n\t\tconst erpModules = modules(t)\n\t\tconst currentPath = location.pathname.toLowerCase()\n\n\t\tconst matchedModule = erpModules.find(\n\t\t\t(mod) =>\n\t\t\t\tmod.link.toLowerCase() === currentPath ||\n\t\t\t\tmod.connectedRoutes?.some((route: string) => currentPath.startsWith(route.toLowerCase()))\n\t\t)\n\n\t\tlet modulesToLoad: string[] = []\n\n\t\tif (matchedModule?.translationModule) {\n\t\t\tmodulesToLoad = [...matchedModule.translationModule, 'common']\n\t\t} else if (!matchedModule && currentPath === '/dashboard') {\n\t\t\tmodulesToLoad = ['common']\n\t\t}\n\n\t\tif (modulesToLoad.length > 0) {\n\t\t\tconst moduleKey = [...modulesToLoad].sort().join(',')\n\n\t\t\t// Skip if same modules are already loaded or currently loading\n\t\t\tif (globalLastLoadedModules === moduleKey || globalIsLoading) {\n\t\t\t\tif (globalInitialLoad) {\n\t\t\t\t\tsetIsLoading(false)\n\t\t\t\t\tglobalInitialLoad = false\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tglobalIsLoading = true\n\t\t\tglobalLastLoadedModules = moduleKey\n\t\t\tsetIsLoading(true)\n\n\t\t\tloadModuleTranslations(modulesToLoad).finally(() => {\n\t\t\t\tglobalIsLoading = false\n\t\t\t\tsetIsLoading(false)\n\t\t\t\tglobalInitialLoad = false\n\t\t\t})\n\t\t} else {\n\t\t\t// No modules to load, but still need to handle initial load state\n\t\t\tif (globalInitialLoad) {\n\t\t\t\tsetIsLoading(false)\n\t\t\t\tglobalInitialLoad = false\n\t\t\t}\n\t\t}\n\t}, [location.pathname, t])\n\n\treturn { isLoading }\n};\n\nexport default useAppTranslations;\n"],"names":[],"mappings":";;;;AAOA,IAAI,0BAA0B;AAC9B,IAAI,kBAAkB;AACtB,IAAI,oBAAoB;AAEjB,MAAM,qBAAqB,MAAM;AACvC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,iBAAiB;AAC5D,QAAM,WAAW,OAAO;AACxB,QAAM,EAAE,EAAA,IAAM,eAAA;AAEd,YAAU,MAAM;AACf,UAAM,aAAa,QAAQ,CAAC;AAC5B,UAAM,cAAc,SAAS,SAAS,YAAA;AAEtC,UAAM,gBAAgB,WAAW;AAAA,MAChC,CAAC,QAAA;;AACA,mBAAI,KAAK,YAAA,MAAkB,iBAC3B,SAAI,oBAAJ,mBAAqB,KAAK,CAAC,UAAkB,YAAY,WAAW,MAAM,aAAa;AAAA;AAAA,IAAC;AAG1F,QAAI,gBAA0B,CAAA;AAE9B,QAAI,+CAAe,mBAAmB;AACrC,sBAAgB,CAAC,GAAG,cAAc,mBAAmB,QAAQ;AAAA,IAC9D,WAAW,CAAC,iBAAiB,gBAAgB,cAAc;AAC1D,sBAAgB,CAAC,QAAQ;AAAA,IAC1B;AAEA,QAAI,cAAc,SAAS,GAAG;AAC7B,YAAM,YAAY,CAAC,GAAG,aAAa,EAAE,KAAA,EAAO,KAAK,GAAG;AAGpD,UAAI,4BAA4B,aAAa,iBAAiB;AAC7D,YAAI,mBAAmB;AACtB,uBAAa,KAAK;AAClB,8BAAoB;AAAA,QACrB;AACA;AAAA,MACD;AAEA,wBAAkB;AAClB,gCAA0B;AAC1B,mBAAa,IAAI;AAEjB,6BAAuB,aAAa,EAAE,QAAQ,MAAM;AACnD,0BAAkB;AAClB,qBAAa,KAAK;AAClB,4BAAoB;AAAA,MACrB,CAAC;AAAA,IACF,OAAO;AAEN,UAAI,mBAAmB;AACtB,qBAAa,KAAK;AAClB,4BAAoB;AAAA,MACrB;AAAA,IACD;AAAA,EACD,GAAG,CAAC,SAAS,UAAU,CAAC,CAAC;AAEzB,SAAO,EAAE,UAAA;AACV;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react-i18next"),o=require("../../utils/translations/index.js"),n=require("../../constants/modules/index.js");let s="",r=!1,a=!0;const i=()=>{const[i,l]=e.useState(a),u=window.location,{t:d}=t.useTranslation();return e.useEffect(()=>{const e=n.default(d),t=u.pathname.toLowerCase(),i=e.find(e=>{var o;return e.link.toLowerCase()===t||(null==(o=e.connectedRoutes)?void 0:o.some(e=>t.startsWith(e.toLowerCase())))});let c=[];if((null==i?void 0:i.translationModule)?c=[...i.translationModule,"common"]:i||"/dashboard"!==t||(c=["common"]),c.length>0){const e=[...c].sort().join(",");if(s===e||r)return void(a&&(l(!1),a=!1));r=!0,s=e,l(!0),o.loadModuleTranslations(c).finally(()=>{r=!1,l(!1),a=!1})}else a&&(l(!1),a=!1)},[u.pathname,d]),{isLoading:i}};exports.default=i,exports.useAppTranslations=i;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/hooks/use-translations.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/hooks/use-translations.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n// import { useLocation } from 'react-router-dom'\nimport { useTranslation } from 'react-i18next'\nimport { loadModuleTranslations } from '../utils/translations'\nimport modules from '../constants/modules'\n\n// Global state to prevent duplicate calls across all hook instances\nlet globalLastLoadedModules = ''\nlet globalIsLoading = false\nlet globalInitialLoad = true\n\nexport const useAppTranslations = () => {\n\tconst [isLoading, setIsLoading] = useState(globalInitialLoad)\n\tconst location = window.location\n\tconst { t } = useTranslation()\n\n\tuseEffect(() => {\n\t\tconst erpModules = modules(t)\n\t\tconst currentPath = location.pathname.toLowerCase()\n\n\t\tconst matchedModule = erpModules.find(\n\t\t\t(mod) =>\n\t\t\t\tmod.link.toLowerCase() === currentPath ||\n\t\t\t\tmod.connectedRoutes?.some((route: string) => currentPath.startsWith(route.toLowerCase()))\n\t\t)\n\n\t\tlet modulesToLoad: string[] = []\n\n\t\tif (matchedModule?.translationModule) {\n\t\t\tmodulesToLoad = [...matchedModule.translationModule, 'common']\n\t\t} else if (!matchedModule && currentPath === '/dashboard') {\n\t\t\tmodulesToLoad = ['common']\n\t\t}\n\n\t\tif (modulesToLoad.length > 0) {\n\t\t\tconst moduleKey = [...modulesToLoad].sort().join(',')\n\n\t\t\t// Skip if same modules are already loaded or currently loading\n\t\t\tif (globalLastLoadedModules === moduleKey || globalIsLoading) {\n\t\t\t\tif (globalInitialLoad) {\n\t\t\t\t\tsetIsLoading(false)\n\t\t\t\t\tglobalInitialLoad = false\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tglobalIsLoading = true\n\t\t\tglobalLastLoadedModules = moduleKey\n\t\t\tsetIsLoading(true)\n\n\t\t\tloadModuleTranslations(modulesToLoad).finally(() => {\n\t\t\t\tglobalIsLoading = false\n\t\t\t\tsetIsLoading(false)\n\t\t\t\tglobalInitialLoad = false\n\t\t\t})\n\t\t} else {\n\t\t\t// No modules to load, but still need to handle initial load state\n\t\t\tif (globalInitialLoad) {\n\t\t\t\tsetIsLoading(false)\n\t\t\t\tglobalInitialLoad = false\n\t\t\t}\n\t\t}\n\t}, [location.pathname, t])\n\n\treturn { isLoading }\n};\n\nexport default useAppTranslations;\n"],"names":["globalLastLoadedModules","globalIsLoading","globalInitialLoad","useAppTranslations","isLoading","setIsLoading","useState","location","window","t","useTranslation","useEffect","erpModules","modules","currentPath","pathname","toLowerCase","matchedModule","find","mod","link","_a","connectedRoutes","some","route","startsWith","modulesToLoad","translationModule","length","moduleKey","sort","join","loadModuleTranslations","finally"],"mappings":"mNAOA,IAAIA,EAA0B,GAC1BC,GAAkB,EAClBC,GAAoB,EAEjB,MAAMC,EAAqB,KACjC,MAAOC,EAAWC,GAAgBC,EAAAA,SAASJ,GACrCK,EAAWC,OAAOD,UAClBE,EAAEA,GAAMC,mBAkDd,OAhDAC,EAAAA,UAAU,KACT,MAAMC,EAAaC,EAAAA,QAAQJ,GACrBK,EAAcP,EAASQ,SAASC,cAEhCC,EAAgBL,EAAWM,KAC/BC,UACA,OAAAA,EAAIC,KAAKJ,gBAAkBF,IAC3B,OAAAO,IAAIC,sBAAJ,EAAAD,EAAqBE,KAAMC,GAAkBV,EAAYW,WAAWD,EAAMR,mBAG5E,IAAIU,EAA0B,GAQ9B,UANIT,WAAeU,mBAClBD,EAAgB,IAAIT,EAAcU,kBAAmB,UAC1CV,GAAiC,eAAhBH,IAC5BY,EAAgB,CAAC,WAGdA,EAAcE,OAAS,EAAG,CAC7B,MAAMC,EAAY,IAAIH,GAAeI,OAAOC,KAAK,KAGjD,GAAI/B,IAA4B6B,GAAa5B,EAK5C,YAJIC,IACHG,GAAa,GACbH,GAAoB,IAKtBD,GAAkB,EAClBD,EAA0B6B,EAC1BxB,GAAa,GAEb2B,yBAAuBN,GAAeO,QAAQ,KAC7ChC,GAAkB,EAClBI,GAAa,GACbH,GAAoB,GAEtB,MAEKA,IACHG,GAAa,GACbH,GAAoB,IAGpB,CAACK,EAASQ,SAAUN,IAEhB,CAAEL"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
import { useDispatch } from "react-redux";
|
|
3
3
|
import { usePages } from "../use-pages/index.esm.js";
|
|
4
|
-
const
|
|
4
|
+
const useGenericDataFetcher = (cols, pagination, fetchAction, customeFilter = "", customDeps, showCreatedBy = true, customFields = []) => {
|
|
5
5
|
const { activePage } = usePages();
|
|
6
6
|
const dispatch = useDispatch();
|
|
7
7
|
const updatedCols = Array.isArray(cols) ? cols : activePage == null ? void 0 : activePage.visible_columns;
|
|
@@ -56,7 +56,6 @@ const useDataFetcher = (cols, pagination, fetchAction, customeFilter = "", custo
|
|
|
56
56
|
return fetchData;
|
|
57
57
|
};
|
|
58
58
|
export {
|
|
59
|
-
|
|
60
|
-
useDataFetcher
|
|
59
|
+
useGenericDataFetcher as default
|
|
61
60
|
};
|
|
62
61
|
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../src/hooks/useDataFetcher.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { useDispatch } from 'react-redux';\nimport { usePages } from './use-pages';\n\ninterface FilterParams {\n\tskip: number;\n\tlimit: number;\n\tsearch?: string;\n\tselect?: string;\n\torder?: string;\n\tfilters?: string;\n}\n\ninterface ActivePage {\n\tsort?: { id: string; desc: boolean };\n\tfilterQueryString?: string;\n\tsearch?: string;\n\tvisible_columns?: { visible: boolean; accessorKey: string }[];\n}\n\
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/hooks/useDataFetcher.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { useDispatch } from 'react-redux';\nimport { usePages } from './use-pages';\n\ninterface FilterParams {\n\tskip: number;\n\tlimit: number;\n\tsearch?: string;\n\tselect?: string;\n\torder?: string;\n\tfilters?: string;\n}\n\ninterface ActivePage {\n\tsort?: { id: string; desc: boolean };\n\tfilterQueryString?: string;\n\tsearch?: string;\n\tvisible_columns?: { visible: boolean; accessorKey: string }[];\n}\n\nconst useGenericDataFetcher = (\n\tcols?: ActivePage,\n\tpagination: { skip: number; limit: number },\n\tfetchAction: (filters: FilterParams) => void,\n\tcustomeFilter: any = '',\n\tcustomDeps?: any[],\n\tshowCreatedBy: boolean = true,\n\tcustomFields?: any = []\n) => {\n\tconst { activePage } = usePages();\n\tconst dispatch = useDispatch();\n\tconst updatedCols = Array.isArray(cols) ? cols : activePage?.visible_columns;\n\n\tconst getProcessedFilters = useCallback(() => {\n\t\tconst { filterQueryString } = activePage || {};\n\t\tconst queryString = filterQueryString?.replaceAll(/[()]/g, \"\") || '';\n\t\tconst extraQueryString = queryString.length ? `&${queryString}` : '';\n\t\tlet filters = customeFilter;\n\n\t\tif (extraQueryString) {\n\t\t\tfilters = filters ? `(${filters}${extraQueryString})` : `(${extraQueryString})`;\n\t\t} else if (filters) {\n\t\t\tfilters = `(${filters})`;\n\t\t}\n\n\t\treturn filters || undefined;\n\t\t//eslint-disable-next-line\n\t}, [activePage.filterQueryString, customeFilter]);\n\n\tconst fetchData = useCallback(() => {\n\t\tif (!fetchAction) {\n\t\t\treturn;\n\t\t}\n\t\tconst { sort = null, search } = activePage;\n\t\tif (!Array.isArray(cols) && activePage?.visible_columns?.length == 0) return;\n\t\tconst filters = getProcessedFilters();\n\t\tconst visibleColumns = updatedCols\n\t\t\t?.filter((vc) => vc.visible)\n\n\t\tconst selectPayload = visibleColumns?.length > 0 ? `[${visibleColumns\n\t\t\t?.map((item) =>\n\t\t\t\titem.accessorKey?.includes(\".\")\n\t\t\t\t\t? item.accessorKey.split(\".\")[0]\n\t\t\t\t\t: item.accessorKey\n\t\t\t)}${showCreatedBy ? ',created_at,created_by_data' : ''}${customFields?.length ? `,${customFields?.join(',')}` : ''}]` : undefined\n\t\tconst payload: FilterParams = {\n\t\t\tskip: activePage?.skip || pagination?.skip,\n\t\t\tlimit: pagination.limit,\n\t\t\tsearch,\n\t\t\tselect: selectPayload,\n\t\t\t...(sort && { order: `${sort.id}:${sort.desc ? -1 : 1}` }),\n\t\t\t...(filters && { filters }),\n\t\t};\n\n\t\tdispatch(fetchAction(payload));\n\t\t//eslint-disable-next-line\n\t}, [\n\t\tupdatedCols?.length,\n\t\tactivePage.sort,\n\t\tactivePage.filterQueryString,\n\t\tactivePage.search,\n\t\t// pagination?.skip,\n\t\tactivePage?.skip,\n\t\tpagination?.limit,\n\t\tdispatch,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t...(customDeps || []),\n\t]);\n\n\n\n\treturn fetchData;\n};\n\nexport default useGenericDataFetcher;\n"],"names":["_a"],"mappings":";;;AAoBA,MAAM,wBAAwB,CAC7B,MACA,YACA,aACA,gBAAqB,IACrB,YACA,gBAAyB,MACzB,eAAqB,CAAA,MACjB;AACJ,QAAM,EAAE,WAAA,IAAe,SAAA;AACvB,QAAM,WAAW,YAAA;AACjB,QAAM,cAAc,MAAM,QAAQ,IAAI,IAAI,OAAO,yCAAY;AAE7D,QAAM,sBAAsB,YAAY,MAAM;AAC7C,UAAM,EAAE,sBAAsB,cAAc,CAAA;AAC5C,UAAM,eAAc,uDAAmB,WAAW,SAAS,QAAO;AAClE,UAAM,mBAAmB,YAAY,SAAS,IAAI,WAAW,KAAK;AAClE,QAAI,UAAU;AAEd,QAAI,kBAAkB;AACrB,gBAAU,UAAU,IAAI,OAAO,GAAG,gBAAgB,MAAM,IAAI,gBAAgB;AAAA,IAC7E,WAAW,SAAS;AACnB,gBAAU,IAAI,OAAO;AAAA,IACtB;AAEA,WAAO,WAAW;AAAA,EAEnB,GAAG,CAAC,WAAW,mBAAmB,aAAa,CAAC;AAEhD,QAAM,YAAY,YAAY,MAAM;;AACnC,QAAI,CAAC,aAAa;AACjB;AAAA,IACD;AACA,UAAM,EAAE,OAAO,MAAM,OAAA,IAAW;AAChC,QAAI,CAAC,MAAM,QAAQ,IAAI,OAAK,8CAAY,oBAAZ,mBAA6B,WAAU,EAAG;AACtE,UAAM,UAAU,oBAAA;AAChB,UAAM,iBAAiB,2CACpB,OAAO,CAAC,OAAO,GAAG;AAErB,UAAM,iBAAgB,iDAAgB,UAAS,IAAI,IAAI,iDACpD;AAAA,MAAI,CAAC,SAAA;;AACN,iBAAAA,MAAA,KAAK,gBAAL,gBAAAA,IAAkB,SAAS,QACxB,KAAK,YAAY,MAAM,GAAG,EAAE,CAAC,IAC7B,KAAK;AAAA;AAAA,KACR,GAAG,gBAAgB,gCAAgC,EAAE,IAAG,6CAAc,UAAS,IAAI,6CAAc,KAAK,IAAI,KAAK,EAAE,MAAM;AACzH,UAAM,UAAwB;AAAA,MAC7B,OAAM,yCAAY,UAAQ,yCAAY;AAAA,MACtC,OAAO,WAAW;AAAA,MAClB;AAAA,MACA,QAAQ;AAAA,MACR,GAAI,QAAQ,EAAE,OAAO,GAAG,KAAK,EAAE,IAAI,KAAK,OAAO,KAAK,CAAC,GAAA;AAAA,MACrD,GAAI,WAAW,EAAE,QAAA;AAAA,IAAQ;AAG1B,aAAS,YAAY,OAAO,CAAC;AAAA,EAE9B,GAAG;AAAA,IACF,2CAAa;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA;AAAA,IAEX,yCAAY;AAAA,IACZ,yCAAY;AAAA,IACZ;AAAA;AAAA,IAEA,GAAI,cAAc,CAAA;AAAA,EAAC,CACnB;AAID,SAAO;AACR;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),l=require("react-redux"),r=require("../use-pages/index.js");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),l=require("react-redux"),r=require("../use-pages/index.js");exports.default=(i,s,t,u="",n,o=!0,a=[])=>{const{activePage:c}=r.usePages(),d=l.useDispatch(),v=Array.isArray(i)?i:null==c?void 0:c.visible_columns,g=e.useCallback(()=>{const{filterQueryString:e}=c||{},l=(null==e?void 0:e.replaceAll(/[()]/g,""))||"",r=l.length?`&${l}`:"";let i=u;return r?i=i?`(${i}${r})`:`(${r})`:i&&(i=`(${i})`),i||void 0},[c.filterQueryString,u]);return e.useCallback(()=>{var e;if(!t)return;const{sort:l=null,search:r}=c;if(!Array.isArray(i)&&0==(null==(e=null==c?void 0:c.visible_columns)?void 0:e.length))return;const u=g(),n=null==v?void 0:v.filter(e=>e.visible),p=(null==n?void 0:n.length)>0?`[${null==n?void 0:n.map(e=>{var l;return(null==(l=e.accessorKey)?void 0:l.includes("."))?e.accessorKey.split(".")[0]:e.accessorKey})}${o?",created_at,created_by_data":""}${(null==a?void 0:a.length)?`,${null==a?void 0:a.join(",")}`:""}]`:void 0,y={skip:(null==c?void 0:c.skip)||(null==s?void 0:s.skip),limit:s.limit,search:r,select:p,...l&&{order:`${l.id}:${l.desc?-1:1}`},...u&&{filters:u}};d(t(y))},[null==v?void 0:v.length,c.sort,c.filterQueryString,c.search,null==c?void 0:c.skip,null==s?void 0:s.limit,d,...n||[]])};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/hooks/useDataFetcher.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { useDispatch } from 'react-redux';\nimport { usePages } from './use-pages';\n\ninterface FilterParams {\n\tskip: number;\n\tlimit: number;\n\tsearch?: string;\n\tselect?: string;\n\torder?: string;\n\tfilters?: string;\n}\n\ninterface ActivePage {\n\tsort?: { id: string; desc: boolean };\n\tfilterQueryString?: string;\n\tsearch?: string;\n\tvisible_columns?: { visible: boolean; accessorKey: string }[];\n}\n\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/hooks/useDataFetcher.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { useDispatch } from 'react-redux';\nimport { usePages } from './use-pages';\n\ninterface FilterParams {\n\tskip: number;\n\tlimit: number;\n\tsearch?: string;\n\tselect?: string;\n\torder?: string;\n\tfilters?: string;\n}\n\ninterface ActivePage {\n\tsort?: { id: string; desc: boolean };\n\tfilterQueryString?: string;\n\tsearch?: string;\n\tvisible_columns?: { visible: boolean; accessorKey: string }[];\n}\n\nconst useGenericDataFetcher = (\n\tcols?: ActivePage,\n\tpagination: { skip: number; limit: number },\n\tfetchAction: (filters: FilterParams) => void,\n\tcustomeFilter: any = '',\n\tcustomDeps?: any[],\n\tshowCreatedBy: boolean = true,\n\tcustomFields?: any = []\n) => {\n\tconst { activePage } = usePages();\n\tconst dispatch = useDispatch();\n\tconst updatedCols = Array.isArray(cols) ? cols : activePage?.visible_columns;\n\n\tconst getProcessedFilters = useCallback(() => {\n\t\tconst { filterQueryString } = activePage || {};\n\t\tconst queryString = filterQueryString?.replaceAll(/[()]/g, \"\") || '';\n\t\tconst extraQueryString = queryString.length ? `&${queryString}` : '';\n\t\tlet filters = customeFilter;\n\n\t\tif (extraQueryString) {\n\t\t\tfilters = filters ? `(${filters}${extraQueryString})` : `(${extraQueryString})`;\n\t\t} else if (filters) {\n\t\t\tfilters = `(${filters})`;\n\t\t}\n\n\t\treturn filters || undefined;\n\t\t//eslint-disable-next-line\n\t}, [activePage.filterQueryString, customeFilter]);\n\n\tconst fetchData = useCallback(() => {\n\t\tif (!fetchAction) {\n\t\t\treturn;\n\t\t}\n\t\tconst { sort = null, search } = activePage;\n\t\tif (!Array.isArray(cols) && activePage?.visible_columns?.length == 0) return;\n\t\tconst filters = getProcessedFilters();\n\t\tconst visibleColumns = updatedCols\n\t\t\t?.filter((vc) => vc.visible)\n\n\t\tconst selectPayload = visibleColumns?.length > 0 ? `[${visibleColumns\n\t\t\t?.map((item) =>\n\t\t\t\titem.accessorKey?.includes(\".\")\n\t\t\t\t\t? item.accessorKey.split(\".\")[0]\n\t\t\t\t\t: item.accessorKey\n\t\t\t)}${showCreatedBy ? ',created_at,created_by_data' : ''}${customFields?.length ? `,${customFields?.join(',')}` : ''}]` : undefined\n\t\tconst payload: FilterParams = {\n\t\t\tskip: activePage?.skip || pagination?.skip,\n\t\t\tlimit: pagination.limit,\n\t\t\tsearch,\n\t\t\tselect: selectPayload,\n\t\t\t...(sort && { order: `${sort.id}:${sort.desc ? -1 : 1}` }),\n\t\t\t...(filters && { filters }),\n\t\t};\n\n\t\tdispatch(fetchAction(payload));\n\t\t//eslint-disable-next-line\n\t}, [\n\t\tupdatedCols?.length,\n\t\tactivePage.sort,\n\t\tactivePage.filterQueryString,\n\t\tactivePage.search,\n\t\t// pagination?.skip,\n\t\tactivePage?.skip,\n\t\tpagination?.limit,\n\t\tdispatch,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t...(customDeps || []),\n\t]);\n\n\n\n\treturn fetchData;\n};\n\nexport default useGenericDataFetcher;\n"],"names":["cols","pagination","fetchAction","customeFilter","customDeps","showCreatedBy","customFields","activePage","usePages","dispatch","useDispatch","updatedCols","Array","isArray","visible_columns","getProcessedFilters","useCallback","filterQueryString","queryString","replaceAll","extraQueryString","length","filters","sort","search","_a","visibleColumns","filter","vc","visible","selectPayload","map","item","accessorKey","includes","split","join","payload","skip","limit","select","order","id","desc"],"mappings":"uKAoB8B,CAC7BA,EACAC,EACAC,EACAC,EAAqB,GACrBC,EACAC,GAAyB,EACzBC,EAAqB,MAErB,MAAMC,WAAEA,GAAeC,aACjBC,EAAWC,EAAAA,cACXC,EAAcC,MAAMC,QAAQb,GAAQA,EAAO,MAAAO,OAAA,EAAAA,EAAYO,gBAEvDC,EAAsBC,EAAAA,YAAY,KACvC,MAAMC,kBAAEA,GAAsBV,GAAc,CAAA,EACtCW,GAAc,MAAAD,OAAA,EAAAA,EAAmBE,WAAW,QAAS,MAAO,GAC5DC,EAAmBF,EAAYG,OAAS,IAAIH,IAAgB,GAClE,IAAII,EAAUnB,EAQd,OANIiB,EACHE,EAAUA,EAAU,IAAIA,IAAUF,KAAsB,IAAIA,KAClDE,IACVA,EAAU,IAAIA,MAGRA,QAAW,GAEhB,CAACf,EAAWU,kBAAmBd,IA4ClC,OA1CkBa,EAAAA,YAAY,WAC7B,IAAKd,EACJ,OAED,MAAMqB,KAAEA,EAAO,KAAAC,OAAMA,GAAWjB,EAChC,IAAKK,MAAMC,QAAQb,IAAgD,IAAvC,OAAAyB,EAAA,MAAAlB,OAAA,EAAAA,EAAYO,sBAAZ,EAAAW,EAA6BJ,QAAa,OACtE,MAAMC,EAAUP,IACVW,EAAiB,MAAAf,OAAA,EAAAA,EACpBgB,OAAQC,GAAOA,EAAGC,SAEfC,GAAgB,MAAAJ,OAAA,EAAAA,EAAgBL,QAAS,EAAI,IAAI,MAAAK,OAAA,EAAAA,EACpDK,IAAKC,UACN,OAAA,OAAAP,EAAAO,EAAKC,kBAAL,EAAAR,EAAkBS,SAAS,MACxBF,EAAKC,YAAYE,MAAM,KAAK,GAC5BH,EAAKC,gBACL5B,EAAgB,8BAAgC,MAAK,MAAAC,OAAA,EAAAA,EAAce,QAAS,IAAI,MAAAf,OAAA,EAAAA,EAAc8B,KAAK,OAAS,WAAQ,EACnHC,EAAwB,CAC7BC,MAAM,MAAA/B,OAAA,EAAAA,EAAY+B,QAAQ,MAAArC,OAAA,EAAAA,EAAYqC,MACtCC,MAAOtC,EAAWsC,MAClBf,SACAgB,OAAQV,KACJP,GAAQ,CAAEkB,MAAO,GAAGlB,EAAKmB,MAAMnB,EAAKoB,MAAO,EAAK,QAChDrB,GAAW,CAAEA,YAGlBb,EAASP,EAAYmC,KAEnB,CACF,MAAA1B,OAAA,EAAAA,EAAaU,OACbd,EAAWgB,KACXhB,EAAWU,kBACXV,EAAWiB,OAEX,MAAAjB,OAAA,EAAAA,EAAY+B,KACZ,MAAArC,OAAA,EAAAA,EAAYsC,MACZ9B,KAEIL,GAAc"}
|
|
@@ -18,8 +18,8 @@ interface ActivePage {
|
|
|
18
18
|
accessorKey: string;
|
|
19
19
|
}[];
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
declare const useGenericDataFetcher: (cols?: ActivePage, pagination: {
|
|
22
22
|
skip: number;
|
|
23
23
|
limit: number;
|
|
24
24
|
}, fetchAction: (filters: FilterParams) => void, customeFilter?: any, customDeps?: any[], showCreatedBy?: boolean, customFields?: any) => () => void;
|
|
25
|
-
export default
|
|
25
|
+
export default useGenericDataFetcher;
|