@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,10 +1,15 @@
1
- import { PropType } from 'vue';
2
- import { TableControls, TableControlContext } from '../types/controls';
1
+ import { PropType, VNodeChild } from 'vue';
2
+ import { TableControlContext, TableControls } from '../types/controls';
3
+ import { TableEditErrorPlacement, TableEditLayout } from '../types/editable';
4
+ import { TableBodyCellSlotProps } from '../types/table';
5
+ type TableEditableCellRuntimeContext = TableControlContext & {
6
+ valueType: string;
7
+ autoFocusToken?: number;
8
+ consumeAutoFocus?: (token: number) => boolean;
9
+ };
3
10
  declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
11
  context: {
5
- type: PropType<TableControlContext & {
6
- valueType: string;
7
- }>;
12
+ type: PropType<TableEditableCellRuntimeContext>;
8
13
  required: true;
9
14
  };
10
15
  controls: {
@@ -12,11 +17,24 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
12
17
  required: true;
13
18
  };
14
19
  ui: PropType<Record<string, string>>;
20
+ /** 'flow' keeps the DOM of a control that sizes its own cell. */
21
+ layout: {
22
+ type: PropType<TableEditLayout>;
23
+ default: string;
24
+ };
25
+ /** The live slot context and the record that sized this cell before editing. */
26
+ displayCell: PropType<TableBodyCellSlotProps<Record<string, unknown>>>;
27
+ original: PropType<Record<string, unknown>>;
28
+ sizer: PropType<(cell: TableBodyCellSlotProps<Record<string, unknown>>) => VNodeChild>;
29
+ /** Reserve one line of text when the hidden layer may be empty. */
30
+ strut: BooleanConstructor;
31
+ errorPlacement: {
32
+ type: PropType<TableEditErrorPlacement>;
33
+ default: string;
34
+ };
15
35
  }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
16
36
  context: {
17
- type: PropType<TableControlContext & {
18
- valueType: string;
19
- }>;
37
+ type: PropType<TableEditableCellRuntimeContext>;
20
38
  required: true;
21
39
  };
22
40
  controls: {
@@ -24,6 +42,25 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
24
42
  required: true;
25
43
  };
26
44
  ui: PropType<Record<string, string>>;
27
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
45
+ /** 'flow' keeps the DOM of a control that sizes its own cell. */
46
+ layout: {
47
+ type: PropType<TableEditLayout>;
48
+ default: string;
49
+ };
50
+ /** The live slot context and the record that sized this cell before editing. */
51
+ displayCell: PropType<TableBodyCellSlotProps<Record<string, unknown>>>;
52
+ original: PropType<Record<string, unknown>>;
53
+ sizer: PropType<(cell: TableBodyCellSlotProps<Record<string, unknown>>) => VNodeChild>;
54
+ /** Reserve one line of text when the hidden layer may be empty. */
55
+ strut: BooleanConstructor;
56
+ errorPlacement: {
57
+ type: PropType<TableEditErrorPlacement>;
58
+ default: string;
59
+ };
60
+ }>> & Readonly<{}>, {
61
+ layout: TableEditLayout;
62
+ strut: boolean;
63
+ errorPlacement: TableEditErrorPlacement;
64
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
28
65
  export default _default;
29
66
  //# sourceMappingURL=TableEditableCell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableEditableCell.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableEditableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAA;AAGtE,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;;;cAMrD,QAAQ,CAAC,mBAAmB,GAAG;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;;;;cAG3C,QAAQ,CAAC,aAAa,CAAC;;;QACrC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;;cAJ5B,QAAQ,CAAC,mBAAmB,GAAG;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;;;;cAG3C,QAAQ,CAAC,aAAa,CAAC;;;QACrC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;AARlD,wBAmCE"}
1
+ {"version":3,"file":"TableEditableCell.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableEditableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,QAAQ,EACb,KAAK,UAAU,EAChB,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAGV,mBAAmB,EACnB,aAAa,EACd,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAG5D,KAAK,+BAA+B,GAAG,mBAAmB,GAAG;IAC3D,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;CAC9C,CAAA;;;cASqB,QAAQ,CAAC,+BAA+B,CAAC;;;;cAG/B,QAAQ,CAAC,aAAa,CAAC;;;QACrC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,iEAAiE;;cACvC,QAAQ,CAAC,eAAe,CAAC;;;IACnD,gFAAgF;iBACzD,QAAQ,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;cAC5D,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;WAClC,QAAQ,CACzB,CAAC,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,UAAU,CACtE;IACD,mEAAmE;;;cAEjC,QAAQ,CAAC,uBAAuB,CAAC;;;;;cAfjD,QAAQ,CAAC,+BAA+B,CAAC;;;;cAG/B,QAAQ,CAAC,aAAa,CAAC;;;QACrC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,iEAAiE;;cACvC,QAAQ,CAAC,eAAe,CAAC;;;IACnD,gFAAgF;iBACzD,QAAQ,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;cAC5D,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;WAClC,QAAQ,CACzB,CAAC,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,UAAU,CACtE;IACD,mEAAmE;;;cAEjC,QAAQ,CAAC,uBAAuB,CAAC;;;;;;;;AAnBvE,wBAiJE"}
@@ -1,8 +1,9 @@
1
- import { defineComponent as a, inject as i, computed as s, createVNode as o } from "vue";
2
- import { useTheme as d } from "../../../core/src/composables/useTheme.mjs";
3
- import { VTABLE_GUILD_INJECTION_KEY as c } from "../../../core/src/plugin/index.mjs";
4
- import { resolveTableThemePreset as u } from "../../../theme/src/presets/index.mjs";
5
- const T = /* @__PURE__ */ a({
1
+ import { defineComponent as g, shallowRef as d, onBeforeUnmount as E, onBeforeMount as O, watch as T, createVNode as p, nextTick as C, isVNode as F } from "vue";
2
+ import h from "./TableEditFrame.mjs";
3
+ function j(e) {
4
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !F(e);
5
+ }
6
+ const P = 'input:not([type="hidden"]):not(:disabled), textarea:not(:disabled), select:not(:disabled), [tabindex]:not([tabindex="-1"])', B = /* @__PURE__ */ g({
6
7
  name: "TableEditableCell",
7
8
  props: {
8
9
  context: {
@@ -13,27 +14,103 @@ const T = /* @__PURE__ */ a({
13
14
  type: Object,
14
15
  required: !0
15
16
  },
16
- ui: Object
17
+ ui: Object,
18
+ /** 'flow' keeps the DOM of a control that sizes its own cell. */
19
+ layout: {
20
+ type: String,
21
+ default: "flow"
22
+ },
23
+ /** The live slot context and the record that sized this cell before editing. */
24
+ displayCell: Object,
25
+ original: Object,
26
+ sizer: Function,
27
+ /** Reserve one line of text when the hidden layer may be empty. */
28
+ strut: Boolean,
29
+ errorPlacement: {
30
+ type: String,
31
+ default: "inline"
32
+ }
17
33
  },
18
- setup(t) {
19
- const n = i(c, null), {
20
- slots: r
21
- } = d("table", s(() => u(n?.themePreset ?? "antdv")), t);
34
+ setup(e) {
35
+ const f = d(null), r = d(!1), u = d(!1);
36
+ let s = !1, a = !1, m;
37
+ function i() {
38
+ clearTimeout(m), u.value = !1;
39
+ }
40
+ function b(l) {
41
+ u.value = !0, m = setTimeout(() => {
42
+ u.value = !1, l.cellEdit.commit("popup-close");
43
+ }, 0);
44
+ }
45
+ E(i);
46
+ async function y(l) {
47
+ if (i(), r.value = !1, s = !1, a = !1, l === void 0 || !e.context.consumeAutoFocus?.(l)) return;
48
+ const t = e.context, o = e.controls[t.valueType]?.cellEdit?.autoOpen;
49
+ r.value = typeof o == "function" ? o(t) : o === !0, await C();
50
+ const c = f.value?.control;
51
+ if (!c || e.context.autoFocusToken !== l) return;
52
+ c.querySelector(P)?.focus({
53
+ preventScroll: !0
54
+ }), r.value = !1;
55
+ }
56
+ O(() => {
57
+ y(e.context.autoFocusToken);
58
+ }), T(() => e.context.autoFocusToken, (l) => {
59
+ y(l);
60
+ });
61
+ function v(l, t) {
62
+ const o = l.cellEdit?.commitOn;
63
+ return typeof o == "function" ? o(t) : o ?? "blur";
64
+ }
65
+ function x(l) {
66
+ const t = e.context.cellEdit;
67
+ if (!t || s || e.context.disabled) return;
68
+ const o = f.value?.$el, c = l.relatedTarget;
69
+ if (c && o?.contains(c)) return;
70
+ const n = e.controls[e.context.valueType];
71
+ n && v(n, e.context) === "blur" && t.commit("blur");
72
+ }
22
73
  return () => {
23
- const e = t.context, l = t.controls[e.valueType];
24
- if (!l) throw new Error(`No table control registered for ${e.valueType}`);
25
- return o("div", {
26
- class: r.editCell()
27
- }, [o("div", {
28
- class: r.editControl(),
29
- "data-invalid": e.error ? !0 : void 0
30
- }, [l(e)]), e.error ? o("span", {
31
- class: r.editError(),
32
- role: "alert"
33
- }, [e.error]) : null]);
74
+ let l;
75
+ const t = e.context, o = e.controls[t.valueType];
76
+ if (!o) throw new Error(`No table control registered for ${t.valueType}`);
77
+ const c = t.cellEdit ? {
78
+ ...t,
79
+ cellEdit: {
80
+ autoOpen: r.value,
81
+ get closingPopup() {
82
+ return u.value;
83
+ },
84
+ commit: (n = "explicit") => {
85
+ if (i(), n === "popup-close") return b(t);
86
+ n === "change" && (a = !0), t.cellEdit.commit(n);
87
+ },
88
+ cancel: () => {
89
+ i(), t.cellEdit.cancel();
90
+ },
91
+ setPopupOpen: (n) => {
92
+ i(), s = n, t.cellEdit.setPopupOpen(n), n ? a = !1 : !a && v(o, t) === "change" && b(t);
93
+ }
94
+ }
95
+ } : t;
96
+ return p(h, {
97
+ ref: f,
98
+ ui: e.ui,
99
+ layout: e.layout,
100
+ displayCell: e.displayCell,
101
+ original: e.original,
102
+ sizer: e.sizer,
103
+ strut: e.strut,
104
+ fill: o.fill === !0,
105
+ error: t.error,
106
+ errorPlacement: e.errorPlacement,
107
+ onFocusout: x
108
+ }, j(l = o(c)) ? l : {
109
+ default: () => [l]
110
+ });
34
111
  };
35
112
  }
36
113
  });
37
114
  export {
38
- T as default
115
+ B as default
39
116
  };
@@ -0,0 +1,76 @@
1
+ import { PropType, SlotsType, VNodeChild } from 'vue';
2
+ import { TableControlContext, TableControlRenderer } from '../types/controls';
3
+ import { TableQueryField, TableQueryLocale, TableQueryProps, TableQuerySlots } from '../types/query-form';
4
+ type Values = Readonly<Record<string, unknown>>;
5
+ type ResolveField = (field: TableQueryField, values: Values, onChange: TableControlContext['onChange']) => {
6
+ control: TableControlContext;
7
+ renderer?: TableControlRenderer;
8
+ };
9
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
10
+ fields: {
11
+ type: PropType<readonly TableQueryField[]>;
12
+ required: true;
13
+ };
14
+ values: {
15
+ type: PropType<Values>;
16
+ required: true;
17
+ };
18
+ resolveField: {
19
+ type: PropType<ResolveField>;
20
+ required: true;
21
+ };
22
+ submitValues: {
23
+ type: PropType<(patch: Record<string, unknown>) => Promise<boolean>>;
24
+ required: true;
25
+ };
26
+ locale: {
27
+ type: PropType<Pick<TableQueryLocale, "more" | "confirm" | "clear">>;
28
+ required: true;
29
+ };
30
+ disabled: BooleanConstructor;
31
+ submitting: BooleanConstructor;
32
+ collapse: BooleanConstructor;
33
+ collapseLabel: PropType<VNodeChild>;
34
+ footerRender: {
35
+ type: PropType<TableQueryProps["footerRender"]>;
36
+ default: undefined;
37
+ };
38
+ getPopupContainer: PropType<TableQueryProps["getPopupContainer"]>;
39
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
40
+ fields: {
41
+ type: PropType<readonly TableQueryField[]>;
42
+ required: true;
43
+ };
44
+ values: {
45
+ type: PropType<Values>;
46
+ required: true;
47
+ };
48
+ resolveField: {
49
+ type: PropType<ResolveField>;
50
+ required: true;
51
+ };
52
+ submitValues: {
53
+ type: PropType<(patch: Record<string, unknown>) => Promise<boolean>>;
54
+ required: true;
55
+ };
56
+ locale: {
57
+ type: PropType<Pick<TableQueryLocale, "more" | "confirm" | "clear">>;
58
+ required: true;
59
+ };
60
+ disabled: BooleanConstructor;
61
+ submitting: BooleanConstructor;
62
+ collapse: BooleanConstructor;
63
+ collapseLabel: PropType<VNodeChild>;
64
+ footerRender: {
65
+ type: PropType<TableQueryProps["footerRender"]>;
66
+ default: undefined;
67
+ };
68
+ getPopupContainer: PropType<TableQueryProps["getPopupContainer"]>;
69
+ }>> & Readonly<{}>, {
70
+ disabled: boolean;
71
+ collapse: boolean;
72
+ footerRender: false | ((context: import('../../../vtable-guild/src/index.ts').TableQueryFooterContext<Record<string, unknown>>) => VNodeChild) | undefined;
73
+ submitting: boolean;
74
+ }, SlotsType<Pick<TableQuerySlots<Record<string, unknown>>, "field">>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
75
+ export default _default;
76
+ //# sourceMappingURL=TableLightFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableLightFilter.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableLightFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAA;AAQZ,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAClF,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAK5B,KAAK,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAC/C,KAAK,YAAY,GAAG,CAClB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,mBAAmB,CAAC,UAAU,CAAC,KACtC;IAAE,OAAO,EAAE,mBAAmB,CAAC;IAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAA;CAAE,CAAA;;;cAwBzC,QAAQ,CAAC,SAAS,eAAe,EAAE,CAAC;;;;cACnC,QAAQ,CAAC,MAAM,CAAC;;;;cACR,QAAQ,CAAC,YAAY,CAAC;;;;cAEpC,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;;;;cAIhE,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;;;;;;mBAM9C,QAAQ,CAAC,UAAU,CAAC;;cAEvB,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;;;uBAGzC,QAAQ,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;;;cAnBpD,QAAQ,CAAC,SAAS,eAAe,EAAE,CAAC;;;;cACnC,QAAQ,CAAC,MAAM,CAAC;;;;cACR,QAAQ,CAAC,YAAY,CAAC;;;;cAEpC,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;;;;cAIhE,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;;;;;;mBAM9C,QAAQ,CAAC,UAAU,CAAC;;cAEvB,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;;;uBAGzC,QAAQ,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;;;;;;;AAtBjF,wBA6WE"}
@@ -0,0 +1,320 @@
1
+ import { defineComponent as M, inject as U, useId as W, shallowRef as b, computed as m, watch as B, nextTick as A, createVNode as r } from "vue";
2
+ import R from "../../../core/src/components/Button.mjs";
3
+ import { VTABLE_GUILD_INJECTION_KEY as Y } from "../../../core/src/plugin/index.mjs";
4
+ import G from "../../../icons/src/FilterFilledIcon.mjs";
5
+ import Q from "../../../icons/src/ElFilterIcon.mjs";
6
+ import V from "../../../icons/src/DownOutlinedIcon.mjs";
7
+ import X from "../../../icons/src/CloseCircleFilledIcon.mjs";
8
+ import { snapshot as Z } from "../utils/snapshot.mjs";
9
+ import { stateEqual as ee } from "../utils/stateEqual.mjs";
10
+ import le from "./TablePopup.mjs";
11
+ function N(t) {
12
+ return t != null && t !== "" && (!Array.isArray(t) || t.length > 0);
13
+ }
14
+ function te({
15
+ value: t,
16
+ options: P
17
+ }, T) {
18
+ return (Array.isArray(t) ? t : [t]).map((u) => {
19
+ const o = P.find((g) => Object.is(g.value, u))?.label;
20
+ return o ?? (u instanceof Date && !Number.isNaN(u.getTime()) ? u.toLocaleString() : (u && typeof u == "object" && "label" in u && (u = u.label), typeof u == "string" || typeof u == "number" || typeof u == "boolean" ? String(u) : ""));
21
+ }).filter(Boolean).join(T);
22
+ }
23
+ const ve = /* @__PURE__ */ M({
24
+ name: "TableLightFilter",
25
+ props: {
26
+ fields: {
27
+ type: Array,
28
+ required: !0
29
+ },
30
+ values: {
31
+ type: Object,
32
+ required: !0
33
+ },
34
+ resolveField: {
35
+ type: Function,
36
+ required: !0
37
+ },
38
+ submitValues: {
39
+ type: Function,
40
+ required: !0
41
+ },
42
+ locale: {
43
+ type: Object,
44
+ required: !0
45
+ },
46
+ disabled: Boolean,
47
+ submitting: Boolean,
48
+ collapse: Boolean,
49
+ collapseLabel: null,
50
+ footerRender: {
51
+ type: [Boolean, Function],
52
+ default: void 0
53
+ },
54
+ getPopupContainer: Function
55
+ },
56
+ slots: Object,
57
+ setup(t, {
58
+ slots: P
59
+ }) {
60
+ const T = U(Y, null), u = W(), o = b(), g = b(null), c = b({}), h = b(!1), y = b(!1), O = (e, l) => typeof e.hidden == "function" ? e.hidden({
61
+ field: e,
62
+ values: l
63
+ }) : !!e.hidden, k = m(() => t.fields.filter((e) => !O(e, t.values))), I = m(() => k.value.filter((e) => t.collapse || e.secondary)), D = m(() => t.collapse ? [] : k.value.filter((e) => !e.secondary)), _ = m(() => ({
64
+ ...t.values,
65
+ ...c.value
66
+ }));
67
+ function j(e) {
68
+ if (!o.value) return [];
69
+ const l = o.value.name;
70
+ return t.fields.filter((a) => !O(a, e) && (l === void 0 ? t.collapse || a.secondary : !t.collapse && !a.secondary && a.name === l));
71
+ }
72
+ const F = m(() => j(_.value)), S = m(() => j(t.values)), f = m(() => t.disabled || t.submitting || h.value);
73
+ function p(e = !1) {
74
+ const l = o.value?.anchor;
75
+ o.value = void 0, c.value = {}, y.value = !1, e && A(() => {
76
+ !o.value && l?.isConnected && l.focus({
77
+ preventScroll: !0
78
+ });
79
+ });
80
+ }
81
+ function x(e, l) {
82
+ if (!f.value) {
83
+ if (o.value?.anchor === e.currentTarget) {
84
+ p();
85
+ return;
86
+ }
87
+ c.value = {}, y.value = !1, o.value = {
88
+ name: l,
89
+ anchor: e.currentTarget
90
+ };
91
+ }
92
+ }
93
+ B(() => [S.value, h.value], ([e, l]) => {
94
+ o.value && !e.length && !l && p();
95
+ }), B(() => [o.value, g.value], async ([e, l]) => {
96
+ if (!e || !l || (await A(), e !== o.value || l !== g.value)) return;
97
+ (l.querySelector('input:not([type="hidden"]):not(:disabled), textarea:not(:disabled), select:not(:disabled)') ?? l).focus({
98
+ preventScroll: !0
99
+ });
100
+ }, {
101
+ flush: "post"
102
+ });
103
+ function z(e, l, a) {
104
+ const n = a?.lightFilter?.formatValue;
105
+ return n ? n(l) : te(l, e.valueType?.endsWith("Range") ? " – " : ", ");
106
+ }
107
+ async function C(e, l) {
108
+ if (f.value) return !1;
109
+ const a = o.value;
110
+ h.value = !0;
111
+ try {
112
+ const n = await t.submitValues(e);
113
+ return a === o.value && a && (y.value = !n, n && (l ? p(!0) : c.value = {})), n;
114
+ } finally {
115
+ h.value = !1;
116
+ }
117
+ }
118
+ function q() {
119
+ return !o.value || f.value ? Promise.resolve(!1) : Object.keys(c.value).length ? C(c.value, !0) : (p(!0), Promise.resolve(!0));
120
+ }
121
+ function K(e, l) {
122
+ if (f.value || !o.value || !F.value.includes(e)) return;
123
+ const {
124
+ control: a,
125
+ renderer: n
126
+ } = t.resolveField(e, _.value, () => {
127
+ });
128
+ if (a.disabled || a.readonly || ee(a.value, l)) return;
129
+ c.value = {
130
+ ...c.value,
131
+ [e.name]: Z(l)
132
+ };
133
+ const d = n?.lightFilter;
134
+ if (o.value.name !== void 0 && d?.submitOnChange) {
135
+ const i = d.closeOnChange;
136
+ C(c.value, typeof i == "function" ? i({
137
+ ...a,
138
+ value: l
139
+ }) : i !== !1);
140
+ }
141
+ }
142
+ function E() {
143
+ const e = o.value;
144
+ if (!e || f.value) return Promise.resolve(!1);
145
+ const l = F.value.filter((a) => {
146
+ const {
147
+ control: n
148
+ } = t.resolveField(a, _.value, () => {
149
+ });
150
+ return !n.disabled && !n.readonly;
151
+ });
152
+ return l.length ? e.name !== void 0 ? (c.value = {
153
+ [e.name]: void 0
154
+ }, Promise.resolve(!0)) : (c.value = Object.fromEntries(l.map((a) => [a.name, void 0])), C(c.value, !1)) : Promise.resolve(!1);
155
+ }
156
+ function $(e) {
157
+ if (e.key !== "Enter" || e.defaultPrevented || e.isComposing) return;
158
+ const l = e.target;
159
+ !(l instanceof HTMLInputElement) || l.closest('[role="combobox"]') || (e.preventDefault(), q());
160
+ }
161
+ function H(e) {
162
+ const {
163
+ control: l,
164
+ renderer: a
165
+ } = t.resolveField(e, t.values, () => {
166
+ }), n = e.label ?? e.name, d = N(l.value), i = d ? z(e, l, a) : void 0, s = o.value?.name === e.name, v = f.value || l.disabled || l.readonly;
167
+ return r("span", {
168
+ key: e.name,
169
+ class: "vtg-light-filter__chip",
170
+ "data-query-field": e.name,
171
+ "data-active": d || void 0,
172
+ "data-invalid": !!l.error || void 0
173
+ }, [r("button", {
174
+ type: "button",
175
+ class: "vtg-light-filter__trigger",
176
+ disabled: v,
177
+ "aria-haspopup": "dialog",
178
+ "aria-expanded": s,
179
+ "aria-controls": s ? u : void 0,
180
+ onClick: (L) => x(L, e.name)
181
+ }, [r("span", null, [n]), i != null && i !== "" ? r("span", {
182
+ class: "vtg-light-filter__value",
183
+ title: typeof i == "string" ? i : void 0
184
+ }, [": ", i]) : null, r(V, {
185
+ class: "vtg-light-filter__icon",
186
+ "aria-hidden": "true"
187
+ }, null)]), d && l.fieldProps.allowClear !== !1 && l.fieldProps.clearable !== !1 ? r("button", {
188
+ type: "button",
189
+ class: "vtg-light-filter__clear",
190
+ "aria-label": `${t.locale.clear} ${typeof n == "string" ? n : e.name}`,
191
+ disabled: v,
192
+ onClick: () => {
193
+ C({
194
+ [e.name]: void 0
195
+ }, !0);
196
+ }
197
+ }, [r(X, {
198
+ class: "vtg-light-filter__icon",
199
+ "aria-hidden": "true"
200
+ }, null)]) : null]);
201
+ }
202
+ function J(e, l) {
203
+ const a = F.value, n = _.value, d = a.map((s) => ({
204
+ field: s,
205
+ ...t.resolveField(s, n, (v) => K(s, v))
206
+ }));
207
+ let i = null;
208
+ return t.footerRender !== !1 && (l || y.value || !d[0]?.renderer?.lightFilter?.submitOnChange) && (i = t.footerRender ? t.footerRender({
209
+ values: n,
210
+ fields: a,
211
+ confirm: q,
212
+ clear: E,
213
+ submitting: f.value
214
+ }) : r("div", {
215
+ class: "vtg-light-filter__footer"
216
+ }, [r(R, {
217
+ size: "sm",
218
+ disabled: f.value,
219
+ onClick: () => {
220
+ E();
221
+ }
222
+ }, {
223
+ default: () => [t.locale.clear]
224
+ }), r(R, {
225
+ type: "primary",
226
+ size: "sm",
227
+ disabled: f.value,
228
+ onClick: () => {
229
+ q();
230
+ }
231
+ }, {
232
+ default: () => [t.locale.confirm]
233
+ })])), [r("div", {
234
+ class: "vtg-light-filter__fields"
235
+ }, [d.map(({
236
+ field: s,
237
+ control: v,
238
+ renderer: L
239
+ }) => {
240
+ const w = {
241
+ ...v,
242
+ lightFilter: {
243
+ grouped: l,
244
+ getPopupContainer: () => e
245
+ }
246
+ };
247
+ return r("div", {
248
+ class: "vtg-light-filter__field",
249
+ key: s.name,
250
+ "data-query-popup-field": s.name,
251
+ "data-query-value-type": s.valueType ?? "text"
252
+ }, [l ? r("label", {
253
+ for: v.id
254
+ }, [s.label ?? s.name]) : null, r("div", {
255
+ "data-query-control-content": ""
256
+ }, [P.field?.({
257
+ field: s,
258
+ values: n,
259
+ control: w,
260
+ layoutType: "LightFilter"
261
+ }) ?? L?.(w)]), v.error ? r("div", {
262
+ class: "vtg-light-filter__error",
263
+ role: "alert"
264
+ }, [v.error]) : null]);
265
+ })]), i];
266
+ }
267
+ return () => {
268
+ const e = o.value, l = !!e && e.name === void 0, a = F.value[0], n = l ? t.locale.more : a?.label ?? a?.name, d = T?.themePreset ?? "antdv";
269
+ return r("div", {
270
+ class: "vtg-light-filter"
271
+ }, [D.value.map(H), I.value.length ? r("span", {
272
+ class: "vtg-light-filter__chip",
273
+ "data-active": I.value.some((i) => N(t.values[i.name])) || void 0
274
+ }, [r("button", {
275
+ type: "button",
276
+ class: "vtg-light-filter__trigger",
277
+ "data-query-more": "",
278
+ "aria-label": typeof t.collapseLabel == "string" ? t.collapseLabel : t.locale.more,
279
+ disabled: f.value,
280
+ "aria-haspopup": "dialog",
281
+ "aria-expanded": l,
282
+ "aria-controls": l ? u : void 0,
283
+ onClick: (i) => x(i)
284
+ }, [t.collapseLabel ?? (t.collapse ? d === "element-plus" ? r(Q, {
285
+ class: "vtg-light-filter__collapse-icon",
286
+ "aria-hidden": "true"
287
+ }, null) : r(G, {
288
+ class: "vtg-light-filter__collapse-icon",
289
+ "aria-hidden": "true"
290
+ }, null) : t.locale.more), t.collapse ? null : r(V, {
291
+ class: "vtg-light-filter__icon",
292
+ "aria-hidden": "true"
293
+ }, null)])]) : null, r(le, {
294
+ open: !!e,
295
+ anchor: e?.anchor,
296
+ outsideBoundary: e?.anchor.parentElement,
297
+ preset: d,
298
+ getPopupContainer: t.getPopupContainer,
299
+ panelRef: (i) => {
300
+ g.value = i;
301
+ },
302
+ class: "vtg-light-filter__popup",
303
+ panelAttrs: {
304
+ id: u,
305
+ role: "dialog",
306
+ "aria-label": typeof n == "string" ? n : a?.name,
307
+ "aria-busy": f.value,
308
+ tabindex: -1,
309
+ onKeydown: $
310
+ },
311
+ onDismiss: () => p()
312
+ }, {
313
+ default: () => [g.value ? J(g.value, l) : null]
314
+ })]);
315
+ };
316
+ }
317
+ });
318
+ export {
319
+ ve as default
320
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TableLightFilter.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableLightFilter.test.d.ts","sourceRoot":"","sources":["../../../../../table/src/components/TableLightFilter.test.ts"],"names":[],"mappings":""}