@secondstaxorg/sscomp 2.1.13 → 2.1.15
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.es.js +6 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +77 -29
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +6 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +3 -3
- package/types/components/TablePrimary/CaretDown.d.ts +6 -0
- package/types/components/TablePrimary/type.d.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -27057,6 +27057,11 @@ const Table = styled.table`
|
|
|
27057
27057
|
line-height: 19px;
|
|
27058
27058
|
font-family: Circular Book Medium, sans-serif;*/
|
|
27059
27059
|
}
|
|
27060
|
+
th .thead-label{
|
|
27061
|
+
width:100%;
|
|
27062
|
+
display: flex;
|
|
27063
|
+
justify-content: space-between;
|
|
27064
|
+
}
|
|
27060
27065
|
tbody tr{
|
|
27061
27066
|
background: ${theme.colors.white};
|
|
27062
27067
|
}
|
|
@@ -27105,42 +27110,85 @@ const Table = styled.table`
|
|
|
27105
27110
|
}
|
|
27106
27111
|
`;
|
|
27107
27112
|
|
|
27108
|
-
const _jsxFileName$p = "D:\\SSX\\Projects\\SSX Comps\\sscomp\\src\\components\\TablePrimary\\index.tsx"; function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$c(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
27113
|
+
const _jsxFileName$p = "D:\\SSX\\Projects\\SSX Comps\\sscomp\\src\\components\\TablePrimary\\index.tsx"; function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$c(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// import CaretDown from "./CaretDown";
|
|
27114
|
+
|
|
27115
|
+
|
|
27116
|
+
|
|
27117
|
+
|
|
27118
|
+
|
|
27119
|
+
const CaretDown = ({direction}) => {
|
|
27120
|
+
return (
|
|
27121
|
+
React$1.createElement('svg', { style: {transform:`rotate(${direction === 'up' ? '180deg' : '0deg'})`,width:15}, fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 448 512" , __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 13}}, React$1.createElement('path', { d: "M201.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 306.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" , __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 13}}))
|
|
27122
|
+
)
|
|
27123
|
+
};
|
|
27124
|
+
|
|
27109
27125
|
/**
|
|
27110
27126
|
* Default SSX table component
|
|
27111
27127
|
*/
|
|
27112
27128
|
const TablePrimary = (props) => {
|
|
27113
|
-
const {thead,children,tbody,clickedRow,showPagination,itemsPerPage,paginatedItems} = props;
|
|
27129
|
+
const {thead,children,tbody,clickedRow,showPagination,itemsPerPage,paginatedItems,sortBy} = props;
|
|
27114
27130
|
const [tbodyItems,setTbodyItems] = React$1.useState([]);
|
|
27115
|
-
const [tbodyOri,setTbodyOri] = React$1.useState(
|
|
27131
|
+
const [tbodyOri,setTbodyOri] = React$1.useState(_nullishCoalesce$2(tbody, () => ( [])));
|
|
27132
|
+
const [dataToShow,setDataToShow] = React$1.useState(_nullishCoalesce$2(tbody, () => ( [])));
|
|
27116
27133
|
const [sortedCol,setSortedCol] = React$1.useState('');
|
|
27134
|
+
const [sortDirection,setSortDirection] = React$1.useState('desc');
|
|
27117
27135
|
|
|
27118
27136
|
React$1.useEffect(()=>{
|
|
27119
|
-
|
|
27120
|
-
|
|
27137
|
+
if (sortBy && thead.some(item => item.dataKey === sortBy)){
|
|
27138
|
+
sortByColumn(sortBy);
|
|
27139
|
+
}
|
|
27140
|
+
},[sortBy]);
|
|
27121
27141
|
|
|
27122
|
-
|
|
27142
|
+
/*useEffect(()=>{
|
|
27123
27143
|
if (tbody){
|
|
27124
|
-
|
|
27144
|
+
thead
|
|
27145
|
+
}
|
|
27146
|
+
},[tbody])*/
|
|
27147
|
+
|
|
27148
|
+
/*function sortByColumn(column:string){
|
|
27149
|
+
if (tbody){
|
|
27150
|
+
if(typeof (tbody as any)[0][column] !== 'string') return
|
|
27125
27151
|
}
|
|
27126
27152
|
if (column === sortedCol){
|
|
27127
27153
|
if (tbody && tbody.length > 0){
|
|
27128
|
-
const sortedItems = [...tbody]
|
|
27129
|
-
sortedItems.sort((a,b) => a[column].localeCompare(b[column]))
|
|
27130
|
-
let revSort = sortedItems.reverse()
|
|
27131
|
-
setTbodyOri(revSort)
|
|
27132
|
-
setSortedCol('')
|
|
27154
|
+
const sortedItems = [...tbody]
|
|
27155
|
+
sortedItems.sort((a:any,b:any) => a[column].localeCompare(b[column]))
|
|
27156
|
+
let revSort = sortedItems.reverse()
|
|
27157
|
+
setTbodyOri(revSort)
|
|
27158
|
+
// setSortedCol('')
|
|
27133
27159
|
}
|
|
27134
27160
|
return
|
|
27135
27161
|
}else if(column !== sortedCol){
|
|
27136
|
-
setSortedCol(column)
|
|
27162
|
+
setSortedCol(column)
|
|
27137
27163
|
if (tbody && tbody.length > 0){
|
|
27138
|
-
const sortedItems = [...tbody]
|
|
27139
|
-
sortedItems.sort((a,b) => a[column].localeCompare(b[column]))
|
|
27140
|
-
setTbodyOri(sortedItems)
|
|
27164
|
+
const sortedItems = [...tbody]
|
|
27165
|
+
sortedItems.sort((a:any,b:any) => a[column].localeCompare(b[column]))
|
|
27166
|
+
setTbodyOri(sortedItems)
|
|
27141
27167
|
}
|
|
27142
27168
|
return
|
|
27143
27169
|
}
|
|
27170
|
+
}*/
|
|
27171
|
+
|
|
27172
|
+
|
|
27173
|
+
function sortByColumn(column) {
|
|
27174
|
+
let sorted;
|
|
27175
|
+
|
|
27176
|
+
if (sortedCol !== column){
|
|
27177
|
+
sorted = tbodyOri.sort((a,b) => a[column].localeCompare(b[column]));
|
|
27178
|
+
setSortDirection('asc');
|
|
27179
|
+
setSortedCol(column);
|
|
27180
|
+
}else {
|
|
27181
|
+
if (sortDirection === 'desc') {
|
|
27182
|
+
sorted = tbodyOri.sort((a,b) => a[column].localeCompare(b[column]));
|
|
27183
|
+
setSortDirection('asc');
|
|
27184
|
+
setSortedCol(column);
|
|
27185
|
+
}else {
|
|
27186
|
+
sorted = tbodyOri.sort((a,b) => b[column].localeCompare(a[column]));
|
|
27187
|
+
setSortDirection('desc');
|
|
27188
|
+
setSortedCol(column);
|
|
27189
|
+
}
|
|
27190
|
+
}
|
|
27191
|
+
setDataToShow(sorted);
|
|
27144
27192
|
}
|
|
27145
27193
|
|
|
27146
27194
|
React$1.useEffect(()=>{
|
|
@@ -27151,33 +27199,33 @@ const TablePrimary = (props) => {
|
|
|
27151
27199
|
|
|
27152
27200
|
return (
|
|
27153
27201
|
React$1.createElement(React$1.Fragment, null
|
|
27154
|
-
, React$1.createElement(TableContainer$1, {__self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27155
|
-
, React$1.createElement(Table, {__self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27156
|
-
, React$1.createElement('thead', {__self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27157
|
-
, React$1.createElement('tr', { className: "rounded-row paragraph2Medium" , __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27202
|
+
, React$1.createElement(TableContainer$1, {__self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 94}}
|
|
27203
|
+
, React$1.createElement(Table, {__self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 95}}
|
|
27204
|
+
, React$1.createElement('thead', {__self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 96}}
|
|
27205
|
+
, React$1.createElement('tr', { className: "rounded-row paragraph2Medium" , __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 97}}
|
|
27158
27206
|
, thead.map((item,index) => (
|
|
27159
27207
|
React$1.createElement('th', { key: index, onClick: ()=>{
|
|
27160
27208
|
sortByColumn(item.dataKey);
|
|
27161
|
-
}, __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27209
|
+
}, __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 99}}, React$1.createElement('span', { className: "thead-label", __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 101}}, item.label, " " , sortedCol === item.dataKey && React$1.createElement(CaretDown, { direction: sortDirection === 'asc' ? 'up' : 'down', __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 101}})))
|
|
27162
27210
|
))
|
|
27163
27211
|
)
|
|
27164
27212
|
)
|
|
27165
|
-
, React$1.createElement('tbody', { className: "rounded-row paragraph2Regular" , __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27213
|
+
, React$1.createElement('tbody', { className: "rounded-row paragraph2Regular" , __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 105}}
|
|
27166
27214
|
, children
|
|
27167
|
-
, !children &&
|
|
27215
|
+
, !children && dataToShow && dataToShow.map((item,index) => (
|
|
27168
27216
|
React$1.createElement('tr', { key: index, className: clickedRow && 'clickable', onClick: ()=>{
|
|
27169
27217
|
if (clickedRow) {
|
|
27170
27218
|
clickedRow(item);
|
|
27171
|
-
}}, __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27219
|
+
}}, __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 108}}
|
|
27172
27220
|
, thead.map((cellItem,index) => (
|
|
27173
|
-
React$1.createElement('td', { key: index, className: (index == thead.length - 1 && clickedRow) ? 'with-arrow' : '', __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27174
|
-
, React$1.createElement('span', {__self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27221
|
+
React$1.createElement('td', { key: index, className: (index == thead.length - 1 && clickedRow) ? 'with-arrow' : '', __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 113}}
|
|
27222
|
+
, React$1.createElement('span', {__self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 114}}
|
|
27175
27223
|
, _nullishCoalesce$2(_optionalChain$c([cellItem, 'access', _ => _.component, 'optionalCall', _2 => _2(item)]), () => ( item[cellItem.dataKey]))
|
|
27176
27224
|
/*{item[cellItem.dataKey]}*/
|
|
27177
27225
|
)
|
|
27178
27226
|
, (index == thead.length - 1 && clickedRow) &&
|
|
27179
|
-
React$1.createElement('svg', { width: "16", height: "16", viewBox: "0 0 16 16" , fill: "none", xmlns: "http://www.w3.org/2000/svg", __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27180
|
-
, React$1.createElement('path', { d: "M10.3592 7.52685L6.58584 3.76019C6.52387 3.6977 6.45013 3.64811 6.36889 3.61426C6.28765 3.58041 6.20052 3.56299 6.11251 3.56299C6.0245 3.56299 5.93736 3.58041 5.85612 3.61426C5.77488 3.64811 5.70115 3.6977 5.63917 3.76019C5.51501 3.8851 5.44531 4.05406 5.44531 4.23019C5.44531 4.40631 5.51501 4.57528 5.63917 4.70019L8.93917 8.03352L5.63917 11.3335C5.51501 11.4584 5.44531 11.6274 5.44531 11.8035C5.44531 11.9796 5.51501 12.1486 5.63917 12.2735C5.70092 12.3365 5.77455 12.3866 5.8558 12.421C5.93705 12.4553 6.0243 12.4732 6.11251 12.4735C6.20071 12.4732 6.28797 12.4553 6.36922 12.421C6.45047 12.3866 6.5241 12.3365 6.58584 12.2735L10.3592 8.50685C10.4268 8.44443 10.4808 8.36866 10.5178 8.28432C10.5547 8.19999 10.5738 8.10892 10.5738 8.01685C10.5738 7.92479 10.5547 7.83372 10.5178 7.74938C10.4808 7.66505 10.4268 7.58928 10.3592 7.52685Z" , fill: "#A4BBDD", __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27227
|
+
React$1.createElement('svg', { width: "16", height: "16", viewBox: "0 0 16 16" , fill: "none", xmlns: "http://www.w3.org/2000/svg", __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 119}}
|
|
27228
|
+
, React$1.createElement('path', { d: "M10.3592 7.52685L6.58584 3.76019C6.52387 3.6977 6.45013 3.64811 6.36889 3.61426C6.28765 3.58041 6.20052 3.56299 6.11251 3.56299C6.0245 3.56299 5.93736 3.58041 5.85612 3.61426C5.77488 3.64811 5.70115 3.6977 5.63917 3.76019C5.51501 3.8851 5.44531 4.05406 5.44531 4.23019C5.44531 4.40631 5.51501 4.57528 5.63917 4.70019L8.93917 8.03352L5.63917 11.3335C5.51501 11.4584 5.44531 11.6274 5.44531 11.8035C5.44531 11.9796 5.51501 12.1486 5.63917 12.2735C5.70092 12.3365 5.77455 12.3866 5.8558 12.421C5.93705 12.4553 6.0243 12.4732 6.11251 12.4735C6.20071 12.4732 6.28797 12.4553 6.36922 12.421C6.45047 12.3866 6.5241 12.3365 6.58584 12.2735L10.3592 8.50685C10.4268 8.44443 10.4808 8.36866 10.5178 8.28432C10.5547 8.19999 10.5738 8.10892 10.5738 8.01685C10.5738 7.92479 10.5547 7.83372 10.5178 7.74938C10.4808 7.66505 10.4268 7.58928 10.3592 7.52685Z" , fill: "#A4BBDD", __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 120}})
|
|
27181
27229
|
)
|
|
27182
27230
|
|
|
27183
27231
|
)
|
|
@@ -27191,7 +27239,7 @@ const TablePrimary = (props) => {
|
|
|
27191
27239
|
React$1.createElement(Pagination, { itemsPerPage: itemsPerPage, items: tbodyOri, paginatedItems: (arr)=>{
|
|
27192
27240
|
setTbodyItems(arr);
|
|
27193
27241
|
paginatedItems(arr);
|
|
27194
|
-
}, __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber:
|
|
27242
|
+
}, __self: undefined, __source: {fileName: _jsxFileName$p, lineNumber: 131}})
|
|
27195
27243
|
|
|
27196
27244
|
)
|
|
27197
27245
|
)
|