@harpercollins/harpercollins-design-system 1.1.0 → 1.2.1

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.
@@ -2,11 +2,13 @@ import { ColumnDef } from "@tanstack/react-table";
2
2
  interface TableProps {
3
3
  data: unknown[];
4
4
  columns: ColumnDef<unknown, unknown>[];
5
- pageCount: number;
6
- totalCount: number;
7
- next: string;
8
- previous: string;
9
- page: number;
5
+ pageCount?: number;
6
+ totalCount?: number;
7
+ next?: string;
8
+ previous?: string;
9
+ page?: number;
10
+ pageable?: boolean;
11
+ pageSize?: number;
10
12
  }
11
- declare function Table({ data: tableData, columns, pageCount, totalCount, next, previous, page, }: TableProps): import("react/jsx-runtime").JSX.Element;
13
+ declare function Table({ data: tableData, columns, pageCount, totalCount, next, previous, page, pageable, pageSize, }: TableProps): import("react/jsx-runtime").JSX.Element;
12
14
  export default Table;
package/dist/esm/index.js CHANGED
@@ -537,6 +537,7 @@ function Zi(e,t){return e?function(e){return"function"==typeof e&&(()=>{const t=
537
537
  padding: var(--spacing--small);
538
538
  display: table-cell;
539
539
  vertical-align: middle;
540
+ word-wrap: break-word;
540
541
 
541
542
  &.name {
542
543
  font-weight: 500;
@@ -559,8 +560,7 @@ function Zi(e,t){return e?function(e){return"function"==typeof e&&(()=>{const t=
559
560
  }
560
561
  }
561
562
 
562
- .uploaded,
563
- .reviewed {
563
+ .flex--column {
564
564
  display: flex;
565
565
  flex-direction: column;
566
566
  }
@@ -614,7 +614,7 @@ function Zi(e,t){return e?function(e){return"function"==typeof e&&(()=>{const t=
614
614
  pointer-events: none;
615
615
  }
616
616
  }
617
- `;function tl({data:r,columns:i,pageCount:l,totalCount:a,next:s,previous:c,page:u}){const[d,g]=o.useState((()=>[...r])),[{pageIndex:p,pageSize:f},m]=o.useState({pageIndex:0,pageSize:10}),h=function(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[o]=n.useState((()=>({current:Ki(t)}))),[r,i]=n.useState((()=>o.current.initialState));return o.current.setOptions((t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),null==e.onStateChange||e.onStateChange(t)}}))),o.current}({columns:i,data:d,getCoreRowModel:e=>ii((()=>[e.options.data]),(t=>{const n={rows:[],flatRows:[],rowsById:{}},o=function(t,r,i){void 0===r&&(r=0);const l=[];for(let s=0;s<t.length;s++){const c=di(e,e._getRowId(t[s],s,i),t[s],s,r,void 0,null==i?void 0:i.id);var a;n.flatRows.push(c),n.rowsById[c.id]=c,l.push(c),e.options.getSubRows&&(c.originalSubRows=e.options.getSubRows(t[s],s),null!=(a=c.originalSubRows)&&a.length&&(c.subRows=o(c.originalSubRows,r+1,c)))}return l};return n.rows=o(t),n}),li(e.options,"debugTable","getRowModel",(()=>e._autoResetPageIndex()))),pageCount:l,state:{pagination:o.useMemo((()=>({pageIndex:p,pageSize:f})),[p,f])},onPaginationChange:m,manualPagination:!0});return o.useEffect((()=>{h.setPageIndex(Number(u-1))}),[u,h]),o.useEffect((()=>{g(r)}),[r]),t(Ji,{children:[e("thead",{children:h.getHeaderGroups().map((t=>e("tr",{children:t.headers.map((t=>e("th",{colSpan:t.colSpan,children:t.isPlaceholder?null:Zi(t.column.columnDef.header,t.getContext())},t.id)))},t.id)))}),e("tbody",{children:h.getRowModel().rows.map((t=>e("tr",{children:t.getVisibleCells().map((t=>e("td",{children:Zi(t.column.columnDef.cell,t.getContext())},t.id)))},t.id)))}),e("tfoot",{children:t(Qi,{children:[t("div",{children:["Total: ",a]}),t(el,{children:[e(io,{type:"link",href:"",disabled:!h.getCanPreviousPage(),children:"<<"}),e(io,{type:"link",href:h.getCanPreviousPage()?c:"",disabled:!h.getCanPreviousPage(),children:"<"}),e(io,{type:"link",href:h.getCanNextPage()?s:"",disabled:!h.getCanNextPage(),children:">"}),e(io,{href:(h.getCanNextPage(),""),type:"link",disabled:!h.getCanNextPage(),children:">>"}),t("span",{children:[e("div",{children:"Page"}),t("strong",{children:[h.getState().pagination.pageIndex+1," of"," ",h.getPageCount()]})]})]})]})})]})}const nl=tn.div`
617
+ `;function tl({data:r,columns:i,pageCount:l,totalCount:a,next:s,previous:c,page:u,pageable:d,pageSize:g}){const[p,f]=o.useState((()=>[...r])),[m,h]=o.useState({pageIndex:0,pageSize:g||10}),v=function(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[o]=n.useState((()=>({current:Ki(t)}))),[r,i]=n.useState((()=>o.current.initialState));return o.current.setOptions((t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),null==e.onStateChange||e.onStateChange(t)}}))),o.current}({columns:i,data:p,getCoreRowModel:e=>ii((()=>[e.options.data]),(t=>{const n={rows:[],flatRows:[],rowsById:{}},o=function(t,r,i){void 0===r&&(r=0);const l=[];for(let s=0;s<t.length;s++){const c=di(e,e._getRowId(t[s],s,i),t[s],s,r,void 0,null==i?void 0:i.id);var a;n.flatRows.push(c),n.rowsById[c.id]=c,l.push(c),e.options.getSubRows&&(c.originalSubRows=e.options.getSubRows(t[s],s),null!=(a=c.originalSubRows)&&a.length&&(c.subRows=o(c.originalSubRows,r+1,c)))}return l};return n.rows=o(t),n}),li(e.options,"debugTable","getRowModel",(()=>e._autoResetPageIndex()))),pageCount:l,state:{pagination:o.useMemo((()=>({pageIndex:m.pageIndex,pageSize:m.pageSize})),[m.pageIndex,m.pageSize])},onPaginationChange:h,manualPagination:!0});return o.useEffect((()=>{void 0!==u&&v.setPageIndex(Number(u-1))}),[u,v]),o.useEffect((()=>{f(r)}),[r]),t(Ji,{children:[v.getHeaderGroups().map((t=>e("thead",{children:e("tr",{children:t.headers.map((t=>e("th",{key:t.id,colSpan:t.colSpan,style:{width:t.getSize()},children:t.isPlaceholder?null:Zi(t.column.columnDef.header,t.getContext())})))},t.id)}))),e("tbody",{children:v.getRowModel().rows.map((t=>e("tr",{children:t.getVisibleCells().map((t=>e("td",{key:t.id,style:{width:t.column.getSize()},children:Zi(t.column.columnDef.cell,t.getContext())})))},t.id)))}),e("tfoot",{children:t(Qi,{children:[void 0!==a?t("div",{children:["Total: ",a]}):null,d?t(el,{children:[e(io,{type:"link",href:v.getCanPreviousPage()?window.location.href:"",disabled:!v.getCanPreviousPage(),children:"<<"}),e(io,{type:"link",href:v.getCanPreviousPage()&&c?c:"",disabled:!v.getCanPreviousPage(),children:"<"}),e(io,{type:"link",href:v.getCanNextPage()&&s?s:"",disabled:!v.getCanNextPage(),children:">"}),e(io,{href:v.getCanNextPage()?`${window.location.href}?page=${String(l)}`:"",type:"link",disabled:!v.getCanNextPage(),children:">>"}),t("span",{children:[e("div",{children:"Page"}),t("strong",{children:[v.getState().pagination.pageIndex+1," of"," ",v.getPageCount()]})]})]}):null]})})]})}const nl=tn.div`
618
618
  background-color: transparent;
619
619
  border-bottom: 2px solid transparent;
620
620
  color: var(--color--grey-dark);