@react-pakistan/util-functions 1.25.55 → 1.25.57

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.
@@ -5,7 +5,7 @@
5
5
  * Generates tables, forms, drawers, and other common UI patterns.
6
6
  */
7
7
  import React, { FC } from 'react';
8
- import { COMPONENT_TYPE, HeaderAction, TableColumn } from '@appcorp/shadcn/components/enhanced-table';
8
+ import { COMPONENT_TYPE, HeaderAction, RowAction, TableColumn } from '@appcorp/shadcn/components/enhanced-table';
9
9
  export declare const DRAWER_TYPES: {
10
10
  FORM_DRAWER: string;
11
11
  FILTER_DRAWER: string;
@@ -59,7 +59,7 @@ interface GenericModulePageProps {
59
59
  context: any;
60
60
  tableBodyCols: TableBodyCol[];
61
61
  headerActions?: HeaderAction[];
62
- rowActions?: any[];
62
+ rowActions?: RowAction[];
63
63
  iconMap?: Record<string, any>;
64
64
  }
65
65
  export declare const createGenericModulePage: (config: ComponentConfig) => React.FC<GenericModulePageProps>;
@@ -42,7 +42,6 @@ var __importStar = (this && this.__importStar) || (function () {
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.createGenericModulePage = exports.GenericDrawer = exports.GenericTable = exports.DRAWER_TYPES = void 0;
44
44
  var react_1 = __importStar(require("react"));
45
- var next_intl_1 = require("next-intl");
46
45
  var general_1 = require("../general");
47
46
  var use_rtl_1 = require("../hooks/use-rtl");
48
47
  var enhanced_table_1 = require("@appcorp/shadcn/components/enhanced-table");
@@ -61,27 +60,25 @@ exports.DRAWER_TYPES = {
61
60
  };
62
61
  var GenericTable = function (_a) {
63
62
  var config = _a.config, context = _a.context, tableBodyCols = _a.tableBodyCols, headerActions = _a.headerActions, rowActions = _a.rowActions;
64
- var t = (0, next_intl_1.useTranslations)(config.moduleName);
65
63
  var isRTL = (0, use_rtl_1.useRTL)();
66
64
  var tableHeadItems = (0, react_1.useMemo)(function () {
67
65
  return config.tableColumns.map(function (col) { return ({
68
- label: t(col.label),
66
+ label: col.label,
69
67
  width: col.width,
70
68
  }); });
71
- }, [config.tableColumns, t]);
69
+ }, [config.tableColumns]);
72
70
  var totalPages = (0, general_1.calculatePages)(context.state.count, context.state.pageLimit);
73
71
  // Build header actions from context or props
74
72
  var allHeaderActions = (0, react_1.useMemo)(function () { return headerActions || context.headerActions || []; }, [headerActions, context.headerActions]);
75
73
  return (react_1.default.createElement("div", { className: "space-y-4 ".concat(isRTL ? 'rtl' : 'ltr'), dir: isRTL ? 'rtl' : 'ltr' },
76
74
  react_1.default.createElement(enhanced_table_1.EnhancedTable, { currentPage: Number(context.state.currentPage), handleNextOnClick: context.handlePageChange, handleOnSelect: context.handlePageLimitChange, handlePreviousOnClick: function () {
77
75
  return context.handlePageChange(context.state.currentPage - 1);
78
- }, handleSearchInput: context.handleSearch, headerActions: allHeaderActions, isNextDisabled: (0, general_1.isNextButtonDisabled)(context.state.currentPage, totalPages), isPreviousDisabled: (0, general_1.isPreviousButtonDisabled)(context.state.currentPage), listOptions: (0, general_1.getAvailablePageLimits)(context.state.count), loading: context.listLoading, nodeSelectKey: "pageLimit", pageLimit: context.state.pageLimit, rowActions: rowActions || context.rowActions || [], searchDisabled: false, searchEnabled: true, searchId: "".concat(config.moduleName.toLowerCase(), "-search"), searchPlaceholder: t(config.searchPlaceholder), searchValue: context.state.searchQuery, tableBodyCols: tableBodyCols, tableBodyRows: context.state.items, tableDescription: t(config.tableDescription), tableHeadItems: tableHeadItems, tableHeading: t(config.tableTitle), totalPages: Number(totalPages) })));
76
+ }, handleSearchInput: context.handleSearch, headerActions: allHeaderActions, isNextDisabled: (0, general_1.isNextButtonDisabled)(context.state.currentPage, totalPages), isPreviousDisabled: (0, general_1.isPreviousButtonDisabled)(context.state.currentPage), listOptions: (0, general_1.getAvailablePageLimits)(context.state.count), loading: context.listLoading, nodeSelectKey: "pageLimit", pageLimit: context.state.pageLimit, rowActions: rowActions || context.rowActions || [], searchDisabled: false, searchEnabled: true, searchId: "".concat(config.moduleName.toLowerCase(), "-search"), searchPlaceholder: config.searchPlaceholder, searchValue: context.state.searchQuery, tableBodyCols: tableBodyCols, tableBodyRows: context.state.items, tableDescription: config.tableDescription, tableHeadItems: tableHeadItems, tableHeading: config.tableTitle, totalPages: Number(totalPages) })));
79
77
  };
80
78
  exports.GenericTable = GenericTable;
81
79
  var GenericDrawer = function (_a) {
82
80
  var _b, _c, _d, _e, _f, _g;
83
81
  var config = _a.config, context = _a.context, formContent = _a.formContent, viewContent = _a.viewContent, filterContent = _a.filterContent, moreActionsContent = _a.moreActionsContent;
84
- var t = (0, next_intl_1.useTranslations)(config.moduleName);
85
82
  var isRTL = (0, use_rtl_1.useRTL)();
86
83
  var closeDrawer = context.closeDrawer || context.handleCloseDrawer;
87
84
  var _h = context.state, disableSaveButton = _h.disableSaveButton, drawer = _h.drawer;
@@ -90,9 +87,9 @@ var GenericDrawer = function (_a) {
90
87
  var isFilterDrawer = drawer === exports.DRAWER_TYPES.FILTER_DRAWER;
91
88
  var isMoreActionsDrawer = drawer === exports.DRAWER_TYPES.MORE_ACTIONS_DRAWER;
92
89
  var isOpen = isFormDrawer || isViewDrawer || isFilterDrawer || isMoreActionsDrawer;
93
- var drawerTitle = t(config.drawerTitle);
90
+ var drawerTitle = config.drawerTitle;
94
91
  var drawerDescription = config.drawerDescription
95
- ? t(config.drawerDescription)
92
+ ? config.drawerDescription
96
93
  : '';
97
94
  var errors = (_b = context.state.errors) !== null && _b !== void 0 ? _b : {};
98
95
  var formHeader = isFormDrawer ? (react_1.default.createElement(enhanced_drawer_header_1.EnhancedDrawerHeader, { title: drawerTitle, description: drawerDescription })) : null;
@@ -32,6 +32,7 @@ export declare const GENERIC_ACTION_TYPES: {
32
32
  readonly SET_DISABLE_SAVE_BUTTON: "SET_DISABLE_SAVE_BUTTON";
33
33
  readonly SET_INPUT_FIELD: "SET_INPUT_FIELD";
34
34
  readonly SET_ERRORS: "SET_ERRORS";
35
+ readonly SET_FILTERS: "SET_FILTERS";
35
36
  };
36
37
  export declare const createGenericReducer: <T>(config: ModuleConfig<T>) => (state: T, action: any) => T;
37
38
  export declare const createGenericModuleHook: <T>(config: ModuleConfig<T>) => () => GenericModuleContext<T>;
@@ -60,6 +61,7 @@ export declare const createGenericModule: <T>(config: ModuleConfig<T>) => {
60
61
  readonly SET_DISABLE_SAVE_BUTTON: "SET_DISABLE_SAVE_BUTTON";
61
62
  readonly SET_INPUT_FIELD: "SET_INPUT_FIELD";
62
63
  readonly SET_ERRORS: "SET_ERRORS";
64
+ readonly SET_FILTERS: "SET_FILTERS";
63
65
  };
64
66
  initialState: T;
65
67
  };
@@ -67,6 +67,7 @@ exports.GENERIC_ACTION_TYPES = {
67
67
  SET_DISABLE_SAVE_BUTTON: 'SET_DISABLE_SAVE_BUTTON',
68
68
  SET_INPUT_FIELD: 'SET_INPUT_FIELD',
69
69
  SET_ERRORS: 'SET_ERRORS',
70
+ SET_FILTERS: 'SET_FILTERS',
70
71
  };
71
72
  // ============================================================================
72
73
  // GENERIC REDUCER FACTORY
@@ -97,6 +98,8 @@ var createGenericReducer = function (config) {
97
98
  return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
98
99
  case exports.GENERIC_ACTION_TYPES.SET_ERRORS:
99
100
  return __assign(__assign({}, state), { errors: action.payload.errors });
101
+ case exports.GENERIC_ACTION_TYPES.SET_FILTERS:
102
+ return __assign(__assign({}, state), action.payload.filters);
100
103
  default:
101
104
  return state;
102
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.25.55",
3
+ "version": "1.25.57",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -75,7 +75,7 @@
75
75
  "lodash.curry": "^4.1.1",
76
76
  "lodash.isequal": "^4.5.0",
77
77
  "next": "^15",
78
- "next-intl": "^4.8.3",
78
+ "next-intl": "^4.9.0",
79
79
  "prettier": "^3.4.2",
80
80
  "react": "^19.2.0",
81
81
  "react-dom": "^19.2.0",