pixelize-design-library 2.2.30 → 2.2.31

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.
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import { TableProps } from "./TableProps";
3
- export default function Table({ data, columns, onSelection, isLoading, isCheckbox, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, tableBorderColor, noBorders, isPagination, onRowClick, selections, isActionFreeze, preferencesUrl, preferencesKey, preferencesName, preferencesPage, authToken, paginationMode, noOfRowsPerPage, totalRecords, onPagination, isTableSettings, headerActions, onGlobalSearch, }: TableProps): React.JSX.Element;
3
+ export default function Table({ data, columns, onSelection, isLoading, isCheckbox, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, tableBorderColor, noBorders, isPagination, onRowClick, selections, isActionFreeze, preferences, paginationMode, noOfRowsPerPage, totalRecords, onPagination, isTableSettings, headerActions, onGlobalSearch, }: TableProps): React.JSX.Element;
@@ -42,39 +42,47 @@ var Divider_1 = __importDefault(require("../Divider/Divider"));
42
42
  var TableSearch_1 = __importDefault(require("./Components/TableSearch"));
43
43
  function Table(_a) {
44
44
  var _b, _c, _d, _e, _f, _g;
45
- var data = _a.data, columns = _a.columns, onSelection = _a.onSelection, isLoading = _a.isLoading, _h = _a.isCheckbox, isCheckbox = _h === void 0 ? false : _h, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, tableBorderColor = _a.tableBorderColor, _j = _a.noBorders, noBorders = _j === void 0 ? false : _j, _k = _a.isPagination, isPagination = _k === void 0 ? true : _k, onRowClick = _a.onRowClick, selections = _a.selections, _l = _a.isActionFreeze, isActionFreeze = _l === void 0 ? true : _l, _m = _a.preferencesUrl, preferencesUrl = _m === void 0 ? "" : _m, _o = _a.preferencesKey, preferencesKey = _o === void 0 ? "" : _o, _p = _a.preferencesName, preferencesName = _p === void 0 ? "" : _p, _q = _a.preferencesPage, preferencesPage = _q === void 0 ? "" : _q, _r = _a.authToken, authToken = _r === void 0 ? "" : _r, _s = _a.paginationMode, paginationMode = _s === void 0 ? "client" : _s, _t = _a.noOfRowsPerPage, noOfRowsPerPage = _t === void 0 ? 50 : _t, _u = _a.totalRecords, totalRecords = _u === void 0 ? 0 : _u, onPagination = _a.onPagination, _v = _a.isTableSettings, isTableSettings = _v === void 0 ? false : _v, headerActions = _a.headerActions, onGlobalSearch = _a.onGlobalSearch;
45
+ var data = _a.data, columns = _a.columns, onSelection = _a.onSelection, isLoading = _a.isLoading, _h = _a.isCheckbox, isCheckbox = _h === void 0 ? false : _h, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, tableBorderColor = _a.tableBorderColor, _j = _a.noBorders, noBorders = _j === void 0 ? false : _j, _k = _a.isPagination, isPagination = _k === void 0 ? true : _k, onRowClick = _a.onRowClick, selections = _a.selections, _l = _a.isActionFreeze, isActionFreeze = _l === void 0 ? true : _l, _m = _a.preferences, preferences = _m === void 0 ? {
46
+ url: "",
47
+ token: "",
48
+ key: "",
49
+ name: "",
50
+ page: "",
51
+ orgId: "",
52
+ } : _m, _o = _a.paginationMode, paginationMode = _o === void 0 ? "client" : _o, _p = _a.noOfRowsPerPage, noOfRowsPerPage = _p === void 0 ? 50 : _p, _q = _a.totalRecords, totalRecords = _q === void 0 ? 0 : _q, onPagination = _a.onPagination, _r = _a.isTableSettings, isTableSettings = _r === void 0 ? false : _r, headerActions = _a.headerActions, onGlobalSearch = _a.onGlobalSearch;
46
53
  var theme = (0, useCustomTheme_1.useCustomTheme)();
47
- var _w = (0, react_1.useState)({}), columnsSearch = _w[0], setColumnsSearch = _w[1];
54
+ var _s = (0, react_1.useState)({}), columnsSearch = _s[0], setColumnsSearch = _s[1];
48
55
  // useEffect(() => {
49
56
  // if (onColumnFilter) {
50
57
  // onColumnFilter(columnsSearch);
51
58
  // }
52
59
  // }, [columnsSearch, onColumnFilter]);
53
60
  var isServerPagination = paginationMode === "server";
54
- var _x = (0, usePreferences_1.useGetPreferences)({
55
- baseUrl: preferencesUrl,
56
- page: preferencesPage,
57
- key: preferencesKey,
58
- name: preferencesName,
59
- authToken: authToken,
60
- }), preferences = _x.preferences, loading = _x.loading;
61
+ var _t = (0, usePreferences_1.useGetPreferences)({
62
+ baseUrl: preferences.url,
63
+ page: preferences.page,
64
+ key: preferences.key,
65
+ name: preferences.name,
66
+ authToken: preferences.token,
67
+ orgId: preferences.orgId,
68
+ }), tablePreferencesData = _t.preferences, loading = _t.loading;
61
69
  var savePreferences = (0, usePreferences_1.useSavePreferences)({
62
- baseUrl: preferencesUrl,
63
- page: preferencesPage,
64
- key: preferencesKey,
65
- name: preferencesName,
66
- authToken: authToken,
70
+ baseUrl: preferences.url,
71
+ page: preferences.page,
72
+ key: preferences.key,
73
+ name: preferences.name,
74
+ authToken: preferences.token,
67
75
  }).savePreferences;
68
76
  var isTableLoading = (0, react_1.useMemo)(function () {
69
77
  return loading || isLoading;
70
78
  }, [loading, isLoading]);
71
79
  var tablePreferences = (0, react_1.useMemo)(function () {
72
- if (preferences.length) {
73
- return preferences[0].json;
80
+ if (tablePreferencesData === null || tablePreferencesData === void 0 ? void 0 : tablePreferencesData.length) {
81
+ return tablePreferencesData[0].json;
74
82
  }
75
83
  return {};
76
- }, [preferences]);
77
- var _y = (0, useTable_1.default)({
84
+ }, [tablePreferencesData]);
85
+ var _u = (0, useTable_1.default)({
78
86
  tableBorderColor: tableBorderColor,
79
87
  data: data,
80
88
  isPagination: isPagination,
@@ -86,7 +94,7 @@ function Table(_a) {
86
94
  noOfRowsPerPage: noOfRowsPerPage,
87
95
  totalRecords: totalRecords,
88
96
  isServerPagination: isServerPagination,
89
- }), tableData = _y.tableData, isContent = _y.isContent, isLink = _y.isLink, headerRefs = _y.headerRefs, columnWidths = _y.columnWidths, handleSort = _y.handleSort, handleCheckbox = _y.handleCheckbox, filteredData = _y.filteredData, startRow = _y.startRow, endRow = _y.endRow, selection = _y.selection, columnsSort = _y.columnsSort, currentPage = _y.currentPage, pages = _y.pages, rowsPerPage = _y.rowsPerPage, handlePageSizeChange = _y.handlePageSizeChange, setCurrentPage = _y.setCurrentPage, columnsList = _y.columnsList, handleColumnPreferences = _y.handleColumnPreferences;
97
+ }), tableData = _u.tableData, isContent = _u.isContent, isLink = _u.isLink, headerRefs = _u.headerRefs, columnWidths = _u.columnWidths, handleSort = _u.handleSort, handleCheckbox = _u.handleCheckbox, filteredData = _u.filteredData, startRow = _u.startRow, endRow = _u.endRow, selection = _u.selection, columnsSort = _u.columnsSort, currentPage = _u.currentPage, pages = _u.pages, rowsPerPage = _u.rowsPerPage, handlePageSizeChange = _u.handlePageSizeChange, setCurrentPage = _u.setCurrentPage, columnsList = _u.columnsList, handleColumnPreferences = _u.handleColumnPreferences;
90
98
  var _filteredData = (0, react_1.useMemo)(function () {
91
99
  return (0, table_1.searchAndSortData)(filteredData, columnsSearch);
92
100
  }, [columnsSearch, filteredData]);
@@ -19,11 +19,6 @@ export type TableProps = {
19
19
  selections?: (string | number)[];
20
20
  onRowClick?: (row: DataObject, header: Record<string | number, string | number>) => void;
21
21
  isActionFreeze?: boolean;
22
- preferencesUrl?: string;
23
- preferencesKey?: string;
24
- preferencesName?: string;
25
- preferencesPage?: string;
26
- authToken?: string;
27
22
  paginationMode?: "client" | "server";
28
23
  noOfRowsPerPage?: number;
29
24
  totalRecords?: number;
@@ -32,6 +27,14 @@ export type TableProps = {
32
27
  headerActions?: HeaderActionsProps;
33
28
  onGlobalSearch?: (searchVal: string) => void;
34
29
  onColumnFilter?: (filters: Record<string, any>) => void;
30
+ preferences?: {
31
+ url: string;
32
+ token: string;
33
+ key?: string;
34
+ name?: string;
35
+ page?: string;
36
+ orgId?: string;
37
+ };
35
38
  };
36
39
  export type HeaderActionsProps = {
37
40
  isDelete?: {
@@ -4,6 +4,7 @@ type PreferencesProps = {
4
4
  page?: string;
5
5
  name?: string;
6
6
  authToken?: string;
7
+ orgId?: string;
7
8
  };
8
9
  type PreferencesResponseProps = {
9
10
  json: Record<string, any>;
@@ -12,7 +13,7 @@ type PreferencesResponseProps = {
12
13
  page: string;
13
14
  preference_id: string;
14
15
  };
15
- declare const useGetPreferences: ({ baseUrl, key, page, name, authToken, }: PreferencesProps) => {
16
+ declare const useGetPreferences: ({ baseUrl, key, page, name, authToken, orgId, }: PreferencesProps) => {
16
17
  preferences: PreferencesResponseProps[];
17
18
  loading: boolean;
18
19
  };
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSavePreferences = exports.useGetPreferences = void 0;
4
4
  var react_1 = require("react");
5
5
  var constructUrl = function (_a) {
6
- var baseUrl = _a.baseUrl, key = _a.key, page = _a.page, name = _a.name;
6
+ var baseUrl = _a.baseUrl, key = _a.key, page = _a.page, name = _a.name, orgId = _a.orgId;
7
7
  var params = new URLSearchParams();
8
+ if (orgId) {
9
+ params.append("orgId", orgId);
10
+ }
8
11
  if (page) {
9
12
  params.append("page", page);
10
13
  }
@@ -18,15 +21,15 @@ var constructUrl = function (_a) {
18
21
  return "".concat(baseUrl).concat(queryString ? "?".concat(queryString) : "");
19
22
  };
20
23
  var useGetPreferences = function (_a) {
21
- var _b = _a.baseUrl, baseUrl = _b === void 0 ? "" : _b, _c = _a.key, key = _c === void 0 ? "" : _c, _d = _a.page, page = _d === void 0 ? "" : _d, _e = _a.name, name = _e === void 0 ? "" : _e, _f = _a.authToken, authToken = _f === void 0 ? "" : _f;
22
- var _g = (0, react_1.useState)([]), preferences = _g[0], setPreferences = _g[1];
23
- var _h = (0, react_1.useState)(false), loading = _h[0], setLoading = _h[1];
24
+ var _b = _a.baseUrl, baseUrl = _b === void 0 ? "" : _b, _c = _a.key, key = _c === void 0 ? "" : _c, _d = _a.page, page = _d === void 0 ? "" : _d, _e = _a.name, name = _e === void 0 ? "" : _e, _f = _a.authToken, authToken = _f === void 0 ? "" : _f, _g = _a.orgId, orgId = _g === void 0 ? "" : _g;
25
+ var _h = (0, react_1.useState)([]), preferences = _h[0], setPreferences = _h[1];
26
+ var _j = (0, react_1.useState)(false), loading = _j[0], setLoading = _j[1];
24
27
  (0, react_1.useEffect)(function () {
25
28
  if (!baseUrl) {
26
29
  return;
27
30
  }
28
31
  setLoading(true);
29
- var url = constructUrl({ baseUrl: baseUrl, key: key, page: page, name: name });
32
+ var url = constructUrl({ baseUrl: baseUrl, key: key, page: page, name: name, orgId: orgId });
30
33
  fetch(url, {
31
34
  headers: {
32
35
  Authorization: authToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelize-design-library",
3
- "version": "2.2.30",
3
+ "version": "2.2.31",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",