@wg-song/bare 0.1.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/.npmignore ADDED
File without changes
package/AGENTS.md ADDED
@@ -0,0 +1,241 @@
1
+ # AGENTS.md — @wg-song/bare 使用指南
2
+
3
+ 本文件面向 AI Agent,帮助 AI 在**不阅读源码**的情况下,正确使用 `@wg-song/bare` 业务组件库完成业务功能开发。
4
+
5
+ ## 1. 角色与目标
6
+
7
+ 你是业务前端开发助手。当前项目已接入 `@wg-song/bare`(Vue3 业务组件库,基于 Ant Design Vue + vxe-table)。
8
+
9
+ 你的任务:使用本库提供的组件、hooks、工具函数完成业务页面开发,**不要自己从零封装通用组件**。
10
+
11
+ ## 2. 基础接入(已默认完成)
12
+
13
+ 接入项目的 `main.ts` 通常已包含:
14
+
15
+ ```ts
16
+ import BareComponents from '@wg-song/bare'
17
+ import '@wg-song/bare/index.css'
18
+
19
+ app.use(BareComponents)
20
+ ```
21
+
22
+ 因此业务页面中直接使用组件即可,无需再次安装或注册。
23
+
24
+ ## 3. 组件选择速查表
25
+
26
+ | 业务场景 | 推荐组件 / API | 不推荐 |
27
+ |---|---|---|
28
+ | 普通表单(新增/编辑) | `Form` + `useForm` | 手写 `<a-form>` |
29
+ | 搜索区 + 表格 | `SearchForm` + `Table` | 手写搜索 + 表格 |
30
+ | 完整列表页(搜索/工具栏/分页) | `PageShell` 或 `PageList` | 用多个组件拼装 |
31
+ | 只读表格展示 | `TableRead` | `Table` 手动配置只读 |
32
+ | 行内编辑表格 | `TableEdit` | 手写单元格编辑 |
33
+ | 父子表/嵌套表格 | `TableChild` | 手写嵌套逻辑 |
34
+ | 分组统计表格 | `TableGroup` / `TableGroupPage` | 手写分组 |
35
+ | 弹窗表单 | `DialogForm` | 手写 `<a-modal>` + 表单 |
36
+ | 命令式确认提示 | `confirm` / `alert` | 手写 Modal |
37
+ | 命令式弹窗/抽屉 | `openModal` / `openDrawer` | 手写 createVNode + render |
38
+ | 页签切换 | `Tabs` / `TabsView` / `PageTabs` | 手写 `<a-tabs>` |
39
+ | 标签页 + 列表组合 | `PageListTabs` | 手写多个列表页切换 |
40
+ | 分割布局 | `SplitPane` / `SplitPaneLayout` | 手写 CSS 分割 |
41
+ | 表格行操作/工具栏 | `ToolbarActionBar` / `ToolbarActionButtonMenu` | 手写按钮组 |
42
+
43
+ ## 4. 标准代码模板
44
+
45
+ ### 4.1 表单页面
46
+
47
+ ```vue
48
+ <script setup lang="ts">
49
+ import { ref } from 'vue'
50
+ import { Form } from '@wg-song/bare'
51
+ import type { FormField } from '@wg-song/bare'
52
+
53
+ const schemas: FormField[] = [
54
+ { field: 'name', label: '名称', component: 'input', required: true },
55
+ { field: 'status', label: '状态', component: 'select', options: [
56
+ { label: '启用', value: 1 },
57
+ { label: '禁用', value: 0 },
58
+ ]},
59
+ ]
60
+
61
+ const model = ref({ name: '', status: 1 })
62
+
63
+ function onSubmit(values: Record<string, any>) {
64
+ console.log(values)
65
+ }
66
+ </script>
67
+
68
+ <template>
69
+ <Form v-model="model" :schemas="schemas" @submit="onSubmit" />
70
+ </template>
71
+ ```
72
+
73
+ ### 4.2 搜索 + 表格
74
+
75
+ ```vue
76
+ <script setup lang="ts">
77
+ import { SearchForm, Table } from '@wg-song/bare'
78
+ import type { FormField, TableColumn } from '@wg-song/bare'
79
+
80
+ const searchSchemas: FormField[] = [
81
+ { field: 'keyword', label: '关键词', component: 'input' },
82
+ ]
83
+
84
+ const columns: TableColumn[] = [
85
+ { field: 'name', title: '名称' },
86
+ { field: 'status', title: '状态' },
87
+ ]
88
+
89
+ const data = [{ name: '示例', status: '启用' }]
90
+ </script>
91
+
92
+ <template>
93
+ <SearchForm :schemas="searchSchemas" />
94
+ <Table :columns="columns" :data="data" />
95
+ </template>
96
+ ```
97
+
98
+ ### 4.3 列表页(推荐)
99
+
100
+ ```vue
101
+ <script setup lang="ts">
102
+ import { PageShell } from '@wg-song/bare'
103
+ import type { FormField, PageShellProps, ActionItem } from '@wg-song/bare'
104
+
105
+ const searchSchemas: FormField[] = [
106
+ { field: 'keyword', label: '关键词', component: 'input' },
107
+ ]
108
+
109
+ const toolbarActions: ActionItem[] = [
110
+ { label: '新增', onClick: () => {} },
111
+ ]
112
+
113
+ const loader: PageShellProps['loader'] = async ({ query, currentPage, pageSize }) => {
114
+ // 调用业务 API
115
+ return { list: [], total: 0 }
116
+ }
117
+ </script>
118
+
119
+ <template>
120
+ <PageShell
121
+ :search-schemas="searchSchemas"
122
+ :loader="loader"
123
+ :toolbar-actions="toolbarActions"
124
+ >
125
+ <template #default="{ tableData, loading }">
126
+ <!-- 渲染表格或其他内容 -->
127
+ </template>
128
+ </PageShell>
129
+ </template>
130
+ ```
131
+
132
+ ### 4.4 弹窗表单
133
+
134
+ ```vue
135
+ <script setup lang="ts">
136
+ import { ref } from 'vue'
137
+ import { DialogForm } from '@wg-song/bare'
138
+ import type { FormField } from '@wg-song/bare'
139
+
140
+ const open = ref(false)
141
+ const schemas: FormField[] = [
142
+ { field: 'name', label: '名称', component: 'input', required: true },
143
+ ]
144
+ </script>
145
+
146
+ <template>
147
+ <DialogForm v-model:open="open" :schemas="schemas" title="新增" @submit="console.log" />
148
+ </template>
149
+ ```
150
+
151
+ ### 4.5 命令式弹窗
152
+
153
+ ```ts
154
+ import { confirm, openModal } from '@wg-song/bare'
155
+
156
+ async function handleDelete() {
157
+ const ok = await confirm('确认删除', '删除后不可恢复')
158
+ if (ok) {
159
+ // 执行删除
160
+ }
161
+ }
162
+
163
+ function handleDetail(row: any) {
164
+ openModal(DetailComponent, { title: '详情', data: row })
165
+ }
166
+ ```
167
+
168
+ ## 5. 类型导入清单
169
+
170
+ ```ts
171
+ import type {
172
+ // 表单
173
+ FormField,
174
+ FormProps,
175
+ FormActionType,
176
+ FormContext,
177
+ SearchFormProps,
178
+ SearchFormInstance,
179
+ DialogFormProps,
180
+
181
+ // 表格
182
+ TableColumn,
183
+ TableProps,
184
+ TableActionType,
185
+ TableReadProps,
186
+ TableEditColumn,
187
+ TableChildProps,
188
+ TableGroupProps,
189
+
190
+ // 列表页
191
+ PageShellProps,
192
+ PageListProps,
193
+ PageListConfig,
194
+ PageListRowActions,
195
+ PageListOptions,
196
+ PageListFetchFn,
197
+ ActionItem,
198
+
199
+ // 弹窗
200
+ ModalContext,
201
+ ModalProps,
202
+ DrawerProps,
203
+
204
+ // 标签页
205
+ TabsProps,
206
+ TabsViewTab,
207
+ PageTabsProps,
208
+ PageListTabsProps,
209
+ } from '@wg-song/bare'
210
+ ```
211
+
212
+ ## 6. 重要约定
213
+
214
+ 1. **优先使用场景组件**:需要列表页时直接用 `PageShell`/`PageList`,不要手动拼装 `SearchForm + Table + Pagination`。
215
+ 2. **表单用 Schema 驱动**:使用 `FormField` 数组描述表单,避免手写大量 `<a-form-item>`。
216
+ 3. **表格列用 `TableColumn` 数组**:通过 `field`、`title`、`formatType` 等属性配置列,避免手写 `<vxe-column>`。
217
+ 4. **命令式弹窗直接用 `confirm` / `openModal`**:无需手动维护 Modal 的显示状态和 DOM。
218
+ 5. **类型从 `@wg-song/bare` 导入**:不要从源码路径或 `dist` 目录导入类型。
219
+ 6. **样式已全局引入**:业务页面不需要再单独引入组件样式。
220
+
221
+ ## 7. 常见错误避免
222
+
223
+ - ❌ `import { Form } from '@wg-song/bare/dist/...'` — 应从 `@wg-song/bare` 根导入。
224
+ - ❌ 在业务页面手写 `<a-form>` 表单 — 应使用 `Form` 组件。
225
+ - ❌ 手动维护 `vxe-table` 实例 — 应使用 `Table` / `TableRead` / `TableEdit`。
226
+ - ❌ 自己写 Modal 的显示逻辑 — 应使用 `DialogForm` / `confirm` / `openModal`。
227
+ - ❌ 从 `@packages` 导入 — 业务应用应使用构建产物包名 `@wg-song/bare`。
228
+
229
+ ## 8. 全局配置
230
+
231
+ 如需在 `main.ts` 中传入全局默认配置:
232
+
233
+ ```ts
234
+ app.use(BareComponents, {
235
+ globalConfig: {
236
+ table: { /* Table 默认配置 */ },
237
+ pageList: { /* PageList 默认配置 */ },
238
+ colPref: { /* 列偏好设置默认配置 */ },
239
+ },
240
+ })
241
+ ```
package/README.md ADDED
@@ -0,0 +1,248 @@
1
+ # @wg-song/bare — Vue3 业务组件库
2
+
3
+ 基于 **Vue 3 + Ant Design Vue + vxe-table** 的业务组件库,提供表单、表格、列表页、弹窗、标签页等高频业务场景组件。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add @wg-song/bare
9
+ ```
10
+
11
+ Peer dependencies(需由接入应用提供):
12
+
13
+ ```json
14
+ {
15
+ "vue": "^3.0.0",
16
+ "ant-design-vue": "^4.0.0",
17
+ "vxe-table": "^4.0.0",
18
+ "vxe-pc-ui": "^4.0.0",
19
+ "@ant-design/icons-vue": "^7.0.0",
20
+ "vue-router": "^4.0.0"
21
+ }
22
+ ```
23
+
24
+ ## 快速开始
25
+
26
+ 在 `main.ts` 中安装:
27
+
28
+ ```ts
29
+ import { createApp } from 'vue'
30
+ import BareComponents from '@wg-song/bare'
31
+ import '@wg-song/bare/index.css'
32
+
33
+ const app = createApp(App)
34
+ app.use(BareComponents)
35
+ app.mount('#app')
36
+ ```
37
+
38
+ > 注意:若使用本库内置的 Vite 应用演示工程,安装时已自动调用 `setupModal(app._context)`,接入方无需手动处理命令式弹窗上下文。
39
+
40
+ ## 组件总览
41
+
42
+ ### 表单 Form
43
+
44
+ | 组件 / API | 说明 |
45
+ |---|---|
46
+ | `Form` | Schema 驱动表单 |
47
+ | `SearchForm` | 搜索表单(含高级搜索、FilterBar) |
48
+ | `SearchFormSimple` | 简易单行搜索 |
49
+ | `DialogForm` | 弹窗表单场景 |
50
+ | `useForm` | 表单核心 hook |
51
+ | `useSearchForm` | 搜索表单 hook |
52
+
53
+ ### 表格 Table
54
+
55
+ | 组件 / API | 说明 |
56
+ |---|---|
57
+ | `Table` | 基础 vxe-table 封装 |
58
+ | `TableRead` | 只读表格(固定操作列等) |
59
+ | `TableEdit` | 行内编辑表格 |
60
+ | `TableChild` | 父子表格 |
61
+ | `TableGroup` / `TableGroupPage` | 分组表格 |
62
+ | `Pagination` | 分页 |
63
+
64
+ ### 列表页 PageList
65
+
66
+ | 组件 / API | 说明 |
67
+ |---|---|
68
+ | `PageList` | 完整列表页 |
69
+ | `PageShell` | 列表页外壳(搜索 + 工具栏 + 表格插槽 + 分页) |
70
+ | `PageEditList` | 可编辑列表页 |
71
+ | `PageChildList` | 子列表页 |
72
+ | `usePageList` | 列表页逻辑 hook |
73
+ | `definePageList` / `defineLoader` | 列表页配置定义 |
74
+
75
+ ### 弹窗 Modal
76
+
77
+ | 组件 / API | 说明 |
78
+ |---|---|
79
+ | `Modal` / `Drawer` | 声明式弹窗/抽屉 |
80
+ | `openModal` / `openDrawer` | 命令式打开弹窗/抽屉 |
81
+ | `confirm` / `alert` | 命令式确认/提示 |
82
+ | `PageModals` | 页面级弹窗管理器 |
83
+
84
+ ### 标签页 Tabs
85
+
86
+ | 组件 / API | 说明 |
87
+ |---|---|
88
+ | `Tabs` | 基础标签页 |
89
+ | `TabsView` / `PageTabs` | 页签视图 |
90
+ | `PageListTabs` | 标签页 + 列表组合 |
91
+ | `useTabState` / `useTabbedList` | 标签页状态 hook |
92
+
93
+ ### 布局与原子组件
94
+
95
+ | 组件 / API | 说明 |
96
+ |---|---|
97
+ | `SplitPane` / `SplitPaneLayout` | 分割面板 |
98
+ | `ToolbarActionBar` / `ToolbarActionButtonMenu` | 表格工具栏操作 |
99
+ | `Button`、`Input`、`Select`、`Tag`、`Link` 等 | 字段级原子组件(同样从 `@wg-song/bare` 导入) |
100
+
101
+ ## 核心使用模式
102
+
103
+ ### 1. Schema 表单
104
+
105
+ ```vue
106
+ <script setup lang="ts">
107
+ import { ref } from 'vue'
108
+ import { Form } from '@wg-song/bare'
109
+ import type { FormField } from '@wg-song/bare'
110
+
111
+ const schemas: FormField[] = [
112
+ { field: 'name', label: '名称', component: 'input', required: true },
113
+ { field: 'status', label: '状态', component: 'select', options: [
114
+ { label: '启用', value: 1 },
115
+ { label: '禁用', value: 0 },
116
+ ]},
117
+ ]
118
+
119
+ const model = ref({ name: '', status: 1 })
120
+
121
+ function onSubmit(values: Record<string, any>) {
122
+ console.log(values)
123
+ }
124
+ </script>
125
+
126
+ <template>
127
+ <Form v-model="model" :schemas="schemas" @submit="onSubmit" />
128
+ </template>
129
+ ```
130
+
131
+ ### 2. 搜索表单 + 表格
132
+
133
+ ```vue
134
+ <script setup lang="ts">
135
+ import { SearchForm, Table } from '@wg-song/bare'
136
+ import type { FormField, TableColumn } from '@wg-song/bare'
137
+
138
+ const searchSchemas: FormField[] = [
139
+ { field: 'keyword', label: '关键词', component: 'input' },
140
+ ]
141
+
142
+ const columns: TableColumn[] = [
143
+ { field: 'name', title: '名称' },
144
+ { field: 'status', title: '状态' },
145
+ ]
146
+
147
+ const data = [
148
+ { name: '示例', status: '启用' },
149
+ ]
150
+ </script>
151
+
152
+ <template>
153
+ <SearchForm :schemas="searchSchemas" />
154
+ <Table :columns="columns" :data="data" />
155
+ </template>
156
+ ```
157
+
158
+ ### 3. 列表页(推荐)
159
+
160
+ ```vue
161
+ <script setup lang="ts">
162
+ import { PageShell } from '@wg-song/bare'
163
+ import type { FormField, PageShellProps } from '@wg-song/bare'
164
+
165
+ const searchSchemas: FormField[] = [
166
+ { field: 'keyword', label: '关键词', component: 'input' },
167
+ ]
168
+
169
+ const loader: PageShellProps['loader'] = async ({ query, currentPage, pageSize }) => {
170
+ // 调用接口
171
+ return { list: [], total: 0 }
172
+ }
173
+
174
+ const toolbarActions = [
175
+ { label: '新增', onClick: () => {} },
176
+ ]
177
+ </script>
178
+
179
+ <template>
180
+ <PageShell :search-schemas="searchSchemas" :loader="loader" :toolbar-actions="toolbarActions">
181
+ <template #default="{ tableData, loading }">
182
+ <!-- 渲染具体表格场景 -->
183
+ </template>
184
+ </PageShell>
185
+ </template>
186
+ ```
187
+
188
+ ### 4. 命令式弹窗
189
+
190
+ ```ts
191
+ import { confirm, openModal } from '@wg-song/bare'
192
+
193
+ async function onDelete() {
194
+ const ok = await confirm('确认删除', '删除后不可恢复')
195
+ if (ok) {
196
+ // 执行删除
197
+ }
198
+ }
199
+
200
+ function onOpen() {
201
+ openModal(MyComponent, { title: '详情', data: row })
202
+ }
203
+ ```
204
+
205
+ ## 全局配置
206
+
207
+ 通过 `app.use(BareComponents, { globalConfig })` 传入:
208
+
209
+ ```ts
210
+ app.use(BareComponents, {
211
+ globalConfig: {
212
+ table: { /* Table 默认配置 */ },
213
+ pageList: { /* PageList 默认配置 */ },
214
+ colPref: { /* 列偏好设置默认配置 */ },
215
+ },
216
+ })
217
+ ```
218
+
219
+ ## 类型导入
220
+
221
+ ```ts
222
+ import type {
223
+ FormField,
224
+ FormProps,
225
+ TableColumn,
226
+ TableProps,
227
+ PageShellProps,
228
+ ActionItem,
229
+ } from '@wg-song/bare'
230
+ ```
231
+
232
+ ## 构建产物
233
+
234
+ `pnpm build:bare` 输出到 `dist/packages/`:
235
+
236
+ - `index.mjs` — ESM 主入口
237
+ - `index.cjs` — CommonJS 入口
238
+ - `index.umd.js` — UMD 入口
239
+ - `index.css` — 样式
240
+ - `types.d.ts` — TypeScript 类型声明
241
+ - `README.md` / `AGENTS.md` — 使用文档与 AI 指南
242
+ - `package.json`
243
+
244
+ 本地联调可在其他项目中:
245
+
246
+ ```json
247
+ "@wg-song/bare": "file:../songwg-business-components/dist/packages"
248
+ ```
@@ -0,0 +1,212 @@
1
+ (function() {
2
+ const y = "\0", R = "__root__", $ = String.fromCharCode(0);
3
+ function I(a) {
4
+ return a.replace(/\\/g, "\\\\").replace(new RegExp($, "g"), "\\0").replace(/:/g, "\\:");
5
+ }
6
+ function N(a, s) {
7
+ return a == null ? s : String(a);
8
+ }
9
+ function S(a, s, c, n) {
10
+ const l = a ?? n, r = s ?? n;
11
+ let o = 0;
12
+ if (typeof l == "number" && typeof r == "number") o = l - r;
13
+ else if (typeof l == "bigint" && typeof r == "bigint") o = l < r ? -1 : l > r ? 1 : 0;
14
+ else if (typeof l == "string" && typeof r == "string") o = l.localeCompare(r, "zh-CN", { numeric: !0 });
15
+ else {
16
+ const t = (e) => typeof e == "number" ? 0 : typeof e == "bigint" ? 1 : typeof e == "string" ? 2 : 3;
17
+ o = t(l) - t(r), o === 0 && (o = String(l).localeCompare(String(r), "zh-CN", { numeric: !0 }));
18
+ }
19
+ return c === "desc" ? -o : o;
20
+ }
21
+ function h(a, s) {
22
+ return a[s];
23
+ }
24
+ function M(a, s, c) {
25
+ const n = /* @__PURE__ */ new Map(), l = [];
26
+ for (const r of a) {
27
+ const o = s.map((u) => {
28
+ const d = r[u.field];
29
+ return {
30
+ fieldKey: u.field,
31
+ value: N(d, c),
32
+ rawValue: d
33
+ };
34
+ }), t = o.map((u) => `${u.fieldKey}:${I(u.value)}`).join(y);
35
+ let e = n.get(t);
36
+ e || (e = {
37
+ parts: o,
38
+ rows: []
39
+ }, n.set(t, e), l.push(e)), e.rows.push(r);
40
+ }
41
+ return l;
42
+ }
43
+ function k(a, s, c) {
44
+ a.sort((n, l) => {
45
+ for (let r = 0; r < s.length; r++) {
46
+ const o = S(n.parts[r].rawValue, l.parts[r].rawValue, s[r].sort ?? "asc", c);
47
+ if (o !== 0) return o;
48
+ }
49
+ return 0;
50
+ });
51
+ }
52
+ function v(a, s, c) {
53
+ const n = [], l = [], r = /* @__PURE__ */ new Map();
54
+ if (s.length === 0) {
55
+ for (const t of a) for (const e of t.rows) n.push({
56
+ ...e,
57
+ _nodeId: `data::::${h(e, c)}`,
58
+ _rowType: "data",
59
+ _groupDepth: 0,
60
+ _parentNodeId: "",
61
+ _sourceRowId: h(e, c)
62
+ });
63
+ return {
64
+ nodes: n,
65
+ groupNodeIds: l
66
+ };
67
+ }
68
+ const o = [];
69
+ for (const t of a) {
70
+ let e = 0;
71
+ for (; e < o.length && e < s.length && o[e]._groupFieldKey === t.parts[e].fieldKey && o[e]._groupValue === t.parts[e].value;) e++;
72
+ for (; o.length > e;) o.pop();
73
+ for (let d = e; d < s.length; d++) {
74
+ const p = s[d], g = t.parts[d], f = d === 0 ? void 0 : o[d - 1], i = f?._nodeId ?? "", w = i || R, _ = r.get(w) ?? 0;
75
+ r.set(w, _ + 1);
76
+ const b = {
77
+ _nodeId: `group::${i}::${p.field}::${_}`,
78
+ _rowType: "group",
79
+ _groupDepth: d,
80
+ _parentNodeId: f?._nodeId,
81
+ _groupFieldKey: p.field,
82
+ _groupLabel: p.label,
83
+ _groupValue: g.value,
84
+ _groupCount: 0
85
+ };
86
+ o.push(b), n.push(b), l.push(b._nodeId);
87
+ }
88
+ const u = o[s.length - 1];
89
+ for (const d of t.rows) {
90
+ for (const p of o) p._groupCount = p._groupCount + 1;
91
+ n.push({
92
+ ...d,
93
+ _nodeId: `data::${u._nodeId}::${h(d, c)}`,
94
+ _rowType: "data",
95
+ _groupDepth: s.length,
96
+ _parentNodeId: u._nodeId,
97
+ _sourceRowId: h(d, c)
98
+ });
99
+ }
100
+ }
101
+ return {
102
+ nodes: n,
103
+ groupNodeIds: l
104
+ };
105
+ }
106
+ function z(a, s) {
107
+ const c = [], n = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
108
+ for (const r of a) {
109
+ let o, t = "";
110
+ for (let e = 0; e < s.length; e++) {
111
+ const u = s[e], d = r.parts[e], p = t ? `${t}${y}${u.field}:${I(d.value)}` : `${u.field}:${I(d.value)}`;
112
+ let g = n.get(p);
113
+ if (!g) {
114
+ const f = l.get(t) ?? 0;
115
+ l.set(t, f + 1), g = {
116
+ nodeId: p,
117
+ fieldKey: u.field,
118
+ label: u.label,
119
+ value: d.value,
120
+ rawValue: d.rawValue,
121
+ depth: e,
122
+ children: [],
123
+ rows: [],
124
+ parent: o,
125
+ size: 0,
126
+ firstRowIndex: -1
127
+ }, n.set(p, g), o ? o.children.push(g) : c.push(g);
128
+ }
129
+ o = g, t = p;
130
+ }
131
+ o && o.rows.push(...r.rows);
132
+ }
133
+ return c;
134
+ }
135
+ function m(a, s) {
136
+ let c = 0;
137
+ for (const n of a) n.firstRowIndex = s + c, n.children.length > 0 ? n.size = m(n.children, s + c) : n.size = n.rows.length, c += n.size;
138
+ return c;
139
+ }
140
+ function C(a, s, c) {
141
+ const n = [];
142
+ if (s.length === 0) {
143
+ for (const t of a.flatMap((e) => e.rows)) n.push({
144
+ ...t,
145
+ _nodeId: `data::::${h(t, c)}`,
146
+ _rowType: "data",
147
+ _groupDepth: 0,
148
+ _parentNodeId: "",
149
+ _sourceRowId: h(t, c),
150
+ _groupSpans: []
151
+ });
152
+ return n;
153
+ }
154
+ let l = 0;
155
+ function r(t, e, u = {}) {
156
+ const d = e.map((i) => ({
157
+ depth: i.depth,
158
+ fieldKey: i.fieldKey,
159
+ label: i.label,
160
+ value: i.value,
161
+ size: i.size,
162
+ isStart: i.firstRowIndex === l,
163
+ nodeId: i.nodeId
164
+ })), p = e[e.length - 1], g = u.isFoldedHeader ? `folded:${p?.nodeId ?? "unknown"}` : h(t, c), f = `data::${u.isFoldedHeader ? "folded" : p?.nodeId ?? "flat"}::${g}`;
165
+ return {
166
+ ...t,
167
+ _nodeId: f,
168
+ _rowType: "data",
169
+ _groupDepth: s.length,
170
+ _parentNodeId: p?.nodeId ?? "",
171
+ _sourceRowId: g,
172
+ _groupSpans: d,
173
+ _isFoldedHeader: u.isFoldedHeader
174
+ };
175
+ }
176
+ function o(t, e) {
177
+ for (const u of t) {
178
+ const d = [...e, u];
179
+ if (u.children.length > 0) {
180
+ o(u.children, d);
181
+ continue;
182
+ }
183
+ for (const p of u.rows) n.push(r(p, d)), l++;
184
+ }
185
+ }
186
+ return o(a, []), n;
187
+ }
188
+ function T(a) {
189
+ const { id: s, rows: c, fields: n, mode: l, fallbackText: r, rowKeyField: o } = a.data, t = n.slice(0, 5), e = M(c, t, r);
190
+ k(e, t, r);
191
+ let u = [], d = [];
192
+ if (l === "rowspan") {
193
+ let i = function(w) {
194
+ for (const _ of w) d.push(_.nodeId), i(_.children);
195
+ };
196
+ const f = z(e, t);
197
+ m(f, 0), u = C(f, t, o), i(f);
198
+ } else {
199
+ const f = v(e, t, o);
200
+ u = f.nodes, d = f.groupNodeIds;
201
+ }
202
+ const p = {
203
+ id: s,
204
+ flatRows: u,
205
+ groupNodeIds: d
206
+ };
207
+ self.postMessage(p);
208
+ }
209
+ self.onmessage = (a) => {
210
+ T(a);
211
+ };
212
+ })();