@shwfed/nuxt 0.7.8 → 0.7.10

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 (174) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/app.d.vue.ts +7 -58
  3. package/dist/runtime/components/app.vue +18 -411
  4. package/dist/runtime/components/app.vue.d.ts +7 -58
  5. package/dist/runtime/components/fields.d.vue.ts +177 -0
  6. package/dist/runtime/components/fields.vue +47 -0
  7. package/dist/runtime/components/fields.vue.d.ts +177 -0
  8. package/dist/runtime/components/table.d.vue.ts +63 -59
  9. package/dist/runtime/components/table.vue +52 -617
  10. package/dist/runtime/components/table.vue.d.ts +63 -59
  11. package/dist/runtime/components/ui/app/App.d.vue.ts +86 -0
  12. package/dist/runtime/components/ui/app/App.vue +414 -0
  13. package/dist/runtime/components/ui/app/App.vue.d.ts +86 -0
  14. package/dist/runtime/components/ui/button-group/ButtonGroupSeparator.vue +1 -1
  15. package/dist/runtime/components/ui/button-group/ButtonGroupText.vue +1 -1
  16. package/dist/runtime/components/ui/calendar/Calendar.d.vue.ts +5 -12
  17. package/dist/runtime/components/ui/calendar/Calendar.vue +77 -92
  18. package/dist/runtime/components/ui/calendar/Calendar.vue.d.ts +5 -12
  19. package/dist/runtime/components/ui/calendar/CalendarCellTrigger.vue +1 -1
  20. package/dist/runtime/components/ui/calendar/index.d.ts +1 -1
  21. package/dist/runtime/components/ui/checkbox/Checkbox.vue +6 -2
  22. package/dist/runtime/components/ui/command/CommandGroup.vue +4 -0
  23. package/dist/runtime/components/ui/dialog/DialogOverlay.vue +1 -1
  24. package/dist/runtime/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
  25. package/dist/runtime/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
  26. package/dist/runtime/components/ui/expression-editor/ExpressionEditor.d.vue.ts +30 -0
  27. package/dist/runtime/components/ui/expression-editor/ExpressionEditor.vue +87 -0
  28. package/dist/runtime/components/ui/expression-editor/ExpressionEditor.vue.d.ts +30 -0
  29. package/dist/runtime/components/ui/expression-editor/index.d.ts +1 -0
  30. package/dist/runtime/components/ui/expression-editor/index.js +1 -0
  31. package/dist/runtime/components/ui/field/FieldContent.vue +1 -1
  32. package/dist/runtime/components/ui/field/FieldDescription.vue +1 -1
  33. package/dist/runtime/components/ui/field/FieldError.vue +2 -2
  34. package/dist/runtime/components/ui/field/FieldLabel.vue +1 -1
  35. package/dist/runtime/components/ui/field/FieldSeparator.vue +1 -1
  36. package/dist/runtime/components/ui/field/index.js +7 -5
  37. package/dist/runtime/components/ui/fields/Fields.d.vue.ts +376 -0
  38. package/dist/runtime/components/ui/fields/Fields.vue +441 -0
  39. package/dist/runtime/components/ui/fields/Fields.vue.d.ts +376 -0
  40. package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.d.vue.ts +163 -0
  41. package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.vue +363 -0
  42. package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.vue.d.ts +163 -0
  43. package/dist/runtime/components/ui/input/Input.d.vue.ts +1 -0
  44. package/dist/runtime/components/ui/input/Input.vue +3 -1
  45. package/dist/runtime/components/ui/input/Input.vue.d.ts +1 -0
  46. package/dist/runtime/components/ui/input-group/InputGroup.vue +3 -0
  47. package/dist/runtime/components/ui/input-group/InputGroupAddon.vue +4 -1
  48. package/dist/runtime/components/ui/input-group/InputGroupCombobox.d.vue.ts +11 -3
  49. package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue +16 -5
  50. package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue.d.ts +11 -3
  51. package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.d.vue.ts +8 -1
  52. package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue +12 -1
  53. package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue.d.ts +8 -1
  54. package/dist/runtime/components/ui/input-group/InputGroupInput.vue +1 -1
  55. package/dist/runtime/components/ui/input-group/InputGroupNumberField.d.vue.ts +5 -2
  56. package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue +10 -4
  57. package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue.d.ts +5 -2
  58. package/dist/runtime/components/ui/input-group/InputGroupText.vue +1 -1
  59. package/dist/runtime/components/ui/input-group/InputGroupTextarea.vue +1 -1
  60. package/dist/runtime/components/ui/input-group/index.js +2 -2
  61. package/dist/runtime/components/ui/label/Label.vue +1 -1
  62. package/dist/runtime/components/ui/locale/Locale.d.vue.ts +20 -0
  63. package/dist/runtime/components/ui/locale/Locale.vue +291 -0
  64. package/dist/runtime/components/ui/locale/Locale.vue.d.ts +20 -0
  65. package/dist/runtime/components/ui/locale/index.d.ts +1 -0
  66. package/dist/runtime/components/ui/locale/index.js +1 -0
  67. package/dist/runtime/components/ui/native-select/NativeSelect.vue +3 -3
  68. package/dist/runtime/components/ui/native-select/NativeSelectOption.d.vue.ts +1 -0
  69. package/dist/runtime/components/ui/native-select/NativeSelectOption.vue +4 -1
  70. package/dist/runtime/components/ui/native-select/NativeSelectOption.vue.d.ts +1 -0
  71. package/dist/runtime/components/ui/navigation-menu/NavigationMenuLink.vue +1 -1
  72. package/dist/runtime/components/ui/navigation-menu/NavigationMenuViewport.vue +1 -1
  73. package/dist/runtime/components/ui/number-field/NumberFieldInput.vue +1 -1
  74. package/dist/runtime/components/ui/range-calendar/RangeCalendarCell.vue +1 -1
  75. package/dist/runtime/components/ui/range-calendar/RangeCalendarCellTrigger.vue +1 -1
  76. package/dist/runtime/components/ui/sheet/SheetOverlay.vue +1 -1
  77. package/dist/runtime/components/ui/switch/Switch.d.vue.ts +24 -0
  78. package/dist/runtime/components/ui/switch/Switch.vue +46 -0
  79. package/dist/runtime/components/ui/switch/Switch.vue.d.ts +24 -0
  80. package/dist/runtime/components/ui/switch/index.d.ts +1 -0
  81. package/dist/runtime/components/ui/switch/index.js +1 -0
  82. package/dist/runtime/components/ui/table/Table.d.vue.ts +81 -0
  83. package/dist/runtime/components/ui/table/Table.vue +792 -0
  84. package/dist/runtime/components/ui/table/Table.vue.d.ts +81 -0
  85. package/dist/runtime/components/ui/table/schema.d.ts +48 -0
  86. package/dist/runtime/components/ui/table/schema.js +126 -0
  87. package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.d.vue.ts +62 -0
  88. package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.vue +2233 -0
  89. package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.vue.d.ts +62 -0
  90. package/dist/runtime/components/ui/table-configurator/menu.d.ts +37 -0
  91. package/dist/runtime/components/ui/table-configurator/menu.js +227 -0
  92. package/dist/runtime/components/ui/tabs/Tabs.d.vue.ts +24 -0
  93. package/dist/runtime/components/ui/tabs/Tabs.vue +30 -0
  94. package/dist/runtime/components/ui/tabs/Tabs.vue.d.ts +24 -0
  95. package/dist/runtime/components/ui/tabs/TabsContent.d.vue.ts +18 -0
  96. package/dist/runtime/components/ui/tabs/TabsContent.vue +23 -0
  97. package/dist/runtime/components/ui/tabs/TabsContent.vue.d.ts +18 -0
  98. package/dist/runtime/components/ui/tabs/TabsList.d.vue.ts +18 -0
  99. package/dist/runtime/components/ui/tabs/TabsList.vue +25 -0
  100. package/dist/runtime/components/ui/tabs/TabsList.vue.d.ts +18 -0
  101. package/dist/runtime/components/ui/tabs/TabsTrigger.d.vue.ts +18 -0
  102. package/dist/runtime/components/ui/tabs/TabsTrigger.vue +27 -0
  103. package/dist/runtime/components/ui/tabs/TabsTrigger.vue.d.ts +18 -0
  104. package/dist/runtime/components/ui/tabs/index.d.ts +4 -0
  105. package/dist/runtime/components/ui/tabs/index.js +4 -0
  106. package/dist/runtime/components/ui/textarea/Textarea.d.vue.ts +1 -0
  107. package/dist/runtime/components/ui/textarea/Textarea.vue +4 -2
  108. package/dist/runtime/components/ui/textarea/Textarea.vue.d.ts +1 -0
  109. package/dist/runtime/components/ui/toggle/Toggle.d.vue.ts +34 -0
  110. package/dist/runtime/components/ui/toggle/Toggle.vue +32 -0
  111. package/dist/runtime/components/ui/toggle/Toggle.vue.d.ts +34 -0
  112. package/dist/runtime/components/ui/toggle/index.d.ts +7 -0
  113. package/dist/runtime/components/ui/toggle/index.js +22 -0
  114. package/dist/runtime/composables/useTableRenderers.d.ts +2 -1
  115. package/dist/runtime/composables/useTableRenderers.js +2 -1
  116. package/dist/runtime/plugins/cel/env.d.ts +2 -2
  117. package/dist/runtime/plugins/cel/env.js +5 -4
  118. package/dist/runtime/plugins/cel/index.d.ts +3 -3
  119. package/dist/runtime/plugins/cel/index.js +7 -3
  120. package/dist/runtime/plugins/markdown/index.d.ts +1 -1
  121. package/dist/runtime/style.css +1 -1
  122. package/dist/runtime/table-renderers/builtins.js +213 -98
  123. package/dist/runtime/table-renderers/registry.d.ts +1 -0
  124. package/dist/runtime/table-renderers/registry.js +3 -0
  125. package/dist/runtime/utils/coders.d.ts +32 -0
  126. package/dist/runtime/utils/coders.js +64 -0
  127. package/dist/runtime/vendor/cel/index.d.ts +17 -0
  128. package/dist/runtime/vendor/cel/index.js +10 -0
  129. package/dist/runtime/vendor/cel-js/LICENSE +21 -0
  130. package/dist/runtime/vendor/cel-js/UPSTREAM.md +17 -0
  131. package/dist/runtime/vendor/cel-js/lib/errors.d.ts +21 -0
  132. package/dist/runtime/vendor/cel-js/lib/errors.js +97 -0
  133. package/dist/runtime/vendor/cel-js/lib/evaluator.d.ts +4 -0
  134. package/dist/runtime/vendor/cel-js/lib/evaluator.js +192 -0
  135. package/dist/runtime/vendor/cel-js/lib/functions.d.ts +53 -0
  136. package/dist/runtime/vendor/cel-js/lib/functions.js +513 -0
  137. package/dist/runtime/vendor/cel-js/lib/globals.d.ts +27 -0
  138. package/dist/runtime/vendor/cel-js/lib/globals.js +33 -0
  139. package/dist/runtime/vendor/cel-js/lib/index.d.ts +469 -0
  140. package/dist/runtime/vendor/cel-js/lib/index.js +18 -0
  141. package/dist/runtime/vendor/cel-js/lib/macros.d.ts +1 -0
  142. package/dist/runtime/vendor/cel-js/lib/macros.js +230 -0
  143. package/dist/runtime/vendor/cel-js/lib/operators.d.ts +117 -0
  144. package/dist/runtime/vendor/cel-js/lib/operators.js +739 -0
  145. package/dist/runtime/vendor/cel-js/lib/optional.d.ts +14 -0
  146. package/dist/runtime/vendor/cel-js/lib/optional.js +161 -0
  147. package/dist/runtime/vendor/cel-js/lib/options.d.ts +23 -0
  148. package/dist/runtime/vendor/cel-js/lib/options.js +47 -0
  149. package/dist/runtime/vendor/cel-js/lib/overloads.d.ts +1 -0
  150. package/dist/runtime/vendor/cel-js/lib/overloads.js +214 -0
  151. package/dist/runtime/vendor/cel-js/lib/parser.d.ts +56 -0
  152. package/dist/runtime/vendor/cel-js/lib/parser.js +827 -0
  153. package/dist/runtime/vendor/cel-js/lib/registry.d.ts +279 -0
  154. package/dist/runtime/vendor/cel-js/lib/registry.js +1596 -0
  155. package/dist/runtime/vendor/cel-js/lib/serialize.d.ts +1 -0
  156. package/dist/runtime/vendor/cel-js/lib/serialize.js +259 -0
  157. package/dist/runtime/vendor/cel-js/lib/type-checker.d.ts +26 -0
  158. package/dist/runtime/vendor/cel-js/lib/type-checker.js +81 -0
  159. package/package.json +9 -4
  160. package/dist/runtime/components/locale.d.vue.ts +0 -14
  161. package/dist/runtime/components/locale.vue +0 -89
  162. package/dist/runtime/components/locale.vue.d.ts +0 -14
  163. package/dist/runtime/components/query.d.vue.ts +0 -30
  164. package/dist/runtime/components/query.vue +0 -266
  165. package/dist/runtime/components/query.vue.d.ts +0 -30
  166. package/dist/runtime/utilities/query-config/global.d.ts +0 -4
  167. package/dist/runtime/utilities/query-config/global.js +0 -18
  168. package/dist/runtime/utilities/query-config/index.d.ts +0 -3
  169. package/dist/runtime/utilities/query-config/index.js +0 -14
  170. package/dist/runtime/utilities/query-config/schema.d.ts +0 -96
  171. package/dist/runtime/utilities/query-config/schema.js +0 -51
  172. /package/dist/runtime/components/{logo.d.vue.ts → ui/logo/Logo.d.vue.ts} +0 -0
  173. /package/dist/runtime/components/{logo.vue → ui/logo/Logo.vue} +0 -0
  174. /package/dist/runtime/components/{logo.vue.d.ts → ui/logo/Logo.vue.d.ts} +0 -0
@@ -1,633 +1,68 @@
1
- <script>
2
- import { FlexRender, getCoreRowModel, getExpandedRowModel, getPaginationRowModel, useVueTable } from "@tanstack/vue-table";
3
- import { useVirtualizer } from "@tanstack/vue-virtual";
4
- import { Icon } from "@iconify/vue";
5
- import { getProperty } from "dot-prop";
6
- import { Pagination } from "reka-ui/namespaced";
7
- import { useI18n } from "vue-i18n";
8
- import { computed, ref } from "vue";
9
- import { useNuxtApp } from "#app";
10
- import { Button } from "./ui/button";
11
- import { NumberField, NumberFieldInput } from "./ui/number-field";
12
- import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
13
- import { useTableRenderers } from "../composables/useTableRenderers";
14
- import { useCheating } from "#imports";
15
- import { defu } from "defu";
16
- </script>
17
-
18
1
  <script setup>
2
+ import { ref } from "vue";
3
+ import UiTable from "./ui/table/Table.vue";
4
+ defineOptions({
5
+ inheritAttrs: false
6
+ });
19
7
  const props = defineProps({
20
- id: { type: String, required: true },
21
- getRowId: { type: String, required: false, default: void 0 },
22
- getSubRows: { type: String, required: false, default: void 0 },
23
- enableRowSelection: { type: String, required: false, default: void 0 },
24
- enableMultiRowSelection: { type: String, required: false, default: void 0 },
25
- columns: { type: Array, required: true },
8
+ config: { type: null, required: true },
26
9
  data: { type: Array, required: true },
27
- cellStyles: { type: String, required: false, default: void 0 },
28
- props: { type: Object, required: false, default: void 0 },
29
- paginationLeft: { type: String, required: false },
30
- paginationRight: { type: String, required: false }
10
+ rowCount: { type: Number, required: false }
31
11
  });
32
- const { t } = useI18n({
33
- messages: props.columns.reduce((acc, column) => {
34
- function f(column2) {
35
- return defu(
36
- acc,
37
- Object.fromEntries(
38
- Object.entries(
39
- column2.title ?? {}
40
- ).map(([locale, message]) => [locale, { [genColumnId(column2)]: message }])
41
- ),
42
- column2.tooltip ? Object.fromEntries(Object.entries(column2.tooltip).map(([locale, message]) => [locale, { [`${genColumnId(column2)}-tooltip`]: message }])) : {},
43
- ...column2.columns?.map((column3) => f(column3)) ?? []
44
- );
45
- }
46
- return f(column);
47
- }, {})
48
- });
49
- const slots = defineSlots();
50
- const { $dsl } = useNuxtApp();
51
- const isCheating = useCheating();
52
- const { resolveTableRenderer } = useTableRenderers();
53
- const containerRef = ref(null);
54
- function genColumnId(column) {
55
- if (typeof column.accessor === "string") {
56
- return column.accessor;
57
- } else if (column.accessor) {
58
- return column.accessor.read;
59
- } else if (column.id) {
60
- return column.id;
61
- }
62
- return crypto.randomUUID();
12
+ const emit = defineEmits(["update:config"]);
13
+ function handleConfigUpdate(config) {
14
+ emit("update:config", config);
63
15
  }
64
- function translate(column) {
65
- if (Array.isArray(column.columns) && column.columns.length > 0) {
66
- return {
67
- id: column.id ?? genColumnId(column),
68
- header: t(genColumnId(column)),
69
- columns: column.columns?.map((column2) => translate(column2)) ?? [],
70
- enableSorting: column.enableSorting ?? false,
71
- enableMultiSort: column.enableMultiSorting,
72
- enablePinning: column.enablePinning,
73
- size: column.size,
74
- meta: {
75
- tooltip: column.tooltip ? `${genColumnId(column)}-tooltip` : void 0,
76
- grow: column.grow ?? false
77
- }
78
- };
79
- }
80
- const renderer = resolveTableRenderer(typeof column.renderer === "string" ? column.renderer : column.renderer?.id ? column.renderer.id : "table.renderer.text");
81
- const options = renderer.parseOptions(column.renderer && typeof column.renderer === "object" && "props" in column.renderer ? column.renderer.props : null);
82
- return {
83
- id: column.id ?? genColumnId(column),
84
- header: (ctx) => renderer.header?.({ ctx, options }) ?? t(genColumnId(column)),
85
- cell: (ctx) => {
86
- if (ctx.column.id in slots) {
87
- return slots[ctx.column.id]?.({ cell: ctx });
88
- }
89
- return renderer.cell({ ctx, options });
90
- },
91
- accessorFn: (row, index) => {
92
- const key = column.accessorKey ? column.accessorKey : column.accessor;
93
- if (typeof key === "string") {
94
- return getProperty(row, key);
95
- } else if (key !== void 0) {
96
- try {
97
- return $dsl.evaluate`${key.read}`({
98
- row,
99
- index: BigInt(index)
100
- });
101
- } catch (e) {
102
- console.error(e);
103
- return void 0;
104
- }
105
- }
106
- return void 0;
107
- },
108
- enableSorting: column.enableSorting ?? false,
109
- enableMultiSort: column.enableMultiSorting,
110
- enablePinning: column.enablePinning,
111
- size: column.size,
112
- columns: column.columns?.map((column2) => translate(column2)) ?? [],
113
- meta: {
114
- tooltip: column.tooltip ? `${genColumnId(column)}-tooltip` : void 0,
115
- grow: column.grow ?? false
116
- },
117
- ...renderer.columnDefOverrides
118
- };
119
- }
120
- const columns = computed(() => {
121
- return props.columns.map((column) => translate(column));
122
- });
123
- const table = useVueTable({
124
- get columns() {
125
- return columns.value;
126
- },
127
- get data() {
128
- return props.data;
16
+ const tableRef = ref(null);
17
+ defineExpose(new Proxy({}, {
18
+ get(_target, property) {
19
+ return tableRef.value ? Reflect.get(tableRef.value, property) : void 0;
129
20
  },
130
- getCoreRowModel: getCoreRowModel(),
131
- getExpandedRowModel: getExpandedRowModel(),
132
- getPaginationRowModel: getPaginationRowModel(),
133
- getRowId: props.getRowId ? (originalRow, index, parent) => {
134
- try {
135
- const key = $dsl.evaluate`${props.getRowId}`(
136
- {
137
- row: originalRow,
138
- index,
139
- parent: parent ? {
140
- id: parent.id,
141
- index: BigInt(parent.index),
142
- original: parent.original
143
- } : null
144
- }
145
- );
146
- if (typeof key === "string") {
147
- return key;
148
- }
149
- } catch (e) {
150
- console.error(e);
151
- }
152
- return parent ? `${parent.index}.${index}` : `${index}`;
153
- } : void 0,
154
- getSubRows: (row, index) => {
155
- if (!props.getSubRows)
156
- return void 0;
157
- try {
158
- const value = $dsl.evaluate`${props.getSubRows}`({
159
- row,
160
- index
161
- });
162
- return Array.isArray(value) ? value : void 0;
163
- } catch (e) {
164
- console.error(e);
165
- return void 0;
166
- }
21
+ has(_target, property) {
22
+ return tableRef.value ? Reflect.has(tableRef.value, property) : false;
167
23
  },
168
- enableRowSelection: (row) => {
169
- if (!props.enableRowSelection)
170
- return true;
171
- try {
172
- return Boolean($dsl.evaluate`${props.enableRowSelection}`({
173
- row: row.original,
174
- index: BigInt(row.index),
175
- id: row.id
176
- }));
177
- } catch (e) {
178
- console.error(e);
179
- return true;
180
- }
24
+ ownKeys() {
25
+ return tableRef.value ? Reflect.ownKeys(tableRef.value) : [];
181
26
  },
182
- enableMultiRowSelection: props.enableMultiRowSelection ? (row) => {
183
- try {
184
- return Boolean($dsl.evaluate`${props.enableMultiRowSelection}`({
185
- row: row.original,
186
- index: BigInt(row.index),
187
- id: row.id
188
- }));
189
- } catch (e) {
190
- console.error(e);
191
- return true;
27
+ getOwnPropertyDescriptor(_target, property) {
28
+ if (!tableRef.value || !Reflect.has(tableRef.value, property)) {
29
+ return void 0;
192
30
  }
193
- } : void 0,
194
- columnResizeMode: "onChange",
195
- ...props.props
196
- });
197
- defineExpose(table);
198
- const rowVirtualizer = useVirtualizer(
199
- computed(() => ({
200
- count: table.getRowModel().rows.length,
201
- estimateSize: () => 35,
202
- getScrollElement: () => containerRef.value,
203
- overscan: 30
204
- }))
205
- );
206
- const rowTotalSize = computed(() => rowVirtualizer.value.getTotalSize());
207
- const rowWindow = computed(() => rowVirtualizer.value.getVirtualItems());
208
- function measureRow(el) {
209
- if (!el || !(el instanceof Element))
210
- return;
211
- rowVirtualizer.value.measureElement(el);
212
- }
213
- const rows = computed(() => table.getRowModel().rows);
214
- function isStyleRecord(x) {
215
- return typeof x === "object" && x !== null && !Array.isArray(x);
216
- }
217
- function getCellStyles(ctx) {
218
- if (!props.cellStyles)
219
- return {};
220
- try {
221
- const result = $dsl.evaluate`${props.cellStyles}`({
222
- row: ctx.row.original,
223
- index: BigInt(ctx.row.index),
224
- id: ctx.column.id,
225
- selected: ctx.row.getIsSelected(),
226
- pinned: ctx.column.getIsPinned()
227
- });
228
- return isStyleRecord(result) ? result : {};
229
- } catch (e) {
230
- console.error(e);
231
- return {};
232
- }
233
- }
234
- function shouldHaveRightBorder(column) {
235
- switch (column.getIsPinned()) {
236
- case "left":
237
- return true;
238
- case "right":
239
- return !column.getIsLastColumn("right");
240
- case false:
241
- return !column.getIsLastColumn("center");
242
- }
243
- }
244
- function shouldHaveLeftBorder(column) {
245
- switch (column.getIsPinned()) {
246
- case "left":
247
- return false;
248
- case "right":
249
- return true;
250
- case false:
251
- return false;
31
+ return {
32
+ configurable: true,
33
+ enumerable: true,
34
+ get() {
35
+ if (!tableRef.value) {
36
+ return void 0;
37
+ }
38
+ return Reflect.get(tableRef.value, property);
39
+ }
40
+ };
252
41
  }
253
- }
254
- function pinnedStyle(column) {
255
- const pinned = column.getIsPinned();
256
- if (!pinned)
257
- return {};
258
- const style = {
259
- [pinned]: `${column.getStart(pinned)}px`
260
- };
261
- if (column.getIsLastColumn("left"))
262
- style.boxShadow = "5px 5px 5px #00000005";
263
- if (column.getIsFirstColumn("right"))
264
- style.boxShadow = "-5px 5px 5px #00000005";
265
- return style;
266
- }
267
- const SORT_ICONS = {
268
- unsorted: "fluent:arrow-sort-16-regular",
269
- asc: "fluent:arrow-sort-up-16-regular",
270
- desc: "fluent:arrow-sort-down-16-regular"
271
- };
272
- function getSortIcon(column) {
273
- const sortDir = column.getIsSorted();
274
- const iconKey = sortDir === false ? "unsorted" : sortDir;
275
- return SORT_ICONS[iconKey];
276
- }
42
+ }));
43
+ </script>
44
+
45
+ <script>
46
+ export { AccessorC, ColumnC, RenderC, TableConfigC } from "./ui/table/schema";
277
47
  </script>
278
48
 
279
49
  <template>
280
- <div
281
- class="flex flex-col h-full"
50
+ <UiTable
51
+ ref="tableRef"
52
+ v-bind="$attrs"
53
+ :config="props.config"
54
+ :data="props.data"
55
+ :row-count="props.rowCount"
56
+ @update:config="handleConfigUpdate"
282
57
  >
283
- <div
284
- ref="containerRef"
285
- class="overflow-scroll overscroll-none flex-1 border border-zinc-200 rounded relative"
58
+ <template
59
+ v-for="(_, slotName) in $slots"
60
+ #[slotName]="slotProps"
286
61
  >
287
- <div :style="{ height: `${rowTotalSize}px` }">
288
- <table class="grid">
289
- <thead class="grid sticky top-0 z-10 select-none">
290
- <tr
291
- v-for="group in table.getHeaderGroups()"
292
- :key="group.id"
293
- class="flex w-full border-b border-zinc-200"
294
- >
295
- <th
296
- v-for="header in group.headers"
297
- :key="header.id"
298
- :colspan="header.colSpan"
299
- :class="[
300
- header.column.columnDef.meta?.grow && 'flex-1',
301
- 'flex items-center gap-2 border-zinc-300 py-2 text-zinc-600',
302
- 'text-xs flex items-center justify-center relative',
303
- 'bg-[color-mix(in_srgb,var(--primary)_10%,white)] group',
304
- header.column.getIsPinned() && 'sticky z-15',
305
- shouldHaveRightBorder(header.column) && 'border-r',
306
- shouldHaveLeftBorder(header.column) && 'border-l'
307
- ]"
308
- :style="{
309
- width: `${header.getSize()}px`,
310
- ...pinnedStyle(header.column)
311
- }"
312
- >
313
- <FlexRender
314
- v-if="!header.isPlaceholder"
315
- :render="header.column.columnDef.header"
316
- :props="header.getContext()"
317
- />
318
-
319
- <Tooltip
320
- v-if="!header.isPlaceholder && header.column.columnDef.meta?.tooltip"
321
- :delay-duration="180"
322
- >
323
- <TooltipTrigger as-child>
324
- <Icon icon="fluent:info-20-regular" />
325
- </TooltipTrigger>
326
- <TooltipContent
327
- align="center"
328
- side="top"
329
- >
330
- <span v-html="$md.inline`${t(`${header.column.id}-tooltip`)}`()" />
331
- </TooltipContent>
332
- </Tooltip>
333
-
334
- <Tooltip
335
- v-if="!header.isPlaceholder && header.column.getCanSort()"
336
- :delay-duration="800"
337
- >
338
- <TooltipTrigger as-child>
339
- <Button
340
- variant="ghost"
341
- size="xs"
342
- :class="[
343
- 'absolute hover:bg-transparent right-1 top-1/2 -translate-y-1/2 transform-3d transition-opacity duration-180',
344
- !header.column.getIsSorted() ? 'opacity-30 hover:opacity-60' : 'text-(--primary)/80 hover:text-(--primary)'
345
- ]"
346
- as-child
347
- >
348
- <button
349
- type="button"
350
- @click="header.column.getToggleSortingHandler()?.($event)"
351
- >
352
- <Icon :icon="getSortIcon(header.column)" />
353
- </button>
354
- </Button>
355
- </TooltipTrigger>
356
- <TooltipContent>
357
- {{
358
- header.column.getIsSorted() ? t(`table-sort-${header.column.getIsSorted()}`) : t("table-sort-unsorted")
359
- }}
360
- </TooltipContent>
361
- </Tooltip>
362
-
363
- <div
364
- v-if="!header.isPlaceholder && header.column.getCanResize() && (!header.column.getIsLastColumn('right') || !table.getIsSomeColumnsPinned('right') && !header.column.getIsLastColumn('center'))"
365
- :class="[
366
- 'group',
367
- 'absolute',
368
- 'top-0',
369
- 'bottom-0',
370
- 'right-0',
371
- 'px-2',
372
- 'translate-x-2',
373
- 'z-5',
374
- 'opacity-0',
375
- 'duration-150',
376
- 'transition-opacity',
377
- 'ease-out',
378
- 'hover:opacity-100',
379
- 'cursor-col-resize'
380
- ]"
381
- @mousedown="header.getResizeHandler()($event)"
382
- >
383
- <div :class="['w-2pt', 'h-full', 'translate-x-1pt', 'transform-3d', 'bg-[color-mix(in_srgb,var(--primary)_80%,white)]']" />
384
- </div>
385
- </th>
386
- </tr>
387
- </thead>
388
-
389
- <tbody
390
- class="grid relative"
391
- :style="{ height: `${rowTotalSize}px` }"
392
- >
393
- <tr
394
- v-for="r in rowWindow"
395
- :key="rows[r.index]?.id ?? r.index"
396
- :ref="measureRow"
397
- class="flex absolute w-full not-last:border-b border-zinc-300"
398
- :data-index="rows[r.index]?.index"
399
- :style="{ transform: `translate3d(0, ${r.start}px, 0)` }"
400
- >
401
- <td
402
- v-for="cell in rows[r.index]?.getVisibleCells() ?? []"
403
- :key="cell.id"
404
- :class="[
405
- 'border-zinc-300',
406
- cell.column.columnDef.meta?.grow && 'flex-1',
407
- cell.column.getIsPinned() && 'sticky z-15',
408
- shouldHaveRightBorder(cell.column) && 'border-r',
409
- shouldHaveLeftBorder(cell.column) && 'border-l'
410
- ]"
411
- :style="{
412
- width: `${cell.column.getSize()}px`,
413
- ...pinnedStyle(cell.column),
414
- ...getCellStyles(cell.getContext())
415
- }"
416
- >
417
- <FlexRender
418
- :render="cell.column.columnDef.cell"
419
- :props="cell.getContext()"
420
- />
421
- </td>
422
- </tr>
423
- </tbody>
424
-
425
- <tfoot class="hidden has-data-footer:grid sticky bottom-0 z-10 select-none border-t border-zinc-200">
426
- <tr
427
- v-for="group in table.getFooterGroups()"
428
- :key="group.id"
429
- class="flex w-full border-zinc-200"
430
- >
431
- <th
432
- v-for="header in group.headers"
433
- :key="header.id"
434
- :colSpan="header.colSpan"
435
- :class="[
436
- header.column.columnDef.meta?.grow && 'flex-1',
437
- 'flex items-center gap-2 border-zinc-300 text-zinc-600 p-0',
438
- 'text-xs flex items-center justify-center relative',
439
- 'bg-[color-mix(in_srgb,var(--primary)_10%,white)] group',
440
- header.column.getIsPinned() && 'sticky z-15',
441
- shouldHaveRightBorder(header.column) && 'border-r',
442
- shouldHaveLeftBorder(header.column) && 'border-l'
443
- ]"
444
- :style="{
445
- width: `${header.getSize()}px`,
446
- ...pinnedStyle(header.column)
447
- }"
448
- >
449
- <FlexRender
450
- v-if="!header.isPlaceholder"
451
- :render="header.column.columnDef.footer"
452
- :props="header.getContext()"
453
- />
454
- </th>
455
- </tr>
456
- </tfoot>
457
- </table>
458
- </div>
459
- </div>
460
-
461
- <div class="flex items-center justify-between w-full py-2 gap-2 text-sm text-zinc-600">
462
- <div
463
- :class="[
464
- 'relative p-1 flex-1 prose prose-zinc text-xs border border-dashed',
465
- isCheating ? 'border-(--primary)/20 rounded hover:border-(--primary)/40 transition-colors duration-150 group cursor-pointer' : 'border-transparent'
466
- ]"
467
- >
468
- <span
469
- v-html="$md.inline`${props.paginationLeft}`({
470
- selected: table.getSelectedRowModel().rows.map((row) => row.original)
471
- })"
472
- />
473
- <Icon
474
- v-if="isCheating"
475
- icon="fluent:edit-20-regular"
476
- class="w-4 h-4 text-(--primary) absolute right-1 top-1/2 -translate-y-1/2 transform-3d group-hover:opacity-100 opacity-50 transition-opacity duration-150"
477
- />
478
- &nbsp;
479
- </div>
480
- <div class="flex items-center gap-4">
481
- <i18n-t
482
- keypath="total"
483
- tag="span"
484
- class="text-xs"
485
- >
486
- <template #count>
487
- <strong>{{ props.data.length }}</strong>
488
- </template>
489
- </i18n-t>
490
- <Pagination.Root
491
- show-edges
492
- :total="props.data.length"
493
- :items-per-page="table.getState().pagination.pageSize"
494
- :page="table.getState().pagination.pageIndex + 1"
495
- @update:page="(page2) => table.setPageIndex(page2 - 1)"
496
- >
497
- <Pagination.List
498
- v-slot="{ items }"
499
- class="flex items-center gap-1"
500
- >
501
- <Pagination.First
502
- :class="[
503
- 'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
504
- 'data-disabled:opacity-50 data-disabled:cursor-not-allowed cursor-pointer'
505
- ]"
506
- >
507
- <Icon
508
- icon="radix-icons:double-arrow-left"
509
- class="w-4 h-4"
510
- />
511
- </Pagination.First>
512
- <Pagination.Prev
513
- :class="[
514
- 'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
515
- 'data-disabled:opacity-50 data-disabled:cursor-not-allowed cursor-pointer'
516
- ]"
517
- >
518
- <Icon
519
- icon="radix-icons:chevron-left"
520
- class="w-4 h-4"
521
- />
522
- </Pagination.Prev>
523
-
524
- <template
525
- v-for="(page, index) in items"
526
- :key="page.type === 'page' ? `${page.type}-${page.value}` : `${page.type}-${index}`"
527
- >
528
- <Pagination.ListItem
529
- v-if="page.type === 'page'"
530
- :class="[
531
- 'w-7 h-7 flex items-center justify-center rounded text-xs bg-transparent',
532
- 'data-selected:text-(--primary) hover:bg-zinc-100 transition cursor-pointer'
533
- ]"
534
- :value="page.value"
535
- >
536
- {{ page.value }}
537
- </Pagination.ListItem>
538
- <Pagination.Ellipsis
539
- v-else
540
- class="w-7 h-7 flex items-center justify-center text-zinc-400"
541
- >
542
- &#8230;
543
- </Pagination.Ellipsis>
544
- </template>
545
-
546
- <Pagination.Next
547
- :class="[
548
- 'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
549
- 'data-disabled:opacity-50 data-disabled:cursor-not-allowed cursor-pointer'
550
- ]"
551
- >
552
- <Icon
553
- icon="radix-icons:chevron-right"
554
- class="w-4 h-4"
555
- />
556
- </Pagination.Next>
557
- <Pagination.Last
558
- :class="[
559
- 'w-7 h-7 flex items-center justify-center bg-transparent hover:bg-zinc-100 transition disabled:opacity-50 rounded text-zinc-600',
560
- 'data-disabled:opacity-50 data-disabled:cursor-not-allowed cursor-pointer'
561
- ]"
562
- >
563
- <Icon
564
- icon="radix-icons:double-arrow-right"
565
- class="w-4 h-4"
566
- />
567
- </Pagination.Last>
568
- </Pagination.List>
569
- </Pagination.Root>
570
- <i18n-t
571
- keypath="goto"
572
- tag="div"
573
- class="text-xs flex items-center gap-2"
574
- >
575
- <template #page>
576
- <NumberField
577
- :model-value="table.getState().pagination.pageIndex + 1"
578
- :min="1"
579
- :max="Math.ceil(props.data.length / table.getState().pagination.pageSize)"
580
- @update:model-value="(value) => table.setPageIndex(value - 1)"
581
- >
582
- <NumberFieldInput class="h-6 w-16 text-xs" />
583
- </NumberField>
584
- </template>
585
- </i18n-t>
586
- </div>
587
- <div
588
- :class="[
589
- 'relative p-1 flex-1 prose prose-zinc text-xs border border-dashed',
590
- isCheating ? 'border-(--primary)/20 rounded hover:border-(--primary)/40 transition-colors duration-150 group cursor-pointer' : 'border-transparent'
591
- ]"
592
- >
593
- <span
594
- v-html="$md.inline`${props.paginationRight}`({
595
- selected: table.getSelectedRowModel().rows.map((row) => row.original)
596
- })"
597
- />
598
- <Icon
599
- v-if="isCheating"
600
- icon="fluent:edit-20-regular"
601
- class="w-4 h-4 text-(--primary) absolute right-1 top-1/2 -translate-y-1/2 transform-3d group-hover:opacity-100 opacity-50 transition-opacity duration-150"
602
- />
603
- &nbsp;
604
- </div>
605
- </div>
606
- </div>
62
+ <slot
63
+ :name="slotName"
64
+ v-bind="slotProps ?? {}"
65
+ />
66
+ </template>
67
+ </UiTable>
607
68
  </template>
608
-
609
- <i18n lang="json">
610
- {
611
- "zh": {
612
- "total": "共 {count} 条",
613
- "goto": "前往 {page} 页",
614
- "table-sort-asc": "升序",
615
- "table-sort-desc": "降序",
616
- "table-sort-unsorted": "未排序"
617
- },
618
- "ja": {
619
- "total": "合計 {count} 件",
620
- "goto": "ページ {page} に移動",
621
- "table-sort-asc": "昇順",
622
- "table-sort-desc": "降順",
623
- "table-sort-unsorted": "未排序"
624
- },
625
- "en": {
626
- "total": "Total {count} items",
627
- "goto": "Go to page {page}",
628
- "table-sort-asc": "Ascending",
629
- "table-sort-desc": "Descending",
630
- "table-sort-unsorted": "Unsorted"
631
- }
632
- }
633
- </i18n>