pixelize-design-library 1.1.15 → 1.1.17

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,5 +1,4 @@
1
1
  import React from "react";
2
- import { KaTableProps } from "./KaTableProps";
3
2
  import * as TableEnums from "ka-table/enums";
4
3
  import * as TableProps from "ka-table/props";
5
4
  import * as TableActionCreator from "ka-table/actionCreators";
@@ -8,6 +7,6 @@ import * as TableUtils from "ka-table/utils";
8
7
  import * as TableFun from "ka-table";
9
8
  import "ka-table/style.css";
10
9
  import "./ka-table.css";
11
- declare const KaTable: ({ columns, data, rowKey, Edit, format, filter, childComponents, columnReorder, columnResizing, editableCells, validation, loading, checkSelect, onRowClick, onSelectionChange, onSortChange, onMenuItemClick, menuItems, }: KaTableProps) => React.JSX.Element;
12
- export default KaTable;
10
+ declare const _default: React.MemoExoticComponent<({ columns, data, rowKey, Edit, format, filter, childComponents, columnReorder, columnResizing, editableCells, validation, loading, checkSelect, onRowClick, onSelectionChange, onSortChange, onMenuItemClick, menuItems, selected, }: any) => React.JSX.Element>;
11
+ export default _default;
13
12
  export { TableEnums, TableActionCreator, TableProps, TableModel, TableUtils, TableFun, };
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -33,21 +22,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
33
22
  __setModuleDefault(result, mod);
34
23
  return result;
35
24
  };
36
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
37
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
38
- if (ar || !(i in from)) {
39
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
40
- ar[i] = from[i];
41
- }
42
- }
43
- return to.concat(ar || Array.prototype.slice.call(from));
44
- };
45
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
27
  };
48
28
  Object.defineProperty(exports, "__esModule", { value: true });
49
29
  exports.TableFun = exports.TableUtils = exports.TableModel = exports.TableProps = exports.TableActionCreator = exports.TableEnums = void 0;
50
- var react_1 = __importStar(require("react"));
30
+ var react_1 = __importDefault(require("react"));
51
31
  var ka_table_1 = require("ka-table");
52
32
  var TableEnums = __importStar(require("ka-table/enums"));
53
33
  exports.TableEnums = TableEnums;
@@ -63,166 +43,25 @@ var TableFun = __importStar(require("ka-table"));
63
43
  exports.TableFun = TableFun;
64
44
  require("ka-table/style.css");
65
45
  require("./ka-table.css");
66
- var CustomHeader_1 = __importDefault(require("./CustomHeader"));
46
+ var useMergedChildComponents_1 = __importDefault(require("./useMergedChildComponents"));
47
+ var selectionCellColumn = {
48
+ key: "select-cell",
49
+ width: 65,
50
+ columnFreeze: true,
51
+ customHeader: false,
52
+ className: "select-cell",
53
+ };
67
54
  var KaTable = function (_a) {
68
55
  var columns = _a.columns, data = _a.data, _b = _a.rowKey, rowKey = _b === void 0 ? "id" : _b, Edit = _a.Edit,
69
56
  // sorting,
70
57
  format = _a.format,
71
58
  // paging,
72
- filter = _a.filter, childComponents = _a.childComponents, columnReorder = _a.columnReorder, columnResizing = _a.columnResizing, editableCells = _a.editableCells, validation = _a.validation, loading = _a.loading, checkSelect = _a.checkSelect, onRowClick = _a.onRowClick, onSelectionChange = _a.onSelectionChange, onSortChange = _a.onSortChange, onMenuItemClick = _a.onMenuItemClick, menuItems = _a.menuItems;
73
- var selectionCellColumn = {
74
- key: "select-cell",
75
- width: 65,
76
- columnFreeze: true,
77
- customHeader: false,
78
- className: "select-cell",
79
- };
59
+ filter = _a.filter, childComponents = _a.childComponents, columnReorder = _a.columnReorder, columnResizing = _a.columnResizing, editableCells = _a.editableCells, validation = _a.validation, loading = _a.loading, checkSelect = _a.checkSelect, onRowClick = _a.onRowClick, onSelectionChange = _a.onSelectionChange, onSortChange = _a.onSortChange, onMenuItemClick = _a.onMenuItemClick, menuItems = _a.menuItems, selected = _a.selected;
80
60
  if (checkSelect &&
81
61
  !columns.some(function (column) { return column.key === "select-cell"; })) {
82
62
  columns.unshift(selectionCellColumn);
83
63
  }
84
- var getPreviousColumnWidth = function (key) {
85
- var index = columns.findIndex(function (column) { return column.key === key; });
86
- if (index > 0) {
87
- return columns[index - 1].width;
88
- }
89
- return 0;
90
- };
91
- var SelectionHeader = function () {
92
- var _a, _b;
93
- var table = TableFun.useTableInstance();
94
- var areAllRowsSelected = TableUtils.kaPropsUtils.areAllFilteredRowsSelected(table.props);
95
- var selectedRows = ((_b = (_a = table === null || table === void 0 ? void 0 : table.props) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : []).filter(function (row) { var _a; return ((_a = table.props.selectedRows) !== null && _a !== void 0 ? _a : []).includes(row[rowKey]); });
96
- var areSomeRowsSelected = selectedRows.length > 0 && !areAllRowsSelected;
97
- var selectAllRef = (0, react_1.useRef)(null);
98
- var prevSelectedRowsRef = (0, react_1.useRef)([]);
99
- (0, react_1.useEffect)(function () {
100
- if (selectAllRef.current) {
101
- selectAllRef.current.indeterminate = areSomeRowsSelected;
102
- }
103
- }, [areSomeRowsSelected]);
104
- (0, react_1.useEffect)(function () {
105
- var prevSelectedRows = prevSelectedRowsRef.current;
106
- if (onSelectionChange &&
107
- selectedRows &&
108
- JSON.stringify(prevSelectedRows) !== JSON.stringify(selectedRows)) {
109
- var selectedRowIds = selectedRows.map(function (row) { return row[rowKey]; });
110
- onSelectionChange(selectedRowIds);
111
- prevSelectedRowsRef.current = selectedRows;
112
- }
113
- }, [selectedRows]);
114
- return (react_1.default.createElement("input", { ref: selectAllRef, type: "checkbox", checked: areAllRowsSelected, onChange: function (event) {
115
- if (event.currentTarget.checked) {
116
- table.selectAllFilteredRows();
117
- }
118
- else {
119
- table.deselectAllFilteredRows();
120
- }
121
- } }));
122
- };
123
- var SelectionCell = function (_a) {
124
- var rowKeyValue = _a.rowKeyValue, isSelectedRow = _a.isSelectedRow, selectedRows = _a.selectedRows, onSelectionChange = _a.onSelectionChange, rowKey = _a.rowKey;
125
- var table = TableFun.useTableInstance();
126
- var prevSelectedRowsRef = (0, react_1.useRef)([]);
127
- (0, react_1.useEffect)(function () {
128
- var prevSelectedRows = prevSelectedRowsRef.current;
129
- if (onSelectionChange &&
130
- selectedRows &&
131
- JSON.stringify(prevSelectedRows) !== JSON.stringify(selectedRows)) {
132
- var selectedRowIds = selectedRows
133
- .filter(function (row) { return row && row[rowKey] !== undefined; })
134
- .map(function (row) { return row[rowKey]; });
135
- onSelectionChange(selectedRowIds);
136
- prevSelectedRowsRef.current = selectedRows;
137
- }
138
- }, [selectedRows, onSelectionChange, rowKey]);
139
- return (react_1.default.createElement("input", { type: "checkbox", checked: isSelectedRow, onChange: function (event) {
140
- if (event.nativeEvent.shiftKey) {
141
- table.selectRowsRange(rowKeyValue, __spreadArray([], selectedRows, true).pop());
142
- }
143
- else if (event.currentTarget.checked) {
144
- table.selectRow(rowKeyValue);
145
- }
146
- else {
147
- table.deselectRow(rowKeyValue);
148
- }
149
- } }));
150
- };
151
- var mergedChildComponents = __assign(__assign({}, childComponents), { headCell: {
152
- content: function (props) {
153
- var _a;
154
- var existingContent = (_a = childComponents.headCell) === null || _a === void 0 ? void 0 : _a.content;
155
- if (existingContent) {
156
- var result = existingContent(props);
157
- if (result) {
158
- return result;
159
- }
160
- }
161
- if (props.column.customHeader === undefined ||
162
- props.column.customHeader === true) {
163
- return (react_1.default.createElement(CustomHeader_1.default, __assign({}, props, { onSortChange: onSortChange, onMenuItemClick: onMenuItemClick, menuItems: menuItems })));
164
- }
165
- if (props.column.key === "select-cell") {
166
- return react_1.default.createElement(SelectionHeader, null);
167
- }
168
- },
169
- elementAttributes: function (props) {
170
- var _a;
171
- var existingElementAttributes = (_a = childComponents.headCell) === null || _a === void 0 ? void 0 : _a.elementAttributes;
172
- if (existingElementAttributes) {
173
- var result = existingElementAttributes(props);
174
- if (result) {
175
- return result;
176
- }
177
- }
178
- if (props.column.columnFreeze) {
179
- var stickyLeft = getPreviousColumnWidth(props.column.key);
180
- return {
181
- style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 3, backgroundColor: "#d9d9db", textAlign: "center" }),
182
- };
183
- }
184
- },
185
- }, cell: {
186
- elementAttributes: function (props) {
187
- var _a;
188
- var existingElementAttributes = (_a = childComponents.cell) === null || _a === void 0 ? void 0 : _a.elementAttributes;
189
- if (existingElementAttributes) {
190
- var result = existingElementAttributes(props);
191
- if (result) {
192
- return result;
193
- }
194
- }
195
- if (props.column.columnFreeze) {
196
- var stickyLeft = getPreviousColumnWidth(props.column.key);
197
- return {
198
- style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 2, backgroundColor: "#d9d9db" }),
199
- };
200
- }
201
- return {
202
- onClick: function () {
203
- if (onRowClick) {
204
- onRowClick(props.rowData, props.column.key);
205
- }
206
- },
207
- };
208
- },
209
- }, tableWrapper: {
210
- elementAttributes: function () { return ({ style: { maxHeight: 600 } }); },
211
- }, cellText: {
212
- content: function (props) {
213
- var _a;
214
- var existingContent = (_a = childComponents.cellText) === null || _a === void 0 ? void 0 : _a.content;
215
- if (existingContent) {
216
- var result = existingContent(props);
217
- if (result) {
218
- return result;
219
- }
220
- }
221
- if (props.column.key === "select-cell") {
222
- return react_1.default.createElement(SelectionCell, __assign({}, props));
223
- }
224
- },
225
- } });
64
+ var mergedChildComponents = (0, useMergedChildComponents_1.default)(childComponents, onSortChange, onMenuItemClick, menuItems, onSelectionChange, rowKey, onRowClick, selected, data.length);
226
65
  return (react_1.default.createElement(ka_table_1.Table, { columns: columns, data: data, rowKeyField: rowKey, editingMode: Edit,
227
66
  // sortingMode={sorting}
228
67
  format: format,
@@ -231,4 +70,4 @@ var KaTable = function (_a) {
231
70
  enabled: true,
232
71
  } }));
233
72
  };
234
- exports.default = KaTable;
73
+ exports.default = react_1.default.memo(KaTable);
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { TableProps } from "./KaTable";
3
+ declare const _default: React.MemoExoticComponent<({ rowKeyValue, selectedRows, onSelectionChange, selected, }: TableProps.ICellTextProps<any> & {
4
+ onSelectionChange: (ids: any[], type: string) => void;
5
+ rowKey: any;
6
+ selected: any;
7
+ }) => React.JSX.Element>;
8
+ export default _default;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ var react_1 = __importDefault(require("react"));
16
+ var KaTable_1 = require("./KaTable");
17
+ var SelectionCell = function (_a) {
18
+ var rowKeyValue = _a.rowKeyValue, selectedRows = _a.selectedRows, onSelectionChange = _a.onSelectionChange, selected = _a.selected;
19
+ var table = KaTable_1.TableFun.useTableInstance();
20
+ var onChangeHandle = function (event) {
21
+ if (event.nativeEvent.shiftKey) {
22
+ table.selectRowsRange(rowKeyValue, __spreadArray([], selectedRows, true).pop());
23
+ }
24
+ else if (event.currentTarget.checked) {
25
+ onSelectionChange(rowKeyValue, "add");
26
+ table.selectRow(rowKeyValue);
27
+ }
28
+ else {
29
+ onSelectionChange(rowKeyValue, "remove");
30
+ table.deselectRow(rowKeyValue);
31
+ }
32
+ };
33
+ return react_1.default.createElement("input", { type: "checkbox", checked: selected, onChange: onChangeHandle });
34
+ };
35
+ exports.default = react_1.default.memo(SelectionCell);
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const _default: React.MemoExoticComponent<({ onSelectionChange, rowKey, selected }: any) => React.JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ var react_1 = __importStar(require("react"));
27
+ var KaTable_1 = require("./KaTable");
28
+ var SelectionHeader = function (_a) {
29
+ var onSelectionChange = _a.onSelectionChange, rowKey = _a.rowKey, selected = _a.selected;
30
+ var table = KaTable_1.TableFun.useTableInstance();
31
+ var selectAllRef = (0, react_1.useRef)(null);
32
+ (0, react_1.useEffect)(function () {
33
+ if (selectAllRef.current) {
34
+ selectAllRef.current.indeterminate = selected === null || selected === void 0 ? void 0 : selected.intederminate;
35
+ }
36
+ }, [selected.intederminate]);
37
+ var handleSelectionChange = (0, react_1.useCallback)(function (checked) {
38
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(checked);
39
+ }, [onSelectionChange]);
40
+ return (react_1.default.createElement("input", { ref: selectAllRef, type: "checkbox", checked: selected === null || selected === void 0 ? void 0 : selected.checked, onChange: function (event) {
41
+ var _a, _b;
42
+ if (event.currentTarget.checked) {
43
+ var totalIds = (_b = (_a = table === null || table === void 0 ? void 0 : table.props) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.map(function (row) { return row[rowKey]; });
44
+ handleSelectionChange(totalIds);
45
+ table.selectAllFilteredRows();
46
+ }
47
+ else {
48
+ handleSelectionChange([]);
49
+ table.deselectAllFilteredRows();
50
+ }
51
+ } }));
52
+ };
53
+ exports.default = react_1.default.memo(SelectionHeader);
@@ -0,0 +1,2 @@
1
+ declare const useMergedChildComponents: (childComponents: any, onSortChange: any, onMenuItemClick: any, menuItems: any, handleSelection: any, rowKey: any, onRowClick: any, selected: any, dataLength: number) => any;
2
+ export default useMergedChildComponents;
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
37
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
38
+ if (ar || !(i in from)) {
39
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
40
+ ar[i] = from[i];
41
+ }
42
+ }
43
+ return to.concat(ar || Array.prototype.slice.call(from));
44
+ };
45
+ var __importDefault = (this && this.__importDefault) || function (mod) {
46
+ return (mod && mod.__esModule) ? mod : { "default": mod };
47
+ };
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ var react_1 = __importStar(require("react"));
50
+ var CustomHeader_1 = __importDefault(require("./CustomHeader"));
51
+ var SelectionHeader_1 = __importDefault(require("./SelectionHeader"));
52
+ var SelectionCell_1 = __importDefault(require("./SelectionCell"));
53
+ var getPreviousColumnWidth = function (columns, key) {
54
+ var index = columns === null || columns === void 0 ? void 0 : columns.findIndex(function (column) { return column.key === key; });
55
+ if (index > 0) {
56
+ return columns[index - 1].width;
57
+ }
58
+ return 0;
59
+ };
60
+ var useMergedChildComponents = function (childComponents, onSortChange, onMenuItemClick, menuItems, handleSelection, rowKey, onRowClick, selected, dataLength) {
61
+ var _a = react_1.default.useState(selected), selections = _a[0], setSelections = _a[1];
62
+ var isAllSelected = (0, react_1.useMemo)(function () {
63
+ return {
64
+ checked: selections.length === dataLength,
65
+ intederminate: selections.length > 0 && selections.length < dataLength,
66
+ };
67
+ }, [selections, dataLength]);
68
+ var cellSelectionHandle = (0, react_1.useCallback)(function (values, type) {
69
+ if (type === "add") {
70
+ setSelections(__spreadArray(__spreadArray([], selections, true), [values], false));
71
+ handleSelection(__spreadArray(__spreadArray([], selections, true), [values], false));
72
+ }
73
+ else if (type === "remove") {
74
+ setSelections(selections.filter(function (value) { return value !== values; }));
75
+ handleSelection(selections.filter(function (value) { return value !== values; }));
76
+ }
77
+ else {
78
+ handleSelection(selections.filter(function (value) { return value !== values; }));
79
+ }
80
+ }, [selections]);
81
+ var headerSelectionHandle = (0, react_1.useCallback)(function (values) {
82
+ setSelections(values);
83
+ handleSelection(values);
84
+ }, [selections]);
85
+ return (0, react_1.useMemo)(function () {
86
+ return __assign(__assign({}, childComponents), { headCell: {
87
+ content: function (props) {
88
+ var _a;
89
+ var existingContent = (_a = childComponents.headCell) === null || _a === void 0 ? void 0 : _a.content;
90
+ if (existingContent) {
91
+ var result = existingContent(props);
92
+ if (result) {
93
+ return result;
94
+ }
95
+ }
96
+ if (props.column.customHeader === undefined ||
97
+ props.column.customHeader === true) {
98
+ return (react_1.default.createElement(CustomHeader_1.default, __assign({}, props, { onSortChange: onSortChange, onMenuItemClick: onMenuItemClick, menuItems: menuItems })));
99
+ }
100
+ if (props.column.key === "select-cell") {
101
+ return (react_1.default.createElement(SelectionHeader_1.default, { onSelectionChange: headerSelectionHandle, rowKey: rowKey, selected: isAllSelected }));
102
+ }
103
+ },
104
+ elementAttributes: function (props) {
105
+ var _a;
106
+ var existingElementAttributes = (_a = childComponents.headCell) === null || _a === void 0 ? void 0 : _a.elementAttributes;
107
+ if (existingElementAttributes) {
108
+ var result = existingElementAttributes(props);
109
+ if (result) {
110
+ return result;
111
+ }
112
+ }
113
+ if (props.column.columnFreeze) {
114
+ var stickyLeft = getPreviousColumnWidth(props.columns, props.column.key);
115
+ return {
116
+ style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 3, backgroundColor: "#d9d9db", textAlign: "center" }),
117
+ };
118
+ }
119
+ },
120
+ }, cell: {
121
+ elementAttributes: function (props) {
122
+ var _a;
123
+ var existingElementAttributes = (_a = childComponents.cell) === null || _a === void 0 ? void 0 : _a.elementAttributes;
124
+ if (existingElementAttributes) {
125
+ var result = existingElementAttributes(props);
126
+ if (result) {
127
+ return result;
128
+ }
129
+ }
130
+ if (props.column.columnFreeze) {
131
+ var stickyLeft = getPreviousColumnWidth(props.columns, props.column.key);
132
+ return {
133
+ style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 2, backgroundColor: "#d9d9db" }),
134
+ };
135
+ }
136
+ return {
137
+ onClick: function () {
138
+ if (onRowClick) {
139
+ onRowClick(props.rowData, props.column.key);
140
+ }
141
+ },
142
+ };
143
+ },
144
+ }, tableWrapper: {
145
+ elementAttributes: function () { return ({ style: { maxHeight: 600 } }); },
146
+ }, cellText: {
147
+ content: function (props) {
148
+ var _a;
149
+ var existingContent = (_a = childComponents.cellText) === null || _a === void 0 ? void 0 : _a.content;
150
+ if (existingContent) {
151
+ var result = existingContent(props);
152
+ if (result) {
153
+ return result;
154
+ }
155
+ }
156
+ if (props.column.key === "select-cell") {
157
+ var isSelected = selections === null || selections === void 0 ? void 0 : selections.includes(props.rowData[rowKey]);
158
+ return (react_1.default.createElement(SelectionCell_1.default, __assign({}, props, { selected: isSelected, onSelectionChange: cellSelectionHandle })));
159
+ }
160
+ },
161
+ } });
162
+ }, [
163
+ childComponents,
164
+ onSortChange,
165
+ onMenuItemClick,
166
+ menuItems,
167
+ handleSelection,
168
+ rowKey,
169
+ onRowClick,
170
+ ]);
171
+ };
172
+ exports.default = useMergedChildComponents;
package/dist/Layout.js CHANGED
@@ -56,7 +56,7 @@ var modal_1 = __importDefault(require("./Pages/modal"));
56
56
  var checkbox_1 = __importDefault(require("./Pages/checkbox"));
57
57
  var toster_1 = __importDefault(require("./Pages/toster"));
58
58
  var input_1 = __importDefault(require("./Pages/input"));
59
- var katable_1 = __importDefault(require("./Pages/katable"));
59
+ var KaTableExample_1 = __importDefault(require("./Pages/KaTableExample"));
60
60
  var alertdialog_1 = __importDefault(require("./Pages/alertdialog"));
61
61
  var Layout = function () {
62
62
  var _a = (0, react_2.useState)(window.location.pathname), currentPath = _a[0], setCurrentPath = _a[1];
@@ -76,7 +76,7 @@ var Layout = function () {
76
76
  var renderPage = function () {
77
77
  switch (currentPath) {
78
78
  case "/katable":
79
- return react_2.default.createElement(katable_1.default, null);
79
+ return react_2.default.createElement(KaTableExample_1.default, null);
80
80
  case "/alertdialog":
81
81
  return react_2.default.createElement(alertdialog_1.default, null);
82
82
  case "/accordion":
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const KaTableExample: () => React.JSX.Element;
3
+ export default KaTableExample;
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ var react_1 = __importStar(require("react"));
41
+ var KaTable_1 = __importDefault(require("../Components/KaTable/KaTable"));
42
+ var KaTable_2 = require("../Components/KaTable/KaTable");
43
+ var icons_1 = require("@chakra-ui/icons");
44
+ var menuItems = [
45
+ { label: "Sort", action: "Sort" },
46
+ { label: "Hide column", action: "Hide column" },
47
+ {
48
+ label: "Filter",
49
+ submenu: [
50
+ { label: "Filter by Date", action: "Filter by Date" },
51
+ { label: "Filter by Name", action: "Filter by Name" },
52
+ { label: "Filter by Status", action: "Filter by Status" },
53
+ ],
54
+ },
55
+ ];
56
+ var DataType = KaTable_2.TableEnums.DataType;
57
+ var dataArray = Array(5)
58
+ .fill(undefined)
59
+ .map(function (_, index) { return ({
60
+ column1: index % 2 === 0,
61
+ column2: "column:2 row:".concat(index + 1),
62
+ column3: index + 5,
63
+ column4: index + 10,
64
+ column5: index + 15,
65
+ column6: index + 20,
66
+ column7: index + 25,
67
+ column8: index + 30,
68
+ column9: index + 35,
69
+ column10: index + 40,
70
+ column11: index + 45,
71
+ column12: index + 50,
72
+ column13: index + 55,
73
+ column14: index + 60,
74
+ column15: new Date(2022, 11, index),
75
+ id: index + 1,
76
+ }); });
77
+ var columns = [
78
+ {
79
+ key: "column1",
80
+ title: "Column 1",
81
+ dataType: DataType.Boolean,
82
+ width: 150,
83
+ columnFreeze: true,
84
+ customHeader: false,
85
+ },
86
+ {
87
+ key: "column2",
88
+ title: "Column 2",
89
+ dataType: DataType.String,
90
+ width: 150,
91
+ },
92
+ {
93
+ key: "column3",
94
+ title: "Column 3",
95
+ dataType: DataType.Number,
96
+ width: 150,
97
+ },
98
+ {
99
+ key: "column4",
100
+ title: "Column 4",
101
+ dataType: DataType.Number,
102
+ width: 150,
103
+ },
104
+ {
105
+ key: "column5",
106
+ title: "Column 5",
107
+ dataType: DataType.Number,
108
+ width: 150,
109
+ },
110
+ {
111
+ key: "column6",
112
+ title: "Column 6",
113
+ dataType: DataType.Number,
114
+ width: 150,
115
+ },
116
+ {
117
+ key: "column7",
118
+ title: "Column 7",
119
+ dataType: DataType.Number,
120
+ width: 150,
121
+ },
122
+ {
123
+ key: "column8",
124
+ title: "Column 8",
125
+ dataType: DataType.Number,
126
+ width: 150,
127
+ },
128
+ {
129
+ key: "column9",
130
+ title: "Column 9",
131
+ dataType: DataType.Number,
132
+ width: 150,
133
+ },
134
+ {
135
+ key: "column10",
136
+ title: "Column 10",
137
+ dataType: DataType.Number,
138
+ width: 150,
139
+ },
140
+ {
141
+ key: "column11",
142
+ title: "Column 11",
143
+ dataType: DataType.Number,
144
+ width: 150,
145
+ },
146
+ {
147
+ key: "column12",
148
+ title: "Column 12",
149
+ dataType: DataType.Number,
150
+ width: 150,
151
+ },
152
+ {
153
+ key: "column13",
154
+ title: "Column 13",
155
+ dataType: DataType.Number,
156
+ width: 150,
157
+ },
158
+ {
159
+ key: "column14",
160
+ title: "Column 14",
161
+ dataType: DataType.Number,
162
+ width: 150,
163
+ },
164
+ {
165
+ key: "column15",
166
+ title: "Column 15",
167
+ dataType: DataType.Date,
168
+ width: 150,
169
+ },
170
+ {
171
+ key: "editColumn",
172
+ width: 80,
173
+ customHeader: false,
174
+ },
175
+ ];
176
+ var KaTableExample = function () {
177
+ var _a = (0, react_1.useState)(false), actionButtons = _a[0], setActionButtons = _a[1];
178
+ var _b = (0, react_1.useState)([]), selectedRows = _b[0], setSelectedRows = _b[1];
179
+ var kaTableFormat = function (props) {
180
+ if (props.column.dataType === DataType.Date) {
181
+ return (props.value &&
182
+ props.value.toLocaleDateString("en", {
183
+ month: "2-digit",
184
+ day: "2-digit",
185
+ year: "numeric",
186
+ }));
187
+ }
188
+ };
189
+ var EditButton = function (_a) {
190
+ var dispatch = _a.dispatch, rowKeyValue = _a.rowKeyValue;
191
+ return (react_1.default.createElement("div", { className: "edit-cell-button" },
192
+ react_1.default.createElement(icons_1.EditIcon, null),
193
+ react_1.default.createElement(icons_1.DeleteIcon, null)));
194
+ };
195
+ var handleSortChange = function (newSortState, columnName) {
196
+ console.log("Sort state for ".concat(columnName, " changed to:"), newSortState);
197
+ };
198
+ var handleMenuItemClick = function (action, columnName) {
199
+ console.log("Menu item clicked for ".concat(columnName, ":"), action);
200
+ };
201
+ var handleCheckSelect = (0, react_1.useCallback)(function (selectedRows) {
202
+ console.log("CB", selectedRows);
203
+ if (selectedRows.length !== 0) {
204
+ setActionButtons(true);
205
+ }
206
+ else {
207
+ setActionButtons(false);
208
+ }
209
+ setSelectedRows(selectedRows);
210
+ }, []);
211
+ console.log(actionButtons, "actionButtons");
212
+ return (react_1.default.createElement("div", null,
213
+ react_1.default.createElement(KaTable_1.default, { data: dataArray, columns: columns, checkSelect: true, onRowClick: function (rowKeyValue) {
214
+ console.log("Row clicked", rowKeyValue);
215
+ }, selected: selectedRows, onSelectionChange: function (selectedRows) {
216
+ handleCheckSelect(selectedRows);
217
+ }, menuItems: menuItems,
218
+ // onSortChange={handleSortChange}
219
+ // onMenuItemClick={handleMenuItemClick}
220
+ // format={kaTableFormat}
221
+ childComponents: {
222
+ cellText: {
223
+ content: function (props) {
224
+ if (props.column.key === "editColumn") {
225
+ return react_1.default.createElement(EditButton, __assign({}, props));
226
+ }
227
+ },
228
+ },
229
+ }, loading: {
230
+ enabled: false,
231
+ text: "Loading data",
232
+ } })));
233
+ };
234
+ exports.default = KaTableExample;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "./bootstrap";
1
2
  import Accordian from "./Components/Accordion/Accordion";
2
3
  import AlertDialog from "./Components/AlertDialog/AlertDialog";
3
4
  import ApexBarChart from "./Components/Apexcharts/ApexBarChart/ApexBarChart";
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // import "./bootstrap";
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -29,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
28
  Object.defineProperty(exports, "__esModule", { value: true });
30
29
  exports.TextInput = exports.Table = exports.Switch = exports.Skeletons = exports.SideBar = exports.SelectSearch = exports.Select = exports.Search = exports.RadioButtonGroup = exports.RadioButton = exports.ProgressBar = exports.ProfilePhotoViewer = exports.ProfileCardFooter = exports.ProfileCardBody = exports.ProfileCardHeader = exports.ProfileCard = exports.PinInput = exports.NumberInput = exports.MultiSelect = exports.NoteTextArea = exports.NavigationBar = exports.ModalFooter = exports.ModalBody = exports.ModalHeader = exports.Modal = exports.Loading = exports.TableFun = exports.TableUtils = exports.TableModel = exports.TableProps = exports.TableEnums = exports.TableActionCreator = exports.KaTable = exports.InputTextArea = exports.Editor = exports.Dropdown = exports.DrawerFooter = exports.DrawerBody = exports.DrawerHeader = exports.Drawer = exports.DatePicker = exports.Checkbox = exports.Card = exports.ButtonGroupIcon = exports.Button = exports.Breadcrumbs = exports.ApexPieChart = exports.ApexBarChart = exports.AlertDialog = exports.Accordian = void 0;
31
30
  exports.ThemesList = exports.useCustomTheme = exports.VerifyEmailOtp = exports.useToaster = exports.ToolTip = exports.Toaster = exports.Timeline = void 0;
31
+ require("./bootstrap");
32
32
  var Accordion_1 = __importDefault(require("./Components/Accordion/Accordion"));
33
33
  exports.Accordian = Accordion_1.default;
34
34
  var AlertDialog_1 = __importDefault(require("./Components/AlertDialog/AlertDialog"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelize-design-library",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",