wimui 0.78.0 → 0.79.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.
- package/README.ja.md +2 -2
- package/README.md +2 -2
- package/dist/components/ai/InteractiveGraph/InteractiveGraph.cjs +1 -1
- package/dist/components/ai/InteractiveGraph/InteractiveGraph.js +22 -37
- package/dist/components/ai/InteractiveGraph/interactive-graph.module.cjs +1 -1
- package/dist/components/ai/InteractiveGraph/interactive-graph.module.js +1 -1
- package/dist/components/data-display/DataGrid/DataGrid.cjs +1 -1
- package/dist/components/data-display/DataGrid/DataGrid.js +136 -111
- package/dist/components/data-display/DataGrid/useDataGridKeyboard.cjs +1 -1
- package/dist/components/data-display/DataGrid/useDataGridKeyboard.js +23 -23
- package/dist/components/data-display/NodeGraph/NodeGraph.cjs +1 -1
- package/dist/components/data-display/NodeGraph/NodeGraph.js +69 -66
- package/dist/components/data-display/NodeGraph/node-graph.module.cjs +1 -1
- package/dist/components/data-display/NodeGraph/node-graph.module.js +1 -1
- package/dist/components/form/Cascader/cascader.module.cjs +1 -1
- package/dist/components/form/Cascader/cascader.module.js +7 -6
- package/dist/components/form/OtpInput/OtpInput.cjs +1 -1
- package/dist/components/form/OtpInput/OtpInput.d.ts +5 -0
- package/dist/components/form/OtpInput/OtpInput.js +48 -41
- package/dist/components/form/SignaturePad/signature-pad.module.cjs +1 -1
- package/dist/components/form/SignaturePad/signature-pad.module.js +7 -6
- package/dist/components/form/Transfer/transfer.module.cjs +1 -1
- package/dist/components/form/Transfer/transfer.module.js +7 -6
- package/dist/components/form/TreeSelect/tree-select.module.cjs +1 -1
- package/dist/components/form/TreeSelect/tree-select.module.js +7 -6
- package/dist/llms/Alert.md +3 -1
- package/dist/llms/Anchor.md +1 -1
- package/dist/llms/AvatarGroup.md +1 -1
- package/dist/llms/Breadcrumb.md +1 -1
- package/dist/llms/CodeDiffViewer.md +2 -0
- package/dist/llms/Combobox.md +1 -1
- package/dist/llms/CommandPalette.md +1 -1
- package/dist/llms/CopyButton.md +1 -1
- package/dist/llms/Countdown.md +2 -0
- package/dist/llms/DatePicker.md +4 -0
- package/dist/llms/DateRangePicker.md +4 -0
- package/dist/llms/DescriptionList.md +2 -0
- package/dist/llms/EmptyState.md +1 -1
- package/dist/llms/Group.md +2 -0
- package/dist/llms/Highlight.md +2 -0
- package/dist/llms/InlineEdit.md +1 -1
- package/dist/llms/InputGroup.md +2 -0
- package/dist/llms/JsonViewer.md +2 -0
- package/dist/llms/Kbd.md +2 -0
- package/dist/llms/KeyboardShortcuts.md +4 -0
- package/dist/llms/LinkButton.md +2 -0
- package/dist/llms/List.md +1 -1
- package/dist/llms/NumberInput.md +1 -1
- package/dist/llms/OtpInput.md +1 -0
- package/dist/llms/Presence.md +2 -0
- package/dist/llms/ProgressRing.md +2 -0
- package/dist/llms/Rating.md +1 -1
- package/dist/llms/SegmentedControl.md +1 -1
- package/dist/llms/Stepper.md +1 -1
- package/dist/llms/Switch.md +2 -0
- package/dist/llms/Table.md +1 -1
- package/dist/llms/TagInput.md +1 -1
- package/dist/llms/ThemeToggle.md +2 -0
- package/dist/llms/Title.md +2 -0
- package/dist/llms/TreeView.md +1 -1
- package/dist/llms-full.txt +49 -34
- package/dist/llms.txt +47 -34
- package/dist/reset.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +1 -1
- package/package.json +20 -17
package/README.ja.md
CHANGED
|
@@ -306,13 +306,13 @@ peer 依存コンポーネントは**コンポーネント別の専用サブパ
|
|
|
306
306
|
| AreaChart, BarChart 等 | `wimui/charts` | `recharts` |
|
|
307
307
|
| Markdown | `wimui/data-display/markdown` | `react-markdown` `remark-gfm` |
|
|
308
308
|
| QRCode | `wimui/data-display/qr-code` | `qrcode.react` |
|
|
309
|
-
| NodeGraph | `wimui/data-display/node-graph` | `@xyflow/react`(`^
|
|
309
|
+
| NodeGraph | `wimui/data-display/node-graph` | `@xyflow/react`(`^13`) |
|
|
310
310
|
| ScheduleView | `wimui/data-display/schedule-view` | `@fullcalendar/core` `@fullcalendar/react` `@fullcalendar/daygrid` `@fullcalendar/timegrid` `@fullcalendar/interaction`(`^6`。@6 を付けて入れてください。FullCalendar 7 には対応しておらず、pnpm は版を指定しないと core と react の最新(7)を入れます) |
|
|
311
311
|
| JsonDiffViewer | `wimui/data-display/json-diff-viewer` | `diff` |
|
|
312
312
|
| StreamingText | `wimui/ai/streaming-text` | `react-markdown` `remark-gfm` |
|
|
313
313
|
| MarkdownRenderer | `wimui/ai/markdown-renderer` | `react-markdown` `remark-gfm` |
|
|
314
314
|
| CodeDiffViewer | `wimui/ai/code-diff-viewer` | `diff` |
|
|
315
|
-
| InteractiveGraph | `wimui/ai/interactive-graph` | `@xyflow/react`(`^
|
|
315
|
+
| InteractiveGraph | `wimui/ai/interactive-graph` | `@xyflow/react`(`^13`) |
|
|
316
316
|
| Audio(`showMetadata` 時のみ) | `wimui` または `wimui/media` | `music-metadata` |
|
|
317
317
|
| FormField / zodResolver | `wimui/rhf` | `react-hook-form` `^7.55` / `@hookform/resolvers` `^5.1 \|\| ^6 \|\| ^7` / `zod` `^4` |
|
|
318
318
|
|
package/README.md
CHANGED
|
@@ -304,13 +304,13 @@ Each peer-dependent component has its **own subpath** whose name documents its p
|
|
|
304
304
|
| AreaChart, BarChart, etc. | `wimui/charts` | `recharts` |
|
|
305
305
|
| Markdown | `wimui/data-display/markdown` | `react-markdown` `remark-gfm` |
|
|
306
306
|
| QRCode | `wimui/data-display/qr-code` | `qrcode.react` |
|
|
307
|
-
| NodeGraph | `wimui/data-display/node-graph` | `@xyflow/react` (`^
|
|
307
|
+
| NodeGraph | `wimui/data-display/node-graph` | `@xyflow/react` (`^13`) |
|
|
308
308
|
| ScheduleView | `wimui/data-display/schedule-view` | `@fullcalendar/core` `@fullcalendar/react` `@fullcalendar/daygrid` `@fullcalendar/timegrid` `@fullcalendar/interaction` (`^6`. Install them with @6: FullCalendar 7 is not supported, and pnpm installs the latest core and react (7) unless you pin them) |
|
|
309
309
|
| JsonDiffViewer | `wimui/data-display/json-diff-viewer` | `diff` |
|
|
310
310
|
| StreamingText | `wimui/ai/streaming-text` | `react-markdown` `remark-gfm` |
|
|
311
311
|
| MarkdownRenderer | `wimui/ai/markdown-renderer` | `react-markdown` `remark-gfm` |
|
|
312
312
|
| CodeDiffViewer | `wimui/ai/code-diff-viewer` | `diff` |
|
|
313
|
-
| InteractiveGraph | `wimui/ai/interactive-graph` | `@xyflow/react` (`^
|
|
313
|
+
| InteractiveGraph | `wimui/ai/interactive-graph` | `@xyflow/react` (`^13`) |
|
|
314
314
|
| Audio (only when `showMetadata`) | `wimui` or `wimui/media` | `music-metadata` |
|
|
315
315
|
| FormField / zodResolver | `wimui/rhf` | `react-hook-form` `^7.55` / `@hookform/resolvers` `^5.1 \|\| ^6 \|\| ^7` / `zod` `^3.25 \|\| ^4` |
|
|
316
316
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs")
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs");;/* empty css */const t=require("./interactive-graph.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime"),a=require("@xyflow/react");var o=({nodes:e,edges:o,height:s=500,width:c=`100%`,className:l,showGrid:u=!0,showMiniMap:d=!0,showControls:f=!0})=>{let p=(0,n.useMemo)(()=>({height:s,width:c}),[s,c]);return(0,i.jsx)(`div`,{className:(0,r.default)(`wim-interactive-graph`,t.default.root,l),style:p,children:(0,i.jsxs)(a.ReactFlow,{nodes:e,edges:o,fitView:!0,children:[u&&(0,i.jsx)(a.Background,{}),d&&(0,i.jsx)(a.MiniMap,{className:t.default.minimap}),f&&(0,i.jsx)(a.Controls,{className:t.default.controls})]})})},s=e=>(0,i.jsx)(a.ReactFlowProvider,{children:(0,i.jsx)(o,{...e})});s.displayName=`InteractiveGraph`,exports.InteractiveGraph=s;
|
|
@@ -1,46 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getWimTheme as e } from "../../../theme.js";
|
|
3
|
-
import { useWim as t } from "../../../WimProvider.js";
|
|
4
2
|
/* empty css */
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { jsx as
|
|
9
|
-
import { Background as
|
|
3
|
+
import e from "./interactive-graph.module.js";
|
|
4
|
+
import { useMemo as t } from "react";
|
|
5
|
+
import n from "classnames";
|
|
6
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
7
|
+
import { Background as a, Controls as o, MiniMap as s, ReactFlow as c, ReactFlowProvider as l } from "@xyflow/react";
|
|
10
8
|
//#region src/components/ai/InteractiveGraph/InteractiveGraph.tsx
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
var h = ({ nodes: e, edges: t, height: r = 500, width: a = "100%", className: p, showGrid: h = !0, showMiniMap: g = !0, showControls: _ = !0 }) => {
|
|
24
|
-
let v = m(), y = i(() => ({
|
|
25
|
-
height: r,
|
|
26
|
-
width: a
|
|
27
|
-
}), [r, a]);
|
|
28
|
-
return /* @__PURE__ */ s("div", {
|
|
29
|
-
className: o("wim-interactive-graph", n.root, p),
|
|
30
|
-
style: y,
|
|
31
|
-
children: /* @__PURE__ */ c(f, {
|
|
32
|
-
nodes: e,
|
|
33
|
-
edges: t,
|
|
9
|
+
var u = ({ nodes: l, edges: u, height: d = 500, width: f = "100%", className: p, showGrid: m = !0, showMiniMap: h = !0, showControls: g = !0 }) => {
|
|
10
|
+
let _ = t(() => ({
|
|
11
|
+
height: d,
|
|
12
|
+
width: f
|
|
13
|
+
}), [d, f]);
|
|
14
|
+
return /* @__PURE__ */ r("div", {
|
|
15
|
+
className: n("wim-interactive-graph", e.root, p),
|
|
16
|
+
style: _,
|
|
17
|
+
children: /* @__PURE__ */ i(c, {
|
|
18
|
+
nodes: l,
|
|
19
|
+
edges: u,
|
|
34
20
|
fitView: !0,
|
|
35
|
-
colorMode: v,
|
|
36
21
|
children: [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
m && /* @__PURE__ */ r(a, {}),
|
|
23
|
+
h && /* @__PURE__ */ r(s, { className: e.minimap }),
|
|
24
|
+
g && /* @__PURE__ */ r(o, { className: e.controls })
|
|
40
25
|
]
|
|
41
26
|
})
|
|
42
27
|
});
|
|
43
|
-
},
|
|
44
|
-
|
|
28
|
+
}, d = (e) => /* @__PURE__ */ r(l, { children: /* @__PURE__ */ r(u, { ...e }) });
|
|
29
|
+
d.displayName = "InteractiveGraph";
|
|
45
30
|
//#endregion
|
|
46
|
-
export {
|
|
31
|
+
export { d as InteractiveGraph };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_eo42r_4`,t=`_minimap_eo42r_25`,n=`_controls_eo42r_38`,r={root:e,minimap:t,controls:n};exports.controls=n,exports.default=r,exports.minimap=t,exports.root=e;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/ai/InteractiveGraph/interactive-graph.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_eo42r_4", t = "_minimap_eo42r_25", n = "_controls_eo42r_38", r = {
|
|
4
4
|
root: e,
|
|
5
5
|
minimap: t,
|
|
6
6
|
controls: n
|
|
@@ -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("../../_internal/useAnnounce.cjs"),a=require("../../navigation/Pagination/Pagination.cjs"),o=require("../Table/Table.cjs"),s=require("./useFixedColumns.cjs"),
|
|
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"),ee=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:te=!1,bordered:g=!1,hoverable:_=!0,stickyHeader:v=!0,height:y,maxHeight:b,emptyMessage:x,mobileCard:S=!1,selection:C,selectedRowKeys:w,onSelectionChange:T,sortConfig:E,onSortChange:D,pagination:O,infiniteScroll:k,className:A,ariaLabel:j,"aria-label":ne,"aria-labelledby":M}){let{t:N}=t.useWimTranslation(n.commonNs),P=h!==!1&&h!==void 0,F=h===!0||h===`blocking`,I=(0,u.useMemo)(()=>C?C===!0?{type:`checkbox`,selectedRowKeys:w??[],onChange:(e,t)=>{T?.(e,t)}}:C:null,[C,w,T]),L=u.default.useRef(null),[R,z]=(0,u.useState)(),B=!!I&&e.some(e=>e.fixed===`left`);u.default.useLayoutEffect(()=>{let e=L.current;if(!B||!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>z(e.offsetWidth));return t.observe(e,{box:`border-box`}),()=>t.disconnect()},[B]);let{fixedLeftOffsets:V,fixedRightOffsets:H}=s.useFixedColumns(e,!!I,R),U=(e,t=!1)=>{let n=V[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=H[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)}:{}},W=(0,u.useCallback)(e=>typeof m==`function`?m(e):e[m],[m]),G=(0,u.useMemo)(()=>!I||p.length===0?!1:p.every(e=>I.selectedRowKeys.includes(W(e))),[p,I,W]),K=(0,u.useMemo)(()=>I?!G&&p.some(e=>I.selectedRowKeys.includes(W(e))):!1,[p,I,G,W]),q=e=>{if(!I)return;let t=e.target.checked,n=t?p.map(W):[],r=t?p:[];I.onChange(n,r)},J=(e,t)=>{if(!I)return;let n=t.target.checked,r=W(e),i=n?[...I.selectedRowKeys,r]:I.selectedRowKeys.filter(e=>e!==r),a=p.filter(e=>i.includes(W(e)));I.onChange(i,a)},{focusedCell:Y,setFocusedCell:X,handleKeyDown:Z,containerRef:Q}=ee.useDataGridKeyboard(e,p,!!I);(0,u.useLayoutEffect)(()=>{let e=Q.current;if(!e)return;let t=e.querySelectorAll(`a[href],button,input,select,textarea,[contenteditable=true],[tabindex]:not([data-row])`);for(let e of t){let t=e.closest(`[data-row]`);if(t&&t!==e){if(Number(t.dataset.row)===Y.row&&Number(t.dataset.col)===Y.col){if(e.dataset.wimTab!==void 0){let t=e.dataset.wimTab;t===``?e.removeAttribute(`tabindex`):e.setAttribute(`tabindex`,t),delete e.dataset.wimTab}}else e.dataset.wimTab===void 0&&(e.dataset.wimTab=e.getAttribute(`tabindex`)??``,e.setAttribute(`tabindex`,`-1`))}}});let re=e=>{let t=e.target.closest(`[data-row]`);if(!t)return;let n=Number(t.dataset.row),r=Number(t.dataset.col);(n!==Y.row||r!==Y.col)&&X({row:n,col:r})},{loaderRef:ie}=c.useInfiniteScroll(k),ae=e.length+ +!!I,{announce:oe,region:se}=i.useAnnounce(),$=p.length===0&&!!x,{ref:ce,region:le}=i.useAnnounceAppearance($);return(0,f.jsxs)(`div`,{className:(0,d.default)(`wim-data-grid`,l.default.root,F&&l.default.loading,S===`md`?l.default.mobileCardMd:S&&l.default.mobileCard,A),"aria-busy":P||void 0,children:[se,le,(0,f.jsxs)(`div`,{className:l.default.container,style:{height:y,maxHeight:b},inert:F||void 0,children:[(0,f.jsxs)(o.Table,{ref:Q,onKeyDown:Z,onFocus:re,role:`grid`,"aria-label":M?void 0:ne??j??N(`a11y.data_grid`),"aria-labelledby":M,"aria-rowcount":p.length+1,"aria-colcount":ae,striped:te,bordered:g,hoverable:_,stickyHeader:v,mobileCard:S,fullWidth:!0,className:(0,d.default)(`wim-table`,l.default.table),containerClassName:l.default.tableContainer,children:[(0,f.jsx)(o.Table.Header,{children:(0,f.jsxs)(o.Table.Row,{children:[I&&(0,f.jsx)(o.Table.Head,{ref:L,role:`columnheader`,selection:!0,stickyLeft:!0,leftOffset:0,stickyZIndex:1150,"data-row":-1,"data-col":-1,"aria-label":N(`a11y.select_all_rows`),tabIndex:Y.row===-1&&Y.col===-1?0:-1,children:(I.type??`checkbox`)===`checkbox`&&(0,f.jsx)(r.Checkbox,{checked:G,indeterminate:K,onChange:q,"aria-label":N(`a11y.select_all_rows`)})}),e.map((e,t)=>{let n=U(e.key,!0);return(0,f.jsx)(o.Table.Head,{role:`columnheader`,style:{width:e.width,minWidth:e.width},sortable:!!(e.sortable&&D),sortDirection:E?.key===e.key?E.direction:`none`,onSort:()=>{if(!e.sortable||!D)return;let t=E?.key===e.key?E.direction===`asc`?`desc`:E.direction===`desc`?`none`:`asc`:`asc`,n=typeof e.title==`string`?e.title:e.key;oe(N(t===`asc`?`dataGrid.sorted_ascending`:t===`desc`?`dataGrid.sorted_descending`:`dataGrid.sort_cleared`,{column:n})),D(e.key,t)},...n,tabIndex:Y.row===-1&&Y.col===t?0:-1,"data-row":-1,"data-col":t,children:e.title},e.key)})]})}),(0,f.jsx)(o.Table.Body,{children:p.map((t,n)=>{let i=W(t),a=I?.selectedRowKeys.includes(i);return(0,f.jsxs)(o.Table.Row,{selected:a,children:[I&&(0,f.jsx)(o.Table.Cell,{role:`gridcell`,selection:!0,stickyLeft:!0,leftOffset:0,stickyZIndex:150,"data-row":n,"data-col":-1,tabIndex:Y.row===n&&Y.col===-1?0:-1,children:(0,f.jsx)(r.Checkbox,{checked:a,onChange:e=>J(t,e),"aria-label":N(`a11y.select_row_numbered`,{row:n+1})})}),e.map((e,r)=>{let i=U(e.key,!1),a=t[e.dataIndex??e.key];return(0,f.jsx)(o.Table.Cell,{role:`gridcell`,label:typeof e.title==`string`?e.title:void 0,...i,"data-row":n,"data-col":r,tabIndex:Y.row===n&&Y.col===r?0:-1,children:e.maxWidth==null?e.render?e.render(a,t,n):a:(0,f.jsx)(`div`,{style:{maxWidth:e.maxWidth},children:e.render?e.render(a,t,n):a})},e.key)})]},i)})})]}),$&&(0,f.jsx)(`div`,{ref:ce,className:l.default.empty,children:x}),k?.hasMore&&(0,f.jsx)(`div`,{ref:ie,className:l.default.loader,children:k.hasMore&&N(`dataGrid.loading_more`)})]}),O&&(0,f.jsxs)(`div`,{className:l.default.footer,inert:F||void 0,children:[(0,f.jsxs)(`div`,{className:l.default.info,children:[N(`dataGrid.displaying`,{shown:p.length,total:O.total}),I?.selectedRowKeys&&I.selectedRowKeys.length>0&&(0,f.jsx)(`span`,{className:l.default.selectionInfo,children:N(`dataGrid.rows_selected`,{selected:I.selectedRowKeys.length})})]}),(0,f.jsx)(`div`,{className:l.default.pagination,children:(0,f.jsx)(a.Pagination,{className:l.default.paginationContent,current:O.current,total:O.total,pageSize:O.pageSize,onChange:O.onChange})})]})]})}exports.DataGrid=p;
|
|
@@ -7,14 +7,14 @@ import { Pagination as a } from "../../navigation/Pagination/Pagination.js";
|
|
|
7
7
|
import { Table as o } from "../Table/Table.js";
|
|
8
8
|
import { useFixedColumns as s } from "./useFixedColumns.js";
|
|
9
9
|
import { useDataGridKeyboard as c } from "./useDataGridKeyboard.js";
|
|
10
|
-
import { useInfiniteScroll as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { jsx as
|
|
10
|
+
import { useInfiniteScroll as l } from "./useInfiniteScroll.js";
|
|
11
|
+
import u from "./datagrid.module.js";
|
|
12
|
+
import d, { useCallback as f, useLayoutEffect as p, useMemo as m, useState as ee } from "react";
|
|
13
|
+
import h from "classnames";
|
|
14
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
15
15
|
//#region src/components/data-display/DataGrid/DataGrid.tsx
|
|
16
|
-
function
|
|
17
|
-
let { t:
|
|
16
|
+
function v({ columns: v, data: y, rowKey: b = "id", loading: x = !1, striped: S = !1, bordered: C = !1, hoverable: w = !0, stickyHeader: T = !0, height: te, maxHeight: ne, emptyMessage: E, mobileCard: D = !1, selection: O, selectedRowKeys: k, onSelectionChange: A, sortConfig: j, onSortChange: M, pagination: N, infiniteScroll: P, className: re, ariaLabel: F, "aria-label": I, "aria-labelledby": L }) {
|
|
17
|
+
let { t: R } = e(t), z = x !== !1 && x !== void 0, B = x === !0 || x === "blocking", V = m(() => O ? O === !0 ? {
|
|
18
18
|
type: "checkbox",
|
|
19
19
|
selectedRowKeys: k ?? [],
|
|
20
20
|
onChange: (e, t) => {
|
|
@@ -24,79 +24,104 @@ function _({ columns: _, data: v, rowKey: y = "id", loading: b = !1, striped: te
|
|
|
24
24
|
O,
|
|
25
25
|
k,
|
|
26
26
|
A
|
|
27
|
-
]),
|
|
28
|
-
|
|
29
|
-
let e =
|
|
30
|
-
if (!
|
|
31
|
-
let t = new ResizeObserver(() =>
|
|
27
|
+
]), H = d.useRef(null), [U, W] = ee(), G = !!V && v.some((e) => e.fixed === "left");
|
|
28
|
+
d.useLayoutEffect(() => {
|
|
29
|
+
let e = H.current;
|
|
30
|
+
if (!G || !e || typeof ResizeObserver > "u") return;
|
|
31
|
+
let t = new ResizeObserver(() => W(e.offsetWidth));
|
|
32
32
|
return t.observe(e, { box: "border-box" }), () => t.disconnect();
|
|
33
|
-
}, [
|
|
34
|
-
let { fixedLeftOffsets:
|
|
35
|
-
let n =
|
|
33
|
+
}, [G]);
|
|
34
|
+
let { fixedLeftOffsets: K, fixedRightOffsets: q } = s(v, !!V, U), J = (e, t = !1) => {
|
|
35
|
+
let n = K[e];
|
|
36
36
|
if (n) return {
|
|
37
37
|
stickyLeft: !0,
|
|
38
38
|
leftOffset: n.offset,
|
|
39
39
|
stickyZIndex: t ? 1e3 + n.zIndex : n.zIndex,
|
|
40
|
-
className:
|
|
40
|
+
className: h(u.cellFixed, n.isLast && u.cellFixedLeftLast)
|
|
41
41
|
};
|
|
42
|
-
let r =
|
|
42
|
+
let r = q[e];
|
|
43
43
|
return r ? {
|
|
44
44
|
stickyRight: !0,
|
|
45
45
|
rightOffset: r.offset,
|
|
46
46
|
stickyZIndex: t ? 1e3 + r.zIndex : r.zIndex,
|
|
47
|
-
className:
|
|
47
|
+
className: h(u.cellFixed, r.isFirst && u.cellFixedRightFirst)
|
|
48
48
|
} : {};
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
]),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
]),
|
|
59
|
-
if (!
|
|
60
|
-
let t = e.target.checked, n = t ?
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
if (!
|
|
64
|
-
let n = t.target.checked, r =
|
|
65
|
-
|
|
66
|
-
}, { focusedCell:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
}, Y = f((e) => typeof b == "function" ? b(e) : e[b], [b]), X = m(() => !V || y.length === 0 ? !1 : y.every((e) => V.selectedRowKeys.includes(Y(e))), [
|
|
50
|
+
y,
|
|
51
|
+
V,
|
|
52
|
+
Y
|
|
53
|
+
]), ie = m(() => V ? !X && y.some((e) => V.selectedRowKeys.includes(Y(e))) : !1, [
|
|
54
|
+
y,
|
|
55
|
+
V,
|
|
56
|
+
X,
|
|
57
|
+
Y
|
|
58
|
+
]), ae = (e) => {
|
|
59
|
+
if (!V) return;
|
|
60
|
+
let t = e.target.checked, n = t ? y.map(Y) : [], r = t ? y : [];
|
|
61
|
+
V.onChange(n, r);
|
|
62
|
+
}, oe = (e, t) => {
|
|
63
|
+
if (!V) return;
|
|
64
|
+
let n = t.target.checked, r = Y(e), i = n ? [...V.selectedRowKeys, r] : V.selectedRowKeys.filter((e) => e !== r), a = y.filter((e) => i.includes(Y(e)));
|
|
65
|
+
V.onChange(i, a);
|
|
66
|
+
}, { focusedCell: Z, setFocusedCell: se, handleKeyDown: ce, containerRef: Q } = c(v, y, !!V);
|
|
67
|
+
p(() => {
|
|
68
|
+
let e = Q.current;
|
|
69
|
+
if (!e) return;
|
|
70
|
+
let t = e.querySelectorAll("a[href],button,input,select,textarea,[contenteditable=true],[tabindex]:not([data-row])");
|
|
71
|
+
for (let e of t) {
|
|
72
|
+
let t = e.closest("[data-row]");
|
|
73
|
+
if (t && t !== e) {
|
|
74
|
+
if (Number(t.dataset.row) === Z.row && Number(t.dataset.col) === Z.col) {
|
|
75
|
+
if (e.dataset.wimTab !== void 0) {
|
|
76
|
+
let t = e.dataset.wimTab;
|
|
77
|
+
t === "" ? e.removeAttribute("tabindex") : e.setAttribute("tabindex", t), delete e.dataset.wimTab;
|
|
78
|
+
}
|
|
79
|
+
} else e.dataset.wimTab === void 0 && (e.dataset.wimTab = e.getAttribute("tabindex") ?? "", e.setAttribute("tabindex", "-1"));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
let le = (e) => {
|
|
84
|
+
let t = e.target.closest("[data-row]");
|
|
85
|
+
if (!t) return;
|
|
86
|
+
let n = Number(t.dataset.row), r = Number(t.dataset.col);
|
|
87
|
+
(n !== Z.row || r !== Z.col) && se({
|
|
88
|
+
row: n,
|
|
89
|
+
col: r
|
|
90
|
+
});
|
|
91
|
+
}, { loaderRef: ue } = l(P), de = v.length + +!!V, { announce: fe, region: pe } = r(), $ = y.length === 0 && !!E, { ref: me, region: he } = i($);
|
|
92
|
+
return /* @__PURE__ */ _("div", {
|
|
93
|
+
className: h("wim-data-grid", u.root, B && u.loading, D === "md" ? u.mobileCardMd : D && u.mobileCard, re),
|
|
94
|
+
"aria-busy": z || void 0,
|
|
70
95
|
children: [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
className:
|
|
96
|
+
pe,
|
|
97
|
+
he,
|
|
98
|
+
/* @__PURE__ */ _("div", {
|
|
99
|
+
className: u.container,
|
|
75
100
|
style: {
|
|
76
|
-
height:
|
|
77
|
-
maxHeight:
|
|
101
|
+
height: te,
|
|
102
|
+
maxHeight: ne
|
|
78
103
|
},
|
|
79
|
-
inert:
|
|
104
|
+
inert: B || void 0,
|
|
80
105
|
children: [
|
|
81
|
-
/* @__PURE__ */
|
|
82
|
-
ref:
|
|
83
|
-
onKeyDown:
|
|
84
|
-
|
|
106
|
+
/* @__PURE__ */ _(o, {
|
|
107
|
+
ref: Q,
|
|
108
|
+
onKeyDown: ce,
|
|
109
|
+
onFocus: le,
|
|
85
110
|
role: "grid",
|
|
86
|
-
"aria-label":
|
|
87
|
-
"aria-labelledby":
|
|
88
|
-
"aria-rowcount":
|
|
89
|
-
"aria-colcount":
|
|
90
|
-
striped:
|
|
91
|
-
bordered:
|
|
92
|
-
hoverable:
|
|
93
|
-
stickyHeader:
|
|
111
|
+
"aria-label": L ? void 0 : I ?? F ?? R("a11y.data_grid"),
|
|
112
|
+
"aria-labelledby": L,
|
|
113
|
+
"aria-rowcount": y.length + 1,
|
|
114
|
+
"aria-colcount": de,
|
|
115
|
+
striped: S,
|
|
116
|
+
bordered: C,
|
|
117
|
+
hoverable: w,
|
|
118
|
+
stickyHeader: T,
|
|
94
119
|
mobileCard: D,
|
|
95
120
|
fullWidth: !0,
|
|
96
|
-
className:
|
|
97
|
-
containerClassName:
|
|
98
|
-
children: [/* @__PURE__ */
|
|
99
|
-
ref:
|
|
121
|
+
className: h("wim-table", u.table),
|
|
122
|
+
containerClassName: u.tableContainer,
|
|
123
|
+
children: [/* @__PURE__ */ g(o.Header, { children: /* @__PURE__ */ _(o.Row, { children: [V && /* @__PURE__ */ g(o.Head, {
|
|
124
|
+
ref: H,
|
|
100
125
|
role: "columnheader",
|
|
101
126
|
selection: !0,
|
|
102
127
|
stickyLeft: !0,
|
|
@@ -104,17 +129,17 @@ function _({ columns: _, data: v, rowKey: y = "id", loading: b = !1, striped: te
|
|
|
104
129
|
stickyZIndex: 1150,
|
|
105
130
|
"data-row": -1,
|
|
106
131
|
"data-col": -1,
|
|
107
|
-
"aria-label":
|
|
108
|
-
tabIndex:
|
|
109
|
-
children: (
|
|
110
|
-
checked:
|
|
111
|
-
indeterminate:
|
|
112
|
-
onChange:
|
|
113
|
-
"aria-label":
|
|
132
|
+
"aria-label": R("a11y.select_all_rows"),
|
|
133
|
+
tabIndex: Z.row === -1 && Z.col === -1 ? 0 : -1,
|
|
134
|
+
children: (V.type ?? "checkbox") === "checkbox" && /* @__PURE__ */ g(n, {
|
|
135
|
+
checked: X,
|
|
136
|
+
indeterminate: ie,
|
|
137
|
+
onChange: ae,
|
|
138
|
+
"aria-label": R("a11y.select_all_rows")
|
|
114
139
|
})
|
|
115
|
-
}),
|
|
116
|
-
let n =
|
|
117
|
-
return /* @__PURE__ */
|
|
140
|
+
}), v.map((e, t) => {
|
|
141
|
+
let n = J(e.key, !0);
|
|
142
|
+
return /* @__PURE__ */ g(o.Head, {
|
|
118
143
|
role: "columnheader",
|
|
119
144
|
style: {
|
|
120
145
|
width: e.width,
|
|
@@ -125,19 +150,19 @@ function _({ columns: _, data: v, rowKey: y = "id", loading: b = !1, striped: te
|
|
|
125
150
|
onSort: () => {
|
|
126
151
|
if (!e.sortable || !M) return;
|
|
127
152
|
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;
|
|
128
|
-
|
|
153
|
+
fe(R(t === "asc" ? "dataGrid.sorted_ascending" : t === "desc" ? "dataGrid.sorted_descending" : "dataGrid.sort_cleared", { column: n })), M(e.key, t);
|
|
129
154
|
},
|
|
130
155
|
...n,
|
|
131
|
-
tabIndex:
|
|
156
|
+
tabIndex: Z.row === -1 && Z.col === t ? 0 : -1,
|
|
132
157
|
"data-row": -1,
|
|
133
|
-
"data-col":
|
|
158
|
+
"data-col": t,
|
|
134
159
|
children: e.title
|
|
135
160
|
}, e.key);
|
|
136
|
-
})] }) }), /* @__PURE__ */
|
|
137
|
-
let r =
|
|
138
|
-
return /* @__PURE__ */
|
|
161
|
+
})] }) }), /* @__PURE__ */ g(o.Body, { children: y.map((e, t) => {
|
|
162
|
+
let r = Y(e), i = V?.selectedRowKeys.includes(r);
|
|
163
|
+
return /* @__PURE__ */ _(o.Row, {
|
|
139
164
|
selected: i,
|
|
140
|
-
children: [
|
|
165
|
+
children: [V && /* @__PURE__ */ g(o.Cell, {
|
|
141
166
|
role: "gridcell",
|
|
142
167
|
selection: !0,
|
|
143
168
|
stickyLeft: !0,
|
|
@@ -145,22 +170,22 @@ function _({ columns: _, data: v, rowKey: y = "id", loading: b = !1, striped: te
|
|
|
145
170
|
stickyZIndex: 150,
|
|
146
171
|
"data-row": t,
|
|
147
172
|
"data-col": -1,
|
|
148
|
-
tabIndex:
|
|
149
|
-
children: /* @__PURE__ */
|
|
173
|
+
tabIndex: Z.row === t && Z.col === -1 ? 0 : -1,
|
|
174
|
+
children: /* @__PURE__ */ g(n, {
|
|
150
175
|
checked: i,
|
|
151
|
-
onChange: (t) =>
|
|
152
|
-
"aria-label":
|
|
176
|
+
onChange: (t) => oe(e, t),
|
|
177
|
+
"aria-label": R("a11y.select_row_numbered", { row: t + 1 })
|
|
153
178
|
})
|
|
154
|
-
}),
|
|
155
|
-
let i =
|
|
156
|
-
return /* @__PURE__ */
|
|
179
|
+
}), v.map((n, r) => {
|
|
180
|
+
let i = J(n.key, !1), a = e[n.dataIndex ?? n.key];
|
|
181
|
+
return /* @__PURE__ */ g(o.Cell, {
|
|
157
182
|
role: "gridcell",
|
|
158
183
|
label: typeof n.title == "string" ? n.title : void 0,
|
|
159
184
|
...i,
|
|
160
185
|
"data-row": t,
|
|
161
|
-
"data-col":
|
|
162
|
-
tabIndex:
|
|
163
|
-
children: n.maxWidth == null ? n.render ? n.render(a, e, t) : a : /* @__PURE__ */
|
|
186
|
+
"data-col": r,
|
|
187
|
+
tabIndex: Z.row === t && Z.col === r ? 0 : -1,
|
|
188
|
+
children: n.maxWidth == null ? n.render ? n.render(a, e, t) : a : /* @__PURE__ */ g("div", {
|
|
164
189
|
style: { maxWidth: n.maxWidth },
|
|
165
190
|
children: n.render ? n.render(a, e, t) : a
|
|
166
191
|
})
|
|
@@ -169,34 +194,34 @@ function _({ columns: _, data: v, rowKey: y = "id", loading: b = !1, striped: te
|
|
|
169
194
|
}, r);
|
|
170
195
|
}) })]
|
|
171
196
|
}),
|
|
172
|
-
$ && /* @__PURE__ */
|
|
173
|
-
ref:
|
|
174
|
-
className:
|
|
197
|
+
$ && /* @__PURE__ */ g("div", {
|
|
198
|
+
ref: me,
|
|
199
|
+
className: u.empty,
|
|
175
200
|
children: E
|
|
176
201
|
}),
|
|
177
|
-
P?.hasMore && /* @__PURE__ */
|
|
178
|
-
ref:
|
|
179
|
-
className:
|
|
180
|
-
children: P.hasMore &&
|
|
202
|
+
P?.hasMore && /* @__PURE__ */ g("div", {
|
|
203
|
+
ref: ue,
|
|
204
|
+
className: u.loader,
|
|
205
|
+
children: P.hasMore && R("dataGrid.loading_more")
|
|
181
206
|
})
|
|
182
207
|
]
|
|
183
208
|
}),
|
|
184
|
-
N && /* @__PURE__ */
|
|
185
|
-
className:
|
|
186
|
-
inert:
|
|
187
|
-
children: [/* @__PURE__ */
|
|
188
|
-
className:
|
|
189
|
-
children: [
|
|
190
|
-
shown:
|
|
209
|
+
N && /* @__PURE__ */ _("div", {
|
|
210
|
+
className: u.footer,
|
|
211
|
+
inert: B || void 0,
|
|
212
|
+
children: [/* @__PURE__ */ _("div", {
|
|
213
|
+
className: u.info,
|
|
214
|
+
children: [R("dataGrid.displaying", {
|
|
215
|
+
shown: y.length,
|
|
191
216
|
total: N.total
|
|
192
|
-
}),
|
|
193
|
-
className:
|
|
194
|
-
children:
|
|
217
|
+
}), V?.selectedRowKeys && V.selectedRowKeys.length > 0 && /* @__PURE__ */ g("span", {
|
|
218
|
+
className: u.selectionInfo,
|
|
219
|
+
children: R("dataGrid.rows_selected", { selected: V.selectedRowKeys.length })
|
|
195
220
|
})]
|
|
196
|
-
}), /* @__PURE__ */
|
|
197
|
-
className:
|
|
198
|
-
children: /* @__PURE__ */
|
|
199
|
-
className:
|
|
221
|
+
}), /* @__PURE__ */ g("div", {
|
|
222
|
+
className: u.pagination,
|
|
223
|
+
children: /* @__PURE__ */ g(a, {
|
|
224
|
+
className: u.paginationContent,
|
|
200
225
|
current: N.current,
|
|
201
226
|
total: N.total,
|
|
202
227
|
pageSize: N.pageSize,
|
|
@@ -208,4 +233,4 @@ function _({ columns: _, data: v, rowKey: y = "id", loading: b = !1, striped: te
|
|
|
208
233
|
});
|
|
209
234
|
}
|
|
210
235
|
//#endregion
|
|
211
|
-
export {
|
|
236
|
+
export { v as DataGrid };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
let e=require("react");function t(t,n,r){let[i,a]=(0,e.useState)({row:-1,col:r?-1:0}),o=(0,e.useRef)(null);return{focusedCell:i,setFocusedCell:a,containerRef:o,handleKeyDown:e=>{let
|
|
2
|
+
let e=require("react");function t(t,n,r){let[i,a]=(0,e.useState)({row:-1,col:r?-1:0}),o=(0,e.useRef)(null),s=(0,e.useRef)(!1);return(0,e.useLayoutEffect)(()=>{s.current&&(s.current=!1,(o.current?.querySelector(`[data-row="${i.row}"][data-col="${i.col}"]`))?.focus())},[i]),{focusedCell:i,setFocusedCell:a,containerRef:o,handleKeyDown:e=>{let o=e.target.closest(`[data-row]`),c=o?Number(o.dataset.row):i.row,l=o?Number(o.dataset.col):i.col,u=c,d=l,f=r?-1:0,p=t.length-1,m=n.length-1;switch(e.key){case`ArrowRight`:l<p&&d++;break;case`ArrowLeft`:l>f&&d--;break;case`ArrowDown`:c<m&&u++;break;case`ArrowUp`:c>-1&&u--;break;case`Home`:e.ctrlKey&&(u=-1),d=f;break;case`End`:e.ctrlKey&&(u=m),d=p;break;case`Enter`:case` `:{let t=document.activeElement;if(t?.getAttribute(`role`)===`columnheader`)return;if(t?.tagName===`TD`||t?.tagName===`TH`||t?.getAttribute(`role`)===`gridcell`){let n=t.querySelector(`input, button, [role="button"]`);n&&(n.click(),e.preventDefault())}return}default:return}(u!==c||d!==l)&&(e.preventDefault(),s.current=!0,a({row:u,col:d}))}}}exports.useDataGridKeyboard=t;
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { useLayoutEffect as e, useRef as t, useState as n } from "react";
|
|
3
3
|
//#region src/components/data-display/DataGrid/useDataGridKeyboard.ts
|
|
4
|
-
function
|
|
5
|
-
let [
|
|
4
|
+
function r(r, i, a) {
|
|
5
|
+
let [o, s] = n({
|
|
6
6
|
row: -1,
|
|
7
|
-
col:
|
|
8
|
-
}),
|
|
9
|
-
return {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
col: a ? -1 : 0
|
|
8
|
+
}), c = t(null), l = t(!1);
|
|
9
|
+
return e(() => {
|
|
10
|
+
l.current && (l.current = !1, (c.current?.querySelector(`[data-row="${o.row}"][data-col="${o.col}"]`))?.focus());
|
|
11
|
+
}, [o]), {
|
|
12
|
+
focusedCell: o,
|
|
13
|
+
setFocusedCell: s,
|
|
14
|
+
containerRef: c,
|
|
13
15
|
handleKeyDown: (e) => {
|
|
14
|
-
let
|
|
16
|
+
let t = e.target.closest("[data-row]"), n = t ? Number(t.dataset.row) : o.row, c = t ? Number(t.dataset.col) : o.col, u = n, d = c, f = a ? -1 : 0, p = r.length - 1, m = i.length - 1;
|
|
15
17
|
switch (e.key) {
|
|
16
18
|
case "ArrowRight":
|
|
17
|
-
c <
|
|
19
|
+
c < p && d++;
|
|
18
20
|
break;
|
|
19
21
|
case "ArrowLeft":
|
|
20
|
-
c >
|
|
22
|
+
c > f && d--;
|
|
21
23
|
break;
|
|
22
24
|
case "ArrowDown":
|
|
23
|
-
|
|
25
|
+
n < m && u++;
|
|
24
26
|
break;
|
|
25
27
|
case "ArrowUp":
|
|
26
|
-
|
|
28
|
+
n > -1 && u--;
|
|
27
29
|
break;
|
|
28
30
|
case "Home":
|
|
29
|
-
e.ctrlKey && (
|
|
31
|
+
e.ctrlKey && (u = -1), d = f;
|
|
30
32
|
break;
|
|
31
33
|
case "End":
|
|
32
|
-
e.ctrlKey && (
|
|
34
|
+
e.ctrlKey && (u = m), d = p;
|
|
33
35
|
break;
|
|
34
36
|
case "Enter":
|
|
35
37
|
case " ": {
|
|
@@ -43,14 +45,12 @@ function n(n, r, i) {
|
|
|
43
45
|
}
|
|
44
46
|
default: return;
|
|
45
47
|
}
|
|
46
|
-
(
|
|
47
|
-
row:
|
|
48
|
-
col:
|
|
49
|
-
})
|
|
50
|
-
(s.current?.querySelector(`[data-row="${l}"][data-col="${u}"]`))?.focus();
|
|
51
|
-
}, 0));
|
|
48
|
+
(u !== n || d !== c) && (e.preventDefault(), l.current = !0, s({
|
|
49
|
+
row: u,
|
|
50
|
+
col: d
|
|
51
|
+
}));
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
//#endregion
|
|
56
|
-
export {
|
|
56
|
+
export { r as useDataGridKeyboard };
|
|
@@ -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("../../../icon/plus.cjs"),ee=require("../../../icon/trash.cjs"),i=require("../../media/Icon/Icon.cjs");;/* empty css */const a=require("./node-graph.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"),l=require("@xyflow/react");var u=[`Backspace`,`Delete`],d=180,f=80;function p(e){let t=1,n=new Set(e.map(e=>e.id));for(;n.has(`node-${t}`);)t+=1;return`node-${t}`}function m(e){if(e.length===0)return{x:f,y:f};let t=Math.max(...e.map(e=>e.position.x)),n=e[e.length-1]?.position.y??f;return{x:t+d,y:n}}var h=o.default.forwardRef(({nodes:e,edges:d,onNodesChange:f,onEdgesChange:h,onConnect:g,nodeTypes:_,edgeTypes:v,nodesDraggable:y=!0,nodesConnectable:b=!0,deleteKeyCode:x,showMiniMap:S=!1,showControls:C=!0,backgroundVariant:w=l.BackgroundVariant.Dots,fitView:T=!0,fitViewOptions:E,defaultEdgeOptions:D,className:O,"aria-label":k,...A},j)=>{let{t:M}=t.useWimTranslation(n.commonNs),N=k??M(`nodeGraph.label`),P=M(`nodeGraph.add_node`),F=M(`nodeGraph.node_name`),I=M(`nodeGraph.new_node`),L=M(`a11y.delete`),R=x===void 0?[...u]:x,z=R!=null,[B,V]=(0,o.useState)(!1),[H,U]=(0,o.useState)(``),W=(0,o.useRef)(null),G=(0,o.useMemo)(()=>e.filter(e=>e.selected),[e]),K=(0,o.useMemo)(()=>d.filter(e=>e.selected),[d]),q=G.length>0||K.length>0,J=H.trim(),Y=R==null?void 0:Array.isArray(R)?R.join(` `):R;(0,o.useEffect)(()=>{B&&W.current?.focus()},[B]);let X=(0,o.useCallback)(()=>{z
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../../icon/plus.cjs"),ee=require("../../../icon/trash.cjs"),i=require("../../media/Icon/Icon.cjs");;/* empty css */const a=require("./node-graph.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"),l=require("@xyflow/react");var u=[`Backspace`,`Delete`],d=180,f=80;function p(e){let t=1,n=new Set(e.map(e=>e.id));for(;n.has(`node-${t}`);)t+=1;return`node-${t}`}function m(e){if(e.length===0)return{x:f,y:f};let t=Math.max(...e.map(e=>e.position.x)),n=e[e.length-1]?.position.y??f;return{x:t+d,y:n}}var h=o.default.forwardRef(({nodes:e,edges:d,onNodesChange:f,onEdgesChange:h,onConnect:g,nodeTypes:_,edgeTypes:v,nodesDraggable:y=!0,nodesConnectable:b=!0,deleteKeyCode:x,showMiniMap:S=!1,showControls:C=!0,backgroundVariant:w=l.BackgroundVariant.Dots,fitView:T=!0,fitViewOptions:E,defaultEdgeOptions:D,className:O,"aria-label":k,...A},j)=>{let{t:M}=t.useWimTranslation(n.commonNs),N=k??M(`nodeGraph.label`),P=M(`nodeGraph.add_node`),F=M(`nodeGraph.node_name`),I=M(`nodeGraph.new_node`),L=M(`a11y.delete`),R=x===void 0?[...u]:x,z=R!=null,[B,V]=(0,o.useState)(!1),[H,U]=(0,o.useState)(``),W=(0,o.useRef)(null),G=(0,o.useMemo)(()=>e.filter(e=>e.selected),[e]),K=(0,o.useMemo)(()=>d.filter(e=>e.selected),[d]),q=G.length>0||K.length>0,J=H.trim(),Y=R==null?void 0:Array.isArray(R)?R.join(` `):R;(0,o.useEffect)(()=>{B&&W.current?.focus()},[B]);let X=(0,o.useCallback)(()=>{if(!z||!J)return;let t=p(e);f(new l.NodeChangeset([{type:`add`,id:t,item:{id:t,position:m(e),data:{label:J}}}])),V(!1),U(``)},[z,J,e,f]),Z=(0,o.useCallback)(()=>{z&&(B?X():V(!0))},[z,B,X]),Q=(0,o.useCallback)(e=>{e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),X()),e.key===`Escape`&&(e.preventDefault(),V(!1),U(``))},[X]),te=(0,o.useCallback)(()=>{if(!z||!q)return;let e=new Set(G.map(e=>e.id)),t=new Set(K.map(e=>e.id));for(let n of d)(e.has(n.source)||e.has(n.target))&&t.add(n.id);t.size>0&&h(new l.EdgeChangeset([...t].map(e=>({type:`remove`,id:e})))),e.size>0&&f(new l.NodeChangeset([...e].map(e=>({type:`remove`,id:e}))))},[z,q,G,K,d,h,f]),$=(0,o.useCallback)(e=>{e.stopPropagation()},[]);return(0,c.jsxs)(`div`,{ref:j,className:(0,s.default)(`wim-node-graph`,a.default.root,O),role:`region`,"aria-label":N,...A,children:[(0,c.jsxs)(l.ReactFlow,{nodes:e,edges:d,onNodesChange:f,onEdgesChange:h,onConnect:g,nodeTypes:_,edgeTypes:v,nodesDraggable:y,nodesConnectable:b,deleteKeyCode:R,fitView:T,fitViewOptions:E,defaultEdgeOptions:D,className:a.default.flow,children:[(0,c.jsx)(l.Background,{variant:w,className:a.default.background}),C&&(0,c.jsx)(l.Controls,{className:a.default.controls}),S&&(0,c.jsx)(l.MiniMap,{className:a.default.miniMap})]}),z&&(0,c.jsxs)(`div`,{className:a.default.tools,children:[B&&(0,c.jsx)(`input`,{ref:W,className:(0,s.default)(`nodrag`,`nopan`,a.default.name),value:H,onChange:e=>U(e.target.value),onKeyDown:Q,onPointerDown:$,onMouseDown:$,"aria-label":F,placeholder:I}),(0,c.jsxs)(`div`,{className:a.default.toolRow,children:[(0,c.jsxs)(`button`,{type:`button`,className:(0,s.default)(`nodrag`,`nopan`,a.default.tool),disabled:B&&!J,onClick:Z,onPointerDown:$,onMouseDown:$,"aria-label":P,"aria-expanded":B,children:[(0,c.jsx)(i.Icon,{component:r.default,size:`sm`}),P]}),(0,c.jsxs)(`button`,{type:`button`,className:(0,s.default)(`nodrag`,`nopan`,a.default.tool),disabled:!q,onClick:te,onPointerDown:$,onMouseDown:$,"aria-label":L,"aria-keyshortcuts":Y,children:[(0,c.jsx)(i.Icon,{component:ee.default,size:`sm`}),L]})]})]})]})});h.displayName=`NodeGraph`,exports.NodeGraph=h;
|