@harpercollins/harpercollins-design-system 1.22.1 → 1.22.3
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 +1 -1
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -420,7 +420,7 @@ function nD(e,t){return"function"==typeof e?e(t):e}function rD(e,t){return n=>{t
|
|
|
420
420
|
display: flex;
|
|
421
421
|
flex-wrap: nowrap;
|
|
422
422
|
}
|
|
423
|
-
`,dT=(e,t,n,r)=>({...e,tableLayout:"fixed",width:"100%",minWidth:`${t}px`,"& thead":{transition:"opacity 0.1s"},"& thead th":{backgroundColor:"var(--palette-primary-50)",fontWeight:"bold",fontSize:"sm",verticalAlign:"middle",position:"sticky",zIndex:
|
|
423
|
+
`,dT=(e,t,n,r)=>({...e,tableLayout:"fixed",width:"100%",minWidth:`${t}px`,"& thead":{transition:"opacity 0.1s"},"& thead th":{backgroundColor:"var(--palette-primary-50)",fontWeight:"bold",fontSize:"sm",verticalAlign:"middle",position:"sticky",zIndex:1,top:r?"var(--header-top, 0px)":0},"& td, & td>div, & td>a":{whiteSpace:n?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis",verticalAlign:"middle"},"& th[data-pinned='right'], & td[data-pinned='right']":{position:"sticky",right:0,background:"var(--palette-common-white)",boxShadow:"-2px 0 4px rgba(0, 0, 0, 0.08)","&::before":{content:'""',position:"absolute",top:0,left:"-10px",width:"10px",height:"100%",background:"linear-gradient(to right, transparent, rgba(0, 0, 0, 0.05))",pointerEvents:"none"}},"& th[data-pinned='right']":{background:"var(--palette-primary-50)"},"& th[data-pinned='left'], & td[data-pinned='left']":{position:"sticky",left:0,background:"var(--palette-common-white)",boxShadow:"2px 0 4px rgba(0, 0, 0, 0.08)","&::after":{content:'""',position:"absolute",top:0,right:"-10px",width:"10px",height:"100%",background:"linear-gradient(to left, transparent, rgba(0, 0, 0, 0.05))",pointerEvents:"none"}},"& th[data-pinned='left']":{background:"var(--palette-primary-50)",zIndex:2},"& .resizer":{position:"absolute",right:0,top:0,height:"100%",width:"3px",background:"var(--palette-primary-500)",cursor:"col-resize",userSelect:"none",touchAction:"none",zIndex:1,"@media (hover: hover)":{opacity:0}},"& .resizer.isResizing":{background:"var(--palette-primary-500)",opacity:1},"& *:hover > .resizer":{"@media (hover: hover)":{opacity:1}},"& th > button":{display:"flex",alignItems:"center",flexWrap:"nowrap",gap:"6px",position:"relative",background:"none",border:"none",cursor:"pointer",padding:0,textAlign:"left",fontWeight:"inherit",color:"inherit",fontSize:"inherit",width:"100%",whiteSpace:"wrap","& i.fade":{opacity:0,transition:"opacity 0.2s ease-in-out"},"&:hover i.fade":{opacity:.5}}}),uT=t.memo(({rows:t,columns:n,rowRender:r,loading:o,tableId:a})=>t.length>0?e.jsx("tbody",{children:t.map(t=>r?r(t,{key:t.id}):e.jsx("tr",{children:t.getVisibleCells().map((n,r)=>{const o=r===t.getVisibleCells().length-1,i=n.column.getIsPinned();return e.jsx("td",{"data-pinned":i||void 0,style:{width:!i&&o?"auto":`calc(var(--${a}-col-${n.id}-size) * 1px)`},children:eT(n.column.columnDef.cell,n.getContext())},n.id)})},t.id))}):e.jsx("tbody",{children:e.jsx("tr",{children:e.jsx("td",{colSpan:n.length,children:e.jsx(vm,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"200px"},children:e.jsx(oT,{children:o?"Loading...":" There is no data available"})})})})}),(e,t)=>e.rowRender===t.rowRender&&e.loading===t.loading&&e.columns===t.columns&&e.rows===t.rows);const pT=bw.div`
|
|
424
424
|
background-color: transparent;
|
|
425
425
|
border-bottom: 2px solid transparent;
|
|
426
426
|
color: var(--color--grey-dark);
|
package/dist/esm/index.js
CHANGED
|
@@ -418,7 +418,7 @@ function Fx(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof
|
|
|
418
418
|
display: flex;
|
|
419
419
|
flex-wrap: nowrap;
|
|
420
420
|
}
|
|
421
|
-
`,zT=(e,t,n,r)=>({...e,tableLayout:"fixed",width:"100%",minWidth:`${t}px`,"& thead":{transition:"opacity 0.1s"},"& thead th":{backgroundColor:"var(--palette-primary-50)",fontWeight:"bold",fontSize:"sm",verticalAlign:"middle",position:"sticky",zIndex:
|
|
421
|
+
`,zT=(e,t,n,r)=>({...e,tableLayout:"fixed",width:"100%",minWidth:`${t}px`,"& thead":{transition:"opacity 0.1s"},"& thead th":{backgroundColor:"var(--palette-primary-50)",fontWeight:"bold",fontSize:"sm",verticalAlign:"middle",position:"sticky",zIndex:1,top:r?"var(--header-top, 0px)":0},"& td, & td>div, & td>a":{whiteSpace:n?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis",verticalAlign:"middle"},"& th[data-pinned='right'], & td[data-pinned='right']":{position:"sticky",right:0,background:"var(--palette-common-white)",boxShadow:"-2px 0 4px rgba(0, 0, 0, 0.08)","&::before":{content:'""',position:"absolute",top:0,left:"-10px",width:"10px",height:"100%",background:"linear-gradient(to right, transparent, rgba(0, 0, 0, 0.05))",pointerEvents:"none"}},"& th[data-pinned='right']":{background:"var(--palette-primary-50)"},"& th[data-pinned='left'], & td[data-pinned='left']":{position:"sticky",left:0,background:"var(--palette-common-white)",boxShadow:"2px 0 4px rgba(0, 0, 0, 0.08)","&::after":{content:'""',position:"absolute",top:0,right:"-10px",width:"10px",height:"100%",background:"linear-gradient(to left, transparent, rgba(0, 0, 0, 0.05))",pointerEvents:"none"}},"& th[data-pinned='left']":{background:"var(--palette-primary-50)",zIndex:2},"& .resizer":{position:"absolute",right:0,top:0,height:"100%",width:"3px",background:"var(--palette-primary-500)",cursor:"col-resize",userSelect:"none",touchAction:"none",zIndex:1,"@media (hover: hover)":{opacity:0}},"& .resizer.isResizing":{background:"var(--palette-primary-500)",opacity:1},"& *:hover > .resizer":{"@media (hover: hover)":{opacity:1}},"& th > button":{display:"flex",alignItems:"center",flexWrap:"nowrap",gap:"6px",position:"relative",background:"none",border:"none",cursor:"pointer",padding:0,textAlign:"left",fontWeight:"inherit",color:"inherit",fontSize:"inherit",width:"100%",whiteSpace:"wrap","& i.fade":{opacity:0,transition:"opacity 0.2s ease-in-out"},"&:hover i.fade":{opacity:.5}}}),MT=o.memo(({rows:t,columns:n,rowRender:r,loading:o,tableId:a})=>t.length>0?e("tbody",{children:t.map(t=>r?r(t,{key:t.id}):e("tr",{children:t.getVisibleCells().map((n,r)=>{const o=r===t.getVisibleCells().length-1,i=n.column.getIsPinned();return e("td",{"data-pinned":i||void 0,style:{width:!i&&o?"auto":`calc(var(--${a}-col-${n.id}-size) * 1px)`},children:CT(n.column.columnDef.cell,n.getContext())},n.id)})},t.id))}):e("tbody",{children:e("tr",{children:e("td",{colSpan:n.length,children:e(Rm,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"200px"},children:e(_T,{children:o?"Loading...":" There is no data available"})})})})}),(e,t)=>e.rowRender===t.rowRender&&e.loading===t.loading&&e.columns===t.columns&&e.rows===t.rows);function $T({id:a,loading:i=!1,maxHeight:l=!1,wrapText:s=!1,rowRender:c,reactTableOptions:d,gridCheckboxes:u=!1,selectedField:p="selected",onSelectionChange:f,onHeaderSelectionChange:m,headerSelectionValue:h=!1,allSelected:g=!1,showStickyScrollbar:v=!1,enableStickyHeader:b=!1,stickyHeaderOffset:y=0}){const[w,x]=o.useState([]),[k,S]=OT(`table.${a}.columnSizing`,{}),C=o.useRef(null),O=o.useRef(null),[D,T]=o.useState(!1),[_,P]=o.useState(!1),I=o.useRef(!1),R=o.useRef(null),E=o.useRef(!1),N=o.useRef(0),{columns:z}=d,M=o.useMemo(()=>{const e=[],t=[];return z.forEach(n=>{const r=n;"left"===r.meta?.pinned&&r.id?e.push(r.id):"right"===r.meta?.pinned&&r.id&&t.push(r.id)}),{left:e,right:t}},[z]),$=o.useCallback(()=>e(TT,{checked:g||h,onChange:e=>{m?.(e.target.checked)},size:"md"}),[g,h,m]),A=o.useCallback(({row:t})=>{const n=t.original,r="boolean"==typeof n[p]&&n[p];return e(TT,{checked:r,onChange:()=>{f?.(t.original)},size:"md",disabled:g})},[f,p,g]),F=o.useMemo(()=>{let e=[...z];if(u){e=[{id:"select",size:32,header:$,cell:A},...e]}return e},[u,z,A,$]),L={getCoreRowModel:kT(),getSortedRowModel:ST(),onSortingChange:x,state:{sorting:w,columnSizing:k,columnPinning:M},enableSorting:!0,enableColumnResizing:!0,columnResizeMode:"onChange",columnResizeDirection:"ltr",defaultColumn:{size:200,minSize:20,maxSize:500},onColumnSizingChange:S},B=function(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=r.useState(()=>({current:xT(t)})),[o,a]=r.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...o,...e.state},onStateChange:t=>{a(t),null==e.onStateChange||e.onStateChange(t)}})),n.current}({...L,...d,getCoreRowModel:kT(),getSortedRowModel:ST(),columns:F,data:d.data,enableSorting:d.enableSorting??!0,enableColumnResizing:d.enableColumnResizing??!0,columnResizeMode:d.columnResizeMode??"onChange",onColumnSizingChange:d.onColumnSizingChange??S,onSortingChange:d.onSortingChange??x,state:{...L.state,...d.state,sorting:d.state?.sorting??w,columnSizing:k,columnPinning:M}}),j=o.useMemo(()=>B.getFlatHeaders().reduce((e,t)=>e+t.getSize(),0),[B.getState().columnSizingInfo,B.getState().columnSizing]);return o.useEffect(()=>{const e=C.current;if(!e)return;const t=()=>{if(!(e.scrollWidth>e.clientWidth))return void T(!1);const t=e.getBoundingClientRect();if(!(t.top<window.innerHeight&&t.bottom>0))return void T(!1);const n=t.bottom,r=window.innerHeight;T(n>r-30)};t();const n=()=>t(),r=()=>t();window.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",r);const o=new ResizeObserver(t);return o.observe(e),()=>{window.removeEventListener("scroll",n),window.removeEventListener("resize",r),o.disconnect()}},[]),o.useEffect(()=>{if(!b){P(!1),I.current=!1;const e=O.current;return void(e&&(e.style.setProperty("--header-top","0px"),e.style.opacity="1"))}const e=C.current,t=O.current;if(!e||!t)return;const n=()=>{const e=t.getBoundingClientRect().top;if(e<=y){E.current||(E.current=!0,t.style.opacity="0"),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{E.current=!1,t.style.opacity="1"},150);const n=y-e;t.style.setProperty("--header-top",`${n}px`),I.current||(I.current=!0,P(!0))}else t.style.opacity="1",E.current=!1,R.current&&clearTimeout(R.current),t.style.setProperty("--header-top","0px"),I.current&&(I.current=!1,P(!1))};n(),window.addEventListener("scroll",n,{passive:!0});const r=()=>{const t=e.scrollTop;t!==N.current&&(N.current=t,n())};return e.addEventListener("scroll",r,{passive:!0}),()=>{window.removeEventListener("scroll",n),e.removeEventListener("scroll",r),R.current&&clearTimeout(R.current)}},[b,y]),t(n,{children:[t(ET,{ref:C,$maxHeight:l,children:[i&&e(Rm,{sx:{position:"absolute",top:0,left:0,width:`${j}px`,height:"100%",backgroundColor:"rgba(255, 255, 255, 0.7)",display:"flex",justifyContent:"center",alignItems:"flex-start",zIndex:1,paddingTop:"10%"},children:e(DT,{})}),t(Ob,{hoverRow:!0,sx:zT((()=>{const e=B.getFlatHeaders(),t={};for(let n=0;n<e.length;n+=1){const r=e[n];t[`--${a}-header-${r.id}-size`]=r.getSize(),t[`--${a}-col-${r.column.id}-size`]=r.column.getSize()}return t})(),j,s,_),children:[B.getHeaderGroups().map(n=>e("thead",{ref:O,children:e("tr",{children:n.headers.map((r,o)=>{const i=o===n.headers.length-1,l=r.column.getIsPinned();return t("th",{colSpan:r.colSpan,"data-pinned":l||void 0,style:{width:!l&&i?"auto":`calc(var(--${a}-header-${r.id}-size) * 1px)`},children:[r.isPlaceholder?null:t(NT,{type:"button","aria-label":`Sort ${r.id} column`,onClick:r.column.getToggleSortingHandler(),onKeyDown:r.column.getToggleSortingHandler(),title:r.column.getCanSort()?"asc"===r.column.getNextSortingOrder()?"Sort ascending":"desc"===r.column.getNextSortingOrder()?"Sort descending":"Clear sort":void 0,children:[CT(r.column.columnDef.header,r.getContext()),{asc:e(SO,{icon:uD,size:"sm"}),desc:e(SO,{icon:dD,size:"sm"})}[r.column.getIsSorted()]??(r.column.getCanSort()&&e(SO,{icon:"desc"===r.column.getNextSortingOrder()?dD:uD,size:"sm",className:"fade"}))]}),r.column.getCanResize()&&e("button",{type:"button","aria-label":`Resize ${r.id} column`,onMouseDown:r.getResizeHandler(),onTouchStart:r.getResizeHandler(),className:"resizer "+(r.column.getIsResizing()?"isResizing":"")})]},r.id)})})},n.id)),e(MT,{rows:B.getSortedRowModel().rows,columns:B.getAllColumns(),rowRender:c,loading:i,tableId:a})]})]}),v&&e(RT,{scrollContainerRef:C,visible:D,constrainToContainer:"main"})]})}const AT=Mx.div`
|
|
422
422
|
background-color: transparent;
|
|
423
423
|
border-bottom: 2px solid transparent;
|
|
424
424
|
color: var(--color--grey-dark);
|