wimui 0.67.0 → 0.69.0

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.
Files changed (102) hide show
  1. package/dist/components/_internal/InlineDisclosure.cjs +2 -0
  2. package/dist/components/_internal/InlineDisclosure.d.ts +22 -0
  3. package/dist/components/_internal/InlineDisclosure.js +47 -0
  4. package/dist/components/_internal/inline-disclosure.module.cjs +2 -0
  5. package/dist/components/_internal/inline-disclosure.module.js +9 -0
  6. package/dist/components/_internal/useAnnounce.cjs +2 -0
  7. package/dist/components/_internal/useAnnounce.d.ts +39 -0
  8. package/dist/components/_internal/useAnnounce.js +41 -0
  9. package/dist/components/data-display/AvatarGroup/AvatarGroup.cjs +1 -1
  10. package/dist/components/data-display/AvatarGroup/AvatarGroup.d.ts +10 -3
  11. package/dist/components/data-display/AvatarGroup/AvatarGroup.js +55 -27
  12. package/dist/components/data-display/AvatarGroup/avatar-group.module.cjs +1 -1
  13. package/dist/components/data-display/AvatarGroup/avatar-group.module.js +8 -6
  14. package/dist/components/data-display/Carousel/Carousel.cjs +1 -1
  15. package/dist/components/data-display/Carousel/Carousel.js +61 -65
  16. package/dist/components/data-display/DataGrid/DataGrid.cjs +1 -1
  17. package/dist/components/data-display/DataGrid/DataGrid.js +78 -74
  18. package/dist/components/data-display/DataGrid/useFixedColumns.cjs +1 -1
  19. package/dist/components/data-display/DataGrid/useFixedColumns.d.ts +6 -1
  20. package/dist/components/data-display/DataGrid/useFixedColumns.js +22 -17
  21. package/dist/components/data-display/SelectionBar/SelectionBar.cjs +2 -0
  22. package/dist/components/data-display/SelectionBar/SelectionBar.d.ts +77 -0
  23. package/dist/components/data-display/SelectionBar/SelectionBar.js +68 -0
  24. package/dist/components/data-display/SelectionBar/selection-bar.module.cjs +2 -0
  25. package/dist/components/data-display/SelectionBar/selection-bar.module.js +10 -0
  26. package/dist/components/data-display/Table/table.module.cjs +1 -1
  27. package/dist/components/data-display/Table/table.module.js +1 -1
  28. package/dist/components/feedback/Snackbar/Snackbar.cjs +1 -1
  29. package/dist/components/feedback/Snackbar/Snackbar.js +8 -9
  30. package/dist/components/feedback/Toast/Toast.cjs +1 -1
  31. package/dist/components/feedback/Toast/Toast.js +60 -71
  32. package/dist/components/form/Cascader/Cascader.cjs +1 -1
  33. package/dist/components/form/Cascader/Cascader.js +4 -4
  34. package/dist/components/form/Combobox/Combobox.cjs +1 -1
  35. package/dist/components/form/Combobox/Combobox.js +11 -11
  36. package/dist/components/form/DatePicker/DatePicker.cjs +1 -1
  37. package/dist/components/form/DatePicker/DatePicker.js +4 -4
  38. package/dist/components/form/FileUpload/FileUpload.cjs +1 -1
  39. package/dist/components/form/FileUpload/FileUpload.js +13 -18
  40. package/dist/components/form/MultiSelect/MultiSelect.cjs +1 -1
  41. package/dist/components/form/MultiSelect/MultiSelect.js +66 -66
  42. package/dist/components/form/Select/Select.cjs +1 -1
  43. package/dist/components/form/Select/Select.js +114 -114
  44. package/dist/components/form/Transfer/Transfer.cjs +1 -1
  45. package/dist/components/form/Transfer/Transfer.js +84 -88
  46. package/dist/components/form/TreeSelect/TreeSelect.cjs +1 -1
  47. package/dist/components/form/TreeSelect/TreeSelect.js +4 -4
  48. package/dist/components/layout/OverflowList/OverflowList.cjs +2 -0
  49. package/dist/components/layout/OverflowList/OverflowList.d.ts +81 -0
  50. package/dist/components/layout/OverflowList/OverflowList.js +85 -0
  51. package/dist/components/layout/OverflowList/getVisibleCount.cjs +2 -0
  52. package/dist/components/layout/OverflowList/getVisibleCount.d.ts +30 -0
  53. package/dist/components/layout/OverflowList/getVisibleCount.js +26 -0
  54. package/dist/components/layout/OverflowList/overflow-list.module.cjs +2 -0
  55. package/dist/components/layout/OverflowList/overflow-list.module.js +10 -0
  56. package/dist/components/layout/SimpleGrid/SimpleGrid.cjs +1 -1
  57. package/dist/components/layout/SimpleGrid/SimpleGrid.js +1 -1
  58. package/dist/components/layout/Toolbar/Toolbar.cjs +1 -1
  59. package/dist/components/layout/Toolbar/Toolbar.d.ts +15 -0
  60. package/dist/components/layout/Toolbar/Toolbar.js +85 -60
  61. package/dist/components/layout/Toolbar/toolbar.module.cjs +1 -1
  62. package/dist/components/layout/Toolbar/toolbar.module.js +8 -6
  63. package/dist/components/media/Lightbox/Lightbox.cjs +1 -1
  64. package/dist/components/media/Lightbox/Lightbox.js +46 -47
  65. package/dist/components/navigation/Breadcrumb/Breadcrumb.cjs +1 -1
  66. package/dist/components/navigation/Breadcrumb/Breadcrumb.d.ts +12 -0
  67. package/dist/components/navigation/Breadcrumb/Breadcrumb.js +88 -53
  68. package/dist/components/navigation/Menubar/Menubar.cjs +1 -1
  69. package/dist/components/navigation/Menubar/Menubar.js +10 -10
  70. package/dist/components/navigation/Pagination/Pagination.cjs +1 -1
  71. package/dist/components/navigation/Pagination/Pagination.js +110 -112
  72. package/dist/data-display-core.d.ts +1 -0
  73. package/dist/data-display.cjs +1 -1
  74. package/dist/data-display.js +2 -1
  75. package/dist/i18n/generated/components.d.ts +1 -1
  76. package/dist/i18n/generated/data-display.cjs +1 -1
  77. package/dist/i18n/generated/data-display.d.ts +1 -1
  78. package/dist/i18n/generated/data-display.js +30 -3
  79. package/dist/i18n/generated/keys.d.ts +3 -1
  80. package/dist/i18n/generated/layout.cjs +2 -0
  81. package/dist/i18n/generated/layout.d.ts +3 -0
  82. package/dist/i18n/generated/layout.js +12 -0
  83. package/dist/i18n/generated/navigation.cjs +2 -0
  84. package/dist/i18n/generated/navigation.d.ts +3 -0
  85. package/dist/i18n/generated/navigation.js +12 -0
  86. package/dist/index.cjs +1 -1
  87. package/dist/index.js +173 -171
  88. package/dist/layout.cjs +1 -1
  89. package/dist/layout.d.ts +1 -0
  90. package/dist/layout.js +3 -2
  91. package/dist/llms-full.txt +58 -3
  92. package/dist/llms.txt +3 -1
  93. package/dist/locales/en/components.json +3 -1
  94. package/dist/locales/en/data-display.json +9 -0
  95. package/dist/locales/ja/components.json +3 -1
  96. package/dist/locales/ja/data-display.json +9 -0
  97. package/dist/locales/pt/components.json +3 -1
  98. package/dist/locales/pt/data-display.json +9 -0
  99. package/dist/styles.css +1 -1
  100. package/dist/wimui.umd.css +1 -1
  101. package/dist/wimui.umd.js +5 -5
  102. package/package.json +38 -35
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),i=require("../../form/Checkbox/Checkbox.cjs"),a=require("../../navigation/Pagination/Pagination.cjs"),o=require("../Table/Table.cjs"),s=require("./useFixedColumns.cjs"),c=require("./useDataGridKeyboard.cjs"),l=require("./useInfiniteScroll.cjs"),u=require("./datagrid.module.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");function m({columns:e,data:m,rowKey:h=`id`,loading:g=!1,striped:_=!1,bordered:v=!1,hoverable:y=!0,stickyHeader:b=!0,height:x,maxHeight:S,emptyMessage:C,mobileCard:w=!1,selection:T,selectedRowKeys:E,onSelectionChange:D,sortConfig:O,onSortChange:k,pagination:A,infiniteScroll:j,className:M,ariaLabel:N,"aria-label":P,"aria-labelledby":F}){let{t:I}=t.useWimTranslation(n.commonNs),L=g!==!1&&g!==void 0,R=g===!0||g===`blocking`,z=(0,d.useMemo)(()=>T?T===!0?{type:`checkbox`,selectedRowKeys:E??[],onChange:(e,t)=>{D?.(e,t)}}:T:null,[T,E,D]),{fixedLeftOffsets:B,fixedRightOffsets:V}=s.useFixedColumns(e,!!z),H=(e,t=!1)=>{let n=B[e];if(n)return{stickyLeft:!0,leftOffset:n.offset,stickyZIndex:t?1e3+n.zIndex:n.zIndex,className:(0,f.default)(u.default.cellFixed,n.isLast&&u.default.cellFixedLeftLast)};let r=V[e];return r?{stickyRight:!0,rightOffset:r.offset,stickyZIndex:t?1e3+r.zIndex:r.zIndex,className:(0,f.default)(u.default.cellFixed,r.isFirst&&u.default.cellFixedRightFirst)}:{}},U=(0,d.useCallback)(e=>typeof h==`function`?h(e):e[h],[h]),W=(0,d.useMemo)(()=>!z||m.length===0?!1:m.every(e=>z.selectedRowKeys.includes(U(e))),[m,z,U]),G=(0,d.useMemo)(()=>z?!W&&m.some(e=>z.selectedRowKeys.includes(U(e))):!1,[m,z,W,U]),K=e=>{if(!z)return;let t=e.target.checked,n=t?m.map(U):[],r=t?m:[];z.onChange(n,r)},q=(e,t)=>{if(!z)return;let n=t.target.checked,r=U(e),i=n?[...z.selectedRowKeys,r]:z.selectedRowKeys.filter(e=>e!==r),a=m.filter(e=>i.includes(U(e)));z.onChange(i,a)},{focusedCell:J,handleKeyDown:Y,containerRef:X}=c.useDataGridKeyboard(e,m,!!z),{loaderRef:Z}=l.useInfiniteScroll(j),Q=e.length+ +!!z,[$,ee]=(0,d.useState)(``);return(0,p.jsxs)(`div`,{className:(0,f.default)(`wim-data-grid`,u.default.root,R&&u.default.loading,w===`md`?u.default.mobileCardMd:w&&u.default.mobileCard,M),"aria-busy":L||void 0,children:[(0,p.jsx)(r.VisuallyHidden,{role:`status`,"aria-atomic":`true`,children:$}),(0,p.jsxs)(`div`,{className:u.default.container,style:{height:x,maxHeight:S},inert:R||void 0,children:[(0,p.jsxs)(o.Table,{ref:X,onKeyDown:Y,tabIndex:0,role:`grid`,"aria-label":F?void 0:P??N??I(`a11y.data_grid`),"aria-labelledby":F,"aria-rowcount":m.length+1,"aria-colcount":Q,striped:_,bordered:v,hoverable:y,stickyHeader:b,mobileCard:w,fullWidth:!0,className:(0,f.default)(`wim-table`,u.default.table),containerClassName:u.default.tableContainer,children:[(0,p.jsx)(o.Table.Header,{children:(0,p.jsxs)(o.Table.Row,{children:[z&&(0,p.jsx)(o.Table.Head,{role:`columnheader`,selection:!0,stickyLeft:!0,leftOffset:0,stickyZIndex:1150,"data-row":-1,"data-col":-1,"aria-label":I(`a11y.select_all_rows`),tabIndex:J.row===-1&&J.col===-1?0:-1,children:(z.type??`checkbox`)===`checkbox`&&(0,p.jsx)(i.Checkbox,{checked:W,indeterminate:G,onChange:K,"aria-label":I(`a11y.select_all_rows`)})}),e.map((e,t)=>{let n=H(e.key,!0);return(0,p.jsx)(o.Table.Head,{role:`columnheader`,style:{width:e.width,minWidth:e.width},sortable:!!(e.sortable&&k),sortDirection:O?.key===e.key?O.direction:`none`,onSort:()=>{if(!e.sortable||!k)return;let t=O?.key===e.key?O.direction===`asc`?`desc`:O.direction===`desc`?`none`:`asc`:`asc`,n=typeof e.title==`string`?e.title:e.key;ee(I(t===`asc`?`dataGrid.sorted_ascending`:t===`desc`?`dataGrid.sorted_descending`:`dataGrid.sort_cleared`,{column:n})),k(e.key,t)},...n,tabIndex:J.row===-1&&J.col===(z?t+1:t)?0:-1,"data-row":-1,"data-col":z?t+1:t,children:e.title},e.key)})]})}),(0,p.jsx)(o.Table.Body,{children:m.map((t,n)=>{let r=U(t),a=z?.selectedRowKeys.includes(r);return(0,p.jsxs)(o.Table.Row,{selected:a,children:[z&&(0,p.jsx)(o.Table.Cell,{role:`gridcell`,selection:!0,stickyLeft:!0,leftOffset:0,stickyZIndex:150,"data-row":n,"data-col":-1,tabIndex:J.row===n&&J.col===-1?0:-1,children:(0,p.jsx)(i.Checkbox,{checked:a,onChange:e=>q(t,e),"aria-label":I(`a11y.select_row_numbered`,{row:n+1})})}),e.map((e,r)=>{let i=H(e.key,!1),a=t[e.dataIndex??e.key];return(0,p.jsx)(o.Table.Cell,{role:`gridcell`,label:typeof e.title==`string`?e.title:void 0,...i,"data-row":n,"data-col":z?r+1:r,tabIndex:J.row===n&&J.col===(z?r+1:r)?0:-1,children:e.maxWidth==null?e.render?e.render(a,t,n):a:(0,p.jsx)(`div`,{style:{maxWidth:e.maxWidth},children:e.render?e.render(a,t,n):a})},e.key)})]},r)})})]}),m.length===0&&C&&(0,p.jsx)(`div`,{role:`status`,className:u.default.empty,children:C}),j?.hasMore&&(0,p.jsx)(`div`,{ref:Z,className:u.default.loader,children:j.hasMore&&I(`dataGrid.loading_more`)})]}),A&&(0,p.jsxs)(`div`,{className:u.default.footer,inert:R||void 0,children:[(0,p.jsxs)(`div`,{className:u.default.info,children:[I(`dataGrid.displaying`,{shown:m.length,total:A.total}),z?.selectedRowKeys&&z.selectedRowKeys.length>0&&(0,p.jsx)(`span`,{className:u.default.selectionInfo,children:I(`dataGrid.rows_selected`,{selected:z.selectedRowKeys.length})})]}),(0,p.jsx)(`div`,{className:u.default.pagination,children:(0,p.jsx)(a.Pagination,{className:u.default.paginationContent,current:A.current,total:A.total,pageSize:A.pageSize,onChange:A.onChange})})]})]})}exports.DataGrid=m;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../form/Checkbox/Checkbox.cjs"),i=require("../../_internal/useAnnounce.cjs"),a=require("../../navigation/Pagination/Pagination.cjs"),o=require("../Table/Table.cjs"),s=require("./useFixedColumns.cjs"),c=require("./useDataGridKeyboard.cjs"),l=require("./useInfiniteScroll.cjs"),u=require("./datagrid.module.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");function m({columns:e,data:m,rowKey:h=`id`,loading:g=!1,striped:_=!1,bordered:v=!1,hoverable:y=!0,stickyHeader:b=!0,height:x,maxHeight:S,emptyMessage:C,mobileCard:w=!1,selection:T,selectedRowKeys:E,onSelectionChange:D,sortConfig:O,onSortChange:k,pagination:A,infiniteScroll:j,className:M,ariaLabel:N,"aria-label":P,"aria-labelledby":F}){let{t:I}=t.useWimTranslation(n.commonNs),L=g!==!1&&g!==void 0,R=g===!0||g===`blocking`,z=(0,d.useMemo)(()=>T?T===!0?{type:`checkbox`,selectedRowKeys:E??[],onChange:(e,t)=>{D?.(e,t)}}:T:null,[T,E,D]),B=d.default.useRef(null),[V,H]=(0,d.useState)(),U=!!z&&e.some(e=>e.fixed===`left`);d.default.useLayoutEffect(()=>{let e=B.current;if(!U||!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>H(e.offsetWidth));return t.observe(e,{box:`border-box`}),()=>t.disconnect()},[U]);let{fixedLeftOffsets:W,fixedRightOffsets:G}=s.useFixedColumns(e,!!z,V),K=(e,t=!1)=>{let n=W[e];if(n)return{stickyLeft:!0,leftOffset:n.offset,stickyZIndex:t?1e3+n.zIndex:n.zIndex,className:(0,f.default)(u.default.cellFixed,n.isLast&&u.default.cellFixedLeftLast)};let r=G[e];return r?{stickyRight:!0,rightOffset:r.offset,stickyZIndex:t?1e3+r.zIndex:r.zIndex,className:(0,f.default)(u.default.cellFixed,r.isFirst&&u.default.cellFixedRightFirst)}:{}},q=(0,d.useCallback)(e=>typeof h==`function`?h(e):e[h],[h]),J=(0,d.useMemo)(()=>!z||m.length===0?!1:m.every(e=>z.selectedRowKeys.includes(q(e))),[m,z,q]),Y=(0,d.useMemo)(()=>z?!J&&m.some(e=>z.selectedRowKeys.includes(q(e))):!1,[m,z,J,q]),X=e=>{if(!z)return;let t=e.target.checked,n=t?m.map(q):[],r=t?m:[];z.onChange(n,r)},Z=(e,t)=>{if(!z)return;let n=t.target.checked,r=q(e),i=n?[...z.selectedRowKeys,r]:z.selectedRowKeys.filter(e=>e!==r),a=m.filter(e=>i.includes(q(e)));z.onChange(i,a)},{focusedCell:Q,handleKeyDown:$,containerRef:ee}=c.useDataGridKeyboard(e,m,!!z),{loaderRef:te}=l.useInfiniteScroll(j),ne=e.length+ +!!z,{announce:re,region:ie}=i.useAnnounce();return(0,p.jsxs)(`div`,{className:(0,f.default)(`wim-data-grid`,u.default.root,R&&u.default.loading,w===`md`?u.default.mobileCardMd:w&&u.default.mobileCard,M),"aria-busy":L||void 0,children:[ie,(0,p.jsxs)(`div`,{className:u.default.container,style:{height:x,maxHeight:S},inert:R||void 0,children:[(0,p.jsxs)(o.Table,{ref:ee,onKeyDown:$,tabIndex:0,role:`grid`,"aria-label":F?void 0:P??N??I(`a11y.data_grid`),"aria-labelledby":F,"aria-rowcount":m.length+1,"aria-colcount":ne,striped:_,bordered:v,hoverable:y,stickyHeader:b,mobileCard:w,fullWidth:!0,className:(0,f.default)(`wim-table`,u.default.table),containerClassName:u.default.tableContainer,children:[(0,p.jsx)(o.Table.Header,{children:(0,p.jsxs)(o.Table.Row,{children:[z&&(0,p.jsx)(o.Table.Head,{ref:B,role:`columnheader`,selection:!0,stickyLeft:!0,leftOffset:0,stickyZIndex:1150,"data-row":-1,"data-col":-1,"aria-label":I(`a11y.select_all_rows`),tabIndex:Q.row===-1&&Q.col===-1?0:-1,children:(z.type??`checkbox`)===`checkbox`&&(0,p.jsx)(r.Checkbox,{checked:J,indeterminate:Y,onChange:X,"aria-label":I(`a11y.select_all_rows`)})}),e.map((e,t)=>{let n=K(e.key,!0);return(0,p.jsx)(o.Table.Head,{role:`columnheader`,style:{width:e.width,minWidth:e.width},sortable:!!(e.sortable&&k),sortDirection:O?.key===e.key?O.direction:`none`,onSort:()=>{if(!e.sortable||!k)return;let t=O?.key===e.key?O.direction===`asc`?`desc`:O.direction===`desc`?`none`:`asc`:`asc`,n=typeof e.title==`string`?e.title:e.key;re(I(t===`asc`?`dataGrid.sorted_ascending`:t===`desc`?`dataGrid.sorted_descending`:`dataGrid.sort_cleared`,{column:n})),k(e.key,t)},...n,tabIndex:Q.row===-1&&Q.col===(z?t+1:t)?0:-1,"data-row":-1,"data-col":z?t+1:t,children:e.title},e.key)})]})}),(0,p.jsx)(o.Table.Body,{children:m.map((t,n)=>{let i=q(t),a=z?.selectedRowKeys.includes(i);return(0,p.jsxs)(o.Table.Row,{selected:a,children:[z&&(0,p.jsx)(o.Table.Cell,{role:`gridcell`,selection:!0,stickyLeft:!0,leftOffset:0,stickyZIndex:150,"data-row":n,"data-col":-1,tabIndex:Q.row===n&&Q.col===-1?0:-1,children:(0,p.jsx)(r.Checkbox,{checked:a,onChange:e=>Z(t,e),"aria-label":I(`a11y.select_row_numbered`,{row:n+1})})}),e.map((e,r)=>{let i=K(e.key,!1),a=t[e.dataIndex??e.key];return(0,p.jsx)(o.Table.Cell,{role:`gridcell`,label:typeof e.title==`string`?e.title:void 0,...i,"data-row":n,"data-col":z?r+1:r,tabIndex:Q.row===n&&Q.col===(z?r+1:r)?0:-1,children:e.maxWidth==null?e.render?e.render(a,t,n):a:(0,p.jsx)(`div`,{style:{maxWidth:e.maxWidth},children:e.render?e.render(a,t,n):a})},e.key)})]},i)})})]}),m.length===0&&C&&(0,p.jsx)(`div`,{role:`status`,className:u.default.empty,children:C}),j?.hasMore&&(0,p.jsx)(`div`,{ref:te,className:u.default.loader,children:j.hasMore&&I(`dataGrid.loading_more`)})]}),A&&(0,p.jsxs)(`div`,{className:u.default.footer,inert:R||void 0,children:[(0,p.jsxs)(`div`,{className:u.default.info,children:[I(`dataGrid.displaying`,{shown:m.length,total:A.total}),z?.selectedRowKeys&&z.selectedRowKeys.length>0&&(0,p.jsx)(`span`,{className:u.default.selectionInfo,children:I(`dataGrid.rows_selected`,{selected:z.selectedRowKeys.length})})]}),(0,p.jsx)(`div`,{className:u.default.pagination,children:(0,p.jsx)(a.Pagination,{className:u.default.paginationContent,current:A.current,total:A.total,pageSize:A.pageSize,onChange:A.onChange})})]})]})}exports.DataGrid=m;
@@ -1,20 +1,20 @@
1
1
  "use client";
2
2
  import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
3
3
  import { commonNs as t } from "../../../i18n/generated/common.js";
4
- import { VisuallyHidden as n } from "../../layout/VisuallyHidden/VisuallyHidden.js";
5
- import { Checkbox as r } from "../../form/Checkbox/Checkbox.js";
4
+ import { Checkbox as n } from "../../form/Checkbox/Checkbox.js";
5
+ import { useAnnounce as r } from "../../_internal/useAnnounce.js";
6
6
  import { Pagination as i } from "../../navigation/Pagination/Pagination.js";
7
7
  import { Table as a } from "../Table/Table.js";
8
8
  import { useFixedColumns as o } from "./useFixedColumns.js";
9
9
  import { useDataGridKeyboard as s } from "./useDataGridKeyboard.js";
10
10
  import { useInfiniteScroll as c } from "./useInfiniteScroll.js";
11
11
  import l from "./datagrid.module.js";
12
- import { useCallback as u, useMemo as d, useState as f } from "react";
13
- import p from "classnames";
14
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
+ import u, { useCallback as d, useMemo as f, useState as p } from "react";
13
+ import m from "classnames";
14
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
15
15
  //#region src/components/data-display/DataGrid/DataGrid.tsx
16
- function g({ columns: g, data: _, rowKey: v = "id", loading: y = !1, striped: b = !1, bordered: x = !1, hoverable: S = !0, stickyHeader: C = !0, height: w, maxHeight: T, emptyMessage: E, mobileCard: D = !1, selection: O, selectedRowKeys: k, onSelectionChange: A, sortConfig: j, onSortChange: M, pagination: N, infiniteScroll: P, className: F, ariaLabel: I, "aria-label": L, "aria-labelledby": R }) {
17
- let { t: z } = e(t), B = y !== !1 && y !== void 0, V = y === !0 || y === "blocking", H = d(() => O ? O === !0 ? {
16
+ function _({ columns: _, data: v, rowKey: y = "id", loading: b = !1, striped: x = !1, bordered: ee = !1, hoverable: S = !0, stickyHeader: C = !0, height: w, maxHeight: T, emptyMessage: E, mobileCard: D = !1, selection: O, selectedRowKeys: k, onSelectionChange: A, sortConfig: j, onSortChange: M, pagination: N, infiniteScroll: P, className: F, ariaLabel: I, "aria-label": L, "aria-labelledby": R }) {
17
+ let { t: z } = e(t), B = b !== !1 && b !== void 0, V = b === !0 || b === "blocking", H = f(() => O ? O === !0 ? {
18
18
  type: "checkbox",
19
19
  selectedRowKeys: k ?? [],
20
20
  onChange: (e, t) => {
@@ -24,49 +24,52 @@ function g({ columns: g, data: _, rowKey: v = "id", loading: y = !1, striped: b
24
24
  O,
25
25
  k,
26
26
  A
27
- ]), { fixedLeftOffsets: U, fixedRightOffsets: W } = o(g, !!H), G = (e, t = !1) => {
28
- let n = U[e];
27
+ ]), U = u.useRef(null), [W, G] = p(), K = !!H && _.some((e) => e.fixed === "left");
28
+ u.useLayoutEffect(() => {
29
+ let e = U.current;
30
+ if (!K || !e || typeof ResizeObserver > "u") return;
31
+ let t = new ResizeObserver(() => G(e.offsetWidth));
32
+ return t.observe(e, { box: "border-box" }), () => t.disconnect();
33
+ }, [K]);
34
+ let { fixedLeftOffsets: q, fixedRightOffsets: J } = o(_, !!H, W), Y = (e, t = !1) => {
35
+ let n = q[e];
29
36
  if (n) return {
30
37
  stickyLeft: !0,
31
38
  leftOffset: n.offset,
32
39
  stickyZIndex: t ? 1e3 + n.zIndex : n.zIndex,
33
- className: p(l.cellFixed, n.isLast && l.cellFixedLeftLast)
40
+ className: m(l.cellFixed, n.isLast && l.cellFixedLeftLast)
34
41
  };
35
- let r = W[e];
42
+ let r = J[e];
36
43
  return r ? {
37
44
  stickyRight: !0,
38
45
  rightOffset: r.offset,
39
46
  stickyZIndex: t ? 1e3 + r.zIndex : r.zIndex,
40
- className: p(l.cellFixed, r.isFirst && l.cellFixedRightFirst)
47
+ className: m(l.cellFixed, r.isFirst && l.cellFixedRightFirst)
41
48
  } : {};
42
- }, K = u((e) => typeof v == "function" ? v(e) : e[v], [v]), q = d(() => !H || _.length === 0 ? !1 : _.every((e) => H.selectedRowKeys.includes(K(e))), [
43
- _,
49
+ }, X = d((e) => typeof y == "function" ? y(e) : e[y], [y]), Z = f(() => !H || v.length === 0 ? !1 : v.every((e) => H.selectedRowKeys.includes(X(e))), [
50
+ v,
44
51
  H,
45
- K
46
- ]), J = d(() => H ? !q && _.some((e) => H.selectedRowKeys.includes(K(e))) : !1, [
47
- _,
52
+ X
53
+ ]), Q = f(() => H ? !Z && v.some((e) => H.selectedRowKeys.includes(X(e))) : !1, [
54
+ v,
48
55
  H,
49
- q,
50
- K
51
- ]), Y = (e) => {
56
+ Z,
57
+ X
58
+ ]), te = (e) => {
52
59
  if (!H) return;
53
- let t = e.target.checked, n = t ? _.map(K) : [], r = t ? _ : [];
60
+ let t = e.target.checked, n = t ? v.map(X) : [], r = t ? v : [];
54
61
  H.onChange(n, r);
55
- }, X = (e, t) => {
62
+ }, ne = (e, t) => {
56
63
  if (!H) return;
57
- let n = t.target.checked, r = K(e), i = n ? [...H.selectedRowKeys, r] : H.selectedRowKeys.filter((e) => e !== r), a = _.filter((e) => i.includes(K(e)));
64
+ let n = t.target.checked, r = X(e), i = n ? [...H.selectedRowKeys, r] : H.selectedRowKeys.filter((e) => e !== r), a = v.filter((e) => i.includes(X(e)));
58
65
  H.onChange(i, a);
59
- }, { focusedCell: Z, handleKeyDown: Q, containerRef: $ } = s(g, _, !!H), { loaderRef: ee } = c(P), te = g.length + +!!H, [ne, re] = f("");
60
- return /* @__PURE__ */ h("div", {
61
- className: p("wim-data-grid", l.root, V && l.loading, D === "md" ? l.mobileCardMd : D && l.mobileCard, F),
66
+ }, { focusedCell: $, handleKeyDown: re, containerRef: ie } = s(_, v, !!H), { loaderRef: ae } = c(P), oe = _.length + +!!H, { announce: se, region: ce } = r();
67
+ return /* @__PURE__ */ g("div", {
68
+ className: m("wim-data-grid", l.root, V && l.loading, D === "md" ? l.mobileCardMd : D && l.mobileCard, F),
62
69
  "aria-busy": B || void 0,
63
70
  children: [
64
- /* @__PURE__ */ m(n, {
65
- role: "status",
66
- "aria-atomic": "true",
67
- children: ne
68
- }),
69
- /* @__PURE__ */ h("div", {
71
+ ce,
72
+ /* @__PURE__ */ g("div", {
70
73
  className: l.container,
71
74
  style: {
72
75
  height: w,
@@ -74,24 +77,25 @@ function g({ columns: g, data: _, rowKey: v = "id", loading: y = !1, striped: b
74
77
  },
75
78
  inert: V || void 0,
76
79
  children: [
77
- /* @__PURE__ */ h(a, {
78
- ref: $,
79
- onKeyDown: Q,
80
+ /* @__PURE__ */ g(a, {
81
+ ref: ie,
82
+ onKeyDown: re,
80
83
  tabIndex: 0,
81
84
  role: "grid",
82
85
  "aria-label": R ? void 0 : L ?? I ?? z("a11y.data_grid"),
83
86
  "aria-labelledby": R,
84
- "aria-rowcount": _.length + 1,
85
- "aria-colcount": te,
86
- striped: b,
87
- bordered: x,
87
+ "aria-rowcount": v.length + 1,
88
+ "aria-colcount": oe,
89
+ striped: x,
90
+ bordered: ee,
88
91
  hoverable: S,
89
92
  stickyHeader: C,
90
93
  mobileCard: D,
91
94
  fullWidth: !0,
92
- className: p("wim-table", l.table),
95
+ className: m("wim-table", l.table),
93
96
  containerClassName: l.tableContainer,
94
- children: [/* @__PURE__ */ m(a.Header, { children: /* @__PURE__ */ h(a.Row, { children: [H && /* @__PURE__ */ m(a.Head, {
97
+ children: [/* @__PURE__ */ h(a.Header, { children: /* @__PURE__ */ g(a.Row, { children: [H && /* @__PURE__ */ h(a.Head, {
98
+ ref: U,
95
99
  role: "columnheader",
96
100
  selection: !0,
97
101
  stickyLeft: !0,
@@ -100,16 +104,16 @@ function g({ columns: g, data: _, rowKey: v = "id", loading: y = !1, striped: b
100
104
  "data-row": -1,
101
105
  "data-col": -1,
102
106
  "aria-label": z("a11y.select_all_rows"),
103
- tabIndex: Z.row === -1 && Z.col === -1 ? 0 : -1,
104
- children: (H.type ?? "checkbox") === "checkbox" && /* @__PURE__ */ m(r, {
105
- checked: q,
106
- indeterminate: J,
107
- onChange: Y,
107
+ tabIndex: $.row === -1 && $.col === -1 ? 0 : -1,
108
+ children: (H.type ?? "checkbox") === "checkbox" && /* @__PURE__ */ h(n, {
109
+ checked: Z,
110
+ indeterminate: Q,
111
+ onChange: te,
108
112
  "aria-label": z("a11y.select_all_rows")
109
113
  })
110
- }), g.map((e, t) => {
111
- let n = G(e.key, !0);
112
- return /* @__PURE__ */ m(a.Head, {
114
+ }), _.map((e, t) => {
115
+ let n = Y(e.key, !0);
116
+ return /* @__PURE__ */ h(a.Head, {
113
117
  role: "columnheader",
114
118
  style: {
115
119
  width: e.width,
@@ -120,19 +124,19 @@ function g({ columns: g, data: _, rowKey: v = "id", loading: y = !1, striped: b
120
124
  onSort: () => {
121
125
  if (!e.sortable || !M) return;
122
126
  let t = j?.key === e.key ? j.direction === "asc" ? "desc" : j.direction === "desc" ? "none" : "asc" : "asc", n = typeof e.title == "string" ? e.title : e.key;
123
- re(z(t === "asc" ? "dataGrid.sorted_ascending" : t === "desc" ? "dataGrid.sorted_descending" : "dataGrid.sort_cleared", { column: n })), M(e.key, t);
127
+ se(z(t === "asc" ? "dataGrid.sorted_ascending" : t === "desc" ? "dataGrid.sorted_descending" : "dataGrid.sort_cleared", { column: n })), M(e.key, t);
124
128
  },
125
129
  ...n,
126
- tabIndex: Z.row === -1 && Z.col === (H ? t + 1 : t) ? 0 : -1,
130
+ tabIndex: $.row === -1 && $.col === (H ? t + 1 : t) ? 0 : -1,
127
131
  "data-row": -1,
128
132
  "data-col": H ? t + 1 : t,
129
133
  children: e.title
130
134
  }, e.key);
131
- })] }) }), /* @__PURE__ */ m(a.Body, { children: _.map((e, t) => {
132
- let n = K(e), i = H?.selectedRowKeys.includes(n);
133
- return /* @__PURE__ */ h(a.Row, {
135
+ })] }) }), /* @__PURE__ */ h(a.Body, { children: v.map((e, t) => {
136
+ let r = X(e), i = H?.selectedRowKeys.includes(r);
137
+ return /* @__PURE__ */ g(a.Row, {
134
138
  selected: i,
135
- children: [H && /* @__PURE__ */ m(a.Cell, {
139
+ children: [H && /* @__PURE__ */ h(a.Cell, {
136
140
  role: "gridcell",
137
141
  selection: !0,
138
142
  stickyLeft: !0,
@@ -140,57 +144,57 @@ function g({ columns: g, data: _, rowKey: v = "id", loading: y = !1, striped: b
140
144
  stickyZIndex: 150,
141
145
  "data-row": t,
142
146
  "data-col": -1,
143
- tabIndex: Z.row === t && Z.col === -1 ? 0 : -1,
144
- children: /* @__PURE__ */ m(r, {
147
+ tabIndex: $.row === t && $.col === -1 ? 0 : -1,
148
+ children: /* @__PURE__ */ h(n, {
145
149
  checked: i,
146
- onChange: (t) => X(e, t),
150
+ onChange: (t) => ne(e, t),
147
151
  "aria-label": z("a11y.select_row_numbered", { row: t + 1 })
148
152
  })
149
- }), g.map((n, r) => {
150
- let i = G(n.key, !1), o = e[n.dataIndex ?? n.key];
151
- return /* @__PURE__ */ m(a.Cell, {
153
+ }), _.map((n, r) => {
154
+ let i = Y(n.key, !1), o = e[n.dataIndex ?? n.key];
155
+ return /* @__PURE__ */ h(a.Cell, {
152
156
  role: "gridcell",
153
157
  label: typeof n.title == "string" ? n.title : void 0,
154
158
  ...i,
155
159
  "data-row": t,
156
160
  "data-col": H ? r + 1 : r,
157
- tabIndex: Z.row === t && Z.col === (H ? r + 1 : r) ? 0 : -1,
158
- children: n.maxWidth == null ? n.render ? n.render(o, e, t) : o : /* @__PURE__ */ m("div", {
161
+ tabIndex: $.row === t && $.col === (H ? r + 1 : r) ? 0 : -1,
162
+ children: n.maxWidth == null ? n.render ? n.render(o, e, t) : o : /* @__PURE__ */ h("div", {
159
163
  style: { maxWidth: n.maxWidth },
160
164
  children: n.render ? n.render(o, e, t) : o
161
165
  })
162
166
  }, n.key);
163
167
  })]
164
- }, n);
168
+ }, r);
165
169
  }) })]
166
170
  }),
167
- _.length === 0 && E && /* @__PURE__ */ m("div", {
171
+ v.length === 0 && E && /* @__PURE__ */ h("div", {
168
172
  role: "status",
169
173
  className: l.empty,
170
174
  children: E
171
175
  }),
172
- P?.hasMore && /* @__PURE__ */ m("div", {
173
- ref: ee,
176
+ P?.hasMore && /* @__PURE__ */ h("div", {
177
+ ref: ae,
174
178
  className: l.loader,
175
179
  children: P.hasMore && z("dataGrid.loading_more")
176
180
  })
177
181
  ]
178
182
  }),
179
- N && /* @__PURE__ */ h("div", {
183
+ N && /* @__PURE__ */ g("div", {
180
184
  className: l.footer,
181
185
  inert: V || void 0,
182
- children: [/* @__PURE__ */ h("div", {
186
+ children: [/* @__PURE__ */ g("div", {
183
187
  className: l.info,
184
188
  children: [z("dataGrid.displaying", {
185
- shown: _.length,
189
+ shown: v.length,
186
190
  total: N.total
187
- }), H?.selectedRowKeys && H.selectedRowKeys.length > 0 && /* @__PURE__ */ m("span", {
191
+ }), H?.selectedRowKeys && H.selectedRowKeys.length > 0 && /* @__PURE__ */ h("span", {
188
192
  className: l.selectionInfo,
189
193
  children: z("dataGrid.rows_selected", { selected: H.selectedRowKeys.length })
190
194
  })]
191
- }), /* @__PURE__ */ m("div", {
195
+ }), /* @__PURE__ */ h("div", {
192
196
  className: l.pagination,
193
- children: /* @__PURE__ */ m(i, {
197
+ children: /* @__PURE__ */ h(i, {
194
198
  className: l.paginationContent,
195
199
  current: N.current,
196
200
  total: N.total,
@@ -203,4 +207,4 @@ function g({ columns: g, data: _, rowKey: v = "id", loading: y = !1, striped: b
203
207
  });
204
208
  }
205
209
  //#endregion
206
- export { g as DataGrid };
210
+ export { _ as DataGrid };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- let e=require("react");function t(e){return typeof e==`number`?e:typeof e==`string`&&e.endsWith(`px`)?parseInt(e,10):0}function n(n,r){return(0,e.useMemo)(()=>{let e={},i=r?60:0,a=100,o=n.filter(e=>e.fixed===`left`);o.forEach((n,r)=>{e[n.key]={offset:i===0?0:`${i}px`,zIndex:a--,isLast:r===o.length-1},i+=t(n.width)});let s={},c=0,l=100,u=n.filter(e=>e.fixed===`right`);return u.reverse().forEach((e,n)=>{s[e.key]={offset:c===0?0:`${c}px`,zIndex:l--,isFirst:n===u.length-1},c+=t(e.width)}),{fixedLeftOffsets:e,fixedRightOffsets:s}},[n,r])}exports.useFixedColumns=n;
2
+ let e=require("react");function t(e){return typeof e==`number`?e:typeof e==`string`&&e.endsWith(`px`)?parseInt(e,10):0}var n=60;function r(r,i,a){return(0,e.useMemo)(()=>{let e={},o=i?a??n:0,s=100,c=r.filter(e=>e.fixed===`left`);c.forEach((n,r)=>{e[n.key]={offset:o===0?0:`${o}px`,zIndex:s--,isLast:r===c.length-1},o+=t(n.width)});let l={},u=0,d=100,f=r.filter(e=>e.fixed===`right`);return f.reverse().forEach((e,n)=>{l[e.key]={offset:u===0?0:`${u}px`,zIndex:d--,isFirst:n===f.length-1},u+=t(e.width)}),{fixedLeftOffsets:e,fixedRightOffsets:l}},[r,i,a])}exports.useFixedColumns=r;
@@ -3,7 +3,12 @@ export type FixedColumnInfo = {
3
3
  offset: number | string;
4
4
  zIndex: number;
5
5
  };
6
- export declare function useFixedColumns<T>(columns: DataGridColumn<T>[], selection: boolean): {
6
+ /**
7
+ * @param selectionWidth 選択の列の、測った幅(px)。選択の列は中身(チェックボックスと
8
+ * 密度で変わる余白)の幅なので、決め打ちの値で積むと、横にスクロールしたときに
9
+ * 左に固定した列とのあいだに隙間や重なりができる
10
+ */
11
+ export declare function useFixedColumns<T>(columns: DataGridColumn<T>[], selection: boolean, selectionWidth?: number): {
7
12
  fixedLeftOffsets: Record<string, FixedColumnInfo>;
8
13
  fixedRightOffsets: Record<string, FixedColumnInfo>;
9
14
  };
@@ -4,28 +4,33 @@ import { useMemo as e } from "react";
4
4
  function t(e) {
5
5
  return typeof e == "number" ? e : typeof e == "string" && e.endsWith("px") ? parseInt(e, 10) : 0;
6
6
  }
7
- function n(n, r) {
7
+ var n = 60;
8
+ function r(r, i, a) {
8
9
  return e(() => {
9
- let e = {}, i = r ? 60 : 0, a = 100, o = n.filter((e) => e.fixed === "left");
10
- o.forEach((n, r) => {
10
+ let e = {}, o = i ? a ?? n : 0, s = 100, c = r.filter((e) => e.fixed === "left");
11
+ c.forEach((n, r) => {
11
12
  e[n.key] = {
12
- offset: i === 0 ? 0 : `${i}px`,
13
- zIndex: a--,
14
- isLast: r === o.length - 1
15
- }, i += t(n.width);
13
+ offset: o === 0 ? 0 : `${o}px`,
14
+ zIndex: s--,
15
+ isLast: r === c.length - 1
16
+ }, o += t(n.width);
16
17
  });
17
- let s = {}, c = 0, l = 100, u = n.filter((e) => e.fixed === "right");
18
- return u.reverse().forEach((e, n) => {
19
- s[e.key] = {
20
- offset: c === 0 ? 0 : `${c}px`,
21
- zIndex: l--,
22
- isFirst: n === u.length - 1
23
- }, c += t(e.width);
18
+ let l = {}, u = 0, d = 100, f = r.filter((e) => e.fixed === "right");
19
+ return f.reverse().forEach((e, n) => {
20
+ l[e.key] = {
21
+ offset: u === 0 ? 0 : `${u}px`,
22
+ zIndex: d--,
23
+ isFirst: n === f.length - 1
24
+ }, u += t(e.width);
24
25
  }), {
25
26
  fixedLeftOffsets: e,
26
- fixedRightOffsets: s
27
+ fixedRightOffsets: l
27
28
  };
28
- }, [n, r]);
29
+ }, [
30
+ r,
31
+ i,
32
+ a
33
+ ]);
29
34
  }
30
35
  //#endregion
31
- export { n as useFixedColumns };
36
+ export { r as useFixedColumns };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../hooks/useMergedRef.cjs"),r=require("../../form/Button/Button.cjs"),i=require("../../layout/Toolbar/Toolbar.cjs"),a=require("../../_internal/useAnnounce.cjs"),o=require("../../../i18n/generated/data-display.cjs"),s=require("./selection-bar.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=1e3,f=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,p=e=>{if(!e)return null;for(let t of Array.from(document.querySelectorAll(f))){if(e.contains(t)||!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)||t.closest(`[hidden], [inert], [aria-hidden="true"]`))continue;let n=getComputedStyle(t);if(n.display!==`none`&&n.visibility!==`hidden`)return t}return null},m=c.default.forwardRef(({count:e,onClear:f,children:m,countLabel:h,clearLabel:g,returnFocusRef:_,className:v,onFocus:y,"aria-label":b,...x},S)=>{let{t:C}=t.useWimTranslation(o.dataDisplayNs),w=c.default.useRef(null),T=n.useMergedRef(S,w),E=e>0,D=a.useAnnounceValue(E?C(`selection_bar.selected`,{count:e}):C(`selection_bar.cleared`)),O=c.default.useRef(!1),k=e=>{O.current=!0,y?.(e)};return c.default.useLayoutEffect(()=>{if(E||!O.current)return;O.current=!1;let e=()=>{let e=document.activeElement;return e&&e!==document.body?!1:((_?.current??p(w.current)??w.current)?.focus(),!0)};if(e())return;let t=Date.now(),n=window.setInterval(()=>{(e()||Date.now()-t>d)&&window.clearInterval(n)},50);return()=>window.clearInterval(n)},[E,_]),(0,u.jsxs)(`div`,{...x,ref:T,tabIndex:-1,className:(0,l.default)(`wim-selection-bar`,s.default.root,v),onFocus:k,children:[D,E&&(0,u.jsxs)(i.Toolbar,{size:`sm`,"aria-label":b??C(`selection_bar.label`),className:s.default.bar,children:[(0,u.jsx)(`span`,{className:s.default.count,children:h?h(e):C(`selection_bar.selected`,{count:e})}),m&&(0,u.jsx)(i.Toolbar.Group,{children:m}),f&&(0,u.jsx)(i.Toolbar.Group,{className:s.default.end,children:(0,u.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:f,children:g??C(`selection_bar.clear`)})})]})]})});m.displayName=`SelectionBar`,exports.SelectionBar=m;
@@ -0,0 +1,77 @@
1
+ import { default as React } from 'react';
2
+ export type SelectionBarProps = Omit<React.ComponentPropsWithoutRef<"div">, "children"> & {
3
+ /**
4
+ * Number of selected items. The bar shows while it is above 0. Keep the component mounted
5
+ * while the count is 0 as well: it holds the status region that announces the count, and a
6
+ * region that appears together with its text is not read by screen readers.
7
+ */
8
+ count: number;
9
+ /**
10
+ * Called by the built-in "Clear selection" button. Leave it out to render no clear button.
11
+ */
12
+ onClear?: () => void;
13
+ /**
14
+ * Actions for the selected items (`Button size="sm"`, `IconButton`, `Popconfirm` ...). They
15
+ * are placed in a `Toolbar`, so the arrow keys move between them.
16
+ */
17
+ children?: React.ReactNode;
18
+ /**
19
+ * Text that states the count. Defaults to the built-in "{count} selected" (en / ja / pt).
20
+ */
21
+ countLabel?: (count: number) => React.ReactNode;
22
+ /**
23
+ * Label of the clear button. Defaults to the built-in "Clear selection".
24
+ */
25
+ clearLabel?: string;
26
+ /**
27
+ * Where focus goes when the bar closes after focus was in it — after the clear button, or
28
+ * after a confirmation opened from the bar (`Popconfirm`) whose trigger is gone. Without it,
29
+ * focus moves to the first focusable element after the bar (with `DataGrid`, the grid).
30
+ */
31
+ returnFocusRef?: React.RefObject<HTMLElement | null>;
32
+ };
33
+ /**
34
+ * SelectionBar shows the number of selected rows, the actions for them and a way to clear the
35
+ * selection. Place it above the Table / DataGrid / List it acts on, and keep it mounted.
36
+ *
37
+ * - The count is announced from a status region that is always present, both when it changes
38
+ * and when the selection is cleared.
39
+ * - When the bar closes after focus was in it, focus moves to `returnFocusRef` or to the first
40
+ * focusable element after the bar, instead of falling to the top of the page.
41
+ *
42
+ * Composition Contract:
43
+ * - Managed by: App consumption (the selection state stays with the caller)
44
+ * - Scroll lock: No
45
+ * - Does not own action semantics — compose Button / IconButton / Popconfirm as children
46
+ */
47
+ export declare const SelectionBar: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children"> & {
48
+ /**
49
+ * Number of selected items. The bar shows while it is above 0. Keep the component mounted
50
+ * while the count is 0 as well: it holds the status region that announces the count, and a
51
+ * region that appears together with its text is not read by screen readers.
52
+ */
53
+ count: number;
54
+ /**
55
+ * Called by the built-in "Clear selection" button. Leave it out to render no clear button.
56
+ */
57
+ onClear?: () => void;
58
+ /**
59
+ * Actions for the selected items (`Button size="sm"`, `IconButton`, `Popconfirm` ...). They
60
+ * are placed in a `Toolbar`, so the arrow keys move between them.
61
+ */
62
+ children?: React.ReactNode;
63
+ /**
64
+ * Text that states the count. Defaults to the built-in "{count} selected" (en / ja / pt).
65
+ */
66
+ countLabel?: (count: number) => React.ReactNode;
67
+ /**
68
+ * Label of the clear button. Defaults to the built-in "Clear selection".
69
+ */
70
+ clearLabel?: string;
71
+ /**
72
+ * Where focus goes when the bar closes after focus was in it — after the clear button, or
73
+ * after a confirmation opened from the bar (`Popconfirm`) whose trigger is gone. Without it,
74
+ * focus moves to the first focusable element after the bar (with `DataGrid`, the grid).
75
+ */
76
+ returnFocusRef?: React.RefObject<HTMLElement | null>;
77
+ } & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,68 @@
1
+ "use client";
2
+ import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
3
+ import { useMergedRef as t } from "../../../hooks/useMergedRef.js";
4
+ import { Button as n } from "../../form/Button/Button.js";
5
+ import { Toolbar as r } from "../../layout/Toolbar/Toolbar.js";
6
+ import { useAnnounceValue as i } from "../../_internal/useAnnounce.js";
7
+ import { dataDisplayNs as a } from "../../../i18n/generated/data-display.js";
8
+ import o from "./selection-bar.module.js";
9
+ import s from "react";
10
+ import c from "classnames";
11
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
12
+ //#region src/components/data-display/SelectionBar/SelectionBar.tsx
13
+ var d = 1e3, f = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])", p = (e) => {
14
+ if (!e) return null;
15
+ for (let t of Array.from(document.querySelectorAll(f))) {
16
+ if (e.contains(t) || !(e.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING) || t.closest("[hidden], [inert], [aria-hidden=\"true\"]")) continue;
17
+ let n = getComputedStyle(t);
18
+ if (n.display !== "none" && n.visibility !== "hidden") return t;
19
+ }
20
+ return null;
21
+ }, m = s.forwardRef(({ count: f, onClear: m, children: h, countLabel: g, clearLabel: _, returnFocusRef: v, className: y, onFocus: b, "aria-label": x, ...S }, C) => {
22
+ let { t: w } = e(a), T = s.useRef(null), E = t(C, T), D = f > 0, O = i(D ? w("selection_bar.selected", { count: f }) : w("selection_bar.cleared")), k = s.useRef(!1), A = (e) => {
23
+ k.current = !0, b?.(e);
24
+ };
25
+ return s.useLayoutEffect(() => {
26
+ if (D || !k.current) return;
27
+ k.current = !1;
28
+ let e = () => {
29
+ let e = document.activeElement;
30
+ return e && e !== document.body ? !1 : ((v?.current ?? p(T.current) ?? T.current)?.focus(), !0);
31
+ };
32
+ if (e()) return;
33
+ let t = Date.now(), n = window.setInterval(() => {
34
+ (e() || Date.now() - t > d) && window.clearInterval(n);
35
+ }, 50);
36
+ return () => window.clearInterval(n);
37
+ }, [D, v]), /* @__PURE__ */ u("div", {
38
+ ...S,
39
+ ref: E,
40
+ tabIndex: -1,
41
+ className: c("wim-selection-bar", o.root, y),
42
+ onFocus: A,
43
+ children: [O, D && /* @__PURE__ */ u(r, {
44
+ size: "sm",
45
+ "aria-label": x ?? w("selection_bar.label"),
46
+ className: o.bar,
47
+ children: [
48
+ /* @__PURE__ */ l("span", {
49
+ className: o.count,
50
+ children: g ? g(f) : w("selection_bar.selected", { count: f })
51
+ }),
52
+ h && /* @__PURE__ */ l(r.Group, { children: h }),
53
+ m && /* @__PURE__ */ l(r.Group, {
54
+ className: o.end,
55
+ children: /* @__PURE__ */ l(n, {
56
+ variant: "ghost",
57
+ size: "sm",
58
+ onClick: m,
59
+ children: _ ?? w("selection_bar.clear")
60
+ })
61
+ })
62
+ ]
63
+ })]
64
+ });
65
+ });
66
+ m.displayName = "SelectionBar";
67
+ //#endregion
68
+ export { m as SelectionBar };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ var e=`_root_dyl0x_2`,t=`_bar_dyl0x_5`,n=`_count_dyl0x_9`,r=`_end_dyl0x_17`,i={root:e,bar:t,count:n,end:r};exports.bar=t,exports.count=n,exports.default=i,exports.end=r,exports.root=e;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ //#region src/components/data-display/SelectionBar/selection-bar.module.scss
3
+ var e = "_root_dyl0x_2", t = "_bar_dyl0x_5", n = "_count_dyl0x_9", r = "_end_dyl0x_17", i = {
4
+ root: e,
5
+ bar: t,
6
+ count: n,
7
+ end: r
8
+ };
9
+ //#endregion
10
+ export { t as bar, n as count, i as default, r as end, e as root };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e=`_scope_qosxz_6`,t=`_container_qosxz_16`,n=`_mobileCard_qosxz_25`,r=`_mobileCardMd_qosxz_25`,i=`_sticky_qosxz_28`,a=`_cardContainer_qosxz_31`,o=`_root_qosxz_5`,s=`_fullWidth_qosxz_83`,c=`_striped_qosxz_86`,l=`_bordered_qosxz_90`,u=`_hoverable_qosxz_105`,d=`_stickyLeft_qosxz_109`,f=`_stickyRight_qosxz_109`,p=`_stickyHeader_qosxz_112`,m=`_selection_qosxz_238`,h=`_body_qosxz_22`,g=`_row_qosxz_22`,_=`_selected_qosxz_393`,v=`_head_qosxz_23`,y=`_sortable_qosxz_416`,b=`_cell_qosxz_492`,x=`_headContent_qosxz_556`,S=`_sortIcon_qosxz_564`,C=`_asc_qosxz_569`,w=`_desc_qosxz_573`,T=`_noScrollbar_qosxz_576`,E=`_subtleScrollbar_qosxz_584`,D={scope:e,container:t,mobileCard:n,mobileCardMd:r,sticky:i,cardContainer:a,root:o,fullWidth:s,striped:c,bordered:l,hoverable:u,stickyLeft:d,stickyRight:f,stickyHeader:p,selection:m,body:h,row:g,selected:_,head:v,sortable:y,cell:b,headContent:x,sortIcon:S,asc:C,desc:w,noScrollbar:T,subtleScrollbar:E};exports.asc=C,exports.body=h,exports.bordered=l,exports.cardContainer=a,exports.cell=b,exports.container=t,exports.default=D,exports.desc=w,exports.fullWidth=s,exports.head=v,exports.headContent=x,exports.hoverable=u,exports.mobileCard=n,exports.mobileCardMd=r,exports.noScrollbar=T,exports.root=o,exports.row=g,exports.scope=e,exports.selected=_,exports.selection=m,exports.sortIcon=S,exports.sortable=y,exports.sticky=i,exports.stickyHeader=p,exports.stickyLeft=d,exports.stickyRight=f,exports.striped=c,exports.subtleScrollbar=E;
2
+ var e=`_scope_9fctq_6`,t=`_container_9fctq_16`,n=`_mobileCard_9fctq_25`,r=`_mobileCardMd_9fctq_25`,i=`_sticky_9fctq_28`,a=`_cardContainer_9fctq_31`,o=`_root_9fctq_5`,s=`_fullWidth_9fctq_83`,c=`_striped_9fctq_86`,l=`_bordered_9fctq_90`,u=`_hoverable_9fctq_105`,d=`_stickyLeft_9fctq_109`,f=`_stickyRight_9fctq_109`,p=`_stickyHeader_9fctq_112`,m=`_selection_9fctq_238`,h=`_body_9fctq_22`,g=`_row_9fctq_22`,_=`_selected_9fctq_393`,v=`_head_9fctq_23`,y=`_sortable_9fctq_416`,b=`_cell_9fctq_490`,x=`_headContent_9fctq_552`,S=`_sortIcon_9fctq_560`,C=`_asc_9fctq_565`,w=`_desc_9fctq_569`,T=`_noScrollbar_9fctq_572`,E=`_subtleScrollbar_9fctq_580`,D={scope:e,container:t,mobileCard:n,mobileCardMd:r,sticky:i,cardContainer:a,root:o,fullWidth:s,striped:c,bordered:l,hoverable:u,stickyLeft:d,stickyRight:f,stickyHeader:p,selection:m,body:h,row:g,selected:_,head:v,sortable:y,cell:b,headContent:x,sortIcon:S,asc:C,desc:w,noScrollbar:T,subtleScrollbar:E};exports.asc=C,exports.body=h,exports.bordered=l,exports.cardContainer=a,exports.cell=b,exports.container=t,exports.default=D,exports.desc=w,exports.fullWidth=s,exports.head=v,exports.headContent=x,exports.hoverable=u,exports.mobileCard=n,exports.mobileCardMd=r,exports.noScrollbar=T,exports.root=o,exports.row=g,exports.scope=e,exports.selected=_,exports.selection=m,exports.sortIcon=S,exports.sortable=y,exports.sticky=i,exports.stickyHeader=p,exports.stickyLeft=d,exports.stickyRight=f,exports.striped=c,exports.subtleScrollbar=E;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  //#region src/components/data-display/Table/table.module.scss
3
- var e = "_scope_qosxz_6", t = "_container_qosxz_16", n = "_mobileCard_qosxz_25", r = "_mobileCardMd_qosxz_25", i = "_sticky_qosxz_28", a = "_cardContainer_qosxz_31", o = "_root_qosxz_5", s = "_fullWidth_qosxz_83", c = "_striped_qosxz_86", l = "_bordered_qosxz_90", u = "_hoverable_qosxz_105", d = "_stickyLeft_qosxz_109", f = "_stickyRight_qosxz_109", p = "_stickyHeader_qosxz_112", m = "_selection_qosxz_238", h = "_body_qosxz_22", g = "_row_qosxz_22", _ = "_selected_qosxz_393", v = "_head_qosxz_23", y = "_sortable_qosxz_416", b = "_cell_qosxz_492", x = "_headContent_qosxz_556", S = "_sortIcon_qosxz_564", C = "_asc_qosxz_569", w = "_desc_qosxz_573", T = "_noScrollbar_qosxz_576", E = "_subtleScrollbar_qosxz_584", D = {
3
+ var e = "_scope_9fctq_6", t = "_container_9fctq_16", n = "_mobileCard_9fctq_25", r = "_mobileCardMd_9fctq_25", i = "_sticky_9fctq_28", a = "_cardContainer_9fctq_31", o = "_root_9fctq_5", s = "_fullWidth_9fctq_83", c = "_striped_9fctq_86", l = "_bordered_9fctq_90", u = "_hoverable_9fctq_105", d = "_stickyLeft_9fctq_109", f = "_stickyRight_9fctq_109", p = "_stickyHeader_9fctq_112", m = "_selection_9fctq_238", h = "_body_9fctq_22", g = "_row_9fctq_22", _ = "_selected_9fctq_393", v = "_head_9fctq_23", y = "_sortable_9fctq_416", b = "_cell_9fctq_490", x = "_headContent_9fctq_552", S = "_sortIcon_9fctq_560", C = "_asc_9fctq_565", w = "_desc_9fctq_569", T = "_noScrollbar_9fctq_572", E = "_subtleScrollbar_9fctq_580", D = {
4
4
  scope: e,
5
5
  container: t,
6
6
  mobileCard: n,
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),n=require("../../form/Button/Button.cjs"),r=require("../../_internal/FeedbackIcon.cjs"),i=require("../../_internal/FeedbackCloseButton.cjs"),a=require("./snackbar.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=({message:e,open:l=!1,intent:u=`default`,position:d=`bottom-center`,autoHideDuration:f=5e3,showCloseButton:p=!1,actionLabel:m,onAction:h,onClose:g,className:_})=>{let[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)(l);l!==S&&(C(l),l?x(!0):y(!1)),(0,o.useEffect)(()=>{if(l){let e=setTimeout(()=>y(!0),10);return()=>clearTimeout(e)}{let e=setTimeout(()=>x(!1),300);return()=>clearTimeout(e)}},[l]);let w=(0,o.useCallback)(()=>{y(!1),setTimeout(()=>{g&&g()},300)},[g]),[T,E]=(0,o.useState)(f),[D,O]=(0,o.useState)(()=>Date.now()),[k,A]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(l&&f>0&&!k){let e=setTimeout(()=>{w()},T);return O(Date.now()),()=>clearTimeout(e)}},[l,f,w,k,T]);let j=()=>{if(f>0){A(!0);let e=Date.now()-D;E(t=>Math.max(0,t-e))}},M=()=>{f>0&&(O(Date.now()),A(!1))},N=()=>{h&&h()},P=u===`danger`||u===`warning`?`alert`:`status`;return(0,c.jsxs)(`div`,{className:(0,s.default)(a.default.wrapper,a.default[d]),children:[(0,c.jsx)(t.VisuallyHidden,{role:P,"aria-atomic":`true`,children:l?e:``}),(b||l)&&(0,c.jsxs)(`div`,{className:(0,s.default)(`wim-snackbar`,a.default.root,u&&a.default[u],v&&a.default.visible,p&&a.default.hasCloseButton,_),onMouseEnter:j,onMouseLeave:M,onFocus:j,onBlur:M,children:[(0,c.jsxs)(`div`,{className:a.default.content,children:[(u===`success`||u===`warning`||u===`danger`)&&(0,c.jsx)(`div`,{className:a.default.icon,children:(0,c.jsx)(r.FeedbackIcon,{intent:u,size:`sm`})}),(0,c.jsx)(`span`,{className:a.default.message,children:e})]}),(0,c.jsxs)(`div`,{className:a.default.actions,children:[m&&(0,c.jsx)(n.Button,{variant:`ghost`,size:`sm`,onClick:N,className:a.default.actionButton,children:m}),(0,c.jsx)(i.FeedbackCloseButton,{onClose:p?w:void 0,className:a.default.closeButton,size:`sm`})]})]})]})},u=(0,o.createContext)(void 0),d=({children:e})=>{let[t,n]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),a=(0,o.useCallback)(e=>{let r=Math.random().toString(36).substr(2,9),a=typeof e==`string`?{message:e}:e;i(!1),setTimeout(()=>{n({...a,id:r}),i(!0)},t?300:0)},[t]),s=(0,o.useCallback)(()=>{i(!1)},[]);return(0,c.jsxs)(u.Provider,{value:{showMessage:a,hideMessage:s},children:[e,(0,c.jsx)(l,{message:``,...t,open:r&&t!==null,onClose:()=>{i(!1),t?.onClose&&t.onClose()}})]})},f=()=>{let e=(0,o.useContext)(u);if(!e)throw Error(`useSnackbar must be used within a SnackbarProvider`);return e};exports.Snackbar=l,exports.SnackbarProvider=d,exports.useSnackbar=f;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../form/Button/Button.cjs"),n=require("../../_internal/useAnnounce.cjs"),r=require("../../_internal/FeedbackIcon.cjs"),i=require("../../_internal/FeedbackCloseButton.cjs"),a=require("./snackbar.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=({message:e,open:l=!1,intent:u=`default`,position:d=`bottom-center`,autoHideDuration:f=5e3,showCloseButton:p=!1,actionLabel:m,onAction:h,onClose:g,className:_})=>{let[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)(l);l!==S&&(C(l),l?x(!0):y(!1)),(0,o.useEffect)(()=>{if(l){let e=setTimeout(()=>y(!0),10);return()=>clearTimeout(e)}{let e=setTimeout(()=>x(!1),300);return()=>clearTimeout(e)}},[l]);let w=(0,o.useCallback)(()=>{y(!1),setTimeout(()=>{g&&g()},300)},[g]),[T,E]=(0,o.useState)(f),[D,O]=(0,o.useState)(()=>Date.now()),[k,A]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(l&&f>0&&!k){let e=setTimeout(()=>{w()},T);return O(Date.now()),()=>clearTimeout(e)}},[l,f,w,k,T]);let j=()=>{if(f>0){A(!0);let e=Date.now()-D;E(t=>Math.max(0,t-e))}},M=()=>{f>0&&(O(Date.now()),A(!1))},N=()=>{h&&h()},P=n.useAnnounceValue(l?e:``,{role:u===`danger`||u===`warning`?`alert`:`status`,initial:!0});return(0,c.jsxs)(`div`,{className:(0,s.default)(a.default.wrapper,a.default[d]),children:[P,(b||l)&&(0,c.jsxs)(`div`,{className:(0,s.default)(`wim-snackbar`,a.default.root,u&&a.default[u],v&&a.default.visible,p&&a.default.hasCloseButton,_),onMouseEnter:j,onMouseLeave:M,onFocus:j,onBlur:M,children:[(0,c.jsxs)(`div`,{className:a.default.content,children:[(u===`success`||u===`warning`||u===`danger`)&&(0,c.jsx)(`div`,{className:a.default.icon,children:(0,c.jsx)(r.FeedbackIcon,{intent:u,size:`sm`})}),(0,c.jsx)(`span`,{className:a.default.message,children:e})]}),(0,c.jsxs)(`div`,{className:a.default.actions,children:[m&&(0,c.jsx)(t.Button,{variant:`ghost`,size:`sm`,onClick:N,className:a.default.actionButton,children:m}),(0,c.jsx)(i.FeedbackCloseButton,{onClose:p?w:void 0,className:a.default.closeButton,size:`sm`})]})]})]})},u=(0,o.createContext)(void 0),d=({children:e})=>{let[t,n]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),a=(0,o.useCallback)(e=>{let r=Math.random().toString(36).substr(2,9),a=typeof e==`string`?{message:e}:e;i(!1),setTimeout(()=>{n({...a,id:r}),i(!0)},t?300:0)},[t]),s=(0,o.useCallback)(()=>{i(!1)},[]);return(0,c.jsxs)(u.Provider,{value:{showMessage:a,hideMessage:s},children:[e,(0,c.jsx)(l,{message:``,...t,open:r&&t!==null,onClose:()=>{i(!1),t?.onClose&&t.onClose()}})]})},f=()=>{let e=(0,o.useContext)(u);if(!e)throw Error(`useSnackbar must be used within a SnackbarProvider`);return e};exports.Snackbar=l,exports.SnackbarProvider=d,exports.useSnackbar=f;