@codebit-programando-solucoes/codebit-web-antd 1.1.16 → 1.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /*! For license information please see index.cjs.LICENSE.txt */
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- "../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react-jsx-runtime.development.js": function(__unused_webpack_module, exports1, __webpack_require__) {
4
+ "../../node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react-jsx-runtime.development.js" (__unused_rspack_module, exports1, __webpack_require__) {
5
5
  /**
6
6
  * @license React
7
7
  * react-jsx-runtime.development.js
@@ -209,7 +209,7 @@ var __webpack_modules__ = {
209
209
  };
210
210
  }();
211
211
  },
212
- "../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react-jsx-runtime.production.js": function(__unused_webpack_module, exports1) {
212
+ "../../node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react-jsx-runtime.production.js" (__unused_rspack_module, exports1) {
213
213
  /**
214
214
  * @license React
215
215
  * react-jsx-runtime.production.js
@@ -240,11 +240,11 @@ var __webpack_modules__ = {
240
240
  exports1.jsx = jsxProd;
241
241
  exports1.jsxs = jsxProd;
242
242
  },
243
- "../../node_modules/.pnpm/react@19.2.0/node_modules/react/jsx-runtime.js": function(module, __unused_webpack_exports, __webpack_require__) {
244
- if ('production' === process.env.NODE_ENV) module.exports = __webpack_require__("../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react-jsx-runtime.production.js");
245
- else module.exports = __webpack_require__("../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react-jsx-runtime.development.js");
243
+ "../../node_modules/.pnpm/react@19.2.3/node_modules/react/jsx-runtime.js" (module, __unused_rspack_exports, __webpack_require__) {
244
+ if ('production' === process.env.NODE_ENV) module.exports = __webpack_require__("../../node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react-jsx-runtime.production.js");
245
+ else module.exports = __webpack_require__("../../node_modules/.pnpm/react@19.2.3/node_modules/react/cjs/react-jsx-runtime.development.js");
246
246
  },
247
- react: function(module) {
247
+ react (module) {
248
248
  module.exports = require("react");
249
249
  }
250
250
  };
@@ -280,7 +280,7 @@ function __webpack_require__(moduleId) {
280
280
  })();
281
281
  (()=>{
282
282
  __webpack_require__.r = (exports1)=>{
283
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
283
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
284
284
  value: 'Module'
285
285
  });
286
286
  Object.defineProperty(exports1, '__esModule', {
@@ -296,12 +296,15 @@ var __webpack_exports__ = {};
296
296
  CssTokenBridge: ()=>CssTokenBridge,
297
297
  LoggedMainContainer: ()=>LoggedMainContainer,
298
298
  Login: ()=>Login,
299
+ CodebitThemeProvider: ()=>CodebitThemeProvider,
300
+ useErrorModal: ()=>useErrorModal,
299
301
  ErrorRetry: ()=>ErrorRetry,
302
+ CodebitThemeContext: ()=>CodebitThemeContext,
300
303
  CodebitConfigContext: ()=>CodebitConfigContext,
301
304
  ListCard: ()=>ListCard,
302
305
  ForgotPassword: ()=>ForgotPassword,
303
306
  LoginContainer: ()=>LoginContainer,
304
- CodebitTheme: ()=>CodebitTheme,
307
+ useErrorMessage: ()=>useErrorMessage,
305
308
  LocalLoginRecoveryPasswordResult: ()=>LocalLoginRecoveryPasswordResult,
306
309
  FilterContainer: ()=>FilterContainer,
307
310
  HandleError: ()=>HandleError,
@@ -309,15 +312,102 @@ var __webpack_exports__ = {};
309
312
  CodebitConfigProvider: ()=>CodebitConfigProvider,
310
313
  ThemeToggle: ()=>ThemeToggle
311
314
  });
312
- var jsx_runtime = __webpack_require__("../../node_modules/.pnpm/react@19.2.0/node_modules/react/jsx-runtime.js");
315
+ var jsx_runtime = __webpack_require__("../../node_modules/.pnpm/react@19.2.3/node_modules/react/jsx-runtime.js");
313
316
  const icons_namespaceObject = require("@ant-design/icons");
314
317
  const external_antd_namespaceObject = require("antd");
315
318
  const external_prop_types_namespaceObject = require("prop-types");
316
319
  var external_prop_types_default = /*#__PURE__*/ __webpack_require__.n(external_prop_types_namespaceObject);
317
320
  var external_react_ = __webpack_require__("react");
318
321
  const external_react_router_namespaceObject = require("react-router");
319
- const external_i18next_namespaceObject = require("i18next");
322
+ const react_namespaceObject = require("@sentry/react");
323
+ const codebit_web_namespaceObject = require("@codebit-programando-solucoes/codebit-web");
324
+ const logger = new codebit_web_namespaceObject.Logger('CodebitConfigContext');
325
+ const CodebitConfigContext = /*#__PURE__*/ (0, external_react_.createContext)(null);
326
+ function CodebitConfigProvider({ children, menuItems, version = '1.0', showVersion = ()=>true, secondarySidebar, secondarySidebarWidth = 280, doLogout, checkLogin }) {
327
+ const [isLogged, setIsLogged] = (0, external_react_.useState)(null);
328
+ const [user, setUser] = (0, external_react_.useState)(null);
329
+ const logout = async ()=>{
330
+ await doLogout();
331
+ setIsLogged(false);
332
+ setUser(null);
333
+ react_namespaceObject.setUser(null);
334
+ };
335
+ (0, external_react_.useEffect)(()=>{
336
+ if (null === isLogged) checkLogin().then((loggedUser)=>{
337
+ if (loggedUser) {
338
+ logger.trace('User data.', loggedUser);
339
+ setIsLogged(true);
340
+ setUser(loggedUser);
341
+ react_namespaceObject.setUser({
342
+ id: loggedUser.id,
343
+ email: loggedUser.email,
344
+ name: loggedUser.name
345
+ });
346
+ } else {
347
+ logger.trace('User not logged in.');
348
+ setIsLogged(false);
349
+ setUser(null);
350
+ react_namespaceObject.setUser(null);
351
+ }
352
+ }).catch((e)=>{
353
+ logger.error('Error fetching session state.', e);
354
+ setIsLogged(false);
355
+ setUser(null);
356
+ });
357
+ }, [
358
+ isLogged
359
+ ]);
360
+ const contextValue = (0, external_react_.useMemo)(()=>({
361
+ menuItems,
362
+ isLogged,
363
+ user,
364
+ logout,
365
+ version,
366
+ showVersion,
367
+ secondarySidebar,
368
+ secondarySidebarWidth
369
+ }), [
370
+ menuItems,
371
+ isLogged,
372
+ user,
373
+ version,
374
+ showVersion,
375
+ secondarySidebar,
376
+ secondarySidebarWidth
377
+ ]);
378
+ return /*#__PURE__*/ (0, jsx_runtime.jsx)(CodebitConfigContext.Provider, {
379
+ value: contextValue,
380
+ children: children
381
+ });
382
+ }
383
+ CodebitConfigProvider.propTypes = {
384
+ children: external_prop_types_default().node.isRequired,
385
+ menuItems: external_prop_types_default().func.isRequired,
386
+ version: external_prop_types_default().string,
387
+ showVersion: external_prop_types_default().func,
388
+ secondarySidebar: external_prop_types_default().func,
389
+ secondarySidebarWidth: external_prop_types_default().number,
390
+ doLogout: external_prop_types_default().func.isRequired,
391
+ checkLogin: external_prop_types_default().func.isRequired
392
+ };
393
+ const ThemeToggle = ()=>{
394
+ const config = (0, external_react_.useContext)(CodebitThemeContext);
395
+ if (!config) throw new Error('ThemeToggle must be used within CodebitThemeContext');
396
+ (0, external_react_.useEffect)(()=>{
397
+ document.documentElement.style.colorScheme = config.isDarkMode ? 'dark' : 'light';
398
+ }, [
399
+ config.isDarkMode
400
+ ]);
401
+ return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Switch, {
402
+ theme: config.isDarkMode ? 'dark' : 'light',
403
+ checked: config.isDarkMode,
404
+ onChange: (value)=>config.setIsDarkMode(value),
405
+ checkedChildren: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MoonOutlined, {}),
406
+ unCheckedChildren: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.SunOutlined, {})
407
+ });
408
+ };
320
409
  const external_react_i18next_namespaceObject = require("react-i18next");
410
+ const external_i18next_namespaceObject = require("i18next");
321
411
  const pt = {
322
412
  codebitWebAntd: {
323
413
  LoggedMainContainer: {
@@ -336,7 +426,8 @@ var __webpack_exports__ = {};
336
426
  genericMessage: 'Ocorreu um erro inesperado.',
337
427
  backHome: 'Voltar para página inicial'
338
428
  },
339
- ErrorRetry: {
429
+ Error: {
430
+ errorTitle: 'Erro',
340
431
  defaultError: 'Erro ao carregar',
341
432
  retryButton: 'Tentar novamente',
342
433
  reloadPageButton: 'Recarregar página',
@@ -437,7 +528,8 @@ var __webpack_exports__ = {};
437
528
  genericMessage: 'An unexpected error occurred.',
438
529
  backHome: 'Back to home'
439
530
  },
440
- ErrorRetry: {
531
+ Error: {
532
+ errorTitle: 'Error',
441
533
  defaultError: 'Failed to load',
442
534
  retryButton: 'Try again',
443
535
  reloadPageButton: 'Reload page',
@@ -537,108 +629,387 @@ var __webpack_exports__ = {};
537
629
  }
538
630
  });
539
631
  const i18n = i18nLib;
540
- const CodebitConfigContext = /*#__PURE__*/ (0, external_react_.createContext)(null);
541
- function CodebitConfigProvider({ children, menuItems, user, onLogout, version = '1.0', showVersion = true, secondarySidebar, secondarySidebarWidth = 280, storeThemeInLocalStorage = true }) {
542
- const getSystemTheme = ()=>globalThis.matchMedia?.('(prefers-color-scheme: dark)')?.matches ?? false;
543
- const [isDarkMode, setIsDarkMode] = (0, external_react_.useState)(()=>{
544
- if (storeThemeInLocalStorage) {
545
- const savedTheme = localStorage.getItem('theme');
546
- if (null !== savedTheme) return 'dark' === savedTheme;
632
+ const useCodebitWebAntdTranslation = ()=>(0, external_react_i18next_namespaceObject.useTranslation)('codebitWebAntd', {
633
+ i18n: i18n
634
+ });
635
+ function useErrorMessage() {
636
+ const { t } = useCodebitWebAntdTranslation();
637
+ const getErrorMessage = (error)=>{
638
+ let status = 'error';
639
+ const responseStatus = error?.response?.status || null;
640
+ let errorMessage = t('Error.defaultError');
641
+ let retryText = t('Error.retryButton');
642
+ let onRetryAction = null;
643
+ if (error?.errorCode) switch(error.errorCode){
644
+ case codebit_web_namespaceObject.ErrorCode.ERR_NETWORK:
645
+ errorMessage = t('Error.networkError');
646
+ break;
647
+ case codebit_web_namespaceObject.ErrorCode.ERR_TIMEOUT:
648
+ errorMessage = t('Error.timeoutError');
649
+ break;
547
650
  }
548
- return getSystemTheme();
651
+ else if (responseStatus) switch(responseStatus){
652
+ case 400:
653
+ errorMessage = t('Error.badRequestError');
654
+ break;
655
+ case 403:
656
+ errorMessage = t('Error.forbiddenError');
657
+ retryText = t('Error.reloadPageButton');
658
+ status = 403;
659
+ onRetryAction = ()=>{
660
+ globalThis.location.reload();
661
+ };
662
+ break;
663
+ case 404:
664
+ errorMessage = t('Error.notFoundError');
665
+ status = 404;
666
+ break;
667
+ case 500:
668
+ errorMessage = t('Error.internalServerError');
669
+ status = 500;
670
+ break;
671
+ case 401:
672
+ errorMessage = t('Error.sessionExpiredError');
673
+ retryText = t('Error.reloadPageButton');
674
+ onRetryAction = ()=>{
675
+ globalThis.location.reload();
676
+ };
677
+ break;
678
+ }
679
+ return {
680
+ errorMessage,
681
+ status,
682
+ retryText,
683
+ onRetryAction
684
+ };
685
+ };
686
+ return {
687
+ getErrorMessage
688
+ };
689
+ }
690
+ const ErrorRetry_logger = new codebit_web_namespaceObject.Logger('ErrorRetry');
691
+ function ErrorRetry({ error, onRetry }) {
692
+ if (error && error instanceof Error) {
693
+ ErrorRetry_logger.error('Fail to load.', error);
694
+ react_namespaceObject.captureException(error);
695
+ }
696
+ const { getErrorMessage } = useErrorMessage();
697
+ const { status, errorMessage, retryText, onRetryAction } = getErrorMessage(error);
698
+ return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Card, {
699
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Result, {
700
+ status: status,
701
+ title: errorMessage,
702
+ extra: [
703
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
704
+ type: 'primary',
705
+ onClick: onRetryAction ?? onRetry,
706
+ icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.ReloadOutlined, {}),
707
+ children: retryText
708
+ }, 'retry')
709
+ ]
710
+ })
549
711
  });
550
- (0, external_react_.useEffect)(()=>{
551
- const mediaQuery = globalThis.matchMedia('(prefers-color-scheme: dark)');
552
- const handleThemeChange = (e)=>{
553
- if (!storeThemeInLocalStorage) return void setIsDarkMode(e.matches);
554
- const savedTheme = localStorage.getItem('theme');
555
- if (null === savedTheme) setIsDarkMode(e.matches);
712
+ }
713
+ ErrorRetry.propTypes = {
714
+ error: external_prop_types_default().object.isRequired,
715
+ onRetry: external_prop_types_default().func.isRequired
716
+ };
717
+ const ListCard_module = {
718
+ listCard: "listCard-ISftFd",
719
+ headerRow: "headerRow-UsZAzP",
720
+ actions: "actions-ig53s2",
721
+ filtersRow: "filtersRow-f3Xk5a",
722
+ expandArea: "expandArea-czOoFS"
723
+ };
724
+ const { Title } = external_antd_namespaceObject.Typography;
725
+ function ListCard({ title, onClearFilters, headerContainer, tableContainer, actions }) {
726
+ const { token } = external_antd_namespaceObject.theme.useToken();
727
+ const { t } = (0, external_react_i18next_namespaceObject.useTranslation)('codebitWebAntd');
728
+ const margin = token['margin'];
729
+ return /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Card, {
730
+ className: ListCard_module.listCard,
731
+ children: [
732
+ /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Row, {
733
+ gutter: margin,
734
+ align: 'middle',
735
+ className: ListCard_module.headerRow,
736
+ children: [
737
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Col, {
738
+ xs: 24,
739
+ sm: 24,
740
+ md: 12,
741
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(Title, {
742
+ level: 4,
743
+ children: title
744
+ })
745
+ }),
746
+ (!!onClearFilters || !!actions) && /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Col, {
747
+ xs: 24,
748
+ sm: 24,
749
+ md: 12,
750
+ className: ListCard_module.actions,
751
+ children: [
752
+ !!onClearFilters && /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
753
+ icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.ClearOutlined, {}),
754
+ onClick: onClearFilters,
755
+ children: t('ListCard.clearFilters')
756
+ }),
757
+ actions
758
+ ]
759
+ })
760
+ ]
761
+ }),
762
+ !!headerContainer && /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Row, {
763
+ gutter: margin,
764
+ className: ListCard_module.filtersRow,
765
+ children: headerContainer
766
+ }),
767
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Layout, {
768
+ className: ListCard_module.expandArea,
769
+ children: tableContainer
770
+ })
771
+ ]
772
+ });
773
+ }
774
+ ListCard.propTypes = {
775
+ title: external_prop_types_default().string.isRequired,
776
+ onClearFilters: external_prop_types_default().func,
777
+ headerContainer: external_prop_types_default().node,
778
+ tableContainer: external_prop_types_default().node,
779
+ actions: external_prop_types_default().node
780
+ };
781
+ ListCard.defaultProps = {
782
+ onClearFilters: null,
783
+ headerContainer: null,
784
+ tableContainer: null,
785
+ actions: null
786
+ };
787
+ const CssTokenBridge = ()=>{
788
+ const { token } = external_antd_namespaceObject.theme.useToken();
789
+ (0, external_react_.useLayoutEffect)(()=>{
790
+ const root = document.documentElement;
791
+ root.style.setProperty('--antd-color-bg-container', token['colorBgContainer']);
792
+ root.style.setProperty('--antd-color-bg-elevated', token['colorBgElevated']);
793
+ root.style.setProperty('--antd-color-bg-layout', token['colorBgLayout']);
794
+ root.style.setProperty('--antd-color-border', token['colorBorder']);
795
+ root.style.setProperty('--antd-color-primary', token['colorPrimary']);
796
+ root.style.setProperty('--antd-color-text', token['colorText']);
797
+ root.style.setProperty('--antd-color-text-secondary', token['colorTextSecondary']);
798
+ root.style.setProperty('--antd-color-split', token['colorSplit']);
799
+ root.style.setProperty('--antd-margin-xxs', `${token['marginXXS']}px`);
800
+ root.style.setProperty('--antd-margin-xs', `${token['marginXS']}px`);
801
+ root.style.setProperty('--antd-margin-sm', `${token['marginSM']}px`);
802
+ root.style.setProperty('--antd-margin', `${token['margin']}px`);
803
+ root.style.setProperty('--antd-margin-md', `${token['marginMD']}px`);
804
+ root.style.setProperty('--antd-margin-lg', `${token['marginLG']}px`);
805
+ root.style.setProperty('--antd-margin-xl', `${token['marginXL']}px`);
806
+ root.style.setProperty('--antd-margin-xxl', `${token['marginXXL']}px`);
807
+ root.style.setProperty('--antd-padding-xxs', `${token['paddingXXS']}px`);
808
+ root.style.setProperty('--antd-padding-xs', `${token['paddingXS']}px`);
809
+ root.style.setProperty('--antd-padding-sm', `${token['paddingSM']}px`);
810
+ root.style.setProperty('--antd-padding', `${token['padding']}px`);
811
+ root.style.setProperty('--antd-padding-md', `${token['paddingMD']}px`);
812
+ root.style.setProperty('--antd-padding-lg', `${token['paddingLG']}px`);
813
+ root.style.setProperty('--antd-padding-xl', `${token['paddingXL']}px`);
814
+ root.style.setProperty('--antd-font-size-xxs', '8px');
815
+ root.style.setProperty('--antd-font-size-xs', '10px');
816
+ root.style.setProperty('--antd-font-size-sm', `${token['fontSizeSM']}px`);
817
+ root.style.setProperty('--antd-font-size', `${token['fontSize']}px`);
818
+ root.style.setProperty('--antd-font-size-lg', `${token['fontSizeLG']}px`);
819
+ root.style.setProperty('--antd-font-size-xl', `${token['fontSizeXL']}px`);
820
+ root.style.setProperty('--antd-font-size-xxl', `${token['fontSizeXXL']}px`);
821
+ root.style.setProperty('--antd-font-size-heading1', `${token['fontSizeHeading1']}px`);
822
+ root.style.setProperty('--antd-font-size-heading2', `${token['fontSizeHeading2']}px`);
823
+ root.style.setProperty('--antd-font-size-heading3', `${token['fontSizeHeading3']}px`);
824
+ root.style.setProperty('--antd-font-size-heading4', `${token['fontSizeHeading4']}px`);
825
+ root.style.setProperty('--antd-font-size-heading5', `${token['fontSizeHeading5']}px`);
826
+ root.style.setProperty('--antd-line-height', token['lineHeight']);
827
+ root.style.setProperty('--antd-line-height-lg', token['lineHeightLG']);
828
+ root.style.setProperty('--antd-control-height-sm', `${token['controlHeightSM']}px`);
829
+ root.style.setProperty('--antd-control-height', `${token['controlHeight']}px`);
830
+ root.style.setProperty('--antd-control-height-lg', `${token['controlHeightLG']}px`);
831
+ root.style.setProperty('--antd-border-radius-sm', `${token['borderRadiusSM']}px`);
832
+ root.style.setProperty('--antd-border-radius', `${token['borderRadius']}px`);
833
+ root.style.setProperty('--antd-border-radius-lg', `${token['borderRadiusLG']}px`);
834
+ }, [
835
+ token
836
+ ]);
837
+ return null;
838
+ };
839
+ const TableContainer_module = {
840
+ tableContainer: "tableContainer-EhNwOm"
841
+ };
842
+ function isPaginationNode(node) {
843
+ if (node.nodeType !== Node.ELEMENT_NODE) return false;
844
+ const element = node;
845
+ return element.classList?.contains('ant-table-pagination') || element.querySelector?.('.ant-table-pagination');
846
+ }
847
+ function hasPaginationInMutation(mutation) {
848
+ return Array.from(mutation.addedNodes).some(isPaginationNode);
849
+ }
850
+ function TableContainer({ children }) {
851
+ const containerRef = (0, external_react_.useRef)(null);
852
+ const containerHeightRef = (0, external_react_.useRef)(null);
853
+ const [scrollY, setScrollY] = (0, external_react_.useState)(void 0);
854
+ (0, external_react_.useLayoutEffect)(()=>{
855
+ const calculateHeights = ()=>{
856
+ if (!containerRef.current) return;
857
+ containerHeightRef.current = containerRef.current.offsetHeight;
858
+ const thead = containerRef.current.querySelector('thead');
859
+ let theadHeight = 0;
860
+ if (thead) {
861
+ const rect = thead.getBoundingClientRect();
862
+ const styles = globalThis.getComputedStyle(thead);
863
+ const marginTop = Number.parseFloat(styles.marginTop) || 0;
864
+ const marginBottom = Number.parseFloat(styles.marginBottom) || 0;
865
+ theadHeight = rect.height + marginTop + marginBottom;
866
+ }
867
+ const pagination = containerRef.current.querySelector('.ant-table-pagination');
868
+ let paginationHeight = 0;
869
+ if (pagination) {
870
+ const rect = pagination.getBoundingClientRect();
871
+ const styles = globalThis.getComputedStyle(pagination);
872
+ const marginTop = Number.parseFloat(styles.marginTop) || 0;
873
+ const marginBottom = Number.parseFloat(styles.marginBottom) || 0;
874
+ paginationHeight = rect.height + marginTop + marginBottom;
875
+ }
876
+ const availableHeight = Math.ceil(containerHeightRef.current) - Math.ceil(theadHeight) - Math.ceil(paginationHeight) - 1;
877
+ setScrollY(availableHeight);
556
878
  };
557
- mediaQuery.addEventListener('change', handleThemeChange);
879
+ calculateHeights();
880
+ const observer = new MutationObserver((mutations)=>{
881
+ const hasPagination = mutations.some(hasPaginationInMutation);
882
+ if (hasPagination) calculateHeights();
883
+ });
884
+ if (containerRef.current) observer.observe(containerRef.current, {
885
+ childList: true,
886
+ subtree: true
887
+ });
888
+ globalThis.addEventListener('resize', calculateHeights);
558
889
  return ()=>{
559
- mediaQuery.removeEventListener('change', handleThemeChange);
890
+ observer.disconnect();
891
+ globalThis.removeEventListener('resize', calculateHeights);
560
892
  };
893
+ }, []);
894
+ const enhancedChildren = scrollY ? /*#__PURE__*/ (0, external_react_.cloneElement)(children, {
895
+ scroll: {
896
+ ...children.props?.scroll,
897
+ y: scrollY,
898
+ x: 'max-content'
899
+ }
900
+ }) : children;
901
+ return /*#__PURE__*/ (0, jsx_runtime.jsx)("div", {
902
+ ref: containerRef,
903
+ className: TableContainer_module.tableContainer,
904
+ children: enhancedChildren
905
+ });
906
+ }
907
+ TableContainer.propTypes = {
908
+ children: external_prop_types_default().element.isRequired
909
+ };
910
+ function FilterContainer({ children, ...props }) {
911
+ const { token } = external_antd_namespaceObject.theme.useToken();
912
+ return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Card, {
913
+ styles: {
914
+ body: {
915
+ padding: token['paddingXS'] + 'px'
916
+ }
917
+ },
918
+ ...props,
919
+ children: children
920
+ });
921
+ }
922
+ FilterContainer.propTypes = {
923
+ children: external_prop_types_default().node.isRequired,
924
+ ...external_antd_namespaceObject.Card.propTypes
925
+ };
926
+ const CodebitThemeContext = /*#__PURE__*/ (0, external_react_.createContext)(null);
927
+ const CodebitThemeProvider = ({ children, storeThemeInLocalStorage = true, ...props })=>{
928
+ const hasLoaded = (0, external_react_.useRef)(false);
929
+ const [isDarkMode, setIsDarkMode] = (0, external_react_.useState)(()=>{
930
+ try {
931
+ if (storeThemeInLocalStorage) {
932
+ const savedTheme = localStorage?.getItem('theme');
933
+ if (null !== savedTheme) return 'dark' === savedTheme;
934
+ }
935
+ return globalThis.matchMedia?.('(prefers-color-scheme: dark)')?.matches ?? false;
936
+ } finally{
937
+ hasLoaded.current = true;
938
+ }
939
+ });
940
+ const toggleTheme = ()=>{
941
+ setIsDarkMode((prev)=>!prev);
942
+ };
943
+ (0, external_react_.useEffect)(()=>{
944
+ const rootElement = document.getElementById('root');
945
+ if (isDarkMode) {
946
+ document.body.classList.add('dark-theme');
947
+ rootElement.classList.add('dark-theme');
948
+ } else {
949
+ document.body.classList.remove('dark-theme');
950
+ rootElement.classList.remove('dark-theme');
951
+ }
952
+ document.documentElement.style.setProperty('--color-primary', isDarkMode ? '#589C75' : '#29D266');
561
953
  }, [
954
+ isDarkMode
955
+ ]);
956
+ (0, external_react_.useEffect)(()=>{
957
+ if (hasLoaded.current && storeThemeInLocalStorage) localStorage.setItem('theme', isDarkMode ? 'dark' : 'light');
958
+ }, [
959
+ isDarkMode,
562
960
  storeThemeInLocalStorage
563
961
  ]);
564
- const toggleTheme = ()=>{
565
- const newTheme = !isDarkMode;
566
- setIsDarkMode(newTheme);
567
- if (storeThemeInLocalStorage) localStorage.setItem('theme', newTheme ? 'dark' : 'light');
568
- };
569
- const resetToSystemTheme = ()=>{
570
- if (storeThemeInLocalStorage) localStorage.removeItem('theme');
571
- setIsDarkMode(getSystemTheme());
572
- };
573
- const contextValue = (0, external_react_.useMemo)(()=>({
574
- menuItems,
575
- user,
576
- onLogout,
577
- version,
578
- showVersion,
579
- i18n: i18n,
580
- secondarySidebar,
581
- secondarySidebarWidth,
962
+ const themeContextValue = (0, external_react_.useMemo)(()=>({
582
963
  isDarkMode,
583
- setIsDarkMode,
584
964
  toggleTheme,
585
- resetToSystemTheme
965
+ setIsDarkMode
586
966
  }), [
587
- menuItems,
588
- user,
589
- onLogout,
590
- version,
591
- showVersion,
592
- secondarySidebar,
593
- secondarySidebarWidth,
594
- isDarkMode,
595
- storeThemeInLocalStorage
967
+ isDarkMode
596
968
  ]);
597
- return /*#__PURE__*/ (0, jsx_runtime.jsxs)(CodebitConfigContext.Provider, {
598
- value: contextValue,
599
- children: [
600
- /*#__PURE__*/ (0, jsx_runtime.jsx)(CssTokenBridge, {}),
601
- children
602
- ]
969
+ return /*#__PURE__*/ (0, jsx_runtime.jsx)(CodebitThemeContext.Provider, {
970
+ value: themeContextValue,
971
+ children: /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.ConfigProvider, {
972
+ theme: {
973
+ algorithm: isDarkMode ? external_antd_namespaceObject.theme.darkAlgorithm : external_antd_namespaceObject.theme.defaultAlgorithm,
974
+ token: {
975
+ colorPrimary: isDarkMode ? '#589C75' : '#29D266',
976
+ colorInfo: isDarkMode ? '#589C75' : '#29D266',
977
+ colorLink: isDarkMode ? '#589C75' : '#29D266'
978
+ },
979
+ components: {
980
+ Menu: {
981
+ itemSelectedBg: isDarkMode ? '#589C75' : '#29D266',
982
+ itemSelectedColor: '#FAFAFA',
983
+ darkItemSelectedBg: isDarkMode ? '#589C75' : '#29D266',
984
+ darkItemSelectedColor: '#FAFAFA'
985
+ },
986
+ Button: {
987
+ colorPrimary: isDarkMode ? '#589C75' : '#29D266',
988
+ colorPrimaryHover: isDarkMode ? '#6DB589' : '#3FE67F',
989
+ colorPrimaryActive: isDarkMode ? '#4A8361' : '#1FBF4D'
990
+ },
991
+ Layout: {
992
+ siderBg: isDarkMode ? '#1a1a1a' : '#001529',
993
+ triggerBg: isDarkMode ? '#589C75' : '#29D266',
994
+ triggerColor: '#FAFAFA'
995
+ },
996
+ Header: {
997
+ colorPrimary: isDarkMode ? '#589C75' : '#29D266'
998
+ }
999
+ }
1000
+ },
1001
+ ...props,
1002
+ children: [
1003
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(CssTokenBridge, {}),
1004
+ children
1005
+ ]
1006
+ })
603
1007
  });
604
- }
605
- CodebitConfigProvider.propTypes = {
1008
+ };
1009
+ CodebitThemeProvider.propTypes = {
606
1010
  children: external_prop_types_default().node.isRequired,
607
- menuItems: external_prop_types_default().arrayOf(external_prop_types_default().shape({
608
- key: external_prop_types_default().string.isRequired,
609
- icon: external_prop_types_default().node,
610
- label: external_prop_types_default().string.isRequired,
611
- roles: external_prop_types_default().arrayOf(external_prop_types_default().string)
612
- })).isRequired,
613
- user: external_prop_types_default().shape({
614
- name: external_prop_types_default().string.isRequired,
615
- email: external_prop_types_default().string.isRequired,
616
- id: external_prop_types_default().string.isRequired,
617
- roles: external_prop_types_default().arrayOf(external_prop_types_default().string).isRequired
618
- }).isRequired,
619
- onLogout: external_prop_types_default().func.isRequired,
620
- version: external_prop_types_default().string,
621
- showVersion: external_prop_types_default().bool,
622
- secondarySidebar: external_prop_types_default().node,
623
- secondarySidebarWidth: external_prop_types_default().number,
624
1011
  storeThemeInLocalStorage: external_prop_types_default().bool
625
1012
  };
626
- const ThemeToggle = ()=>{
627
- const config = (0, external_react_.useContext)(CodebitConfigContext);
628
- if (!config) throw new Error('ThemeToggle must be used within CodebitConfigProvider');
629
- (0, external_react_.useEffect)(()=>{
630
- document.documentElement.style.colorScheme = config.isDarkMode ? 'dark' : 'light';
631
- }, [
632
- config.isDarkMode
633
- ]);
634
- return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Switch, {
635
- theme: config.isDarkMode ? 'dark' : 'light',
636
- checked: config.isDarkMode,
637
- onChange: config.toggleTheme,
638
- checkedChildren: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MoonOutlined, {}),
639
- unCheckedChildren: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.SunOutlined, {})
640
- });
641
- };
642
1013
  const LoggedMainContainer_module = {
643
1014
  layout: "layout-mL5o6I",
644
1015
  drawer: "drawer-oj0mJX",
@@ -659,9 +1030,6 @@ var __webpack_exports__ = {};
659
1030
  headerSpace: "headerSpace-Fd_iha",
660
1031
  content: "content-OZHp2h"
661
1032
  };
662
- const useCodebitWebAntdTranslation = ()=>(0, external_react_i18next_namespaceObject.useTranslation)('codebitWebAntd', {
663
- i18n: i18n
664
- });
665
1033
  const { Header, Sider, Content } = external_antd_namespaceObject.Layout;
666
1034
  const { Text } = external_antd_namespaceObject.Typography;
667
1035
  function LoggedMainContainer({ children }) {
@@ -672,11 +1040,13 @@ var __webpack_exports__ = {};
672
1040
  const { t } = useCodebitWebAntdTranslation();
673
1041
  const navigate = (0, external_react_router_namespaceObject.useNavigate)();
674
1042
  const location = (0, external_react_router_namespaceObject.useLocation)();
675
- const config = (0, external_react_.useContext)(CodebitConfigContext);
676
- if (!config) throw new Error('LoggedContainer must be used within CodebitConfigProvider');
677
- const { menuItems, user, onLogout, version, showVersion, isDarkMode, secondarySidebar, secondarySidebarWidth = 280 } = config;
1043
+ const configCodebit = (0, external_react_.useContext)(CodebitConfigContext);
1044
+ const configTheme = (0, external_react_.useContext)(CodebitThemeContext);
1045
+ if (!configCodebit || !configTheme) throw new Error('LoggedContainer must be used within CodebitConfigProvider and CodebitThemeContext');
1046
+ const { logout, user, menuItems, version, showVersion, secondarySidebar, secondarySidebarWidth = 280 } = configCodebit;
1047
+ const { isDarkMode } = configTheme;
678
1048
  const systemTheme = isDarkMode ? 'dark' : 'light';
679
- const filteredMenuItems = (0, external_react_.useMemo)(()=>menuItems.filter((item)=>{
1049
+ const filteredMenuItems = (0, external_react_.useMemo)(()=>menuItems(user).filter((item)=>{
680
1050
  if (!item.roles) return true;
681
1051
  if (!user || !user.roles) return false;
682
1052
  if (item.roles) return item.roles.some((role)=>user.roles.includes(role));
@@ -694,7 +1064,7 @@ var __webpack_exports__ = {};
694
1064
  return ()=>window.removeEventListener('resize', checkScreenSize);
695
1065
  }, []);
696
1066
  const handleLogout = async ()=>{
697
- if (onLogout) await onLogout();
1067
+ await logout?.();
698
1068
  if (isMobile) setDrawerVisible(false);
699
1069
  navigate('/');
700
1070
  };
@@ -725,7 +1095,7 @@ var __webpack_exports__ = {};
725
1095
  /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Layout.Content, {
726
1096
  className: LoggedMainContainer_module.menuSpacer
727
1097
  }),
728
- showVersion && version && /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Menu, {
1098
+ showVersion?.(user) && version && /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Menu, {
729
1099
  theme: systemTheme,
730
1100
  mode: 'horizontal',
731
1101
  className: LoggedMainContainer_module.versionMenu,
@@ -777,339 +1147,71 @@ var __webpack_exports__ = {};
777
1147
  collapsed: !collapsed,
778
1148
  breakpoint: 'lg',
779
1149
  collapsedWidth: 80,
780
- className: LoggedMainContainer_module.sider,
781
- children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Layout, {
782
- className: LoggedMainContainer_module.siderLayout,
783
- children: menuContent
784
- })
785
- }),
786
- secondarySidebar && !isMobile ? /*#__PURE__*/ (0, jsx_runtime.jsx)(Sider, {
787
- theme: systemTheme,
788
- width: secondarySidebarWidth,
789
- className: `${LoggedMainContainer_module.secondarySidebar} ${isDarkMode ? LoggedMainContainer_module.secondarySidebarDark : ''}`,
790
- children: secondarySidebar
791
- }) : /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Drawer, {
792
- placement: 'right',
793
- onClose: ()=>setSecondarySidebarDrawerVisible(false),
794
- open: secondarySidebarDrawerVisible,
795
- width: 280,
796
- className: LoggedMainContainer_module.drawer,
797
- title: null,
798
- closeIcon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.CloseOutlined, {}),
799
- children: secondarySidebar
800
- }),
801
- /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Layout, {
802
- children: [
803
- /*#__PURE__*/ (0, jsx_runtime.jsxs)(Header, {
804
- className: `${LoggedMainContainer_module.header} ${isMobile ? LoggedMainContainer_module.mobile : ''}`,
805
- children: [
806
- /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Space, {
807
- children: isMobile ? /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
808
- type: 'text',
809
- icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MenuOutlined, {}),
810
- onClick: ()=>setDrawerVisible(true)
811
- }) : /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
812
- type: 'text',
813
- icon: collapsed ? /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MenuUnfoldOutlined, {}) : /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MenuFoldOutlined, {}),
814
- onClick: ()=>setCollapsed(!collapsed)
815
- })
816
- }),
817
- /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Space, {
818
- size: isMobile ? 'small' : 'middle',
819
- className: `${LoggedMainContainer_module.headerSpace} ${isMobile ? LoggedMainContainer_module.mobile : ''}`,
820
- children: [
821
- secondarySidebar && isMobile && /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
822
- type: 'text',
823
- icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MenuOutlined, {}),
824
- onClick: ()=>setSecondarySidebarDrawerVisible(true)
825
- }),
826
- !isMobile && /*#__PURE__*/ (0, jsx_runtime.jsx)(Text, {
827
- children: t('LoggedMainContainer.theme')
828
- }),
829
- /*#__PURE__*/ (0, jsx_runtime.jsx)(ThemeToggle, {})
830
- ]
831
- })
832
- ]
833
- }),
834
- /*#__PURE__*/ (0, jsx_runtime.jsx)(Content, {
835
- className: `${LoggedMainContainer_module.content} ${isMobile ? LoggedMainContainer_module.mobile : ''}`,
836
- children: children
837
- })
838
- ]
839
- })
840
- ]
841
- });
842
- }
843
- LoggedMainContainer.propTypes = {
844
- children: external_prop_types_default().node.isRequired
845
- };
846
- const codebit_web_namespaceObject = require("@codebit-programando-solucoes/codebit-web");
847
- const react_namespaceObject = require("@sentry/react");
848
- function ErrorRetry({ error, onRetry }) {
849
- const { t } = useCodebitWebAntdTranslation();
850
- if (error && error instanceof Error) {
851
- console.error('Fail to load.', error);
852
- react_namespaceObject.captureException(error);
853
- }
854
- const responseStatus = error?.response?.status || null;
855
- let errorMessage = t('ErrorRetry.defaultError');
856
- let retryText = t('ErrorRetry.retryButton');
857
- let status = 'error';
858
- if (error?.errorCode) switch(error.errorCode){
859
- case codebit_web_namespaceObject.ErrorCode.ERR_NETWORK:
860
- errorMessage = t('ErrorRetry.networkError');
861
- break;
862
- case codebit_web_namespaceObject.ErrorCode.ERR_TIMEOUT:
863
- errorMessage = t('ErrorRetry.timeoutError');
864
- break;
865
- }
866
- else if (responseStatus) switch(responseStatus){
867
- case 400:
868
- errorMessage = t('ErrorRetry.badRequestError');
869
- break;
870
- case 403:
871
- errorMessage = t('ErrorRetry.forbiddenError');
872
- retryText = t('ErrorRetry.reloadPageButton');
873
- onRetry = ()=>{
874
- globalThis.location.reload();
875
- };
876
- status = 403;
877
- break;
878
- case 404:
879
- errorMessage = t('ErrorRetry.notFoundError');
880
- status = 404;
881
- break;
882
- case 500:
883
- errorMessage = t('ErrorRetry.internalServerError');
884
- status = 500;
885
- break;
886
- case 401:
887
- errorMessage = t('ErrorRetry.sessionExpiredError');
888
- retryText = t('ErrorRetry.reloadPageButton');
889
- onRetry = ()=>{
890
- globalThis.location.reload();
891
- };
892
- break;
893
- }
894
- return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Card, {
895
- children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Result, {
896
- status: status,
897
- title: errorMessage,
898
- extra: [
899
- /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
900
- type: 'primary',
901
- onClick: onRetry,
902
- icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.ReloadOutlined, {}),
903
- children: retryText
904
- }, 'retry')
905
- ]
906
- })
907
- });
908
- }
909
- ErrorRetry.propTypes = {
910
- error: external_prop_types_default().object.isRequired,
911
- onRetry: external_prop_types_default().func.isRequired
912
- };
913
- const ListCard_module = {
914
- listCard: "listCard-ISftFd",
915
- headerRow: "headerRow-UsZAzP",
916
- actions: "actions-ig53s2",
917
- filtersRow: "filtersRow-f3Xk5a",
918
- expandArea: "expandArea-czOoFS"
919
- };
920
- const { Title } = external_antd_namespaceObject.Typography;
921
- function ListCard({ title, onClearFilters, headerContainer, tableContainer, actions }) {
922
- const { token } = external_antd_namespaceObject.theme.useToken();
923
- const { t } = (0, external_react_i18next_namespaceObject.useTranslation)('codebitWebAntd');
924
- const margin = token['margin'];
925
- return /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Card, {
926
- className: ListCard_module.listCard,
927
- children: [
928
- /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Row, {
929
- gutter: margin,
930
- align: 'middle',
931
- className: ListCard_module.headerRow,
1150
+ className: LoggedMainContainer_module.sider,
1151
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Layout, {
1152
+ className: LoggedMainContainer_module.siderLayout,
1153
+ children: menuContent
1154
+ })
1155
+ }),
1156
+ secondarySidebar && !isMobile ? /*#__PURE__*/ (0, jsx_runtime.jsx)(Sider, {
1157
+ theme: systemTheme,
1158
+ width: secondarySidebarWidth,
1159
+ className: `${LoggedMainContainer_module.secondarySidebar} ${isDarkMode ? LoggedMainContainer_module.secondarySidebarDark : ''}`,
1160
+ children: secondarySidebar(user)
1161
+ }) : /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Drawer, {
1162
+ placement: 'right',
1163
+ onClose: ()=>setSecondarySidebarDrawerVisible(false),
1164
+ open: secondarySidebarDrawerVisible,
1165
+ width: 280,
1166
+ className: LoggedMainContainer_module.drawer,
1167
+ title: null,
1168
+ closeIcon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.CloseOutlined, {}),
1169
+ children: secondarySidebar(user)
1170
+ }),
1171
+ /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Layout, {
932
1172
  children: [
933
- /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Col, {
934
- xs: 24,
935
- sm: 24,
936
- md: 12,
937
- children: /*#__PURE__*/ (0, jsx_runtime.jsx)(Title, {
938
- level: 4,
939
- children: title
940
- })
941
- }),
942
- (!!onClearFilters || !!actions) && /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Col, {
943
- xs: 24,
944
- sm: 24,
945
- md: 12,
946
- className: ListCard_module.actions,
1173
+ /*#__PURE__*/ (0, jsx_runtime.jsxs)(Header, {
1174
+ className: `${LoggedMainContainer_module.header} ${isMobile ? LoggedMainContainer_module.mobile : ''}`,
947
1175
  children: [
948
- !!onClearFilters && /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
949
- icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.ClearOutlined, {}),
950
- onClick: onClearFilters,
951
- children: t('ListCard.clearFilters')
1176
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Space, {
1177
+ children: isMobile ? /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
1178
+ type: 'text',
1179
+ icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MenuOutlined, {}),
1180
+ onClick: ()=>setDrawerVisible(true)
1181
+ }) : /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
1182
+ type: 'text',
1183
+ icon: collapsed ? /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MenuUnfoldOutlined, {}) : /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MenuFoldOutlined, {}),
1184
+ onClick: ()=>setCollapsed(!collapsed)
1185
+ })
952
1186
  }),
953
- actions
1187
+ /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Space, {
1188
+ size: isMobile ? 'small' : 'middle',
1189
+ className: `${LoggedMainContainer_module.headerSpace} ${isMobile ? LoggedMainContainer_module.mobile : ''}`,
1190
+ children: [
1191
+ secondarySidebar && isMobile && /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
1192
+ type: 'text',
1193
+ icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MenuOutlined, {}),
1194
+ onClick: ()=>setSecondarySidebarDrawerVisible(true)
1195
+ }),
1196
+ !isMobile && /*#__PURE__*/ (0, jsx_runtime.jsx)(Text, {
1197
+ children: t('LoggedMainContainer.theme')
1198
+ }),
1199
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(ThemeToggle, {})
1200
+ ]
1201
+ })
954
1202
  ]
1203
+ }),
1204
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(Content, {
1205
+ className: `${LoggedMainContainer_module.content} ${isMobile ? LoggedMainContainer_module.mobile : ''}`,
1206
+ children: children
955
1207
  })
956
1208
  ]
957
- }),
958
- !!headerContainer && /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Row, {
959
- gutter: margin,
960
- className: ListCard_module.filtersRow,
961
- children: headerContainer
962
- }),
963
- /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Layout, {
964
- className: ListCard_module.expandArea,
965
- children: tableContainer
966
1209
  })
967
1210
  ]
968
1211
  });
969
1212
  }
970
- ListCard.propTypes = {
971
- title: external_prop_types_default().string.isRequired,
972
- onClearFilters: external_prop_types_default().func,
973
- headerContainer: external_prop_types_default().node,
974
- tableContainer: external_prop_types_default().node,
975
- actions: external_prop_types_default().node
976
- };
977
- ListCard.defaultProps = {
978
- onClearFilters: null,
979
- headerContainer: null,
980
- tableContainer: null,
981
- actions: null
982
- };
983
- const CssTokenBridge = ()=>{
984
- const { token } = external_antd_namespaceObject.theme.useToken();
985
- (0, external_react_.useLayoutEffect)(()=>{
986
- const root = document.documentElement;
987
- root.style.setProperty('--antd-color-bg-container', token['colorBgContainer']);
988
- root.style.setProperty('--antd-color-bg-elevated', token['colorBgElevated']);
989
- root.style.setProperty('--antd-color-bg-layout', token['colorBgLayout']);
990
- root.style.setProperty('--antd-color-border', token['colorBorder']);
991
- root.style.setProperty('--antd-color-primary', token['colorPrimary']);
992
- root.style.setProperty('--antd-color-text', token['colorText']);
993
- root.style.setProperty('--antd-color-text-secondary', token['colorTextSecondary']);
994
- root.style.setProperty('--antd-color-split', token['colorSplit']);
995
- root.style.setProperty('--antd-margin-xxs', `${token['marginXXS']}px`);
996
- root.style.setProperty('--antd-margin-xs', `${token['marginXS']}px`);
997
- root.style.setProperty('--antd-margin-sm', `${token['marginSM']}px`);
998
- root.style.setProperty('--antd-margin', `${token['margin']}px`);
999
- root.style.setProperty('--antd-margin-md', `${token['marginMD']}px`);
1000
- root.style.setProperty('--antd-margin-lg', `${token['marginLG']}px`);
1001
- root.style.setProperty('--antd-margin-xl', `${token['marginXL']}px`);
1002
- root.style.setProperty('--antd-margin-xxl', `${token['marginXXL']}px`);
1003
- root.style.setProperty('--antd-padding-xxs', `${token['paddingXXS']}px`);
1004
- root.style.setProperty('--antd-padding-xs', `${token['paddingXS']}px`);
1005
- root.style.setProperty('--antd-padding-sm', `${token['paddingSM']}px`);
1006
- root.style.setProperty('--antd-padding', `${token['padding']}px`);
1007
- root.style.setProperty('--antd-padding-md', `${token['paddingMD']}px`);
1008
- root.style.setProperty('--antd-padding-lg', `${token['paddingLG']}px`);
1009
- root.style.setProperty('--antd-padding-xl', `${token['paddingXL']}px`);
1010
- root.style.setProperty('--antd-font-size-sm', `${token['fontSizeSM']}px`);
1011
- root.style.setProperty('--antd-font-size', `${token['fontSize']}px`);
1012
- root.style.setProperty('--antd-font-size-lg', `${token['fontSizeLG']}px`);
1013
- root.style.setProperty('--antd-font-size-xl', `${token['fontSizeXL']}px`);
1014
- root.style.setProperty('--antd-line-height', token['lineHeight']);
1015
- root.style.setProperty('--antd-line-height-lg', token['lineHeightLG']);
1016
- root.style.setProperty('--antd-control-height-sm', `${token['controlHeightSM']}px`);
1017
- root.style.setProperty('--antd-control-height', `${token['controlHeight']}px`);
1018
- root.style.setProperty('--antd-control-height-lg', `${token['controlHeightLG']}px`);
1019
- root.style.setProperty('--antd-border-radius-sm', `${token['borderRadiusSM']}px`);
1020
- root.style.setProperty('--antd-border-radius', `${token['borderRadius']}px`);
1021
- root.style.setProperty('--antd-border-radius-lg', `${token['borderRadiusLG']}px`);
1022
- }, [
1023
- token
1024
- ]);
1025
- return null;
1026
- };
1027
- const TableContainer_module = {
1028
- tableContainer: "tableContainer-EhNwOm"
1029
- };
1030
- function isPaginationNode(node) {
1031
- if (node.nodeType !== Node.ELEMENT_NODE) return false;
1032
- const element = node;
1033
- return element.classList?.contains('ant-table-pagination') || element.querySelector?.('.ant-table-pagination');
1034
- }
1035
- function hasPaginationInMutation(mutation) {
1036
- return Array.from(mutation.addedNodes).some(isPaginationNode);
1037
- }
1038
- function TableContainer({ children }) {
1039
- const containerRef = (0, external_react_.useRef)(null);
1040
- const containerHeightRef = (0, external_react_.useRef)(null);
1041
- const [scrollY, setScrollY] = (0, external_react_.useState)(void 0);
1042
- (0, external_react_.useLayoutEffect)(()=>{
1043
- const calculateHeights = ()=>{
1044
- if (!containerRef.current) return;
1045
- containerHeightRef.current = containerRef.current.offsetHeight;
1046
- const thead = containerRef.current.querySelector('thead');
1047
- let theadHeight = 0;
1048
- if (thead) {
1049
- const rect = thead.getBoundingClientRect();
1050
- const styles = globalThis.getComputedStyle(thead);
1051
- const marginTop = Number.parseFloat(styles.marginTop) || 0;
1052
- const marginBottom = Number.parseFloat(styles.marginBottom) || 0;
1053
- theadHeight = rect.height + marginTop + marginBottom;
1054
- }
1055
- const pagination = containerRef.current.querySelector('.ant-table-pagination');
1056
- let paginationHeight = 0;
1057
- if (pagination) {
1058
- const rect = pagination.getBoundingClientRect();
1059
- const styles = globalThis.getComputedStyle(pagination);
1060
- const marginTop = Number.parseFloat(styles.marginTop) || 0;
1061
- const marginBottom = Number.parseFloat(styles.marginBottom) || 0;
1062
- paginationHeight = rect.height + marginTop + marginBottom;
1063
- }
1064
- const availableHeight = Math.ceil(containerHeightRef.current) - Math.ceil(theadHeight) - Math.ceil(paginationHeight) - 1;
1065
- setScrollY(availableHeight);
1066
- };
1067
- calculateHeights();
1068
- const observer = new MutationObserver((mutations)=>{
1069
- const hasPagination = mutations.some(hasPaginationInMutation);
1070
- if (hasPagination) calculateHeights();
1071
- });
1072
- if (containerRef.current) observer.observe(containerRef.current, {
1073
- childList: true,
1074
- subtree: true
1075
- });
1076
- globalThis.addEventListener('resize', calculateHeights);
1077
- return ()=>{
1078
- observer.disconnect();
1079
- globalThis.removeEventListener('resize', calculateHeights);
1080
- };
1081
- }, []);
1082
- const enhancedChildren = scrollY ? /*#__PURE__*/ (0, external_react_.cloneElement)(children, {
1083
- scroll: {
1084
- ...children.props?.scroll,
1085
- y: scrollY,
1086
- x: 'max-content'
1087
- }
1088
- }) : children;
1089
- return /*#__PURE__*/ (0, jsx_runtime.jsx)("div", {
1090
- ref: containerRef,
1091
- className: TableContainer_module.tableContainer,
1092
- children: enhancedChildren
1093
- });
1094
- }
1095
- TableContainer.propTypes = {
1096
- children: external_prop_types_default().element.isRequired
1097
- };
1098
- function FilterContainer({ children, ...props }) {
1099
- const { token } = external_antd_namespaceObject.theme.useToken();
1100
- return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Card, {
1101
- styles: {
1102
- body: {
1103
- padding: token['paddingXS'] + 'px'
1104
- }
1105
- },
1106
- ...props,
1107
- children: children
1108
- });
1109
- }
1110
- FilterContainer.propTypes = {
1111
- children: external_prop_types_default().node.isRequired,
1112
- ...external_antd_namespaceObject.Card.propTypes
1213
+ LoggedMainContainer.propTypes = {
1214
+ children: external_prop_types_default().node.isRequired
1113
1215
  };
1114
1216
  const Login_module = {
1115
1217
  containerRow: "containerRow-lnjnDt",
@@ -1122,8 +1224,8 @@ var __webpack_exports__ = {};
1122
1224
  loginHeader: "loginHeader-bBGO5B"
1123
1225
  };
1124
1226
  function LoginContainer({ title, children }) {
1125
- const config = (0, external_react_.useContext)(CodebitConfigContext);
1126
- if (!config) throw new Error('Login must be used within CodebitConfigProvider');
1227
+ const config = (0, external_react_.useContext)(CodebitThemeContext);
1228
+ if (!config) throw new Error('Login must be used within CodebitThemeContext');
1127
1229
  const { t } = useCodebitWebAntdTranslation();
1128
1230
  const classList = [
1129
1231
  Login_module.loginCard
@@ -1183,7 +1285,7 @@ var __webpack_exports__ = {};
1183
1285
  ]).isRequired,
1184
1286
  children: external_prop_types_default().node
1185
1287
  };
1186
- const logger = new codebit_web_namespaceObject.Logger('Login');
1288
+ const Login_logger = new codebit_web_namespaceObject.Logger('Login');
1187
1289
  const LocalLoginAuthenticationResult = Object.freeze({
1188
1290
  INVALID_EMAIL: 'INVALID_EMAIL',
1189
1291
  INVALID_PASSWORD: 'INVALID_PASSWORD',
@@ -1268,7 +1370,7 @@ var __webpack_exports__ = {};
1268
1370
  });
1269
1371
  break;
1270
1372
  default:
1271
- logger.warn('Unhandled authentication result:', result);
1373
+ Login_logger.warn('Unhandled authentication result:', result);
1272
1374
  modal.error({
1273
1375
  title: t('Login.authenticationFailed'),
1274
1376
  content: t('Common.genericError'),
@@ -1276,7 +1378,7 @@ var __webpack_exports__ = {};
1276
1378
  });
1277
1379
  }
1278
1380
  } catch (error) {
1279
- logger.error(error);
1381
+ Login_logger.error(error);
1280
1382
  react_namespaceObject.captureException(error);
1281
1383
  modal.error({
1282
1384
  title: t('Login.errorTitle'),
@@ -1597,63 +1699,38 @@ var __webpack_exports__ = {};
1597
1699
  navigateToLogin: external_prop_types_default().func,
1598
1700
  submitRecoveryPassword: external_prop_types_default().func.isRequired
1599
1701
  };
1600
- const CodebitTheme = (props)=>{
1601
- const { token } = external_antd_namespaceObject.theme.useToken();
1602
- const config = (0, external_react_.useContext)(CodebitConfigContext);
1603
- if (!config) throw new Error('CodebitTheme must be used within CodebitConfigProvider');
1604
- const { isDarkMode } = config;
1605
- (0, external_react_.useEffect)(()=>{
1606
- const rootElement = document.getElementById('root');
1607
- if (isDarkMode) {
1608
- document.body.classList.add('dark-theme');
1609
- rootElement.classList.add('dark-theme');
1610
- } else {
1611
- document.body.classList.remove('dark-theme');
1612
- rootElement.classList.remove('dark-theme');
1702
+ const useErrorModal_logger = new codebit_web_namespaceObject.Logger('useErrorModal');
1703
+ function useErrorModal() {
1704
+ const { modal } = external_antd_namespaceObject.App.useApp();
1705
+ const { getErrorMessage } = useErrorMessage();
1706
+ const { t } = useCodebitWebAntdTranslation();
1707
+ const showErrorModal = (error, title, closeButtonText, onClose)=>{
1708
+ if (error && error instanceof Error) {
1709
+ useErrorModal_logger.error('Fail to load.', error);
1710
+ react_namespaceObject.captureException(error);
1613
1711
  }
1614
- document.documentElement.style.setProperty('--color-primary', isDarkMode ? '#589C75' : '#29D266');
1615
- }, [
1616
- isDarkMode,
1617
- token.colorBgContainer
1618
- ]);
1619
- return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.ConfigProvider, {
1620
- theme: {
1621
- algorithm: isDarkMode ? external_antd_namespaceObject.theme.darkAlgorithm : external_antd_namespaceObject.theme.defaultAlgorithm,
1622
- token: {
1623
- colorPrimary: isDarkMode ? '#589C75' : '#29D266',
1624
- colorInfo: isDarkMode ? '#589C75' : '#29D266',
1625
- colorLink: isDarkMode ? '#589C75' : '#29D266'
1626
- },
1627
- components: {
1628
- Menu: {
1629
- itemSelectedBg: isDarkMode ? '#589C75' : '#29D266',
1630
- itemSelectedColor: '#FAFAFA',
1631
- darkItemSelectedBg: isDarkMode ? '#589C75' : '#29D266',
1632
- darkItemSelectedColor: '#FAFAFA'
1633
- },
1634
- Button: {
1635
- colorPrimary: isDarkMode ? '#589C75' : '#29D266',
1636
- colorPrimaryHover: isDarkMode ? '#6DB589' : '#3FE67F',
1637
- colorPrimaryActive: isDarkMode ? '#4A8361' : '#1FBF4D'
1638
- },
1639
- Layout: {
1640
- siderBg: isDarkMode ? '#1a1a1a' : '#001529',
1641
- triggerBg: isDarkMode ? '#589C75' : '#29D266',
1642
- triggerColor: '#FAFAFA'
1643
- },
1644
- Header: {
1645
- colorPrimary: isDarkMode ? '#589C75' : '#29D266'
1646
- }
1647
- }
1648
- },
1649
- ...props
1650
- });
1651
- };
1652
- CodebitTheme.propTypes = {};
1712
+ const { errorMessage, retryText, onRetryAction } = getErrorMessage(error);
1713
+ if (error && error instanceof Error) {
1714
+ useErrorModal_logger.error(error);
1715
+ react_namespaceObject.captureException(error);
1716
+ }
1717
+ onClose = onClose ?? onRetryAction;
1718
+ modal.error({
1719
+ title: title || t('Error.errorTitle'),
1720
+ content: errorMessage + '.',
1721
+ afterClose: onClose,
1722
+ okText: closeButtonText || (onClose ? retryText : t('Common.close'))
1723
+ });
1724
+ };
1725
+ return {
1726
+ showErrorModal
1727
+ };
1728
+ }
1653
1729
  })();
1654
1730
  exports.CodebitConfigContext = __webpack_exports__.CodebitConfigContext;
1655
1731
  exports.CodebitConfigProvider = __webpack_exports__.CodebitConfigProvider;
1656
- exports.CodebitTheme = __webpack_exports__.CodebitTheme;
1732
+ exports.CodebitThemeContext = __webpack_exports__.CodebitThemeContext;
1733
+ exports.CodebitThemeProvider = __webpack_exports__.CodebitThemeProvider;
1657
1734
  exports.CssTokenBridge = __webpack_exports__.CssTokenBridge;
1658
1735
  exports.ErrorRetry = __webpack_exports__.ErrorRetry;
1659
1736
  exports.FilterContainer = __webpack_exports__.FilterContainer;
@@ -1667,10 +1744,13 @@ exports.Login = __webpack_exports__.Login;
1667
1744
  exports.LoginContainer = __webpack_exports__.LoginContainer;
1668
1745
  exports.TableContainer = __webpack_exports__.TableContainer;
1669
1746
  exports.ThemeToggle = __webpack_exports__.ThemeToggle;
1670
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
1747
+ exports.useErrorMessage = __webpack_exports__.useErrorMessage;
1748
+ exports.useErrorModal = __webpack_exports__.useErrorModal;
1749
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
1671
1750
  "CodebitConfigContext",
1672
1751
  "CodebitConfigProvider",
1673
- "CodebitTheme",
1752
+ "CodebitThemeContext",
1753
+ "CodebitThemeProvider",
1674
1754
  "CssTokenBridge",
1675
1755
  "ErrorRetry",
1676
1756
  "FilterContainer",
@@ -1683,8 +1763,10 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
1683
1763
  "Login",
1684
1764
  "LoginContainer",
1685
1765
  "TableContainer",
1686
- "ThemeToggle"
1687
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
1766
+ "ThemeToggle",
1767
+ "useErrorMessage",
1768
+ "useErrorModal"
1769
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
1688
1770
  Object.defineProperty(exports, '__esModule', {
1689
1771
  value: true
1690
1772
  });