@vtable-guild/vtable-guild 2.9.0-alpha.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/css/index.css +296 -9
  2. package/css/presets/antdv.css +3 -0
  3. package/css/presets/element-plus.css +3 -0
  4. package/css/style.css +544 -43
  5. package/css/tailwind3-utilities.css +189 -32
  6. package/css/tailwind3.css +355 -11
  7. package/css/tailwind4.css +355 -11
  8. package/css/transitions.css +53 -2
  9. package/dist/core/src/utils/types.d.ts +3 -0
  10. package/dist/core/src/utils/types.d.ts.map +1 -1
  11. package/dist/css/index.css +296 -9
  12. package/dist/css/presets/antdv.css +3 -0
  13. package/dist/css/presets/element-plus.css +3 -0
  14. package/dist/css/style.css +544 -43
  15. package/dist/css/tailwind3-utilities.css +189 -32
  16. package/dist/css/tailwind3.css +355 -11
  17. package/dist/css/tailwind4.css +355 -11
  18. package/dist/css/transitions.css +53 -2
  19. package/dist/icons/src/EditOutlinedIcon.d.ts +3 -0
  20. package/dist/icons/src/EditOutlinedIcon.d.ts.map +1 -0
  21. package/dist/icons/src/EditOutlinedIcon.mjs +9 -0
  22. package/dist/icons/src/ElFilterIcon.mjs +9 -0
  23. package/dist/icons/src/index.d.ts +1 -0
  24. package/dist/icons/src/index.d.ts.map +1 -1
  25. package/dist/index.full.mjs +9349 -7117
  26. package/dist/index.mjs +112 -106
  27. package/dist/table/src/components/Table.d.ts +1 -1
  28. package/dist/table/src/components/TableCell.d.ts.map +1 -1
  29. package/dist/table/src/components/TableCell.mjs +118 -147
  30. package/dist/table/src/components/TableEditFrame.d.ts +58 -0
  31. package/dist/table/src/components/TableEditFrame.d.ts.map +1 -0
  32. package/dist/table/src/components/TableEditFrame.mjs +127 -0
  33. package/dist/table/src/components/TableEditLayout.test.d.ts +2 -0
  34. package/dist/table/src/components/TableEditLayout.test.d.ts.map +1 -0
  35. package/dist/table/src/components/TableEditableCell.d.ts +46 -9
  36. package/dist/table/src/components/TableEditableCell.d.ts.map +1 -1
  37. package/dist/table/src/components/TableEditableCell.mjs +99 -22
  38. package/dist/table/src/components/TableLightFilter.d.ts +76 -0
  39. package/dist/table/src/components/TableLightFilter.d.ts.map +1 -0
  40. package/dist/table/src/components/TableLightFilter.mjs +320 -0
  41. package/dist/table/src/components/TableLightFilter.test.d.ts +2 -0
  42. package/dist/table/src/components/TableLightFilter.test.d.ts.map +1 -0
  43. package/dist/table/src/components/TableQuery.d.ts +107 -46
  44. package/dist/table/src/components/TableQuery.d.ts.map +1 -1
  45. package/dist/table/src/components/TableQuery.mjs +481 -184
  46. package/dist/table/src/components/TableQueryNative.test.d.ts +2 -0
  47. package/dist/table/src/components/TableQueryNative.test.d.ts.map +1 -0
  48. package/dist/table/src/components/TableSelectionAlert.d.ts +1 -1
  49. package/dist/table/src/components/TableSelectionAlert.d.ts.map +1 -1
  50. package/dist/table/src/components/TableSelectionAlert.mjs +109 -55
  51. package/dist/table/src/components/VTableEditCell.test.d.ts +2 -0
  52. package/dist/table/src/components/VTableEditCell.test.d.ts.map +1 -0
  53. package/dist/table/src/components/VTableEditCell.vue.d.ts +18 -3
  54. package/dist/table/src/components/VTableEditCell.vue.d.ts.map +1 -1
  55. package/dist/table/src/components/VTableEditCell.vue.mjs +172 -10
  56. package/dist/table/src/components/VTableEditShell.vue.d.ts +38 -0
  57. package/dist/table/src/components/VTableEditShell.vue.d.ts.map +1 -0
  58. package/dist/table/src/components/VTableEditShell.vue.mjs +37 -0
  59. package/dist/table/src/components/VTableEditShell.vue2.mjs +4 -0
  60. package/dist/table/src/components/VTableQuery.vue.d.ts +4 -3
  61. package/dist/table/src/components/VTableQuery.vue.d.ts.map +1 -1
  62. package/dist/table/src/components/VTableQuery.vue.mjs +53 -31
  63. package/dist/table/src/components/VirtualTableBody.mjs +24 -23
  64. package/dist/table/src/components/renderCellDisplay.d.ts +6 -0
  65. package/dist/table/src/components/renderCellDisplay.d.ts.map +1 -0
  66. package/dist/table/src/components/renderCellDisplay.mjs +37 -0
  67. package/dist/table/src/composables/useQueryCollapseMotion.d.ts +4 -0
  68. package/dist/table/src/composables/useQueryCollapseMotion.d.ts.map +1 -0
  69. package/dist/table/src/composables/useQueryCollapseMotion.mjs +48 -0
  70. package/dist/table/src/composables/useQueryCollapseMotion.test.d.ts +2 -0
  71. package/dist/table/src/composables/useQueryCollapseMotion.test.d.ts.map +1 -0
  72. package/dist/table/src/composables/useSelection.d.ts.map +1 -1
  73. package/dist/table/src/composables/useSelection.mjs +157 -148
  74. package/dist/table/src/composables/useTableEdit.d.ts +17 -0
  75. package/dist/table/src/composables/useTableEdit.d.ts.map +1 -1
  76. package/dist/table/src/composables/useTableEdit.mjs +326 -266
  77. package/dist/table/src/composables/useTableEditable.d.ts.map +1 -1
  78. package/dist/table/src/composables/useTableEditable.mjs +321 -89
  79. package/dist/table/src/controls.d.ts.map +1 -1
  80. package/dist/table/src/controls.mjs +198 -79
  81. package/dist/table/src/index.d.ts +2 -0
  82. package/dist/table/src/index.d.ts.map +1 -1
  83. package/dist/table/src/types/controls.d.ts +61 -3
  84. package/dist/table/src/types/controls.d.ts.map +1 -1
  85. package/dist/table/src/types/controls.mjs +4 -0
  86. package/dist/table/src/types/editable.d.ts +78 -4
  87. package/dist/table/src/types/editable.d.ts.map +1 -1
  88. package/dist/table/src/types/editable.typecheck.d.ts.map +1 -1
  89. package/dist/table/src/types/editing.d.ts +5 -2
  90. package/dist/table/src/types/editing.d.ts.map +1 -1
  91. package/dist/table/src/types/query-form.d.ts +76 -15
  92. package/dist/table/src/types/query-form.d.ts.map +1 -1
  93. package/dist/table/src/types/query-form.typecheck.d.ts +4 -0
  94. package/dist/table/src/types/query-form.typecheck.d.ts.map +1 -1
  95. package/dist/table/src/types/table.d.ts +1 -0
  96. package/dist/table/src/types/table.d.ts.map +1 -1
  97. package/dist/table/src/utils/cell.d.ts +18 -12
  98. package/dist/table/src/utils/cell.d.ts.map +1 -1
  99. package/dist/table/src/utils/cell.mjs +95 -94
  100. package/dist/table/src/utils/draftEqual.d.ts +2 -0
  101. package/dist/table/src/utils/draftEqual.d.ts.map +1 -0
  102. package/dist/table/src/utils/draftEqual.mjs +22 -0
  103. package/dist/table/src/utils/queryFields.mjs +11 -11
  104. package/dist/table/src/utils/queryFilterLayout.d.ts +29 -0
  105. package/dist/table/src/utils/queryFilterLayout.d.ts.map +1 -0
  106. package/dist/table/src/utils/queryFilterLayout.mjs +74 -0
  107. package/dist/table/src/utils/queryFilterLayout.test.d.ts +2 -0
  108. package/dist/table/src/utils/queryFilterLayout.test.d.ts.map +1 -0
  109. package/dist/table/src/utils/queryInlineLayout.d.ts +22 -0
  110. package/dist/table/src/utils/queryInlineLayout.d.ts.map +1 -0
  111. package/dist/table/src/utils/queryInlineLayout.mjs +92 -0
  112. package/dist/table/src/utils/queryInlineLayout.test.d.ts +2 -0
  113. package/dist/table/src/utils/queryInlineLayout.test.d.ts.map +1 -0
  114. package/dist/table/src/utils/snapshot.d.ts +2 -0
  115. package/dist/table/src/utils/snapshot.d.ts.map +1 -1
  116. package/dist/table/src/utils/snapshot.mjs +18 -13
  117. package/dist/theme/src/presets/antdv/table-locale.d.ts +6 -0
  118. package/dist/theme/src/presets/antdv/table-locale.d.ts.map +1 -1
  119. package/dist/theme/src/presets/antdv/table-locale.mjs +16 -2
  120. package/dist/theme/src/presets/antdv/table.d.ts +18 -8
  121. package/dist/theme/src/presets/antdv/table.d.ts.map +1 -1
  122. package/dist/theme/src/presets/antdv/table.mjs +56 -12
  123. package/dist/theme/src/presets/element-plus/table-locale.d.ts +6 -0
  124. package/dist/theme/src/presets/element-plus/table-locale.d.ts.map +1 -1
  125. package/dist/theme/src/presets/element-plus/table-locale.mjs +16 -2
  126. package/dist/theme/src/presets/element-plus/table.d.ts +18 -8
  127. package/dist/theme/src/presets/element-plus/table.d.ts.map +1 -1
  128. package/dist/theme/src/presets/element-plus/table.mjs +57 -10
  129. package/dist/theme/src/query.d.ts +34 -57
  130. package/dist/theme/src/query.d.ts.map +1 -1
  131. package/dist/theme/src/query.mjs +23 -24
  132. package/dist/theme/src/selection-alert.d.ts +8 -0
  133. package/dist/theme/src/selection-alert.d.ts.map +1 -1
  134. package/dist/theme/src/selection-alert.mjs +2 -0
  135. package/dist/vtable-guild/src/index.d.ts +1 -1
  136. package/dist/vtable-guild/src/index.d.ts.map +1 -1
  137. package/package.json +2 -1
@@ -1,11 +1,21 @@
1
- import { defineComponent as ae, inject as ne, computed as y, useId as le, ref as K, watch as ue, onBeforeUnmount as re, createVNode as n, mergeProps as oe, toValue as C, Fragment as se, nextTick as ie } from "vue";
2
- import { useTheme as de } from "../../../core/src/composables/useTheme.mjs";
3
- import F from "../../../core/src/components/Button.mjs";
4
- import { VTABLE_GUILD_INJECTION_KEY as ce } from "../../../core/src/plugin/index.mjs";
5
- import { resolveQueryThemePreset as ye, queryEnUS as fe, queryZhCN as me } from "../../../theme/src/query.mjs";
6
- import { snapshot as R } from "../utils/snapshot.mjs";
7
- import { stateEqual as Y } from "../utils/stateEqual.mjs";
8
- const Se = /* @__PURE__ */ ae({
1
+ import { defineComponent as je, inject as Ae, computed as d, useId as Le, ref as W, shallowRef as Ie, watch as Ee, onBeforeUnmount as Qe, createVNode as i, mergeProps as K, h as _, nextTick as We, toValue as $, Fragment as _e, isVNode as $e } from "vue";
2
+ import { useTheme as De } from "../../../core/src/composables/useTheme.mjs";
3
+ import he from "../../../core/src/components/Button.mjs";
4
+ import { VTABLE_GUILD_INJECTION_KEY as Me } from "../../../core/src/plugin/index.mjs";
5
+ import Ve from "../../../icons/src/DownOutlinedIcon.mjs";
6
+ import { resolveQueryThemePreset as Ge, queryEnUS as Ue, queryZhCN as He } from "../../../theme/src/query.mjs";
7
+ import { TABLE_QUERY_FORM_ADAPTER as ze } from "../types/controls.mjs";
8
+ import Ye from "./TableLightFilter.mjs";
9
+ import { useQueryFilterWidth as Je, getQueryFilterLayout as Ke } from "../utils/queryFilterLayout.mjs";
10
+ import { useQueryInlineLayout as Ze } from "../utils/queryInlineLayout.mjs";
11
+ import { useQueryCollapseMotion as Xe } from "../composables/useQueryCollapseMotion.mjs";
12
+ import { deriveTableQueryFields as et } from "../utils/queryFields.mjs";
13
+ import { snapshot as ue } from "../utils/snapshot.mjs";
14
+ import { stateEqual as re } from "../utils/stateEqual.mjs";
15
+ function tt(e) {
16
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !$e(e);
17
+ }
18
+ const bt = /* @__PURE__ */ je({
9
19
  name: "TableQuery",
10
20
  inheritAttrs: !1,
11
21
  props: {
@@ -17,35 +27,62 @@ const Se = /* @__PURE__ */ ae({
17
27
  type: String,
18
28
  default: "form"
19
29
  },
20
- fields: {
21
- type: Array,
22
- required: !0
23
- },
30
+ fields: Array,
31
+ columns: Array,
24
32
  controls: {
25
33
  type: Object,
26
34
  required: !0
27
35
  },
28
- layout: {
36
+ layoutType: {
29
37
  type: String,
30
- default: "light"
38
+ default: "QueryFilter"
31
39
  },
32
- autoSubmit: Boolean,
33
- debounceTime: {
34
- type: Number,
35
- default: 0
40
+ formMode: String,
41
+ queryLayout: String,
42
+ formProps: Object,
43
+ layout: String,
44
+ span: [Number, Object],
45
+ defaultColsNumber: Number,
46
+ defaultFormItemsNumber: Number,
47
+ defaultCollapsed: {
48
+ type: Boolean,
49
+ default: void 0
36
50
  },
37
- hiddenPolicy: {
38
- type: String,
39
- default: "preserve"
51
+ collapsed: {
52
+ type: Boolean,
53
+ default: void 0
54
+ },
55
+ onCollapse: Function,
56
+ collapseRender: {
57
+ type: [Boolean, Function],
58
+ default: void 0
40
59
  },
41
- collapsedCount: {
42
- type: Number,
43
- default: 3
60
+ optionRender: {
61
+ type: [Boolean, Function],
62
+ default: void 0
44
63
  },
45
- collapsible: {
64
+ searchText: String,
65
+ resetText: String,
66
+ labelWidth: [Number, String],
67
+ searchGutter: [Number, Array],
68
+ split: Boolean,
69
+ preserve: {
46
70
  type: Boolean,
47
71
  default: !0
48
72
  },
73
+ showHiddenNum: Boolean,
74
+ submitter: {
75
+ type: [Boolean, Object],
76
+ default: void 0
77
+ },
78
+ submitterColSpanProps: Object,
79
+ collapse: Boolean,
80
+ collapseLabel: null,
81
+ footerRender: {
82
+ type: [Boolean, Function],
83
+ default: void 0
84
+ },
85
+ getPopupContainer: Function,
49
86
  disabled: Boolean,
50
87
  validate: Function,
51
88
  errors: Object,
@@ -55,192 +92,452 @@ const Se = /* @__PURE__ */ ae({
55
92
  },
56
93
  emits: {
57
94
  submitted: (e) => !0,
58
- reset: (e) => !0
95
+ reset: (e) => !0,
96
+ "update:collapsed": (e) => !0
59
97
  },
60
98
  slots: Object,
61
99
  setup(e, {
62
- attrs: Z,
63
- slots: I,
64
- emit: _,
65
- expose: z
100
+ attrs: oe,
101
+ slots: h,
102
+ emit: Z,
103
+ expose: qe
66
104
  }) {
67
- const U = ne(ce, null), {
68
- slots: r
69
- } = de("query", y(() => ye(U?.themePreset)), e), v = y(() => ({
70
- ...U?.locale === "en-US" ? fe : me,
105
+ const ie = Ae(Me, null), {
106
+ slots: v
107
+ } = De("query", d(() => Ge(ie?.themePreset)), e), T = d(() => ({
108
+ ...ie?.locale === "en-US" ? Ue : He,
71
109
  ...e.locale
72
- })), H = le(), q = K(!1), b = K();
73
- let S, x, f = 0, m = !1, P, g, O;
74
- const A = y(() => [...e.fields].sort((a, t) => (a.order ?? 0) - (t.order ?? 0))), E = (a) => ({
75
- field: a,
76
- values: e.query.draft.value
77
- }), M = (a) => typeof a.hidden == "function" ? a.hidden(E(a)) : !!a.hidden, j = y(() => A.value.filter((a) => !M(a))), Q = y(() => Math.max(1, Math.floor(e.collapsedCount || 1))), V = y(() => e.collapsible && j.value.length > Q.value), W = y(() => V.value && e.query.collapsed.value ? j.value.slice(0, Q.value) : j.value), B = y(() => e.disabled || q.value || e.query.submitting.value);
78
- function N() {
79
- clearTimeout(S), S = void 0;
110
+ })), Fe = Le(), R = W(null), pe = Je(R), X = Ie(null), m = d(() => e.formMode !== "builtin" && e.rootTag === "form" && e.layoutType === "QueryFilter" ? e.controls[ze] : void 0), q = d(() => !!m.value && e.queryLayout !== "grid"), x = d(() => e.disabled || !!m.value && !!e.formProps?.disabled), Ce = d(() => {
111
+ const t = m.value;
112
+ if (t?.kind === "element-plus") {
113
+ if (e.formProps?.labelPosition === "top") return "vertical";
114
+ if (e.formProps?.inline === !0) return "inline";
115
+ }
116
+ const n = t?.kind === "antdv" ? e.formProps?.layout : void 0;
117
+ return n === "inline" || n === "horizontal" || n === "vertical" ? n : e.layout ?? (q.value ? "inline" : p.value.layout);
118
+ }), se = W(null), ee = Ze(se), I = W(!1), j = W();
119
+ let D, P = 0, N = !1, M, A, V, L;
120
+ const O = d(() => e.fields ? [...e.fields].sort((t, n) => (n.order ?? 0) - (t.order ?? 0)) : et(e.columns ?? [])), y = d(() => e.query.draft.value), G = (t, n = y.value) => ({
121
+ field: t,
122
+ values: n
123
+ }), de = (t) => typeof t.hidden == "function" ? t.hidden(G(t)) : !!t.hidden, w = d(() => O.value.filter((t) => !de(t))), Te = d(() => e.submitter || void 0), U = d(() => !!h.actions || e.optionRender !== !1 && e.submitter !== !1), te = W(e.defaultCollapsed), F = d(() => e.collapsed ?? (U.value && (te.value ?? e.query.collapsed.value)));
124
+ Xe(R, d(() => e.layoutType === "QueryFilter" ? F.value : void 0));
125
+ const p = d(() => Ke(w.value, {
126
+ width: pe.value,
127
+ layout: e.layout,
128
+ span: e.span,
129
+ defaultColsNumber: e.defaultColsNumber,
130
+ defaultFormItemsNumber: e.defaultFormItemsNumber,
131
+ collapsed: F.value,
132
+ submitterColSpanProps: e.submitterColSpanProps,
133
+ showActions: U.value
134
+ })), E = d(() => q.value ? F.value && ee.value?.canCollapse ? w.value.slice(0, ee.value.collapsedCount) : w.value : p.value.fields.map(({
135
+ field: t
136
+ }) => t)), Pe = d(() => q.value ? !!ee.value?.canCollapse : p.value.canCollapse), ce = d(() => w.value.length - E.value.length), fe = d(() => {
137
+ const [t, n] = Array.isArray(e.searchGutter) ? e.searchGutter : [e.searchGutter, void 0];
138
+ return {
139
+ "--vtg-query-label-width": typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth,
140
+ "--vtg-query-column-gap": t === void 0 ? void 0 : `${t}px`,
141
+ "--vtg-query-row-gap": n === void 0 ? void 0 : `${n}px`
142
+ };
143
+ }), H = d(() => x.value || I.value || e.query.submitting.value);
144
+ function ne() {
145
+ const t = !F.value;
146
+ e.collapsed === void 0 && (te.value === void 0 ? e.query.toggleCollapsed() : te.value = t), e.onCollapse?.(t), Z("update:collapsed", t);
80
147
  }
81
- ue(() => [e.layout, e.autoSubmit, e.disabled], N, {
148
+ Ee(() => [e.layoutType, x.value, e.query, m.value], Q, {
82
149
  flush: "sync"
83
150
  });
84
- function k() {
85
- N(), f++, x?.abort(), O?.(!1), O = void 0, x = void 0, q.value = !1, P = void 0, g = void 0;
151
+ function Q() {
152
+ P++, D?.abort(), L?.(), L = void 0, V?.(!1), V = void 0, D = void 0, I.value = !1, M = void 0, A = void 0;
86
153
  }
87
- function X() {
88
- return e.hiddenPolicy === "omit" ? {
89
- omitFields: A.value.filter(M).map((a) => a.name)
90
- } : void 0;
154
+ function we() {
155
+ if (e.preserve) return;
156
+ const t = new Set(e.layoutType === "LightFilter" ? w.value : E.value);
157
+ return {
158
+ omitFields: O.value.filter((n) => !t.has(n)).map(({
159
+ name: n
160
+ }) => n)
161
+ };
91
162
  }
92
- function h(a) {
93
- if (m || e.disabled) return Promise.resolve(!1);
94
- if (N(), g && P === a) return g;
95
- k();
96
- const t = f, l = new AbortController();
97
- x = l, P = a, b.value = void 0, a === "reset" && e.query.resetFields();
98
- const s = R(e.query.draft.value), i = X();
99
- q.value = !0;
100
- let d;
101
- return g = new Promise((u) => {
102
- d = u;
103
- }), O = d, (async () => {
104
- let u = !1;
163
+ async function Se(t) {
164
+ const n = m.value, a = X.value;
165
+ if (!n || !a) return !0;
166
+ if (t === "reset")
167
+ return a.clearValidate?.(), !0;
168
+ const u = (e.preserve ? w.value : E.value).map(({
169
+ name: r
170
+ }) => r);
171
+ if (!u.length) return !0;
172
+ try {
173
+ return await (n.kind === "antdv" ? a.validateFields?.(u) : a.validateField?.(u)) !== !1;
174
+ } catch {
175
+ return !1;
176
+ }
177
+ }
178
+ function B(t, n) {
179
+ if (N || x.value) return Promise.resolve(!1);
180
+ if (A && M === t) return A;
181
+ Q();
182
+ const a = P, u = new AbortController();
183
+ D = u, M = t, j.value = void 0;
184
+ const r = e.query.draft, c = r.value;
185
+ t === "reset" ? (X.value?.resetFields?.(), e.query.resetFields()) : n && (r.value = {
186
+ ...y.value,
187
+ ...ue(n)
188
+ });
189
+ const l = ue(y.value);
190
+ n && (L = () => {
191
+ re(l, r.value) && (r.value = c);
192
+ });
193
+ const o = we();
194
+ I.value = !0;
195
+ let b;
196
+ return A = new Promise((f) => {
197
+ b = f;
198
+ }), V = b, (async () => {
199
+ let f = !1;
105
200
  try {
106
- if (a === "reset" && await ie(), m || t !== f || l.signal.aborted) return !1;
107
- const o = await e.validate?.(s, {
108
- fields: j.value,
109
- action: a,
110
- signal: l.signal
201
+ if ((t === "reset" || n) && await We(), N || a !== P || u.signal.aborted || m.value && !await Se(t) || N || a !== P || u.signal.aborted) return !1;
202
+ const s = await e.validate?.(l, {
203
+ fields: w.value,
204
+ action: t,
205
+ signal: u.signal
111
206
  });
112
- return m || t !== f || l.signal.aborted ? !1 : o === !1 ? (b.value = v.value.validationFailed, !1) : !Y(s, e.query.draft.value) || (q.value = !1, u = await (a === "reset" ? e.query.reset(i) : e.query.submit(i)), m || t !== f) ? !1 : (_(a === "reset" ? "reset" : "submitted", u), u);
113
- } catch (o) {
114
- return !m && t === f && (b.value = o instanceof Error ? o.message : String(o)), !1;
207
+ return N || a !== P || u.signal.aborted ? !1 : s === !1 ? (j.value = T.value.validationFailed, !1) : !re(l, y.value) || (L = void 0, I.value = !1, f = await (t === "reset" ? e.query.reset(o) : e.query.submit(o)), N || a !== P) ? !1 : (Z(t === "reset" ? "reset" : "submitted", f), f);
208
+ } catch (s) {
209
+ return !N && a === P && (j.value = s instanceof Error ? s.message : String(s)), !1;
115
210
  } finally {
116
- t === f && (q.value = !1, P = void 0, x = void 0, g = void 0, O = void 0);
211
+ a === P && (L?.(), L = void 0, I.value = !1, M = void 0, D = void 0, A = void 0, V = void 0);
117
212
  }
118
- })().then(d), g;
213
+ })().then(b), A;
214
+ }
215
+ function Re(t) {
216
+ const n = G(t), a = typeof t.disabled == "function" ? t.disabled(n) : t.disabled, u = typeof t.readonly == "function" ? t.readonly(n) : t.readonly;
217
+ return !x.value && !e.query.submitting.value && !de(t) && !a && !u;
119
218
  }
120
- function p(a, t) {
121
- a = A.value.find((u) => u.name === a.name) ?? a;
122
- const l = E(a), s = typeof a.disabled == "function" ? a.disabled(l) : a.disabled, i = typeof a.readonly == "function" ? a.readonly(l) : a.readonly;
123
- if (e.disabled || e.query.submitting.value || s || i || Y(e.query.draft.value[a.name], t)) return;
124
- k(), b.value = void 0;
125
- const d = e.query.draft;
126
- d.value = {
127
- ...d.value,
128
- [a.name]: R(t)
129
- }, e.layout === "light" && e.autoSubmit && (S = setTimeout(() => {
130
- S = void 0, !m && e.layout === "light" && e.autoSubmit && !e.disabled && h("submit");
131
- }, Math.max(0, e.debounceTime)));
219
+ function ve(t, n) {
220
+ const a = O.value.find((r) => r.name === t);
221
+ if (!a || !Re(a) || re(y.value[t], n)) return;
222
+ Q(), j.value = void 0;
223
+ const u = e.query.draft;
224
+ u.value = {
225
+ ...y.value,
226
+ [t]: ue(n)
227
+ };
132
228
  }
133
- re(() => {
134
- m = !0, k();
229
+ function xe(t) {
230
+ if (H.value) return Promise.resolve(!1);
231
+ const n = Object.fromEntries(O.value.filter((a) => Object.hasOwn(t, a.name)).map(({
232
+ name: a
233
+ }) => [a, t[a]]));
234
+ return Object.keys(n).length ? B("submit", n) : Promise.resolve(!0);
235
+ }
236
+ Qe(() => {
237
+ N = !0, Q();
135
238
  });
136
- const $ = {
137
- submit: () => h("submit"),
138
- reset: () => h("reset"),
139
- cancel: k
239
+ const ye = {
240
+ submit: () => B("submit"),
241
+ reset: () => B("reset"),
242
+ cancel: Q
140
243
  };
141
- return z($), () => {
142
- const a = e.rootTag;
143
- return n(a, oe(Z, {
144
- class: r.root(),
145
- "data-query-layout": e.layout,
146
- "aria-label": v.value.label,
147
- onSubmit: (t) => {
148
- t.preventDefault(), h("submit");
149
- }
244
+ qe(ye);
245
+ function ae(t, n, a) {
246
+ const u = G(t, n), r = e.errors?.[t.name] ?? $(t.dictionary?.error)?.message, c = [...$(t.options) ?? $(t.dictionary?.options) ?? []], l = n[t.name];
247
+ for (const S of Array.isArray(l) ? l : [l]) {
248
+ if (!t.dictionary || !["string", "number", "boolean"].includes(typeof S) || c.some((Y) => Object.is(Y.value, S))) continue;
249
+ const z = S, g = $(t.dictionary.valueEnum).get(z), C = typeof g == "string" ? g : g?.text;
250
+ typeof C == "string" && c.push({
251
+ value: z,
252
+ label: C,
253
+ ...typeof g == "object" ? {
254
+ status: g.status
255
+ } : {}
256
+ });
257
+ }
258
+ const o = typeof t.readonly == "function" ? t.readonly(u) : !!t.readonly, b = x.value || e.query.submitting.value || (typeof t.disabled == "function" ? t.disabled(u) : !!t.disabled), f = {
259
+ value: l,
260
+ onChange: a,
261
+ fieldProps: typeof t.fieldProps == "function" ? t.fieldProps(u) : t.fieldProps ?? {},
262
+ options: c,
263
+ disabled: b,
264
+ readonly: o,
265
+ loading: $(t.dictionary?.loading) ?? !1,
266
+ error: r,
267
+ id: `${Fe}-${t.name}`,
268
+ name: t.name,
269
+ mode: "query",
270
+ onSearch: t.dictionary ? (S) => {
271
+ t.dictionary.search(S);
272
+ } : void 0
273
+ }, s = t.valueType ?? "text", k = Object.hasOwn(e.controls, s) ? e.controls[s] : void 0;
274
+ return {
275
+ control: f,
276
+ renderer: k ?? e.controls.text,
277
+ valueType: k ? s : "text"
278
+ };
279
+ }
280
+ function me(t, n, a, u, r) {
281
+ const c = m.value, l = (o) => {
282
+ o.defaultPrevented || (o.preventDefault(), B(r));
283
+ };
284
+ return _(c?.Button ?? he, K({
285
+ key: t,
286
+ type: a
287
+ }, u, {
288
+ [c?.Button && c.kind === "element-plus" ? "nativeType" : "htmlType"]: r === "submit" && e.rootTag === "form" ? "submit" : "button",
289
+ disabled: H.value || !!u.disabled,
290
+ onClick: l
150
291
  }), {
151
- default: () => [n("div", {
152
- class: r.fields()
153
- }, [W.value.map((t) => {
154
- const l = E(t), s = `${H}-${t.name}`, i = e.errors?.[t.name] ?? C(t.dictionary?.error)?.message, d = typeof t.readonly == "function" ? t.readonly(l) : !!t.readonly, u = e.disabled || e.query.submitting.value || (typeof t.disabled == "function" ? t.disabled(l) : !!t.disabled), o = [...C(t.options) ?? C(t.dictionary?.options) ?? []], w = e.query.draft.value[t.name];
155
- for (const c of Array.isArray(w) ? w : [w]) {
156
- if (!t.dictionary || !["string", "number", "boolean"].includes(typeof c) || o.some((te) => Object.is(te.value, c))) continue;
157
- const T = C(t.dictionary.valueEnum).get(c), J = typeof T == "string" ? T : T?.text;
158
- typeof J == "string" && o.push({
159
- value: c,
160
- label: J,
161
- ...typeof T == "object" ? {
162
- status: T.status
163
- } : {}
164
- });
165
- }
166
- const L = {
167
- value: w,
168
- onChange: (c) => p(t, c),
169
- fieldProps: typeof t.fieldProps == "function" ? t.fieldProps(l) : t.fieldProps ?? {},
170
- options: o,
171
- disabled: u,
172
- readonly: d,
173
- loading: C(t.dictionary?.loading) ?? !1,
174
- error: i,
175
- id: s,
176
- name: t.name,
177
- mode: "query",
178
- onSearch: t.dictionary ? (c) => {
179
- t.dictionary.search(c);
180
- } : void 0
181
- }, D = t.valueType ?? "text", G = Object.prototype.hasOwnProperty.call(e.controls, D) ? e.controls[D] : void 0, ee = G ?? e.controls.text;
182
- return n("div", {
183
- key: t.name,
184
- class: r.field(),
185
- "data-query-field": t.name
186
- }, [n("label", {
187
- class: r.label(),
188
- for: s
189
- }, [t.label ?? t.name]), n("div", {
190
- class: r.control(),
191
- "data-query-value-type": G ? D : "text"
192
- }, [I.field?.({
193
- field: t,
194
- values: e.query.draft.value,
195
- control: L
196
- }) ?? ee?.(L), i ? n("div", {
197
- class: r.error(),
198
- role: "alert",
199
- id: `${s}-error`
200
- }, [i]) : null])]);
201
- })]), n("div", {
202
- class: r.actions()
203
- }, [I.actions?.({
204
- ...$,
205
- submitting: B.value,
206
- collapsed: e.query.collapsed.value,
207
- toggleCollapsed: e.query.toggleCollapsed
208
- }) ?? n(se, null, [n(F, {
209
- htmlType: "button",
210
- disabled: B.value,
211
- onClick: (t) => {
212
- t.preventDefault(), h("reset");
213
- }
292
+ default: () => n
293
+ });
294
+ }
295
+ function le() {
296
+ let t;
297
+ const n = Pe.value && e.collapseRender !== !1, a = {
298
+ ...ye,
299
+ submitting: H.value,
300
+ collapsed: F.value,
301
+ toggleCollapsed: ne,
302
+ showCollapseButton: n
303
+ };
304
+ if (h.actions) return h.actions(a);
305
+ const u = Te.value, {
306
+ resetButtonProps: r,
307
+ submitButtonProps: c
308
+ } = u ?? {}, l = [r !== !1 && me("reset", u?.searchConfig?.resetText ?? e.resetText ?? T.value.reset, "default", r ?? {}, "reset"), c !== !1 && me("submit", u?.searchConfig?.submitText ?? e.searchText ?? T.value.submit, "primary", c ?? {}, "submit")].filter(Boolean), o = u?.render ?? e.optionRender, b = o === !1 ? null : typeof o == "function" ? o(a, l) : l, f = (s, k) => typeof e.collapseRender == "function" ? e.collapseRender(s) : s ? `${T.value.expand}${e.showHiddenNum ? ` (${k})` : ""}` : T.value.collapse;
309
+ if (m.value) {
310
+ const s = q.value && e.collapseRender !== !1;
311
+ return i("div", {
312
+ class: v.actions(),
313
+ "data-query-inline-action-content": q.value ? "" : void 0
314
+ }, [i("div", {
315
+ "data-query-inline-buttons": q.value ? "" : void 0,
316
+ "data-query-native-buttons": ""
317
+ }, [b]), n || s ? i("button", {
318
+ type: "button",
319
+ disabled: x.value,
320
+ class: v.collapse(),
321
+ onClick: ne,
322
+ "aria-expanded": !F.value,
323
+ "aria-hidden": !n || void 0,
324
+ tabindex: n ? void 0 : -1,
325
+ "data-query-native-toggle": "",
326
+ "data-query-inline-toggle": q.value ? "" : void 0,
327
+ "data-query-inline-folded": n ? void 0 : ""
328
+ }, [f(F.value, ce.value), typeof e.collapseRender != "function" ? i(Ve, {
329
+ "aria-hidden": "true"
330
+ }, null) : null]) : null]);
331
+ }
332
+ return i(_e, null, [b, n ? i(he, {
333
+ type: "link",
334
+ htmlType: "button",
335
+ disabled: x.value,
336
+ class: v.collapse(),
337
+ onClick: ne,
338
+ "aria-expanded": !F.value
339
+ }, tt(t = f(F.value, ce.value)) ? t : {
340
+ default: () => [t]
341
+ }) : null]);
342
+ }
343
+ function Ne() {
344
+ const t = m.value, n = q.value, a = new Map(p.value.fields.map((l) => [l.field.name, l])), u = new Set(E.value.map(({
345
+ name: l
346
+ }) => l)), r = new Set(w.value.map(({
347
+ name: l
348
+ }) => l)), c = n || e.preserve ? O.value : E.value;
349
+ return i("div", {
350
+ ref: n ? se : void 0,
351
+ class: v.fields(),
352
+ "data-query-inline": n ? "" : void 0,
353
+ "data-query-grid": n ? void 0 : "",
354
+ style: fe.value
355
+ }, [c.map((l) => {
356
+ const {
357
+ control: o,
358
+ renderer: b
359
+ } = ae(l, y.value, (J) => {
360
+ ve(l.name, J);
361
+ }), f = u.has(l.name), s = n && r.has(l.name) && !f, k = a.get(l.name), S = typeof l.formItemProps == "function" ? l.formItemProps(G(l)) : l.formItemProps ?? {}, z = e.preserve || f, g = S.label ?? l.label ?? l.name, C = t.kind === "antdv", Y = {
362
+ key: l.name,
363
+ hidden: !f && !s,
364
+ inert: s || void 0,
365
+ "aria-hidden": s || void 0,
366
+ "data-query-field": l.name,
367
+ "data-query-inline-field": n && r.has(l.name) ? l.name : void 0,
368
+ "data-query-inline-folded": s ? "" : void 0
369
+ }, ge = _(t.FormItem, {
370
+ ...S,
371
+ label: typeof g == "string" ? g : void 0,
372
+ [C ? "name" : "prop"]: z ? l.name : void 0,
373
+ [C ? "htmlFor" : "for"]: o.id,
374
+ ...o.error && C ? {
375
+ validateStatus: "error",
376
+ help: o.error
377
+ } : {},
378
+ ...o.error && !C ? {
379
+ error: o.error
380
+ } : {},
381
+ ...n && !C ? Y : {}
214
382
  }, {
215
- default: () => [v.value.reset]
216
- }), n(F, {
217
- type: "primary",
218
- htmlType: e.rootTag === "form" ? "submit" : "button",
219
- disabled: B.value,
220
- onClick: (t) => {
221
- t.preventDefault(), h("submit");
383
+ ...typeof g == "string" ? {} : {
384
+ label: () => g
385
+ },
386
+ default: () => {
387
+ const J = h.field ? h.field({
388
+ field: l,
389
+ values: y.value,
390
+ control: o,
391
+ layoutType: "QueryFilter"
392
+ }) : b?.(o);
393
+ return n ? J : i("div", {
394
+ "data-query-control-content": ""
395
+ }, [J]);
222
396
  }
397
+ });
398
+ return n && !C ? ge : i("div", K(Y, {
399
+ style: n ? void 0 : k?.style,
400
+ "data-query-split": !n && e.split && k?.endsRow ? "" : void 0
401
+ }), [ge]);
402
+ }), U.value ? n && t.kind === "element-plus" ? _(t.FormItem, {
403
+ "data-query-actions": "",
404
+ "data-query-inline-actions": ""
405
+ }, {
406
+ default: le
407
+ }) : i("div", {
408
+ class: n ? void 0 : e.submitterColSpanProps?.class,
409
+ style: n ? void 0 : [p.value.actionStyle, e.submitterColSpanProps?.style],
410
+ "data-query-actions": "",
411
+ "data-query-inline-actions": n ? "" : void 0
412
+ }, [_(t.FormItem, null, {
413
+ default: le
414
+ })]) : null]);
415
+ }
416
+ function Oe(t) {
417
+ !(t.target instanceof HTMLFormElement) || t.target.parentElement !== R.value || (t.preventDefault(), t.stopPropagation(), B("submit"));
418
+ }
419
+ function Be(t) {
420
+ !(t.target instanceof HTMLFormElement) || t.target.parentElement !== R.value || (t.preventDefault(), t.stopPropagation(), B("reset"));
421
+ }
422
+ const be = () => j.value || e.query.error.value ? i("div", {
423
+ class: v.feedback(),
424
+ role: "alert"
425
+ }, [j.value ?? e.query.error.value?.message]) : null;
426
+ function ke() {
427
+ const t = new Map(p.value.fields.map((a) => [a.field.name, a])), n = e.preserve ? O.value : p.value.fields.map(({
428
+ field: a
429
+ }) => a);
430
+ return i("div", {
431
+ class: v.fields(),
432
+ "data-query-grid": "",
433
+ style: fe.value
434
+ }, [n.map((a) => {
435
+ const u = t.get(a.name), {
436
+ control: r,
437
+ renderer: c,
438
+ valueType: l
439
+ } = ae(a, y.value, (o) => {
440
+ ve(a.name, o);
441
+ });
442
+ return i("div", {
443
+ key: a.name,
444
+ class: v.field(),
445
+ style: u?.style,
446
+ hidden: !u,
447
+ "data-query-field": a.name,
448
+ "data-query-split": e.split && u?.endsRow ? "" : void 0
449
+ }, [i("label", {
450
+ class: v.label(),
451
+ for: r.id
452
+ }, [a.label ?? a.name]), i("div", {
453
+ class: v.control(),
454
+ "data-query-value-type": l
455
+ }, [i("div", {
456
+ "data-query-control-content": ""
457
+ }, [h.field ? h.field({
458
+ field: a,
459
+ values: y.value,
460
+ control: r,
461
+ layoutType: "QueryFilter"
462
+ }) : c?.(r)]), r.error ? i("div", {
463
+ class: v.error(),
464
+ role: "alert",
465
+ id: `${r.id}-error`
466
+ }, [r.error]) : null])]);
467
+ }), U.value ? i("div", {
468
+ class: [v.actions(), e.submitterColSpanProps?.class],
469
+ style: [p.value.actionStyle, e.submitterColSpanProps?.style],
470
+ "data-query-actions": ""
471
+ }, [le()]) : null]);
472
+ }
473
+ return () => {
474
+ const t = e.rootTag, n = e.layoutType === "LightFilter", a = m.value;
475
+ if (a) {
476
+ const u = a.kind === "antdv", r = Ce.value, c = r === "vertical" ? "top" : "right";
477
+ return i("div", K(oe, {
478
+ ref: R,
479
+ class: v.root(),
480
+ "data-query-form-mode": "native",
481
+ "data-query-form-preset": a.kind,
482
+ "data-query-layout-type": e.layoutType,
483
+ "data-query-layout": r
223
484
  }, {
224
- default: () => [v.value.submit]
225
- }), V.value ? n(F, {
226
- type: "link",
227
- htmlType: "button",
228
- disabled: e.disabled,
229
- class: r.collapse(),
230
- onClick: (t) => {
231
- t.preventDefault(), e.query.toggleCollapsed();
485
+ onSubmitCapture: Oe,
486
+ onResetCapture: Be
487
+ }), [_(a.Form, {
488
+ ...u ? {
489
+ layout: r
490
+ } : {
491
+ inline: q.value,
492
+ labelPosition: c
493
+ },
494
+ ...e.labelWidth === void 0 ? {} : u ? {
495
+ labelCol: {
496
+ style: {
497
+ width: typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth
498
+ }
499
+ }
500
+ } : {
501
+ labelWidth: e.labelWidth
232
502
  },
233
- "aria-expanded": !e.query.collapsed.value
503
+ ...e.formProps,
504
+ ref: X,
505
+ "aria-label": T.value.label,
506
+ model: y.value,
507
+ disabled: e.disabled || !!e.formProps?.disabled
234
508
  }, {
235
- default: () => [e.query.collapsed.value ? v.value.expand : v.value.collapse]
236
- }) : null])]), b.value || e.query.error.value ? n("div", {
237
- class: r.feedback(),
238
- role: "alert"
239
- }, [b.value ?? e.query.error.value?.message]) : null]
509
+ default: Ne
510
+ }), be()]);
511
+ }
512
+ return i(t, K(oe, {
513
+ ref: R,
514
+ class: v.root(),
515
+ "data-query-layout-type": e.layoutType,
516
+ "data-query-layout": n ? void 0 : p.value.layout,
517
+ "aria-label": T.value.label,
518
+ onSubmit: (u) => {
519
+ u.target === R.value && (u.preventDefault(), n || B("submit"));
520
+ }
521
+ }), {
522
+ default: () => [n ? i(Ye, {
523
+ fields: O.value,
524
+ values: y.value,
525
+ disabled: e.disabled,
526
+ submitting: H.value,
527
+ collapse: e.collapse,
528
+ collapseLabel: e.collapseLabel,
529
+ footerRender: e.footerRender,
530
+ getPopupContainer: e.getPopupContainer,
531
+ locale: T.value,
532
+ resolveField: ae,
533
+ submitValues: xe
534
+ }, h.field ? {
535
+ field: h.field
536
+ } : void 0) : ke(), be()]
240
537
  });
241
538
  };
242
539
  }
243
540
  });
244
541
  export {
245
- Se as default
542
+ bt as default
246
543
  };