@harpercollins/harpercollins-design-system 1.8.74 → 1.8.75
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/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/types/src/components/data-display/Table/Table.d.ts +2 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/data-display/Table/Table.d.ts +2 -1
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ interface TableProps {
|
|
|
10
10
|
page?: number;
|
|
11
11
|
pageable?: boolean;
|
|
12
12
|
pageSize?: number;
|
|
13
|
+
maxHeight?: boolean;
|
|
13
14
|
}
|
|
14
|
-
declare function Table({ id, data: tableData, columns, pageCount, totalCount, next, previous, page, pageable, pageSize, }: TableProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare function Table({ id, data: tableData, columns, pageCount, totalCount, next, previous, page, pageable, pageSize, maxHeight, }: TableProps): import("react/jsx-runtime").JSX.Element;
|
|
15
16
|
export default Table;
|
package/dist/esm/index.js
CHANGED
|
@@ -863,7 +863,7 @@ function ac(e,t){const n=rc(e,t);return"production"!==process.env.NODE_ENV?(...t
|
|
|
863
863
|
function cS(e,t){return e?function(e){return"function"==typeof e&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}(r=e)||"function"==typeof r||function(e){return"object"==typeof e&&"symbol"==typeof e.$$typeof&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}(r)?n.createElement(e,t):e:null;var r}function uS(e,t){const[n,r]=s((()=>{if("undefined"==typeof window)return t;try{const n=window.localStorage.getItem(e);return n?JSON.parse(n):t}catch(e){return console.log(e),t}}));return[n,t=>{try{const o=t instanceof Function?t(n):t;r(o),"undefined"!=typeof window&&window.localStorage.setItem(e,JSON.stringify(o))}catch(e){console.log(e)}}]}const dS=rn.div`
|
|
864
864
|
overflow-x: auto;
|
|
865
865
|
width: 100%;
|
|
866
|
-
max-height: 90vh;
|
|
866
|
+
max-height: ${({maxHeight:e})=>e?"90vh":"100%"};
|
|
867
867
|
`,pS=rn.table`
|
|
868
868
|
border-collapse: collapse;
|
|
869
869
|
position: relative;
|
|
@@ -1054,7 +1054,7 @@ function cS(e,t){return e?function(e){return"function"==typeof e&&(()=>{const t=
|
|
|
1054
1054
|
gap: var(--spacing--small);
|
|
1055
1055
|
align-items: center;
|
|
1056
1056
|
font-size: var(--font-size--small);
|
|
1057
|
-
`;function hS({id:o,data:a,columns:i,pageCount:l,totalCount:s,next:c,previous:u,page:d,pageable:p,pageSize:f}){const[
|
|
1057
|
+
`;function hS({id:o,data:a,columns:i,pageCount:l,totalCount:s,next:c,previous:u,page:d,pageable:p,pageSize:f,maxHeight:m=!0}){const[g,h]=r.useState((()=>[...a])),[v,b]=r.useState([]),[y,w]=r.useState({pageIndex:0,pageSize:f||10}),[x,S]=uS(`table.${o}.columnSizing`,{}),C=function(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[r]=n.useState((()=>({current:sS(t)}))),[o,a]=n.useState((()=>r.current.initialState));return r.current.setOptions((t=>({...t,...e,state:{...o,...e.state},onStateChange:t=>{a(t),null==e.onStateChange||e.onStateChange(t)}}))),r.current}({columns:i,data:g,getCoreRowModel:e=>gx((()=>[e.options.data]),(t=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(t,o,a){void 0===o&&(o=0);const i=[];for(let s=0;s<t.length;s++){const c=xx(e,e._getRowId(t[s],s,a),t[s],s,o,void 0,null==a?void 0:a.id);var l;n.flatRows.push(c),n.rowsById[c.id]=c,i.push(c),e.options.getSubRows&&(c.originalSubRows=e.options.getSubRows(t[s],s),null!=(l=c.originalSubRows)&&l.length&&(c.subRows=r(c.originalSubRows,o+1,c)))}return i};return n.rows=r(t),n}),hx(e.options,"debugTable","getRowModel",(()=>e._autoResetPageIndex()))),getSortedRowModel:e=>gx((()=>[e.getState().sorting,e.getPreSortedRowModel()]),((t,n)=>{if(!n.rows.length||null==t||!t.length)return n;const r=e.getState().sorting,o=[],a=r.filter((t=>{var n;return null==(n=e.getColumn(t.id))?void 0:n.getCanSort()})),i={};a.forEach((t=>{const n=e.getColumn(t.id);n&&(i[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})}));const l=e=>{const t=e.map((e=>({...e})));return t.sort(((e,t)=>{for(let r=0;r<a.length;r+=1){var n;const o=a[r],l=i[o.id],s=l.sortUndefined,c=null!=(n=null==o?void 0:o.desc)&&n;let u=0;if(s){const n=void 0===e.getValue(o.id),r=void 0===t.getValue(o.id);if(n||r){if("first"===s)return n?-1:1;if("last"===s)return n?1:-1;u=n&&r?0:n?s:-s}}if(0===u&&(u=l.sortingFn(e,t,o.id)),0!==u)return c&&(u*=-1),l.invertSorting&&(u*=-1),u}return e.index-t.index})),t.forEach((e=>{var t;o.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=l(e.subRows))})),t};return{rows:l(n.rows),flatRows:o,rowsById:n.rowsById}}),hx(e.options,"debugTable","getSortedRowModel",(()=>e._autoResetPageIndex()))),onSortingChange:b,pageCount:l,state:{pagination:r.useMemo((()=>({pageIndex:y.pageIndex,pageSize:y.pageSize})),[y.pageIndex,y.pageSize]),sorting:v,columnSizing:x},onPaginationChange:w,manualPagination:!0,enableColumnResizing:!0,columnResizeMode:"onChange",defaultColumn:{size:200,minSize:50,maxSize:500},onColumnSizingChange:S});return r.useEffect((()=>{void 0!==d&&C.setPageIndex(Number(d-1))}),[d,C]),r.useEffect((()=>{h(a)}),[a]),t(dS,{maxHeight:m,children:[t(pS,{children:[C.getHeaderGroups().map((n=>e("thead",{children:e("tr",{children:n.headers.map((n=>t("th",{colSpan:n.colSpan,style:{width:n.getSize()},children:[n.isPlaceholder?null:t("button",{type:"button",className:n.column.getCanSort()?"cursor-pointer select-none":"",onClick:n.column.getToggleSortingHandler(),onKeyDown:n.column.getToggleSortingHandler(),title:n.column.getCanSort()?"asc"===n.column.getNextSortingOrder()?"Sort ascending":"desc"===n.column.getNextSortingOrder()?"Sort descending":"Clear sort":void 0,children:[{asc:e(Di,{name:["fas","arrow-up"],size:"small"}),desc:e(Di,{name:["fas","arrow-down"],size:"small"})}[n.column.getIsSorted()]??(n.column.getCanSort()&&e(Di,{name:["fas","arrow-up"],size:"small",className:"fade"})),cS(n.column.columnDef.header,n.getContext())]}),n.column.getCanResize()&&e("button",{type:"button","aria-label":"Resize column",onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler(),className:"resizer "+(n.column.getIsResizing()?"isResizing":"")})]},n.id)))})},n.id))),e("tbody",{children:C.getRowModel().rows.length>0?C.getRowModel().rows.map((t=>e("tr",{children:t.getVisibleCells().map((t=>e("td",{style:{width:t.column.getSize()},children:cS(t.column.columnDef.cell,t.getContext())},t.id)))},t.id))):e("tr",{children:e("td",{colSpan:i.length,style:{textAlign:"center"},children:"No data"})})})]}),t(fS,{children:[void 0!==s?t("div",{children:["Total: ",s]}):null,p?t(mS,{children:[e(Dy,{type:"link",href:C.getCanPreviousPage()?window.location.href:"",disabled:!C.getCanPreviousPage(),children:"<<"}),e(Dy,{type:"link",href:C.getCanPreviousPage()&&u?u:"",disabled:!C.getCanPreviousPage(),children:"<"}),e(Dy,{type:"link",href:C.getCanNextPage()&&c?c:"",disabled:!C.getCanNextPage(),children:">"}),e(Dy,{href:C.getCanNextPage()?`${window.location.href}?page=${String(l)}`:"",type:"link",disabled:!C.getCanNextPage(),children:">>"}),t(gS,{children:[e("span",{children:"Page"}),t("strong",{children:[C.getState().pagination.pageIndex+1," of"," ",C.getPageCount()]})]})]}):null]})]})}const vS=rn.div`
|
|
1058
1058
|
background-color: transparent;
|
|
1059
1059
|
border-bottom: 2px solid transparent;
|
|
1060
1060
|
color: var(--color--grey-dark);
|