wimui 0.64.3 → 0.64.4

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.
@@ -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("../../form/Checkbox/Checkbox.cjs"),i=require("../../navigation/Pagination/Pagination.cjs"),a=require("../Table/Table.cjs"),o=require("./useFixedColumns.cjs"),s=require("./useDataGridKeyboard.cjs"),c=require("./useInfiniteScroll.cjs"),l=require("./datagrid.module.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");function p({columns:e,data:p,rowKey:m=`id`,loading:h=!1,striped:g=!1,bordered:_=!1,hoverable:v=!0,stickyHeader:y=!0,height:b,maxHeight:x,emptyMessage:S,mobileCard:C=!1,selection:w,selectedRowKeys:T,onSelectionChange:E,sortConfig:D,onSortChange:O,pagination:k,infiniteScroll:A,className:j,ariaLabel:M,"aria-label":N,"aria-labelledby":P}){let{t:F}=t.useWimTranslation(n.commonNs),I=h!==!1&&h!==void 0,L=h===!0||h===`blocking`,R=(0,u.useMemo)(()=>w?w===!0?{type:`checkbox`,selectedRowKeys:T??[],onChange:(e,t)=>{E?.(e,t)}}:w:null,[w,T,E]),{fixedLeftOffsets:z,fixedRightOffsets:B}=o.useFixedColumns(e,!!R),V=(e,t=!1)=>{let n=z[e];if(n)return{stickyLeft:!0,leftOffset:n.offset,stickyZIndex:t?1e3+n.zIndex:n.zIndex,className:(0,d.default)(l.default.cellFixed,n.isLast&&l.default.cellFixedLeftLast)};let r=B[e];return r?{stickyRight:!0,rightOffset:r.offset,stickyZIndex:t?1e3+r.zIndex:r.zIndex,className:(0,d.default)(l.default.cellFixed,r.isFirst&&l.default.cellFixedRightFirst)}:{}},H=(0,u.useCallback)(e=>typeof m==`function`?m(e):e[m],[m]),U=(0,u.useMemo)(()=>!R||p.length===0?!1:p.every(e=>R.selectedRowKeys.includes(H(e))),[p,R,H]),W=(0,u.useMemo)(()=>R?!U&&p.some(e=>R.selectedRowKeys.includes(H(e))):!1,[p,R,U,H]),G=e=>{if(!R)return;let t=e.target.checked,n=t?p.map(H):[],r=t?p:[];R.onChange(n,r)},K=(e,t)=>{if(!R)return;let n=t.target.checked,r=H(e),i=n?[...R.selectedRowKeys,r]:R.selectedRowKeys.filter(e=>e!==r),a=p.filter(e=>i.includes(H(e)));R.onChange(i,a)},{focusedCell:q,handleKeyDown:J,containerRef:Y}=s.useDataGridKeyboard(e,p,!!R),{loaderRef:X}=c.useInfiniteScroll(A),Z=e.length+ +!!R;return(0,f.jsxs)(`div`,{className:(0,d.default)(`wim-data-grid`,l.default.root,L&&l.default.loading,C===`md`?l.default.mobileCardMd:C&&l.default.mobileCard,j),"aria-busy":I||void 0,children:[(0,f.jsxs)(`div`,{className:l.default.container,style:{height:b,maxHeight:x},inert:L||void 0,children:[(0,f.jsxs)(a.Table,{ref:Y,onKeyDown:J,tabIndex:0,role:`grid`,"aria-label":P?void 0:N??M??F(`a11y.data_grid`),"aria-labelledby":P,"aria-rowcount":p.length+1,"aria-colcount":Z,striped:g,bordered:_,hoverable:v,stickyHeader:y,mobileCard:C,fullWidth:!0,className:(0,d.default)(`wim-table`,l.default.table),containerClassName:l.default.tableContainer,children:[(0,f.jsx)(a.Table.Header,{children:(0,f.jsxs)(a.Table.Row,{children:[R&&(0,f.jsx)(a.Table.Head,{role:`columnheader`,selection:!0,stickyLeft:!0,leftOffset:0,stickyZIndex:1150,"data-row":-1,"data-col":-1,"aria-label":F(`a11y.select_all_rows`),tabIndex:q.row===-1&&q.col===-1?0:-1,children:(R.type??`checkbox`)===`checkbox`&&(0,f.jsx)(r.Checkbox,{checked:U,indeterminate:W,onChange:G,"aria-label":F(`a11y.select_all_rows`)})}),e.map((e,t)=>{let n=V(e.key,!0);return(0,f.jsx)(a.Table.Head,{role:`columnheader`,style:{width:e.width,minWidth:e.width},sortable:!!(e.sortable&&O),sortDirection:D?.key===e.key?D.direction:`none`,onSort:()=>{if(!e.sortable||!O)return;let t=D?.key===e.key?D.direction===`asc`?`desc`:D.direction===`desc`?`none`:`asc`:`asc`;O(e.key,t)},...n,tabIndex:q.row===-1&&q.col===(R?t+1:t)?0:-1,"data-row":-1,"data-col":R?t+1:t,children:e.title},e.key)})]})}),(0,f.jsx)(a.Table.Body,{children:p.map((t,n)=>{let i=H(t),o=R?.selectedRowKeys.includes(i);return(0,f.jsxs)(a.Table.Row,{selected:o,children:[R&&(0,f.jsx)(a.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,f.jsx)(r.Checkbox,{checked:o,onChange:e=>K(t,e),"aria-label":F(`a11y.select_row`)})}),e.map((e,r)=>{let i=V(e.key,!1),o=t[e.dataIndex??e.key];return(0,f.jsx)(a.Table.Cell,{role:`gridcell`,label:typeof e.title==`string`?e.title:void 0,...i,"data-row":n,"data-col":R?r+1:r,tabIndex:q.row===n&&q.col===(R?r+1:r)?0:-1,children:e.maxWidth==null?e.render?e.render(o,t,n):o:(0,f.jsx)(`div`,{style:{maxWidth:e.maxWidth},children:e.render?e.render(o,t,n):o})},e.key)})]},i)})})]}),p.length===0&&S&&(0,f.jsx)(`div`,{role:`status`,className:l.default.empty,children:S}),A?.hasMore&&(0,f.jsx)(`div`,{ref:X,className:l.default.loader,children:A.hasMore&&F(`dataGrid.loading_more`)})]}),k&&(0,f.jsxs)(`div`,{className:l.default.footer,inert:L||void 0,children:[(0,f.jsxs)(`div`,{className:l.default.info,children:[F(`dataGrid.displaying`,{shown:p.length,total:k.total}),R?.selectedRowKeys&&R.selectedRowKeys.length>0&&(0,f.jsx)(`span`,{className:l.default.selectionInfo,children:F(`dataGrid.rows_selected`,{selected:R.selectedRowKeys.length})})]}),(0,f.jsx)(`div`,{className:l.default.pagination,children:(0,f.jsx)(i.Pagination,{className:l.default.paginationContent,current:k.current,total:k.total,pageSize:k.pageSize,onChange:k.onChange})})]})]})}exports.DataGrid=p;
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;
@@ -1,197 +1,206 @@
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 { Checkbox as n } from "../../form/Checkbox/Checkbox.js";
5
- import { Pagination as r } from "../../navigation/Pagination/Pagination.js";
6
- import { Table as i } from "../Table/Table.js";
7
- import { useFixedColumns as a } from "./useFixedColumns.js";
8
- import { useDataGridKeyboard as o } from "./useDataGridKeyboard.js";
9
- import { useInfiniteScroll as s } from "./useInfiniteScroll.js";
10
- import c from "./datagrid.module.js";
11
- import { useCallback as l, useMemo as u } from "react";
12
- import d from "classnames";
13
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
4
+ import { VisuallyHidden as n } from "../../layout/VisuallyHidden/VisuallyHidden.js";
5
+ import { Checkbox as r } from "../../form/Checkbox/Checkbox.js";
6
+ import { Pagination as i } from "../../navigation/Pagination/Pagination.js";
7
+ import { Table as a } from "../Table/Table.js";
8
+ import { useFixedColumns as o } from "./useFixedColumns.js";
9
+ import { useDataGridKeyboard as s } from "./useDataGridKeyboard.js";
10
+ import { useInfiniteScroll as c } from "./useInfiniteScroll.js";
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";
14
15
  //#region src/components/data-display/DataGrid/DataGrid.tsx
15
- function m({ columns: m, data: h, rowKey: g = "id", loading: _ = !1, striped: v = !1, bordered: y = !1, hoverable: b = !0, stickyHeader: x = !0, height: S, maxHeight: C, emptyMessage: w, mobileCard: T = !1, selection: E, selectedRowKeys: D, onSelectionChange: O, sortConfig: k, onSortChange: A, pagination: j, infiniteScroll: M, className: N, ariaLabel: P, "aria-label": F, "aria-labelledby": I }) {
16
- let { t: L } = e(t), R = _ !== !1 && _ !== void 0, z = _ === !0 || _ === "blocking", B = u(() => E ? E === !0 ? {
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 ? {
17
18
  type: "checkbox",
18
- selectedRowKeys: D ?? [],
19
+ selectedRowKeys: k ?? [],
19
20
  onChange: (e, t) => {
20
- O?.(e, t);
21
+ A?.(e, t);
21
22
  }
22
- } : E : null, [
23
- E,
24
- D,
25
- O
26
- ]), { fixedLeftOffsets: V, fixedRightOffsets: H } = a(m, !!B), U = (e, t = !1) => {
27
- let n = V[e];
23
+ } : O : null, [
24
+ O,
25
+ k,
26
+ A
27
+ ]), { fixedLeftOffsets: U, fixedRightOffsets: W } = o(g, !!H), G = (e, t = !1) => {
28
+ let n = U[e];
28
29
  if (n) return {
29
30
  stickyLeft: !0,
30
31
  leftOffset: n.offset,
31
32
  stickyZIndex: t ? 1e3 + n.zIndex : n.zIndex,
32
- className: d(c.cellFixed, n.isLast && c.cellFixedLeftLast)
33
+ className: p(l.cellFixed, n.isLast && l.cellFixedLeftLast)
33
34
  };
34
- let r = H[e];
35
+ let r = W[e];
35
36
  return r ? {
36
37
  stickyRight: !0,
37
38
  rightOffset: r.offset,
38
39
  stickyZIndex: t ? 1e3 + r.zIndex : r.zIndex,
39
- className: d(c.cellFixed, r.isFirst && c.cellFixedRightFirst)
40
+ className: p(l.cellFixed, r.isFirst && l.cellFixedRightFirst)
40
41
  } : {};
41
- }, W = l((e) => typeof g == "function" ? g(e) : e[g], [g]), G = u(() => !B || h.length === 0 ? !1 : h.every((e) => B.selectedRowKeys.includes(W(e))), [
42
- h,
43
- B,
44
- W
45
- ]), K = u(() => B ? !G && h.some((e) => B.selectedRowKeys.includes(W(e))) : !1, [
46
- h,
47
- B,
48
- G,
49
- W
50
- ]), q = (e) => {
51
- if (!B) return;
52
- let t = e.target.checked, n = t ? h.map(W) : [], r = t ? h : [];
53
- B.onChange(n, r);
54
- }, J = (e, t) => {
55
- if (!B) return;
56
- let n = t.target.checked, r = W(e), i = n ? [...B.selectedRowKeys, r] : B.selectedRowKeys.filter((e) => e !== r), a = h.filter((e) => i.includes(W(e)));
57
- B.onChange(i, a);
58
- }, { focusedCell: Y, handleKeyDown: X, containerRef: Z } = o(m, h, !!B), { loaderRef: Q } = s(M), $ = m.length + +!!B;
59
- return /* @__PURE__ */ p("div", {
60
- className: d("wim-data-grid", c.root, z && c.loading, T === "md" ? c.mobileCardMd : T && c.mobileCard, N),
61
- "aria-busy": R || void 0,
62
- children: [/* @__PURE__ */ p("div", {
63
- className: c.container,
64
- style: {
65
- height: S,
66
- maxHeight: C
67
- },
68
- inert: z || void 0,
69
- children: [
70
- /* @__PURE__ */ p(i, {
71
- ref: Z,
72
- onKeyDown: X,
73
- tabIndex: 0,
74
- role: "grid",
75
- "aria-label": I ? void 0 : F ?? P ?? L("a11y.data_grid"),
76
- "aria-labelledby": I,
77
- "aria-rowcount": h.length + 1,
78
- "aria-colcount": $,
79
- striped: v,
80
- bordered: y,
81
- hoverable: b,
82
- stickyHeader: x,
83
- mobileCard: T,
84
- fullWidth: !0,
85
- className: d("wim-table", c.table),
86
- containerClassName: c.tableContainer,
87
- children: [/* @__PURE__ */ f(i.Header, { children: /* @__PURE__ */ p(i.Row, { children: [B && /* @__PURE__ */ f(i.Head, {
88
- role: "columnheader",
89
- selection: !0,
90
- stickyLeft: !0,
91
- leftOffset: 0,
92
- stickyZIndex: 1150,
93
- "data-row": -1,
94
- "data-col": -1,
95
- "aria-label": L("a11y.select_all_rows"),
96
- tabIndex: Y.row === -1 && Y.col === -1 ? 0 : -1,
97
- children: (B.type ?? "checkbox") === "checkbox" && /* @__PURE__ */ f(n, {
98
- checked: G,
99
- indeterminate: K,
100
- onChange: q,
101
- "aria-label": L("a11y.select_all_rows")
102
- })
103
- }), m.map((e, t) => {
104
- let n = U(e.key, !0);
105
- return /* @__PURE__ */ f(i.Head, {
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
+ _,
44
+ H,
45
+ K
46
+ ]), J = d(() => H ? !q && _.some((e) => H.selectedRowKeys.includes(K(e))) : !1, [
47
+ _,
48
+ H,
49
+ q,
50
+ K
51
+ ]), Y = (e) => {
52
+ if (!H) return;
53
+ let t = e.target.checked, n = t ? _.map(K) : [], r = t ? _ : [];
54
+ H.onChange(n, r);
55
+ }, X = (e, t) => {
56
+ 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)));
58
+ 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),
62
+ "aria-busy": B || void 0,
63
+ children: [
64
+ /* @__PURE__ */ m(n, {
65
+ role: "status",
66
+ "aria-atomic": "true",
67
+ children: ne
68
+ }),
69
+ /* @__PURE__ */ h("div", {
70
+ className: l.container,
71
+ style: {
72
+ height: w,
73
+ maxHeight: T
74
+ },
75
+ inert: V || void 0,
76
+ children: [
77
+ /* @__PURE__ */ h(a, {
78
+ ref: $,
79
+ onKeyDown: Q,
80
+ tabIndex: 0,
81
+ role: "grid",
82
+ "aria-label": R ? void 0 : L ?? I ?? z("a11y.data_grid"),
83
+ "aria-labelledby": R,
84
+ "aria-rowcount": _.length + 1,
85
+ "aria-colcount": te,
86
+ striped: b,
87
+ bordered: x,
88
+ hoverable: S,
89
+ stickyHeader: C,
90
+ mobileCard: D,
91
+ fullWidth: !0,
92
+ className: p("wim-table", l.table),
93
+ containerClassName: l.tableContainer,
94
+ children: [/* @__PURE__ */ m(a.Header, { children: /* @__PURE__ */ h(a.Row, { children: [H && /* @__PURE__ */ m(a.Head, {
106
95
  role: "columnheader",
107
- style: {
108
- width: e.width,
109
- minWidth: e.width
110
- },
111
- sortable: !!(e.sortable && A),
112
- sortDirection: k?.key === e.key ? k.direction : "none",
113
- onSort: () => {
114
- if (!e.sortable || !A) return;
115
- let t = k?.key === e.key ? k.direction === "asc" ? "desc" : k.direction === "desc" ? "none" : "asc" : "asc";
116
- A(e.key, t);
117
- },
118
- ...n,
119
- tabIndex: Y.row === -1 && Y.col === (B ? t + 1 : t) ? 0 : -1,
96
+ selection: !0,
97
+ stickyLeft: !0,
98
+ leftOffset: 0,
99
+ stickyZIndex: 1150,
120
100
  "data-row": -1,
121
- "data-col": B ? t + 1 : t,
122
- children: e.title
123
- }, e.key);
124
- })] }) }), /* @__PURE__ */ f(i.Body, { children: h.map((e, t) => {
125
- let r = W(e), a = B?.selectedRowKeys.includes(r);
126
- return /* @__PURE__ */ p(i.Row, {
127
- selected: a,
128
- children: [B && /* @__PURE__ */ f(i.Cell, {
129
- role: "gridcell",
130
- selection: !0,
131
- stickyLeft: !0,
132
- leftOffset: 0,
133
- stickyZIndex: 150,
134
- "data-row": t,
135
- "data-col": -1,
136
- tabIndex: Y.row === t && Y.col === -1 ? 0 : -1,
137
- children: /* @__PURE__ */ f(n, {
138
- checked: a,
139
- onChange: (t) => J(e, t),
140
- "aria-label": L("a11y.select_row")
141
- })
142
- }), m.map((n, r) => {
143
- let a = U(n.key, !1), o = e[n.dataIndex ?? n.key];
144
- return /* @__PURE__ */ f(i.Cell, {
101
+ "data-col": -1,
102
+ "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,
108
+ "aria-label": z("a11y.select_all_rows")
109
+ })
110
+ }), g.map((e, t) => {
111
+ let n = G(e.key, !0);
112
+ return /* @__PURE__ */ m(a.Head, {
113
+ role: "columnheader",
114
+ style: {
115
+ width: e.width,
116
+ minWidth: e.width
117
+ },
118
+ sortable: !!(e.sortable && M),
119
+ sortDirection: j?.key === e.key ? j.direction : "none",
120
+ onSort: () => {
121
+ if (!e.sortable || !M) return;
122
+ 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);
124
+ },
125
+ ...n,
126
+ tabIndex: Z.row === -1 && Z.col === (H ? t + 1 : t) ? 0 : -1,
127
+ "data-row": -1,
128
+ "data-col": H ? t + 1 : t,
129
+ children: e.title
130
+ }, 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, {
134
+ selected: i,
135
+ children: [H && /* @__PURE__ */ m(a.Cell, {
145
136
  role: "gridcell",
146
- label: typeof n.title == "string" ? n.title : void 0,
147
- ...a,
137
+ selection: !0,
138
+ stickyLeft: !0,
139
+ leftOffset: 0,
140
+ stickyZIndex: 150,
148
141
  "data-row": t,
149
- "data-col": B ? r + 1 : r,
150
- tabIndex: Y.row === t && Y.col === (B ? r + 1 : r) ? 0 : -1,
151
- children: n.maxWidth == null ? n.render ? n.render(o, e, t) : o : /* @__PURE__ */ f("div", {
152
- style: { maxWidth: n.maxWidth },
153
- children: n.render ? n.render(o, e, t) : o
142
+ "data-col": -1,
143
+ tabIndex: Z.row === t && Z.col === -1 ? 0 : -1,
144
+ children: /* @__PURE__ */ m(r, {
145
+ checked: i,
146
+ onChange: (t) => X(e, t),
147
+ "aria-label": z("a11y.select_row_numbered", { row: t + 1 })
154
148
  })
155
- }, n.key);
156
- })]
157
- }, r);
158
- }) })]
159
- }),
160
- h.length === 0 && w && /* @__PURE__ */ f("div", {
161
- role: "status",
162
- className: c.empty,
163
- children: w
164
- }),
165
- M?.hasMore && /* @__PURE__ */ f("div", {
166
- ref: Q,
167
- className: c.loader,
168
- children: M.hasMore && L("dataGrid.loading_more")
169
- })
170
- ]
171
- }), j && /* @__PURE__ */ p("div", {
172
- className: c.footer,
173
- inert: z || void 0,
174
- children: [/* @__PURE__ */ p("div", {
175
- className: c.info,
176
- children: [L("dataGrid.displaying", {
177
- shown: h.length,
178
- total: j.total
179
- }), B?.selectedRowKeys && B.selectedRowKeys.length > 0 && /* @__PURE__ */ f("span", {
180
- className: c.selectionInfo,
181
- children: L("dataGrid.rows_selected", { selected: B.selectedRowKeys.length })
149
+ }), g.map((n, r) => {
150
+ let i = G(n.key, !1), o = e[n.dataIndex ?? n.key];
151
+ return /* @__PURE__ */ m(a.Cell, {
152
+ role: "gridcell",
153
+ label: typeof n.title == "string" ? n.title : void 0,
154
+ ...i,
155
+ "data-row": t,
156
+ "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", {
159
+ style: { maxWidth: n.maxWidth },
160
+ children: n.render ? n.render(o, e, t) : o
161
+ })
162
+ }, n.key);
163
+ })]
164
+ }, n);
165
+ }) })]
166
+ }),
167
+ _.length === 0 && E && /* @__PURE__ */ m("div", {
168
+ role: "status",
169
+ className: l.empty,
170
+ children: E
171
+ }),
172
+ P?.hasMore && /* @__PURE__ */ m("div", {
173
+ ref: ee,
174
+ className: l.loader,
175
+ children: P.hasMore && z("dataGrid.loading_more")
176
+ })
177
+ ]
178
+ }),
179
+ N && /* @__PURE__ */ h("div", {
180
+ className: l.footer,
181
+ inert: V || void 0,
182
+ children: [/* @__PURE__ */ h("div", {
183
+ className: l.info,
184
+ children: [z("dataGrid.displaying", {
185
+ shown: _.length,
186
+ total: N.total
187
+ }), H?.selectedRowKeys && H.selectedRowKeys.length > 0 && /* @__PURE__ */ m("span", {
188
+ className: l.selectionInfo,
189
+ children: z("dataGrid.rows_selected", { selected: H.selectedRowKeys.length })
190
+ })]
191
+ }), /* @__PURE__ */ m("div", {
192
+ className: l.pagination,
193
+ children: /* @__PURE__ */ m(i, {
194
+ className: l.paginationContent,
195
+ current: N.current,
196
+ total: N.total,
197
+ pageSize: N.pageSize,
198
+ onChange: N.onChange
199
+ })
182
200
  })]
183
- }), /* @__PURE__ */ f("div", {
184
- className: c.pagination,
185
- children: /* @__PURE__ */ f(r, {
186
- className: c.paginationContent,
187
- current: j.current,
188
- total: j.total,
189
- pageSize: j.pageSize,
190
- onChange: j.onChange
191
- })
192
- })]
193
- })]
201
+ })
202
+ ]
194
203
  });
195
204
  }
196
205
  //#endregion
197
- export { m as DataGrid };
206
+ export { g as DataGrid };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),r=require("../Button/Button.cjs"),i=require("../../../i18n/generated/form.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("./file-upload.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=({label:e,buttonLabel:u,noFileLabel:d,accept:f,multiple:p=!1,disabled:m=!1,value:h,onChange:g,className:_,iconName:v,iconPosition:y,size:b=`md`,error:x,required:S,layout:C=`vertical`,"aria-label":w,"aria-labelledby":T,"aria-describedby":E})=>{let{t:D}=t.useWimTranslation(i.formNs),O=`wim-fileupload-${s.default.useId()}`,k=e?`${O}-label`:void 0,A=x?`${O}-error`:void 0,j=S?`${O}-required`:void 0,M=[E,A,j].filter(Boolean).join(` `)||void 0,N=(0,s.useRef)(null),[P,F]=(0,s.useState)(null),I=()=>{N.current?.click()},L=e=>{let t=e.target.files;F(t),g&&g(t)},R=h===void 0?P?Array.from(P).map(e=>e.name):[]:h,z=R.length>0?R.join(`, `):d??D(`fileupload.no_file`);return(0,l.jsx)(a.FieldTemplate,{label:e,error:x,required:S,layout:C,labelId:k,errorId:A,className:(0,c.default)(`wim-file-upload`,o.default.root,o.default[b],_),children:(0,l.jsxs)(`div`,{className:o.default.controls,children:[(0,l.jsx)(`input`,{type:`file`,ref:N,accept:f,multiple:p,disabled:m,onChange:L,className:o.default.input,"aria-hidden":`true`,tabIndex:-1}),(0,l.jsx)(r.Button,{onClick:I,disabled:m,variant:`outline`,icon:v,iconPosition:y,size:b,"aria-labelledby":k??T,"aria-label":k||T?void 0:w,"aria-describedby":M,"aria-invalid":x?!0:void 0,children:u??D(`fileupload.button`)}),S&&(0,l.jsx)(n.VisuallyHidden,{id:j,children:D(`form.required`)}),(0,l.jsx)(`span`,{className:(0,c.default)(o.default.fileNames,o.default[b],m&&o.default.disabled),"aria-disabled":m||void 0,children:z})]})})};exports.FileUpload=u;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),r=require("../Button/Button.cjs"),i=require("../../../i18n/generated/form.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("./file-upload.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=({label:e,buttonLabel:u,noFileLabel:d,accept:f,multiple:p=!1,disabled:m=!1,value:h,onChange:g,className:_,iconName:v,iconPosition:y,size:b=`md`,error:x,required:S,layout:C=`vertical`,"aria-label":w,"aria-labelledby":T,"aria-describedby":E})=>{let{t:D}=t.useWimTranslation(i.formNs),O=`wim-fileupload-${s.default.useId()}`,k=e?`${O}-label`:void 0,A=x?`${O}-error`:void 0,j=S?`${O}-required`:void 0,M=`${O}-files`,N=[E,M,A,j].filter(Boolean).join(` `),P=(0,s.useRef)(null),[F,I]=(0,s.useState)(null),[L,R]=(0,s.useState)(``),z=(0,s.useRef)(void 0);(0,s.useEffect)(()=>()=>clearTimeout(z.current),[]);let B=()=>{P.current?.click()},V=e=>{let t=e.target.files;if(I(t),clearTimeout(z.current),R(``),t&&t.length>0){let e=Array.from(t).map(e=>e.name).join(`, `);z.current=setTimeout(()=>R(D(`fileupload.selected`,{files:e})),700)}g&&g(t)},H=h===void 0?F?Array.from(F).map(e=>e.name):[]:h,U=H.length>0?H.join(`, `):d??D(`fileupload.no_file`);return(0,l.jsx)(a.FieldTemplate,{label:e,error:x,required:S,layout:C,labelId:k,errorId:A,className:(0,c.default)(`wim-file-upload`,o.default.root,o.default[b],_),children:(0,l.jsxs)(`div`,{className:o.default.controls,children:[(0,l.jsx)(`input`,{type:`file`,ref:P,accept:f,multiple:p,disabled:m,onChange:V,className:o.default.input,"aria-hidden":`true`,tabIndex:-1}),(0,l.jsx)(r.Button,{onClick:B,disabled:m,variant:`outline`,icon:v,iconPosition:y,size:b,"aria-labelledby":k??T,"aria-label":k||T?void 0:w,"aria-describedby":N,"aria-invalid":x?!0:void 0,children:u??D(`fileupload.button`)}),S&&(0,l.jsx)(n.VisuallyHidden,{id:j,children:D(`form.required`)}),(0,l.jsx)(n.VisuallyHidden,{role:`status`,"aria-atomic":`true`,children:L}),(0,l.jsx)(`span`,{id:M,className:(0,c.default)(o.default.fileNames,o.default[b],m&&o.default.disabled),"aria-disabled":m||void 0,children:U})]})})};exports.FileUpload=u;
@@ -5,68 +5,81 @@ import { Button as n } from "../Button/Button.js";
5
5
  import { formNs as r } from "../../../i18n/generated/form.js";
6
6
  import { FieldTemplate as i } from "../FieldTemplate/FieldTemplate.js";
7
7
  import a from "./file-upload.module.js";
8
- import o, { useRef as s, useState as c } from "react";
9
- import l from "classnames";
10
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
8
+ import o, { useEffect as s, useRef as c, useState as l } from "react";
9
+ import u from "classnames";
10
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
11
11
  //#region src/components/form/FileUpload/FileUpload.tsx
12
- var f = ({ label: f, buttonLabel: p, noFileLabel: m, accept: h, multiple: g = !1, disabled: _ = !1, value: v, onChange: y, className: b, iconName: x, iconPosition: S, size: C = "md", error: w, required: T, layout: E = "vertical", "aria-label": D, "aria-labelledby": O, "aria-describedby": k }) => {
13
- let { t: A } = e(r), j = `wim-fileupload-${o.useId()}`, M = f ? `${j}-label` : void 0, N = w ? `${j}-error` : void 0, P = T ? `${j}-required` : void 0, F = [
14
- k,
15
- N,
16
- P
17
- ].filter(Boolean).join(" ") || void 0, I = s(null), [L, R] = c(null), z = () => {
18
- I.current?.click();
19
- }, B = (e) => {
12
+ var p = ({ label: p, buttonLabel: m, noFileLabel: h, accept: g, multiple: _ = !1, disabled: v = !1, value: y, onChange: b, className: x, iconName: S, iconPosition: C, size: w = "md", error: T, required: E, layout: D = "vertical", "aria-label": O, "aria-labelledby": k, "aria-describedby": A }) => {
13
+ let { t: j } = e(r), M = `wim-fileupload-${o.useId()}`, N = p ? `${M}-label` : void 0, P = T ? `${M}-error` : void 0, F = E ? `${M}-required` : void 0, I = `${M}-files`, L = [
14
+ A,
15
+ I,
16
+ P,
17
+ F
18
+ ].filter(Boolean).join(" "), R = c(null), [z, B] = l(null), [V, H] = l(""), U = c(void 0);
19
+ s(() => () => clearTimeout(U.current), []);
20
+ let W = () => {
21
+ R.current?.click();
22
+ }, G = (e) => {
20
23
  let t = e.target.files;
21
- R(t), y && y(t);
22
- }, V = v === void 0 ? L ? Array.from(L).map((e) => e.name) : [] : v, H = V.length > 0 ? V.join(", ") : m ?? A("fileupload.no_file");
23
- return /* @__PURE__ */ u(i, {
24
- label: f,
25
- error: w,
26
- required: T,
27
- layout: E,
28
- labelId: M,
29
- errorId: N,
30
- className: l("wim-file-upload", a.root, a[C], b),
31
- children: /* @__PURE__ */ d("div", {
24
+ if (B(t), clearTimeout(U.current), H(""), t && t.length > 0) {
25
+ let e = Array.from(t).map((e) => e.name).join(", ");
26
+ U.current = setTimeout(() => H(j("fileupload.selected", { files: e })), 700);
27
+ }
28
+ b && b(t);
29
+ }, K = y === void 0 ? z ? Array.from(z).map((e) => e.name) : [] : y, q = K.length > 0 ? K.join(", ") : h ?? j("fileupload.no_file");
30
+ return /* @__PURE__ */ d(i, {
31
+ label: p,
32
+ error: T,
33
+ required: E,
34
+ layout: D,
35
+ labelId: N,
36
+ errorId: P,
37
+ className: u("wim-file-upload", a.root, a[w], x),
38
+ children: /* @__PURE__ */ f("div", {
32
39
  className: a.controls,
33
40
  children: [
34
- /* @__PURE__ */ u("input", {
41
+ /* @__PURE__ */ d("input", {
35
42
  type: "file",
36
- ref: I,
37
- accept: h,
38
- multiple: g,
39
- disabled: _,
40
- onChange: B,
43
+ ref: R,
44
+ accept: g,
45
+ multiple: _,
46
+ disabled: v,
47
+ onChange: G,
41
48
  className: a.input,
42
49
  "aria-hidden": "true",
43
50
  tabIndex: -1
44
51
  }),
45
- /* @__PURE__ */ u(n, {
46
- onClick: z,
47
- disabled: _,
52
+ /* @__PURE__ */ d(n, {
53
+ onClick: W,
54
+ disabled: v,
48
55
  variant: "outline",
49
- icon: x,
50
- iconPosition: S,
51
- size: C,
52
- "aria-labelledby": M ?? O,
53
- "aria-label": M || O ? void 0 : D,
54
- "aria-describedby": F,
55
- "aria-invalid": w ? !0 : void 0,
56
- children: p ?? A("fileupload.button")
56
+ icon: S,
57
+ iconPosition: C,
58
+ size: w,
59
+ "aria-labelledby": N ?? k,
60
+ "aria-label": N || k ? void 0 : O,
61
+ "aria-describedby": L,
62
+ "aria-invalid": T ? !0 : void 0,
63
+ children: m ?? j("fileupload.button")
57
64
  }),
58
- T && /* @__PURE__ */ u(t, {
59
- id: P,
60
- children: A("form.required")
65
+ E && /* @__PURE__ */ d(t, {
66
+ id: F,
67
+ children: j("form.required")
61
68
  }),
62
- /* @__PURE__ */ u("span", {
63
- className: l(a.fileNames, a[C], _ && a.disabled),
64
- "aria-disabled": _ || void 0,
65
- children: H
69
+ /* @__PURE__ */ d(t, {
70
+ role: "status",
71
+ "aria-atomic": "true",
72
+ children: V
73
+ }),
74
+ /* @__PURE__ */ d("span", {
75
+ id: I,
76
+ className: u(a.fileNames, a[w], v && a.disabled),
77
+ "aria-disabled": v || void 0,
78
+ children: q
66
79
  })
67
80
  ]
68
81
  })
69
82
  });
70
83
  };
71
84
  //#endregion
72
- export { f as FileUpload };
85
+ export { p as FileUpload };