@dazhicheng/ui 1.6.10 → 1.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/components/tt-form/src/useFormContext.js +1 -1
  2. package/dist/components/tt-table/index.js +4 -5
  3. package/dist/components/tt-table/src/TableForm.vue.js +2 -3
  4. package/dist/hooks/useBasicDataOptions.js +111 -96
  5. package/dist/hooks/useDataPermissionOptions.js +83 -85
  6. package/dist/hooks/useOwnerRoutePath.d.ts +5 -0
  7. package/dist/hooks/useOwnerRoutePath.js +7 -0
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.js +115 -129
  10. package/dist/packages/utils/src/is.js +37 -46
  11. package/dist/style.css +1 -1
  12. package/package.json +1 -1
  13. package/dist/components/tt-vtable/index.js +0 -54
  14. package/dist/components/tt-vtable/src/components/TtVTable.vue.d.ts +0 -188
  15. package/dist/components/tt-vtable/src/components/TtVTable.vue.js +0 -227
  16. package/dist/components/tt-vtable/src/components/TtVTable.vue2.js +0 -4
  17. package/dist/components/tt-vtable/src/components/TtVTableForm.vue.d.ts +0 -32
  18. package/dist/components/tt-vtable/src/components/TtVTableForm.vue.js +0 -121
  19. package/dist/components/tt-vtable/src/components/TtVTableForm.vue2.js +0 -4
  20. package/dist/components/tt-vtable/src/components/VTableEmpty.vue.d.ts +0 -64
  21. package/dist/components/tt-vtable/src/components/VTableEmpty.vue.js +0 -97
  22. package/dist/components/tt-vtable/src/components/VTableEmpty.vue2.js +0 -4
  23. package/dist/components/tt-vtable/src/components/VTablePagination.vue.d.ts +0 -53
  24. package/dist/components/tt-vtable/src/components/VTablePagination.vue.js +0 -52
  25. package/dist/components/tt-vtable/src/components/VTablePagination.vue2.js +0 -4
  26. package/dist/components/tt-vtable/src/components/VTableSelectionAlert.vue.d.ts +0 -35
  27. package/dist/components/tt-vtable/src/components/VTableSelectionAlert.vue.js +0 -50
  28. package/dist/components/tt-vtable/src/components/VTableSelectionAlert.vue2.js +0 -4
  29. package/dist/components/tt-vtable/src/components/VTableToolbar.vue.d.ts +0 -63
  30. package/dist/components/tt-vtable/src/components/VTableToolbar.vue.js +0 -126
  31. package/dist/components/tt-vtable/src/components/VTableToolbar.vue2.js +0 -4
  32. package/dist/components/tt-vtable/src/components/VTableViewport.vue.js +0 -133
  33. package/dist/components/tt-vtable/src/components/VTableViewport.vue2.js +0 -4
  34. package/dist/components/tt-vtable/src/composables/useVTable.d.ts +0 -41
  35. package/dist/components/tt-vtable/src/composables/useVTable.js +0 -25
  36. package/dist/components/tt-vtable/src/composables/useVTableFormRender.d.ts +0 -13
  37. package/dist/components/tt-vtable/src/composables/useVTableFormRender.js +0 -92
  38. package/dist/components/tt-vtable/src/composables/useVTableRender.d.ts +0 -13
  39. package/dist/components/tt-vtable/src/composables/useVTableRender.js +0 -13
  40. package/dist/components/tt-vtable/src/engine/visactor/createListTable.d.ts +0 -10
  41. package/dist/components/tt-vtable/src/engine/visactor/createListTable.js +0 -63
  42. package/dist/components/tt-vtable/src/engine/visactor/createVueCellLayout.d.ts +0 -37
  43. package/dist/components/tt-vtable/src/engine/visactor/createVueCellLayout.js +0 -133
  44. package/dist/components/tt-vtable/src/engine/visactor/index.d.ts +0 -8
  45. package/dist/components/tt-vtable/src/engine/visactor/native-boundaries.d.ts +0 -23
  46. package/dist/components/tt-vtable/src/engine/visactor/native-boundaries.js +0 -70
  47. package/dist/components/tt-vtable/src/engine/visactor/record-adapter.d.ts +0 -38
  48. package/dist/components/tt-vtable/src/engine/visactor/record-adapter.js +0 -41
  49. package/dist/components/tt-vtable/src/engine/visactor/toColumnDefinitions.d.ts +0 -45
  50. package/dist/components/tt-vtable/src/engine/visactor/toColumnDefinitions.js +0 -73
  51. package/dist/components/tt-vtable/src/engine/visactor/toListTableOptions.d.ts +0 -25
  52. package/dist/components/tt-vtable/src/engine/visactor/toListTableOptions.js +0 -25
  53. package/dist/components/tt-vtable/src/engine/visactor/types.d.ts +0 -29
  54. package/dist/components/tt-vtable/src/features/column-preferences/column-preference-storage.d.ts +0 -5
  55. package/dist/components/tt-vtable/src/features/column-preferences/column-preference-storage.js +0 -52
  56. package/dist/components/tt-vtable/src/features/column-preferences/useColumnPreferences.d.ts +0 -74
  57. package/dist/components/tt-vtable/src/features/column-preferences/useColumnPreferences.js +0 -232
  58. package/dist/components/tt-vtable/src/features/editing/useCellEditing.d.ts +0 -48
  59. package/dist/components/tt-vtable/src/features/editing/useCellEditing.js +0 -102
  60. package/dist/components/tt-vtable/src/features/form-integration/useVTableForm.d.ts +0 -51
  61. package/dist/components/tt-vtable/src/features/pagination/useTablePagination.d.ts +0 -40
  62. package/dist/components/tt-vtable/src/features/pagination/useTablePagination.js +0 -51
  63. package/dist/components/tt-vtable/src/features/querying/useRecordQuery.d.ts +0 -38
  64. package/dist/components/tt-vtable/src/features/querying/useRecordQuery.js +0 -57
  65. package/dist/components/tt-vtable/src/features/records/index.d.ts +0 -3
  66. package/dist/components/tt-vtable/src/features/records/record-index.d.ts +0 -122
  67. package/dist/components/tt-vtable/src/features/records/record-index.js +0 -209
  68. package/dist/components/tt-vtable/src/features/records/useRecordSource.d.ts +0 -41
  69. package/dist/components/tt-vtable/src/features/records/useRecordSource.js +0 -249
  70. package/dist/components/tt-vtable/src/features/selection/useRowSelection.d.ts +0 -65
  71. package/dist/components/tt-vtable/src/features/selection/useRowSelection.js +0 -129
  72. package/dist/components/tt-vtable/src/features/tree/useTreeRecords.d.ts +0 -60
  73. package/dist/components/tt-vtable/src/features/tree/useTreeRecords.js +0 -125
  74. package/dist/components/tt-vtable/src/public/column-preferences.d.ts +0 -32
  75. package/dist/components/tt-vtable/src/public/index.d.ts +0 -8
  76. package/dist/components/tt-vtable/src/public/table-api.d.ts +0 -215
  77. package/dist/components/tt-vtable/src/public/table-column.d.ts +0 -123
  78. package/dist/components/tt-vtable/src/public/table-errors.d.ts +0 -26
  79. package/dist/components/tt-vtable/src/public/table-errors.js +0 -26
  80. package/dist/components/tt-vtable/src/public/table-events.d.ts +0 -69
  81. package/dist/components/tt-vtable/src/public/table-props.d.ts +0 -216
  82. package/dist/components/tt-vtable/src/public/table-slots.d.ts +0 -37
  83. package/dist/components/tt-vtable/src/runtime/createVTableController.d.ts +0 -12
  84. package/dist/components/tt-vtable/src/runtime/createVTableController.js +0 -238
  85. package/dist/components/tt-vtable/src/runtime/createVTableRuntime.d.ts +0 -79
  86. package/dist/components/tt-vtable/src/runtime/createVTableRuntime.js +0 -380
@@ -1,102 +0,0 @@
1
- import "axios";
2
- import "element-plus";
3
- import { isError as B } from "../../../../../packages/utils/src/is.js";
4
- import { shallowRef as g, computed as F } from "vue";
5
- import "dayjs";
6
- import "numeral";
7
- import "xe-utils";
8
- import "dayjs/plugin/utc";
9
- import "dayjs/plugin/timezone";
10
- import "../../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
11
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
12
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
13
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
14
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
15
- import "lodash-es";
16
- function o(e, a) {
17
- return !!e && !!a && e.rowKey === a.rowKey && e.field === a.field;
18
- }
19
- function N(e) {
20
- if (e === !1) return new Error("Cell validation failed.");
21
- if (!(e === !0 || !e))
22
- return new Error(e);
23
- }
24
- function S(e) {
25
- return new Error(B(e) ? String(e).replace(/^Error:\s*/, "") : String(e));
26
- }
27
- function P(e) {
28
- const a = g(), d = g(!1), u = g();
29
- let n = 0;
30
- const K = F(() => !!a.value);
31
- async function x(l, c) {
32
- var i;
33
- const r = e.getRecordByKey(l);
34
- if (!r) throw new Error(`Cannot edit missing record "${String(l)}".`);
35
- const t = e.getFieldValue(r, c);
36
- n += 1, u.value = void 0, a.value = { rowKey: l, field: c, previousValue: t, value: t }, await ((i = e.startNativeEditing) == null ? void 0 : i.call(e, l, c));
37
- }
38
- function w(l) {
39
- a.value && (a.value = { ...a.value, value: l });
40
- }
41
- async function y(l = ((c) => (c = a.value) == null ? void 0 : c.value)()) {
42
- var m, V, h;
43
- const r = a.value;
44
- if (!r) return !1;
45
- const t = e.getRecordByKey(r.rowKey);
46
- if (!t) return !1;
47
- const i = (m = e.getValidator) == null ? void 0 : m.call(e, r.field);
48
- if (!i)
49
- return u.value = void 0, !0;
50
- n += 1;
51
- const f = n;
52
- d.value = !0, u.value = void 0;
53
- try {
54
- const E = await i({
55
- record: t,
56
- rowKey: r.rowKey,
57
- field: r.field,
58
- previousValue: r.previousValue,
59
- value: l
60
- });
61
- if (f !== n || !o(r, a.value)) return !1;
62
- const v = N(E);
63
- return u.value = v, v && ((V = e.onError) == null || V.call(e, v)), !v;
64
- } catch (E) {
65
- const v = S(E);
66
- return f !== n || !o(r, a.value) || (u.value = v, (h = e.onError) == null || h.call(e, v)), !1;
67
- } finally {
68
- f === n && (d.value = !1);
69
- }
70
- }
71
- async function C(l = ((c) => (c = a.value) == null ? void 0 : c.value)()) {
72
- var t, i;
73
- const r = a.value;
74
- if (!r || d.value || (w(l), !await y(l) || !o(r, a.value))) return !1;
75
- try {
76
- if (await e.setCellValue(r.rowKey, r.field, l, "editing"), !o(r, a.value)) return !1;
77
- const f = {
78
- rowKey: r.rowKey,
79
- field: r.field,
80
- previousValue: r.previousValue,
81
- value: l,
82
- changedFields: [r.field],
83
- source: "editing"
84
- };
85
- return a.value = void 0, u.value = void 0, (t = e.onCommit) == null || t.call(e, f), !0;
86
- } catch (f) {
87
- const m = S(f);
88
- return u.value = m, (i = e.onError) == null || i.call(e, m), !1;
89
- }
90
- }
91
- function s() {
92
- var l;
93
- n += 1, d.value = !1, u.value = void 0, a.value = void 0, (l = e.cancelNativeEditing) == null || l.call(e);
94
- }
95
- function q() {
96
- s();
97
- }
98
- return { activeCell: a, isValidating: d, validationError: u, isEditing: K, start: x, setValue: w, commit: C, cancel: s, validate: y, release: q };
99
- }
100
- export {
101
- P as useCellEditing
102
- };
@@ -1,51 +0,0 @@
1
- import { Ref } from 'vue';
2
- import { TtExtendedFormApi, TtFormProps } from '../../../../tt-form';
3
- import { TtVTableApi, TtVTableRowKey } from '../../public/table-api';
4
- import { TtVTableProps } from '../../public/table-props';
5
- /** TtVTableForm 的组合属性。 */
6
- export interface TtVTableFormProps<Row extends Record<string, unknown>, Key extends TtVTableRowKey = TtVTableRowKey, FormValues extends Record<string, unknown> = Record<string, unknown>> {
7
- /** TtForm 配置。 */
8
- form: TtFormProps<FormValues>;
9
- /** TtVTable 配置。 */
10
- table: TtVTableProps<Row, Key, FormValues>;
11
- }
12
- /** TtVTableForm 仅组合 form 与 table 两个命名空间。 */
13
- export interface TtVTableFormApi<Row extends Record<string, unknown>, Key extends TtVTableRowKey = TtVTableRowKey> {
14
- /** 稳定 TtForm API。 */
15
- form: TtExtendedFormApi;
16
- /** 稳定 TtVTable API。 */
17
- table: TtVTableApi<Row, Key>;
18
- }
19
- /** 表单查询状态写入策略。 */
20
- export interface VTableFormQueryStrategy {
21
- /** 是否把分页恢复为初始状态。 */
22
- resetPagination: boolean;
23
- /** 是否同时清理排序和筛选。 */
24
- resetSortAndFilters: boolean;
25
- }
26
- /** 表单与表格联动 feature 所需依赖。 */
27
- export interface UseVTableFormOptions<FormValues extends Record<string, unknown>> {
28
- /** 初始查询参数根快照。 */
29
- initialQueryParams?: Readonly<Partial<FormValues>>;
30
- /** 原子写入查询参数及对应重置策略。 */
31
- applyQueryState: (queryParams: Readonly<Partial<FormValues>>, strategy: VTableFormQueryStrategy) => void;
32
- /** 使用当前查询状态发起远程请求。 */
33
- fetchRecords: () => Promise<boolean>;
34
- /** 表单提交并准备查询前调用。 */
35
- onSubmit?: (values: Readonly<FormValues>) => Promise<void> | void;
36
- /** 表单重置并准备查询前调用。 */
37
- onReset?: (values: Readonly<FormValues>) => Promise<void> | void;
38
- }
39
- /** 表单与表格联动状态及动作。 */
40
- export interface VTableFormIntegration<FormValues extends Record<string, unknown>> {
41
- /** 当前不可变查询参数根快照。 */
42
- queryParams: Readonly<Ref<Readonly<Partial<FormValues>>>>;
43
- /** 是否正在执行提交或重置查询。 */
44
- isSubmitting: Readonly<Ref<boolean>>;
45
- /** 提交表单并执行一次查询。 */
46
- submit: (values: FormValues) => Promise<boolean>;
47
- /** 重置表单状态并执行一次查询。 */
48
- reset: (values: FormValues) => Promise<boolean>;
49
- }
50
- /** 创建表单提交、重置与表格查询之间的单向联动。 */
51
- export declare function useVTableForm<FormValues extends Record<string, unknown>>(options: UseVTableFormOptions<FormValues>): VTableFormIntegration<FormValues>;
@@ -1,40 +0,0 @@
1
- import { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
2
- import { TtVTablePageChange } from '../../public/table-events';
3
- /** 暴露给 runtime 的分页状态与动作。 */
4
- export interface VTablePagination<Row> {
5
- /** 当前从 1 开始的页码。 */
6
- page: Readonly<Ref<number>>;
7
- /** 每页记录数。 */
8
- pageSize: Readonly<Ref<number>>;
9
- /** 记录总数。 */
10
- total: ComputedRef<number>;
11
- /** 总页数。 */
12
- pageCount: ComputedRef<number>;
13
- /** 当前本地页记录,远程模式下为已加载记录。 */
14
- pageRecords: ComputedRef<readonly Row[]>;
15
- /** 修改当前页码。 */
16
- setPage: (page: number) => void;
17
- /** 修改每页数量并回到第一页。 */
18
- setPageSize: (pageSize: number) => void;
19
- /** 恢复配置的初始分页状态。 */
20
- reset: () => void;
21
- /** 接收最近一次有效远程响应的总数。 */
22
- setRemoteTotal: (total: number) => void;
23
- /** records 或 total 变化后校正页码。 */
24
- reconcilePage: () => void;
25
- }
26
- /** 分页 feature 所需依赖。 */
27
- export interface UseTablePaginationOptions<Row> {
28
- /** 初始从 1 开始的页码。 */
29
- initialPage?: number;
30
- /** 初始每页记录数。 */
31
- initialPageSize?: number;
32
- /** 是否使用远程记录源。 */
33
- isRemote: MaybeRefOrGetter<boolean>;
34
- /** 读取 runtime 当前加载的记录。 */
35
- getRecords: () => readonly Row[];
36
- /** 每次语义分页变化调用一次。 */
37
- onChange?: (change: TtVTablePageChange) => Promise<void> | void;
38
- }
39
- /** 创建单一状态源的本地或远程分页。 */
40
- export declare function useTablePagination<Row>(options: UseTablePaginationOptions<Row>): VTablePagination<Row>;
@@ -1,51 +0,0 @@
1
- import { shallowRef as f, computed as s, toValue as h, watch as S } from "vue";
2
- function r(e, i) {
3
- return !Number.isFinite(e) || e <= 0 ? i : Math.max(1, Math.floor(e));
4
- }
5
- function x(e) {
6
- return !Number.isFinite(e) || e <= 0 ? 0 : Math.floor(e);
7
- }
8
- function b(e) {
9
- const i = r(e.initialPage ?? 1, 1), o = r(e.initialPageSize ?? 20, 20), a = f(i), n = f(o), m = f(0), c = s(() => h(e.isRemote) ? m.value : e.getRecords().length), l = s(() => Math.max(1, Math.ceil(c.value / n.value))), P = s(() => {
10
- const u = e.getRecords();
11
- if (h(e.isRemote)) return u;
12
- const t = (a.value - 1) * n.value;
13
- return u.slice(t, t + n.value);
14
- });
15
- function g(u) {
16
- var t;
17
- (t = e.onChange) == null || t.call(e, { page: a.value, pageSize: n.value, reason: u });
18
- }
19
- function d(u) {
20
- const t = Math.min(r(u, a.value), l.value);
21
- t !== a.value && (a.value = t, g("page"));
22
- }
23
- function z(u) {
24
- const t = r(u, n.value);
25
- t === n.value && a.value === 1 || (n.value = t, a.value = 1, g("page-size"));
26
- }
27
- function R() {
28
- a.value === i && n.value === o || (a.value = i, n.value = o, g("reset"));
29
- }
30
- function M(u) {
31
- m.value = x(u), v();
32
- }
33
- function v() {
34
- a.value <= l.value || (a.value = l.value);
35
- }
36
- return S(c, v), {
37
- page: a,
38
- pageSize: n,
39
- total: c,
40
- pageCount: l,
41
- pageRecords: P,
42
- setPage: d,
43
- setPageSize: z,
44
- reset: R,
45
- setRemoteTotal: M,
46
- reconcilePage: v
47
- };
48
- }
49
- export {
50
- b as useTablePagination
51
- };
@@ -1,38 +0,0 @@
1
- import { MaybeRefOrGetter, Ref } from 'vue';
2
- import { TtVTableFetchRequest, TtVTableFetchResponse } from '../../public/table-props';
3
- /** 挂载 AbortSignal 前用于发起请求的快照。 */
4
- export type VTableRecordRequestSnapshot<QueryParams extends Record<string, unknown>> = Omit<TtVTableFetchRequest<QueryParams>, "signal">;
5
- /** 暴露给 runtime 的远程查询状态与动作。 */
6
- export interface VTableRecordQuery<QueryParams extends Record<string, unknown>> {
7
- /** 最新请求是否进行中。 */
8
- isFetching: Readonly<Ref<boolean>>;
9
- /** 最近一次被接纳请求的错误。 */
10
- error: Readonly<Ref<Error | undefined>>;
11
- /** 使用当前状态和可选覆盖参数执行请求。 */
12
- fetch: (overrides?: Partial<VTableRecordRequestSnapshot<QueryParams>>) => Promise<boolean>;
13
- /** 不重置分页并重放最近一次被接纳的请求。 */
14
- refresh: () => Promise<boolean>;
15
- /** 取消当前请求并使其响应失效。 */
16
- cancel: () => void;
17
- }
18
- /** 远程查询 feature 所需依赖。 */
19
- export interface UseRecordQueryOptions<Row, QueryParams extends Record<string, unknown>> {
20
- /** 远程记录请求回调。 */
21
- fetchRecords: (request: TtVTableFetchRequest<QueryParams>) => Promise<TtVTableFetchResponse<Row>>;
22
- /** 读取最新请求状态。 */
23
- getRequestSnapshot: () => VTableRecordRequestSnapshot<QueryParams>;
24
- /** 最新请求成功后替换 runtime 记录。 */
25
- replaceRecords: (records: readonly Row[]) => Promise<void> | void;
26
- /** 最新请求成功后保存总数。 */
27
- setTotal: (total: number) => void;
28
- /** 仅按根引用监听的 maybe-reactive 查询参数。 */
29
- queryParams?: MaybeRefOrGetter<QueryParams>;
30
- /** 是否立即执行首次请求。 */
31
- immediate?: boolean;
32
- /** 最新请求被接纳后调用。 */
33
- onSuccess?: (response: TtVTableFetchResponse<Row>, request: TtVTableFetchRequest<QueryParams>) => void;
34
- /** 最新且未中止的请求失败时调用。 */
35
- onError?: (error: Error, request: TtVTableFetchRequest<QueryParams>) => void;
36
- }
37
- /** 创建可防止请求竞态的远程记录查询 feature。 */
38
- export declare function useRecordQuery<Row, QueryParams extends Record<string, unknown> = Record<string, unknown>>(options: UseRecordQueryOptions<Row, QueryParams>): VTableRecordQuery<QueryParams>;
@@ -1,57 +0,0 @@
1
- import "axios";
2
- import "element-plus";
3
- import { isError as p } from "../../../../../packages/utils/src/is.js";
4
- import { shallowRef as h, watch as E, toValue as v, onScopeDispose as R } from "vue";
5
- import "dayjs";
6
- import "numeral";
7
- import "xe-utils";
8
- import "dayjs/plugin/utc";
9
- import "dayjs/plugin/timezone";
10
- import "../../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
11
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
12
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
13
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
14
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
15
- import "lodash-es";
16
- function w(r) {
17
- return new Error(p(r) ? String(r).replace(/^Error:\s*/, "") : String(r));
18
- }
19
- function y(r) {
20
- return r.name === "AbortError";
21
- }
22
- function I(r) {
23
- const c = h(!1), n = h();
24
- let e, t = 0, o;
25
- async function i(S = {}) {
26
- var d, q;
27
- e == null || e.abort(), e = new AbortController(), t += 1;
28
- const s = t, m = { ...r.getRequestSnapshot(), ...S }, a = {
29
- ...m,
30
- signal: e.signal
31
- };
32
- c.value = !0, n.value = void 0;
33
- try {
34
- const u = await r.fetchRecords(a);
35
- return s !== t || a.signal.aborted || (await r.replaceRecords(u.records), s !== t || a.signal.aborted) ? !1 : (r.setTotal(u.total), o = m, (d = r.onSuccess) == null || d.call(r, u, a), !0);
36
- } catch (u) {
37
- const l = w(u);
38
- return s !== t || a.signal.aborted || y(l) || (n.value = l, (q = r.onError) == null || q.call(r, l, a)), !1;
39
- } finally {
40
- s === t && (c.value = !1);
41
- }
42
- }
43
- function g() {
44
- return i(o);
45
- }
46
- function f() {
47
- t += 1, e == null || e.abort(), e = void 0, c.value = !1;
48
- }
49
- return r.queryParams ? E(
50
- () => v(r.queryParams),
51
- () => void i(),
52
- { immediate: r.immediate ?? !0 }
53
- ) : (r.immediate ?? !0) && i(), R(f), { isFetching: c, error: n, fetch: i, refresh: g, cancel: f };
54
- }
55
- export {
56
- I as useRecordQuery
57
- };
@@ -1,3 +0,0 @@
1
- /** TtVTable records feature 与 rowKey 索引。 */
2
- export * from './record-index';
3
- export * from './useRecordSource';
@@ -1,122 +0,0 @@
1
- import { TtVTableFieldPath, TtVTableRowKey, TtVTableRowKeySource } from '../../public';
2
- /** 根记录或树节点在源 records 中的索引路径。 */
3
- export type TtVTableRecordPath = readonly number[];
4
- /** rowKey 索引中的一条记录位置。 */
5
- export interface TtVTableRecordLocation<Row, Key extends TtVTableRowKey = TtVTableRowKey> {
6
- /** 当前业务主键。 */
7
- rowKey: Key;
8
- /** 当前运行时记录。 */
9
- record: Row;
10
- /** 从根 records 到当前记录的源索引路径。 */
11
- path: TtVTableRecordPath;
12
- }
13
- /**
14
- * 把字段路径规范为可逐层读取的片段。
15
- * @param field 字段或点分隔字段路径
16
- * @returns 路径片段
17
- */
18
- export declare function toFieldSegments(field: TtVTableFieldPath): (number | string)[];
19
- /**
20
- * 按字段路径读取记录值。
21
- * @param record 业务记录
22
- * @param field 字段或点分隔字段路径
23
- * @returns 路径对应值
24
- */
25
- export declare function getRecordFieldValue<Row extends Record<string, unknown>>(record: Readonly<Row>, field: TtVTableFieldPath): unknown;
26
- /**
27
- * 判断值是否是合法业务主键。
28
- * @param rowKey 待判断主键
29
- * @returns 是否为非空字符串或有限数字
30
- */
31
- export declare function isValidVTableRowKey(rowKey: unknown): rowKey is TtVTableRowKey;
32
- /**
33
- * 按字段路径创建只复制命中分支的新记录。
34
- * @param record 原记录
35
- * @param field 字段或点分隔字段路径
36
- * @param value 待写值
37
- * @returns 更新后的记录
38
- */
39
- export declare function toRecordWithFieldValue<Row extends Record<string, unknown>>(record: Row, field: TtVTableFieldPath, value: unknown): Row;
40
- /**
41
- * 按字段路径直接修改共享记录。
42
- * @param record 共享记录
43
- * @param field 字段或点分隔字段路径
44
- * @param value 待写值
45
- */
46
- export declare function setSharedRecordFieldValue<Row extends Record<string, unknown>>(record: Row, field: TtVTableFieldPath, value: unknown): void;
47
- /**
48
- * 按源索引路径读取根记录或树节点。
49
- * @param records 根记录集合
50
- * @param path 源索引路径
51
- * @param childrenField 子节点字段路径
52
- * @returns 命中的记录
53
- */
54
- export declare function getRecordAtPath<Row extends Record<string, unknown>>(records: readonly Row[], path: TtVTableRecordPath, childrenField: string): Row | undefined;
55
- /**
56
- * 在运行时根数组中替换记录,并只复制树路径上的父分支。
57
- * @param records 运行时根记录数组
58
- * @param path 目标源索引路径
59
- * @param nextRecord 更新后的目标记录
60
- * @param childrenField 子节点字段路径
61
- */
62
- export declare function replaceRecordAtPath<Row extends Record<string, unknown>>(records: Row[], path: TtVTableRecordPath, nextRecord: Row, childrenField: string): void;
63
- /** 维护 rowKey 到源索引路径的稳定映射。 */
64
- export declare class TtVTableRecordIndex<Row extends Record<string, unknown>, Key extends TtVTableRowKey = TtVTableRowKey> {
65
- /** 业务主键字段路径或读取函数。 */
66
- private readonly rowKeySource;
67
- /** 子节点字段路径。 */
68
- private readonly childrenField;
69
- /** 当前主键位置映射。 */
70
- private locations;
71
- /**
72
- * 创建空 rowKey 索引。
73
- * @param rowKeySource 业务主键字段路径或读取函数
74
- * @param childrenField 子节点字段路径
75
- */
76
- constructor(rowKeySource: TtVTableRowKeySource<Row, Key>, childrenField?: string);
77
- /** 当前索引记录数量。 */
78
- get size(): number;
79
- /**
80
- * 从业务记录读取并校验主键。
81
- * @param record 业务记录
82
- * @returns 合法业务主键
83
- */
84
- getRowKey(record: Row): Key;
85
- /**
86
- * 使用新的根记录重建并原子替换索引。
87
- * @param records 运行时根记录
88
- */
89
- replace(records: readonly Row[]): void;
90
- /**
91
- * 判断索引是否包含主键。
92
- * @param rowKey 业务主键
93
- * @returns 是否存在
94
- */
95
- has(rowKey: Key): boolean;
96
- /**
97
- * 按主键读取位置。
98
- * @param rowKey 业务主键
99
- * @returns 当前记录位置
100
- */
101
- getLocation(rowKey: Key): TtVTableRecordLocation<Row, Key> | undefined;
102
- /**
103
- * 按主键读取记录。
104
- * @param rowKey 业务主键
105
- * @returns 当前运行时记录
106
- */
107
- getRecord(rowKey: Key): Row | undefined;
108
- /**
109
- * 原子迁移一条记录的主键、引用和路径。
110
- * @param previousRowKey 变化前主键
111
- * @param nextRowKey 变化后主键
112
- * @param record 更新后的记录
113
- * @param path 当前源索引路径
114
- */
115
- replaceLocation(previousRowKey: Key, nextRowKey: Key, record: Row, path: TtVTableRecordPath): void;
116
- /**
117
- * 更新 copy-on-write 后树分支上的记录引用。
118
- * @param records 当前运行时根记录
119
- * @param path 已修改记录路径
120
- */
121
- refreshBranch(records: readonly Row[], path: TtVTableRecordPath): void;
122
- }
@@ -1,209 +0,0 @@
1
- var b = Object.defineProperty;
2
- var E = (r, t, o) => t in r ? b(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o;
3
- var f = (r, t, o) => E(r, typeof t != "symbol" ? t + "" : t, o);
4
- import "axios";
5
- import "element-plus";
6
- import { isFunction as F, isArray as u, isNumber as g, isString as I, isObject as T } from "../../../../../packages/utils/src/is.js";
7
- import "vue";
8
- import "dayjs";
9
- import "numeral";
10
- import "xe-utils";
11
- import "dayjs/plugin/utc";
12
- import "dayjs/plugin/timezone";
13
- import "../../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
14
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
15
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
16
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
17
- import "../../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
18
- import "lodash-es";
19
- import { createTtVTableError as m } from "../../public/table-errors.js";
20
- function L(r) {
21
- return g(r) ? [r] : r.split(".").filter(Boolean);
22
- }
23
- function V(r) {
24
- return T(r) || u(r);
25
- }
26
- function w(r, t) {
27
- return u(r) ? g(t) ? r[t] : void 0 : r[t];
28
- }
29
- function p(r, t) {
30
- let o = r;
31
- const e = L(t);
32
- for (const i of e) {
33
- if (!V(o)) return;
34
- o = w(o, i);
35
- }
36
- return o;
37
- }
38
- function K(r) {
39
- return I(r) ? !!r : g(r) && Number.isFinite(r);
40
- }
41
- function y(r) {
42
- return u(r) ? [...r] : T(r) ? { ...r } : {};
43
- }
44
- function R(r, t, o) {
45
- if (u(r)) {
46
- g(t) && (r[t] = o);
47
- return;
48
- }
49
- r[t] = o;
50
- }
51
- function A(r, t, o) {
52
- const e = L(t);
53
- if (!e.length) return r;
54
- const i = { ...r };
55
- let c = r, n = i;
56
- return e.forEach((s, l) => {
57
- if (l === e.length - 1) {
58
- R(n, s, o);
59
- return;
60
- }
61
- const h = V(c) ? w(c, s) : void 0, d = y(h);
62
- R(n, s, d), c = h, n = d;
63
- }), i;
64
- }
65
- function _(r, t, o) {
66
- let e = r, i;
67
- for (let c = 0; c < t.length; c += 1) {
68
- const n = t[c];
69
- if (n === void 0 || (i = e[n], !i)) return;
70
- if (c === t.length - 1) return i;
71
- const s = p(i, o);
72
- if (!u(s)) return;
73
- e = s;
74
- }
75
- return i;
76
- }
77
- function q(r, t, o, e) {
78
- if (!t.length) return;
79
- if (t.length === 1) {
80
- const n = t[0];
81
- if (n === void 0) return;
82
- r[n] = o;
83
- return;
84
- }
85
- let i = o;
86
- for (let n = t.length - 2; n >= 0; n -= 1) {
87
- const s = t.slice(0, n + 1), l = _(r, s, e);
88
- if (!l) return;
89
- const a = p(l, e);
90
- if (!u(a)) return;
91
- const h = [...a], d = t[n + 1];
92
- if (d === void 0) return;
93
- h[d] = i, i = A(l, e, h);
94
- }
95
- const c = t[0];
96
- c !== void 0 && (r[c] = i);
97
- }
98
- class G {
99
- /**
100
- * 创建空 rowKey 索引。
101
- * @param rowKeySource 业务主键字段路径或读取函数
102
- * @param childrenField 子节点字段路径
103
- */
104
- constructor(t, o = "children") {
105
- /** 业务主键字段路径或读取函数。 */
106
- f(this, "rowKeySource");
107
- /** 子节点字段路径。 */
108
- f(this, "childrenField");
109
- /** 当前主键位置映射。 */
110
- f(this, "locations", /* @__PURE__ */ new Map());
111
- this.rowKeySource = t, this.childrenField = o;
112
- }
113
- /** 当前索引记录数量。 */
114
- get size() {
115
- return this.locations.size;
116
- }
117
- /**
118
- * 从业务记录读取并校验主键。
119
- * @param record 业务记录
120
- * @returns 合法业务主键
121
- */
122
- getRowKey(t) {
123
- const o = F(this.rowKeySource) ? this.rowKeySource(t) : p(t, this.rowKeySource);
124
- if (!K(o))
125
- throw m("TT_VTABLE_ROW_KEY_INVALID", "rowKey 必须是非空字符串或有限数字。", { rowKey: o });
126
- return o;
127
- }
128
- /**
129
- * 使用新的根记录重建并原子替换索引。
130
- * @param records 运行时根记录
131
- */
132
- replace(t) {
133
- const o = /* @__PURE__ */ new Map(), e = (i, c) => {
134
- i.forEach((n, s) => {
135
- const l = this.getRowKey(n);
136
- if (o.has(l))
137
- throw m("TT_VTABLE_DUPLICATE_ROW_KEY", `rowKey ${String(l)} 在整棵记录树中重复。`, {
138
- rowKey: l
139
- });
140
- const a = [...c, s];
141
- o.set(l, { rowKey: l, record: n, path: a });
142
- const h = p(n, this.childrenField);
143
- u(h) && h.length && e(h, a);
144
- });
145
- };
146
- e(t, []), this.locations = o;
147
- }
148
- /**
149
- * 判断索引是否包含主键。
150
- * @param rowKey 业务主键
151
- * @returns 是否存在
152
- */
153
- has(t) {
154
- return this.locations.has(t);
155
- }
156
- /**
157
- * 按主键读取位置。
158
- * @param rowKey 业务主键
159
- * @returns 当前记录位置
160
- */
161
- getLocation(t) {
162
- return this.locations.get(t);
163
- }
164
- /**
165
- * 按主键读取记录。
166
- * @param rowKey 业务主键
167
- * @returns 当前运行时记录
168
- */
169
- getRecord(t) {
170
- var o;
171
- return (o = this.locations.get(t)) == null ? void 0 : o.record;
172
- }
173
- /**
174
- * 原子迁移一条记录的主键、引用和路径。
175
- * @param previousRowKey 变化前主键
176
- * @param nextRowKey 变化后主键
177
- * @param record 更新后的记录
178
- * @param path 当前源索引路径
179
- */
180
- replaceLocation(t, o, e, i) {
181
- if (o !== t && this.locations.has(o))
182
- throw m("TT_VTABLE_DUPLICATE_ROW_KEY", `rowKey ${String(o)} 已存在。`, {
183
- rowKey: o
184
- });
185
- this.locations.delete(t), this.locations.set(o, { rowKey: o, record: e, path: [...i] });
186
- }
187
- /**
188
- * 更新 copy-on-write 后树分支上的记录引用。
189
- * @param records 当前运行时根记录
190
- * @param path 已修改记录路径
191
- */
192
- refreshBranch(t, o) {
193
- for (let e = 1; e <= o.length; e += 1) {
194
- const i = o.slice(0, e), c = _(t, i, this.childrenField);
195
- if (!c) continue;
196
- const n = this.getRowKey(c), s = this.locations.get(n);
197
- s && (s.record = c, s.path = i);
198
- }
199
- }
200
- }
201
- export {
202
- G as TtVTableRecordIndex,
203
- _ as getRecordAtPath,
204
- p as getRecordFieldValue,
205
- K as isValidVTableRowKey,
206
- q as replaceRecordAtPath,
207
- L as toFieldSegments,
208
- A as toRecordWithFieldValue
209
- };