@profeskills/vuejs-ui 0.2.2

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 (109) hide show
  1. package/ConfirmDialog.vue.d.ts +2 -0
  2. package/HBadge.vue.d.ts +17 -0
  3. package/HDialog.vue.d.ts +23 -0
  4. package/HMetricCard.vue.d.ts +7 -0
  5. package/HTooltip.vue.d.ts +16 -0
  6. package/LICENSE +21 -0
  7. package/README.md +47 -0
  8. package/StatCard.vue.d.ts +10 -0
  9. package/badge/Badge.vue.d.ts +18 -0
  10. package/badge/index.d.ts +1 -0
  11. package/badge/index.js +2 -0
  12. package/checkbox/Checkbox.vue.d.ts +12 -0
  13. package/checkbox/index.d.ts +1 -0
  14. package/checkbox/index.js +2 -0
  15. package/chunks/badge-Bs0JHyBd.js +17 -0
  16. package/chunks/checkbox-Dy2MEOEB.js +28 -0
  17. package/chunks/data-table-CmHz_5Gm.js +1106 -0
  18. package/chunks/dialog-B5d9RrVM.js +91 -0
  19. package/chunks/dropdown-menu-DjfkyvUs.js +190 -0
  20. package/chunks/select-sj-TTDYA.js +132 -0
  21. package/chunks/separator-nJXJBrX8.js +30 -0
  22. package/chunks/sheet-Bloy0C7L.js +91 -0
  23. package/chunks/tabs-CmEu-lQt.js +84 -0
  24. package/chunks/tooltip-Ck8h37A5.js +62 -0
  25. package/composables/useConfirm.d.ts +11 -0
  26. package/composables/useConfirm.js +13 -0
  27. package/composables/useTableInstance.d.ts +9 -0
  28. package/composables/useTableInstance.js +16 -0
  29. package/data-table/DataTable.vue.d.ts +17 -0
  30. package/data-table/DataTableColumnHeader.vue.d.ts +7 -0
  31. package/data-table/DataTableColumnsVisibility.vue.d.ts +2 -0
  32. package/data-table/DataTablePagination.vue.d.ts +6 -0
  33. package/data-table/DataTableSkeleton.vue.d.ts +9 -0
  34. package/data-table/advanced/DataTableAdvancedToolbar.vue.d.ts +31 -0
  35. package/data-table/advanced/DataTableFilterItem.vue.d.ts +13 -0
  36. package/data-table/advanced/DataTableMultiFilter.vue.d.ts +15 -0
  37. package/data-table/advanced/views/DataTableViewsDropdown.vue.d.ts +21 -0
  38. package/data-table/advanced/views/utils.d.ts +6 -0
  39. package/data-table/index.d.ts +10 -0
  40. package/data-table/index.js +2 -0
  41. package/dialog/Dialog.vue.d.ts +21 -0
  42. package/dialog/DialogClose.vue.d.ts +12 -0
  43. package/dialog/DialogContent.vue.d.ts +21 -0
  44. package/dialog/DialogDescription.vue.d.ts +15 -0
  45. package/dialog/DialogFooter.vue.d.ts +15 -0
  46. package/dialog/DialogHeader.vue.d.ts +15 -0
  47. package/dialog/DialogTitle.vue.d.ts +15 -0
  48. package/dialog/DialogTrigger.vue.d.ts +12 -0
  49. package/dialog/index.d.ts +8 -0
  50. package/dialog/index.js +2 -0
  51. package/dropdown-menu/DropdownMenu.vue.d.ts +21 -0
  52. package/dropdown-menu/DropdownMenuCheckboxItem.vue.d.ts +23 -0
  53. package/dropdown-menu/DropdownMenuContent.vue.d.ts +26 -0
  54. package/dropdown-menu/DropdownMenuItem.vue.d.ts +22 -0
  55. package/dropdown-menu/DropdownMenuLabel.vue.d.ts +16 -0
  56. package/dropdown-menu/DropdownMenuRadioGroup.vue.d.ts +19 -0
  57. package/dropdown-menu/DropdownMenuRadioItem.vue.d.ts +21 -0
  58. package/dropdown-menu/DropdownMenuRoot.vue.d.ts +12 -0
  59. package/dropdown-menu/DropdownMenuSeparator.vue.d.ts +5 -0
  60. package/dropdown-menu/DropdownMenuShortcut.vue.d.ts +15 -0
  61. package/dropdown-menu/DropdownMenuSub.vue.d.ts +16 -0
  62. package/dropdown-menu/DropdownMenuSubContent.vue.d.ts +15 -0
  63. package/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts +17 -0
  64. package/dropdown-menu/DropdownMenuTrigger.vue.d.ts +16 -0
  65. package/dropdown-menu/index.d.ts +13 -0
  66. package/dropdown-menu/index.js +2 -0
  67. package/index.d.ts +20 -0
  68. package/index.js +142 -0
  69. package/package.json +128 -0
  70. package/select/Select.vue.d.ts +24 -0
  71. package/select/SelectContent.vue.d.ts +24 -0
  72. package/select/SelectGroup.vue.d.ts +12 -0
  73. package/select/SelectItem.vue.d.ts +21 -0
  74. package/select/SelectLabel.vue.d.ts +15 -0
  75. package/select/SelectSeparator.vue.d.ts +5 -0
  76. package/select/SelectTrigger.vue.d.ts +21 -0
  77. package/select/SelectValue.vue.d.ts +15 -0
  78. package/select/index.d.ts +8 -0
  79. package/select/index.js +2 -0
  80. package/separator/Separator.vue.d.ts +10 -0
  81. package/separator/index.d.ts +1 -0
  82. package/separator/index.js +2 -0
  83. package/sheet/Sheet.vue.d.ts +21 -0
  84. package/sheet/SheetClose.vue.d.ts +12 -0
  85. package/sheet/SheetContent.vue.d.ts +19 -0
  86. package/sheet/SheetDescription.vue.d.ts +15 -0
  87. package/sheet/SheetFooter.vue.d.ts +15 -0
  88. package/sheet/SheetHeader.vue.d.ts +15 -0
  89. package/sheet/SheetTitle.vue.d.ts +15 -0
  90. package/sheet/SheetTrigger.vue.d.ts +12 -0
  91. package/sheet/index.d.ts +8 -0
  92. package/sheet/index.js +2 -0
  93. package/styles.css +2 -0
  94. package/tabs/Tabs.vue.d.ts +20 -0
  95. package/tabs/TabsContent.vue.d.ts +16 -0
  96. package/tabs/TabsList.vue.d.ts +16 -0
  97. package/tabs/TabsTrigger.vue.d.ts +16 -0
  98. package/tabs/index.d.ts +4 -0
  99. package/tabs/index.js +2 -0
  100. package/tooltip/Tooltip.vue.d.ts +21 -0
  101. package/tooltip/TooltipContent.vue.d.ts +23 -0
  102. package/tooltip/TooltipProvider.vue.d.ts +17 -0
  103. package/tooltip/TooltipTrigger.vue.d.ts +12 -0
  104. package/tooltip/index.d.ts +4 -0
  105. package/tooltip/index.js +2 -0
  106. package/types.d.ts +32 -0
  107. package/types.js +0 -0
  108. package/utils.d.ts +5 -0
  109. package/utils.js +11 -0
@@ -0,0 +1,1106 @@
1
+ import { showConfirm as e } from "../composables/useConfirm.js";
2
+ import { getIsMacOS as t } from "../utils.js";
3
+ import { a as n, c as r, o as i, r as a, s as o } from "./select-sj-TTDYA.js";
4
+ import { useTableInstance as s } from "../composables/useTableInstance.js";
5
+ import { d as c, f as l, o as u, p as d, u as f } from "./dropdown-menu-DjfkyvUs.js";
6
+ import { Fragment as p, Teleport as m, computed as h, createBlock as g, createCommentVNode as _, createElementBlock as v, createElementVNode as y, createTextVNode as b, createVNode as x, defineComponent as S, nextTick as C, normalizeClass as w, normalizeStyle as T, onMounted as ee, onUnmounted as te, openBlock as E, ref as D, renderList as O, renderSlot as k, toDisplayString as A, unref as j, vModelCheckbox as M, vModelText as N, watch as P, withCtx as F, withDirectives as I, withKeys as L, withModifiers as R } from "vue";
7
+ import { ArrowDownIcon as z, ArrowUpDownIcon as B, ArrowUpIcon as V, BookmarkIcon as H, BookmarkPlusIcon as U, CheckIcon as W, ChevronDownIcon as ne, ChevronLeftIcon as G, ChevronRightIcon as K, ChevronsLeftIcon as q, ChevronsRightIcon as J, EyeOffIcon as Y, ListFilterIcon as re, ListIcon as ie, Loader2Icon as X, PencilIcon as Z, PlusIcon as ae, RotateCcwIcon as oe, SaveIcon as se, SearchIcon as ce, SlidersHorizontalIcon as le, TypeIcon as ue, XIcon as de } from "lucide-vue-next";
8
+ import { FlexRender as Q } from "@tanstack/vue-table";
9
+ import { useRoute as fe, useRouter as pe } from "vue-router";
10
+ //#endregion
11
+ //#region src/HTooltip.vue
12
+ var me = /* @__PURE__ */ S({
13
+ __name: "HTooltip",
14
+ props: {
15
+ text: {},
16
+ placement: {}
17
+ },
18
+ setup(e) {
19
+ let t = e, n = D(!1), r = D(null), i = h(() => {
20
+ if (!n.value) return {};
21
+ let e = r.value;
22
+ if (!e) return {};
23
+ let i = e.getBoundingClientRect(), a = t.placement ?? "top";
24
+ if (a === "top-end") return {
25
+ position: "fixed",
26
+ top: `${i.top - 4}px`,
27
+ left: `${i.right}px`,
28
+ transform: "translate(-100%, -100%)",
29
+ zIndex: "9999"
30
+ };
31
+ if (a === "left") return {
32
+ position: "fixed",
33
+ top: `${i.top + i.height / 2}px`,
34
+ left: `${i.left - 4}px`,
35
+ transform: "translate(-100%, -50%)",
36
+ zIndex: "9999"
37
+ };
38
+ let o = a === "top";
39
+ return {
40
+ position: "fixed",
41
+ left: `${i.left + i.width / 2}px`,
42
+ top: o ? `${i.top - 4}px` : `${i.bottom + 4}px`,
43
+ transform: o ? "translate(-50%, -100%)" : "translate(-50%, 0)",
44
+ zIndex: "9999"
45
+ };
46
+ });
47
+ return (t, a) => (E(), v("div", {
48
+ class: "h-tip-wrap",
49
+ ref_key: "wrapRef",
50
+ ref: r,
51
+ onMouseenter: a[0] ||= (e) => n.value = !0,
52
+ onMouseleave: a[1] ||= (e) => n.value = !1,
53
+ onFocus: a[2] ||= (e) => n.value = !0,
54
+ onBlur: a[3] ||= (e) => n.value = !1
55
+ }, [k(t.$slots, "default"), (E(), g(m, { to: "body" }, [n.value && e.text ? (E(), v("div", {
56
+ key: 0,
57
+ class: "h-tip-bubble",
58
+ style: T(i.value)
59
+ }, A(e.text), 5)) : _("", !0)]))], 544));
60
+ }
61
+ }), he = { class: "h-dt-scroll" }, $ = { class: "h-dt-table" }, ge = { class: "h-dt-thead" }, _e = ["colSpan"], ve = { class: "h-dt-tbody" }, ye = ["data-state"], be = { key: 1 }, xe = ["colSpan"], Se = /* @__PURE__ */ S({
62
+ __name: "DataTable",
63
+ props: {
64
+ table: {},
65
+ columns: {}
66
+ },
67
+ setup(e) {
68
+ return (t, n) => (E(), v("div", he, [y("table", $, [y("thead", ge, [(E(!0), v(p, null, O(e.table.getHeaderGroups(), (e) => (E(), v("tr", {
69
+ key: e.id,
70
+ class: "h-dt-hrow"
71
+ }, [(E(!0), v(p, null, O(e.headers, (e) => (E(), v("th", {
72
+ key: e.id,
73
+ colSpan: e.colSpan,
74
+ class: "h-dt-th",
75
+ style: T(e.column.getSize() === 150 ? {} : {
76
+ width: `${e.column.getSize()}px`,
77
+ minWidth: `${e.column.getSize()}px`,
78
+ maxWidth: `${e.column.getSize()}px`
79
+ })
80
+ }, [e.isPlaceholder ? _("", !0) : (E(), g(j(Q), {
81
+ key: 0,
82
+ render: e.column.columnDef.header,
83
+ props: e.getContext()
84
+ }, null, 8, ["render", "props"]))], 12, _e))), 128))]))), 128))]), y("tbody", ve, [e.table.getRowModel().rows?.length ? (E(!0), v(p, { key: 0 }, O(e.table.getRowModel().rows, (e) => (E(), v("tr", {
85
+ key: e.id,
86
+ "data-state": e.getIsSelected() ? "selected" : void 0,
87
+ class: "h-dt-row"
88
+ }, [(E(!0), v(p, null, O(e.getVisibleCells(), (e) => (E(), v("td", {
89
+ key: e.id,
90
+ class: "h-dt-td"
91
+ }, [x(j(Q), {
92
+ render: e.column.columnDef.cell,
93
+ props: e.getContext()
94
+ }, null, 8, ["render", "props"])]))), 128))], 8, ye))), 128)) : (E(), v("tr", be, [y("td", {
95
+ colSpan: e.columns.length,
96
+ class: "h-dt-empty"
97
+ }, " Aucun résultat. ", 8, xe)]))])])]));
98
+ }
99
+ }), Ce = { class: "rounded-md border" }, we = { class: "w-full caption-bottom text-sm" }, Te = { class: "[&_tr]:border-b" }, Ee = { class: "border-b" }, De = /* @__PURE__ */ S({
100
+ __name: "DataTableSkeleton",
101
+ props: {
102
+ rowCount: { default: 10 },
103
+ columnCount: { default: 7 }
104
+ },
105
+ setup(e) {
106
+ return (t, n) => (E(), v("div", Ce, [y("table", we, [y("thead", Te, [y("tr", Ee, [(E(!0), v(p, null, O(e.columnCount, (e) => (E(), v("th", {
107
+ key: e,
108
+ class: "h-10 px-2"
109
+ }, [...n[0] ||= [y("div", { class: "h-4 w-full rounded bg-muted animate-pulse" }, null, -1)]]))), 128))])]), y("tbody", null, [(E(!0), v(p, null, O(e.rowCount, (t) => (E(), v("tr", {
110
+ key: t,
111
+ class: "border-b"
112
+ }, [(E(!0), v(p, null, O(e.columnCount, (e) => (E(), v("td", {
113
+ key: e,
114
+ class: "p-2"
115
+ }, [y("div", {
116
+ class: "h-4 rounded bg-muted animate-pulse",
117
+ style: T({ width: `${Math.random() * 40 + 60}%` })
118
+ }, null, 4)]))), 128))]))), 128))])])]));
119
+ }
120
+ }), Oe = { class: "flex w-full items-center justify-end gap-3 px-3 py-1.5" }, ke = { class: "text-xs text-muted-foreground tabular-nums w-[52px] text-center" }, Ae = { class: "flex items-center gap-1" }, je = ["disabled"], Me = ["disabled"], Ne = ["disabled"], Pe = ["disabled"], Fe = /* @__PURE__ */ S({
121
+ __name: "DataTablePagination",
122
+ props: { table: {} },
123
+ setup(e) {
124
+ let t = e, s = h(() => t.table.getState().pagination.pageIndex + 1), c = h(() => Math.max(1, t.table.getPageCount()));
125
+ return (t, l) => (E(), v("div", Oe, [
126
+ x(j(r), {
127
+ "model-value": String(e.table.getState().pagination.pageSize),
128
+ "onUpdate:modelValue": l[0] ||= (t) => e.table.setPageSize(Number(t))
129
+ }, {
130
+ default: F(() => [x(j(o), { class: "h-7 w-[62px] text-xs px-2 gap-1 [&>svg]:size-3" }, {
131
+ default: F(() => [x(j(a))]),
132
+ _: 1
133
+ }), x(j(i), {
134
+ position: "popper",
135
+ side: "top",
136
+ align: "end",
137
+ "side-offset": 4,
138
+ class: "min-w-[62px]"
139
+ }, {
140
+ default: F(() => [(E(), v(p, null, O([
141
+ 10,
142
+ 20,
143
+ 30,
144
+ 40,
145
+ 50
146
+ ], (e) => x(j(n), {
147
+ key: e,
148
+ value: String(e),
149
+ class: "text-xs"
150
+ }, {
151
+ default: F(() => [b(A(e), 1)]),
152
+ _: 2
153
+ }, 1032, ["value"])), 64))]),
154
+ _: 1
155
+ })]),
156
+ _: 1
157
+ }, 8, ["model-value"]),
158
+ y("span", ke, A(s.value) + " / " + A(c.value), 1),
159
+ y("div", Ae, [
160
+ y("button", {
161
+ type: "button",
162
+ class: "flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",
163
+ disabled: s.value <= 1,
164
+ onClick: l[1] ||= (t) => e.table.setPageIndex(0)
165
+ }, [x(j(q), { class: "size-3.5" })], 8, je),
166
+ y("button", {
167
+ type: "button",
168
+ class: "flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",
169
+ disabled: s.value <= 1,
170
+ onClick: l[2] ||= (t) => e.table.previousPage()
171
+ }, [x(j(G), { class: "size-3.5" })], 8, Me),
172
+ y("button", {
173
+ type: "button",
174
+ class: "flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",
175
+ disabled: s.value >= c.value,
176
+ onClick: l[3] ||= (t) => e.table.nextPage()
177
+ }, [x(j(K), { class: "size-3.5" })], 8, Ne),
178
+ y("button", {
179
+ type: "button",
180
+ class: "flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",
181
+ disabled: s.value >= c.value,
182
+ onClick: l[4] ||= (t) => e.table.setPageIndex(e.table.getPageCount() - 1)
183
+ }, [x(j(J), { class: "size-3.5" })], 8, Pe)
184
+ ])
185
+ ]));
186
+ }
187
+ }), Ie = { class: "p-1" }, Le = ["onMousedown"], Re = {
188
+ key: 0,
189
+ viewBox: "0 0 12 12",
190
+ class: "size-3 fill-current"
191
+ }, ze = /* @__PURE__ */ S({
192
+ __name: "DataTableColumnsVisibility",
193
+ setup(e) {
194
+ let { table: t } = s(), n = pe(), r = fe(), i = D(null), a = D(!1), o = D({}), c = h(() => t.getAllColumns().filter((e) => e.accessorFn !== void 0 && e.getCanHide()));
195
+ function l(e) {
196
+ e.toggleVisibility(!e.getIsVisible()), C(() => {
197
+ let e = c.value.filter((e) => e.getIsVisible()).map((e) => e.id), t = e.length === c.value.length, i = { ...r.query };
198
+ t ? delete i.cols : i.cols = e.join("."), n.replace({ query: i });
199
+ });
200
+ }
201
+ function u() {
202
+ if (a.value) {
203
+ a.value = !1;
204
+ return;
205
+ }
206
+ if (i.value) {
207
+ let e = i.value.getBoundingClientRect();
208
+ o.value = {
209
+ top: `${e.bottom + 4}px`,
210
+ right: `${window.innerWidth - e.right}px`
211
+ };
212
+ }
213
+ a.value = !0;
214
+ }
215
+ function d(e) {
216
+ a.value && i.value && !i.value.contains(e.target) && (a.value = !1);
217
+ }
218
+ return ee(() => document.addEventListener("mousedown", d)), te(() => document.removeEventListener("mousedown", d)), (e, t) => (E(), v("div", {
219
+ class: "relative",
220
+ ref_key: "rootRef",
221
+ ref: i
222
+ }, [x(me, {
223
+ text: "Colonnes visibles",
224
+ placement: "top-end"
225
+ }, {
226
+ default: F(() => [y("button", {
227
+ type: "button",
228
+ onClick: u,
229
+ class: "flex size-7 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground"
230
+ }, [x(j(le), { class: "size-4" })])]),
231
+ _: 1
232
+ }), (E(), g(m, { to: "body" }, [a.value ? (E(), v("div", {
233
+ key: 0,
234
+ style: T(o.value),
235
+ class: "fixed z-[400] w-48 rounded-md border bg-popover shadow-md",
236
+ onMousedown: t[0] ||= R(() => {}, ["stop"])
237
+ }, [t[2] ||= y("p", { class: "border-b px-3 py-2 text-xs font-semibold text-muted-foreground" }, "Toggle columns", -1), y("div", Ie, [(E(!0), v(p, null, O(c.value, (e) => (E(), v("div", {
238
+ key: e.id,
239
+ class: "flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm capitalize hover:bg-accent",
240
+ onMousedown: R((t) => l(e), ["prevent", "stop"])
241
+ }, [y("div", { class: w(["flex size-4 shrink-0 items-center justify-center rounded border border-primary", e.getIsVisible() ? "bg-primary text-primary-foreground" : "bg-background"]) }, [e.getIsVisible() ? (E(), v("svg", Re, [...t[1] ||= [y("polyline", {
242
+ points: "1,6 4,10 11,2",
243
+ stroke: "currentColor",
244
+ "stroke-width": "2",
245
+ fill: "none",
246
+ "stroke-linecap": "round"
247
+ }, null, -1)]])) : _("", !0)], 2), y("span", null, A(e.id), 1)], 40, Le))), 128))])], 36)) : _("", !0)]))], 512));
248
+ }
249
+ }), Be = {
250
+ key: 0,
251
+ class: "flex items-center space-x-2"
252
+ }, Ve = { class: "-ml-3 h-8 data-[state=open]:bg-accent flex items-center gap-1 rounded px-2 hover:bg-accent hover:text-accent-foreground text-xs font-medium" }, He = {
253
+ key: 1,
254
+ class: "text-xs font-medium"
255
+ }, Ue = /* @__PURE__ */ S({
256
+ __name: "DataTableColumnHeader",
257
+ props: {
258
+ column: {},
259
+ title: {}
260
+ },
261
+ setup(e) {
262
+ return (t, n) => e.column.getCanSort() ? (E(), v("div", Be, [x(j(d), null, {
263
+ default: F(() => [x(j(l), { asChild: "" }, {
264
+ default: F(() => [y("button", Ve, [y("span", null, A(e.title), 1), e.column.getIsSorted() === "asc" ? (E(), g(j(V), {
265
+ key: 0,
266
+ class: "size-3.5"
267
+ })) : e.column.getIsSorted() === "desc" ? (E(), g(j(z), {
268
+ key: 1,
269
+ class: "size-3.5"
270
+ })) : (E(), g(j(B), {
271
+ key: 2,
272
+ class: "size-3.5 text-muted-foreground"
273
+ }))])]),
274
+ _: 1
275
+ }), x(j(c), { align: "start" }, {
276
+ default: F(() => [
277
+ x(j(f), { onClick: n[0] ||= (t) => e.column.toggleSorting(!1) }, {
278
+ default: F(() => [x(j(V), { class: "mr-2 size-3.5 text-muted-foreground/70" }), n[3] ||= b(" Asc ", -1)]),
279
+ _: 1
280
+ }),
281
+ x(j(f), { onClick: n[1] ||= (t) => e.column.toggleSorting(!0) }, {
282
+ default: F(() => [x(j(z), { class: "mr-2 size-3.5 text-muted-foreground/70" }), n[4] ||= b(" Desc ", -1)]),
283
+ _: 1
284
+ }),
285
+ x(j(u)),
286
+ x(j(f), { onClick: n[2] ||= (t) => e.column.toggleVisibility(!1) }, {
287
+ default: F(() => [x(j(Y), { class: "mr-2 size-3.5 text-muted-foreground/70" }), n[5] ||= b(" Hide ", -1)]),
288
+ _: 1
289
+ })
290
+ ]),
291
+ _: 1
292
+ })]),
293
+ _: 1
294
+ })])) : (E(), v("div", He, A(e.title), 1));
295
+ }
296
+ }), We = [
297
+ "title",
298
+ "status",
299
+ "priority",
300
+ "createdAt"
301
+ ], Ge = [
302
+ "title",
303
+ "status",
304
+ "priority",
305
+ "sort",
306
+ "operator"
307
+ ];
308
+ function Ke(e, t) {
309
+ return {
310
+ filters: e.filter((e) => e.filterValues && e.filterValues.length > 0).map((e) => ({
311
+ field: e.value,
312
+ value: e.options?.length ? `${e.filterValues.join(".")}~${e.filterOperator}` : `${e.filterValues[0]}~${e.filterOperator}`,
313
+ isMulti: !!e.isMulti
314
+ })),
315
+ operator: t.operator || "and",
316
+ sort: t.sort || void 0
317
+ };
318
+ }
319
+ function qe(e) {
320
+ let t = {}, n = e.filterParams;
321
+ if (e.columns && e.columns.length > 0 && e.columns.length < We.length && (t.cols = e.columns.join(".")), !n) return t.viewId = e.id, t.page = "1", t.per_page = "10", t;
322
+ for (let e of n.filters ?? []) Ge.includes(e.field) && (t[e.field] = e.isMulti ? `${e.value}~multi` : e.value);
323
+ return n.operator && (t.operator = n.operator), n.sort && (t.sort = n.sort), t.page = "1", t.per_page = "10", t.viewId = e.id, t;
324
+ }
325
+ function Je(e) {
326
+ return [
327
+ "title",
328
+ "status",
329
+ "priority"
330
+ ].some((t) => !!e[t]) || !!e.sort && e.sort !== "createdAt.desc" || !!e.operator && e.operator !== "and";
331
+ }
332
+ //#endregion
333
+ //#region src/data-table/advanced/views/DataTableViewsDropdown.vue?vue&type=script&setup=true&lang.ts
334
+ var Ye = ["title"], Xe = { class: "truncate" }, Ze = { class: "flex items-center border-b px-3 py-2" }, Qe = { class: "p-3 space-y-2" }, $e = { class: "flex items-center gap-2 text-xs text-muted-foreground" }, et = {
335
+ key: 0,
336
+ class: "text-xs text-destructive"
337
+ }, tt = ["disabled"], nt = { class: "flex items-center border-b px-3 py-2" }, rt = { class: "p-3 space-y-2" }, it = { class: "flex items-center gap-2 text-xs text-muted-foreground" }, at = {
338
+ key: 0,
339
+ class: "text-xs text-destructive"
340
+ }, ot = { class: "flex gap-2" }, st = ["disabled"], ct = ["disabled"], lt = { class: "flex items-center border-b px-3 py-1.5" }, ut = { class: "max-h-52 overflow-auto p-1" }, dt = ["onClick"], ft = { class: "truncate" }, pt = {
341
+ key: 0,
342
+ class: "ml-1 shrink-0 rounded bg-accent px-1 text-[10px] uppercase text-muted-foreground"
343
+ }, mt = ["onClick"], ht = {
344
+ key: 0,
345
+ class: "py-4 text-center text-xs text-muted-foreground"
346
+ }, gt = { class: "border-t p-1" }, _t = /* @__PURE__ */ S({
347
+ __name: "DataTableViewsDropdown",
348
+ props: {
349
+ views: {},
350
+ filterParams: {},
351
+ onCreateView: { type: Function },
352
+ onUpdateView: { type: Function },
353
+ onDeleteView: { type: Function },
354
+ defaultLabel: {}
355
+ },
356
+ setup(n) {
357
+ let r = n, i = pe(), a = fe(), { table: o } = s(), c = t(), l = D(null), u = D(null), d = D(null), f = D(!1), S = D({}), k = D("list"), F = D(""), z = D(""), B = D(""), V = D(!1), H = D(!1), U = D(""), W = D(""), K = D(!1), q = D(!1), J = D(!1), Y = D(null), re = h(() => r.views.find((e) => e.id === a.query.viewId) ?? null), ie = h(() => r.views.filter((e) => e.name.toLowerCase().includes(F.value.toLowerCase())));
358
+ function X() {
359
+ if (!l.value) return;
360
+ let e = l.value.getBoundingClientRect();
361
+ S.value = {
362
+ top: `${e.bottom + 4}px`,
363
+ left: `${e.left}px`
364
+ };
365
+ }
366
+ function oe() {
367
+ if (f.value) {
368
+ f.value = !1;
369
+ return;
370
+ }
371
+ X(), f.value = !0;
372
+ }
373
+ function se() {
374
+ f.value = !1, k.value = "list", F.value = "";
375
+ }
376
+ function le(e) {
377
+ if (!e) i.replace({
378
+ path: "/",
379
+ query: {}
380
+ });
381
+ else {
382
+ let t = qe(e);
383
+ if (i.replace({
384
+ path: "/",
385
+ query: t
386
+ }), e.columns) {
387
+ let t = {};
388
+ We.forEach((n) => {
389
+ t[n] = (e.columns ?? []).includes(n);
390
+ }), o.setColumnVisibility(t);
391
+ } else o.setColumnVisibility({});
392
+ }
393
+ se();
394
+ }
395
+ function ue(e) {
396
+ Y.value = e, U.value = e.name, W.value = "", K.value = e.isPublic, k.value = "edit", C(() => d.value?.focus());
397
+ }
398
+ async function de() {
399
+ if (B.value = "", !z.value.trim()) {
400
+ B.value = "Name is required";
401
+ return;
402
+ }
403
+ H.value = !0;
404
+ let e = o.getVisibleFlatColumns().filter((e) => e.accessorFn !== void 0 && e.getCanHide()).map((e) => e.id), t = await r.onCreateView({
405
+ name: z.value.trim(),
406
+ columns: e,
407
+ filterParams: r.filterParams,
408
+ isPublic: V.value
409
+ });
410
+ if (H.value = !1, t?.status === "error") {
411
+ B.value = t.message;
412
+ return;
413
+ }
414
+ if (t?.view?.id) {
415
+ let e = {
416
+ ...a.query,
417
+ viewId: t.view.id,
418
+ page: "1"
419
+ };
420
+ i.replace({ query: e });
421
+ }
422
+ z.value = "", V.value = !1, se();
423
+ }
424
+ async function Q() {
425
+ if (W.value = "", !U.value.trim() || !Y.value) {
426
+ W.value = "Name is required";
427
+ return;
428
+ }
429
+ q.value = !0;
430
+ let e = await r.onUpdateView(Y.value.id, {
431
+ name: U.value.trim(),
432
+ columns: Y.value.columns ?? void 0,
433
+ filterParams: Y.value.filterParams ?? void 0,
434
+ isPublic: K.value
435
+ });
436
+ if (q.value = !1, e?.status === "error") {
437
+ W.value = e.message;
438
+ return;
439
+ }
440
+ k.value = "list";
441
+ }
442
+ async function me() {
443
+ Y.value && await e({
444
+ title: "Supprimer la vue",
445
+ description: `Supprimer définitivement la vue "${Y.value.name}" ?`,
446
+ confirmLabel: "Supprimer",
447
+ variant: "destructive"
448
+ }) && (J.value = !0, await r.onDeleteView(Y.value.id), J.value = !1, re.value?.id === Y.value.id && i.replace({
449
+ path: "/",
450
+ query: {}
451
+ }), k.value = "list");
452
+ }
453
+ function he(e) {
454
+ f.value && (l.value?.contains(e.target) || se());
455
+ }
456
+ function $(e) {
457
+ let t = document.activeElement?.tagName;
458
+ (e.metaKey || e.ctrlKey) && e.key === "v" && t !== "INPUT" && t !== "TEXTAREA" && (e.preventDefault(), setTimeout(() => {
459
+ X(), f.value = !0;
460
+ }, 100)), e.key === "Escape" && f.value && se();
461
+ }
462
+ return ee(() => {
463
+ document.addEventListener("mousedown", he), window.addEventListener("keydown", $), window.addEventListener("scroll", X, !0), window.addEventListener("resize", X);
464
+ }), te(() => {
465
+ document.removeEventListener("mousedown", he), window.removeEventListener("keydown", $), window.removeEventListener("scroll", X, !0), window.removeEventListener("resize", X);
466
+ }), P(f, (e) => {
467
+ e || (k.value = "list", F.value = "");
468
+ }), (e, t) => (E(), v("div", {
469
+ class: "relative",
470
+ ref_key: "rootRef",
471
+ ref: l
472
+ }, [y("button", {
473
+ type: "button",
474
+ onClick: oe,
475
+ class: "flex h-7 w-36 shrink-0 items-center justify-between rounded-md border border-input bg-background px-2.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus:outline-none",
476
+ title: `Open views (${j(c) ? "⌘" : "Ctrl"}+V)`
477
+ }, [y("span", Xe, A(re.value?.name || r.defaultLabel || "Tout"), 1), x(j(ne), { class: "ml-1 size-4 shrink-0 opacity-50" })], 8, Ye), (E(), g(m, { to: "body" }, [f.value ? (E(), v("div", {
478
+ key: 0,
479
+ style: T(S.value),
480
+ class: "fixed z-[500] w-[200px] rounded-md border bg-popover shadow-md",
481
+ onMousedown: t[11] ||= R(() => {}, ["stop"]),
482
+ onClick: t[12] ||= R(() => {}, ["stop"])
483
+ }, [k.value === "create" ? (E(), v(p, { key: 0 }, [y("div", Ze, [y("button", {
484
+ type: "button",
485
+ onClick: t[0] ||= (e) => k.value = "list",
486
+ class: "mr-2 rounded p-0.5 hover:bg-accent"
487
+ }, [x(j(G), { class: "size-4" })]), t[13] ||= y("span", { class: "text-sm font-medium" }, "New view", -1)]), y("div", Qe, [
488
+ I(y("input", {
489
+ ref_key: "createInputRef",
490
+ ref: u,
491
+ "onUpdate:modelValue": t[1] ||= (e) => z.value = e,
492
+ placeholder: "View name",
493
+ class: "w-full rounded-md border border-input bg-background px-3 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring placeholder:text-muted-foreground",
494
+ onKeyup: [L(de, ["enter"]), t[2] ||= L((e) => k.value = "list", ["escape"])]
495
+ }, null, 544), [[N, z.value]]),
496
+ y("label", $e, [I(y("input", {
497
+ type: "checkbox",
498
+ "onUpdate:modelValue": t[3] ||= (e) => V.value = e
499
+ }, null, 512), [[M, V.value]]), t[14] ||= b(" Rendre publique (visible par tous) ", -1)]),
500
+ B.value ? (E(), v("p", et, A(B.value), 1)) : _("", !0),
501
+ y("button", {
502
+ type: "button",
503
+ onClick: de,
504
+ disabled: H.value,
505
+ class: "w-full rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
506
+ }, A(H.value ? "Saving…" : "Save view"), 9, tt)
507
+ ])], 64)) : k.value === "edit" && Y.value ? (E(), v(p, { key: 1 }, [y("div", nt, [y("button", {
508
+ type: "button",
509
+ onClick: t[4] ||= (e) => k.value = "list",
510
+ class: "mr-2 rounded p-0.5 hover:bg-accent"
511
+ }, [x(j(G), { class: "size-4" })]), t[15] ||= y("span", { class: "text-sm font-medium" }, "Edit view", -1)]), y("div", rt, [
512
+ I(y("input", {
513
+ ref_key: "editInputRef",
514
+ ref: d,
515
+ "onUpdate:modelValue": t[5] ||= (e) => U.value = e,
516
+ placeholder: "View name",
517
+ class: "w-full rounded-md border border-input bg-background px-3 py-1.5 text-sm outline-none focus:ring-2 focus:ring-ring placeholder:text-muted-foreground",
518
+ onKeyup: [L(Q, ["enter"]), t[6] ||= L((e) => k.value = "list", ["escape"])]
519
+ }, null, 544), [[N, U.value]]),
520
+ y("label", it, [I(y("input", {
521
+ type: "checkbox",
522
+ "onUpdate:modelValue": t[7] ||= (e) => K.value = e
523
+ }, null, 512), [[M, K.value]]), t[16] ||= b(" Rendre publique (visible par tous) ", -1)]),
524
+ W.value ? (E(), v("p", at, A(W.value), 1)) : _("", !0),
525
+ y("div", ot, [y("button", {
526
+ type: "button",
527
+ onClick: Q,
528
+ disabled: q.value,
529
+ class: "flex-1 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
530
+ }, A(q.value ? "Saving…" : "Update"), 9, st), y("button", {
531
+ type: "button",
532
+ onClick: me,
533
+ disabled: J.value,
534
+ class: "rounded-md border border-destructive px-3 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/10 disabled:opacity-50"
535
+ }, A(J.value ? "…" : "Delete"), 9, ct)])
536
+ ])], 64)) : (E(), v(p, { key: 2 }, [
537
+ y("div", lt, [x(j(ce), { class: "mr-2 size-4 shrink-0 opacity-50" }), I(y("input", {
538
+ "onUpdate:modelValue": t[8] ||= (e) => F.value = e,
539
+ placeholder: "Search views…",
540
+ class: "h-8 w-full bg-transparent py-1 text-sm outline-none placeholder:text-muted-foreground"
541
+ }, null, 512), [[N, F.value]])]),
542
+ y("div", ut, [
543
+ y("button", {
544
+ type: "button",
545
+ class: w(["flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground", { "bg-accent text-accent-foreground": !re.value }]),
546
+ onClick: t[9] ||= (e) => le(null)
547
+ }, A(r.defaultLabel || "Tout"), 3),
548
+ (E(!0), v(p, null, O(ie.value, (e) => (E(), v("div", {
549
+ key: e.id,
550
+ class: w(["group flex w-full cursor-pointer items-center justify-between rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground", { "bg-accent text-accent-foreground": re.value?.id === e.id }]),
551
+ onClick: (t) => le(e)
552
+ }, [
553
+ y("span", ft, A(e.name), 1),
554
+ e.isPublic ? (E(), v("span", pt, "Public")) : _("", !0),
555
+ y("span", {
556
+ class: "invisible ml-auto flex size-5 shrink-0 items-center justify-center rounded p-0.5 hover:bg-neutral-200 group-hover:visible dark:hover:bg-neutral-700",
557
+ onClick: R((t) => ue(e), ["stop"])
558
+ }, [x(j(Z), { class: "size-3" })], 8, mt)
559
+ ], 10, dt))), 128)),
560
+ ie.value.length === 0 && F.value ? (E(), v("p", ht, "No view found.")) : _("", !0)
561
+ ]),
562
+ y("div", gt, [y("button", {
563
+ type: "button",
564
+ class: "flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground",
565
+ onClick: t[10] ||= (e) => {
566
+ k.value = "create", C(() => u.value?.focus());
567
+ }
568
+ }, [x(j(ae), { class: "mr-2 size-4" }), t[17] ||= b(" Add view ", -1)])])
569
+ ], 64))], 36)) : _("", !0)]))], 512));
570
+ }
571
+ }), vt = { class: "capitalize font-semibold text-foreground" }, yt = { class: "text-muted-foreground font-normal" }, bt = { class: "max-w-[100px] truncate font-semibold text-foreground" }, xt = { class: "flex items-center gap-2 border-b px-3 py-2" }, St = { class: "text-xs font-semibold capitalize text-foreground" }, Ct = {
572
+ key: 0,
573
+ class: "absolute left-0 top-full z-[700] mt-1 min-w-[140px] rounded-md border bg-popover shadow-md"
574
+ }, wt = ["onMousedown"], Tt = { class: "p-2" }, Et = {
575
+ key: 0,
576
+ class: "px-2 py-3 text-center text-xs text-muted-foreground italic"
577
+ }, Dt = ["placeholder"], Ot = { class: "relative mb-2" }, kt = { class: "max-h-44 space-y-0.5 overflow-y-auto" }, At = ["onMousedown"], jt = {
578
+ key: 0,
579
+ viewBox: "0 0 12 12",
580
+ class: "size-3 fill-none stroke-current",
581
+ "stroke-width": "2",
582
+ "stroke-linecap": "round"
583
+ }, Mt = { class: "capitalize" }, Nt = {
584
+ key: 0,
585
+ class: "py-2 text-center text-xs text-muted-foreground"
586
+ }, Pt = /* @__PURE__ */ S({
587
+ __name: "DataTableFilterItem",
588
+ props: {
589
+ option: {},
590
+ autoOpen: { type: Boolean }
591
+ },
592
+ emits: ["update", "remove"],
593
+ setup(e, { emit: t }) {
594
+ let n = e, r = t, i = D(null), a = D(null), o = D(null), s = D(!1), c = D(!1), l = D({}), u = D(""), d = [
595
+ {
596
+ label: "contains",
597
+ value: "ilike"
598
+ },
599
+ {
600
+ label: "does not contain",
601
+ value: "not ilike"
602
+ },
603
+ {
604
+ label: "equals",
605
+ value: "eq"
606
+ },
607
+ {
608
+ label: "does not equal",
609
+ value: "ne"
610
+ },
611
+ {
612
+ label: "starts with",
613
+ value: "startswith"
614
+ },
615
+ {
616
+ label: "ends with",
617
+ value: "endswith"
618
+ },
619
+ {
620
+ label: "is empty",
621
+ value: "empty"
622
+ },
623
+ {
624
+ label: "is not empty",
625
+ value: "not_empty"
626
+ }
627
+ ], f = [
628
+ {
629
+ label: "is",
630
+ value: "eq"
631
+ },
632
+ {
633
+ label: "is not",
634
+ value: "ne"
635
+ },
636
+ {
637
+ label: "is empty",
638
+ value: "empty"
639
+ },
640
+ {
641
+ label: "is not empty",
642
+ value: "not_empty"
643
+ }
644
+ ], S = h(() => n.option.options?.length ? f : d), k = D(n.option.filterOperator ?? (n.option.options?.length ? "eq" : "ilike")), M = D(n.option.filterValues?.[0] ?? ""), F = D([...n.option.filterValues ?? []]), z = h(() => S.value.find((e) => e.value === k.value)?.label ?? k.value), B = h(() => k.value === "empty" || k.value === "not_empty" ? !0 : n.option.options?.length ? F.value.length > 0 : !!M.value.trim()), V = h(() => k.value === "empty" || k.value === "not_empty" ? "" : n.option.options?.length ? F.value.join(", ") : M.value), H = h(() => (n.option.options ?? []).filter((e) => e.label.toLowerCase().includes(u.value.toLowerCase())));
645
+ function U() {
646
+ if (!i.value) return;
647
+ let e = i.value.getBoundingClientRect(), t = Math.min(e.left, window.innerWidth - 288 - 8);
648
+ l.value = {
649
+ top: `${e.bottom + 4}px`,
650
+ left: `${Math.max(4, t)}px`
651
+ };
652
+ }
653
+ function W() {
654
+ if (s.value) {
655
+ s.value = !1;
656
+ return;
657
+ }
658
+ U(), s.value = !0, C(() => a.value?.focus());
659
+ }
660
+ function G() {
661
+ s.value = !1, r("remove", n.option);
662
+ }
663
+ function K(e) {
664
+ k.value = e, c.value = !1, J(), e !== "empty" && e !== "not_empty" && C(() => a.value?.focus());
665
+ }
666
+ function q(e) {
667
+ let t = F.value.indexOf(e);
668
+ t >= 0 ? F.value.splice(t, 1) : F.value.push(e), J();
669
+ }
670
+ function J() {
671
+ let e;
672
+ e = k.value === "empty" || k.value === "not_empty" ? [] : n.option.options?.length ? [...F.value] : M.value.trim() ? [M.value.trim()] : [], r("update", {
673
+ ...n.option,
674
+ filterValues: e,
675
+ filterOperator: k.value
676
+ });
677
+ }
678
+ P(M, () => {
679
+ n.option.options?.length || J();
680
+ });
681
+ function Y(e) {
682
+ s.value && (i.value?.contains(e.target) || (s.value = !1, c.value = !1));
683
+ }
684
+ return ee(() => {
685
+ document.addEventListener("mousedown", Y), n.autoOpen && C(() => {
686
+ U(), s.value = !0, C(() => a.value?.focus());
687
+ });
688
+ }), te(() => document.removeEventListener("mousedown", Y)), P(() => n.autoOpen, (e) => {
689
+ e && !s.value && C(() => {
690
+ U(), s.value = !0, C(() => a.value?.focus());
691
+ });
692
+ }), P(() => n.option.filterValues, (e) => {
693
+ n.option.options?.length ? F.value = [...e ?? []] : M.value = e?.[0] ?? "";
694
+ }), P(() => n.option.filterOperator, (e) => {
695
+ e && (k.value = e);
696
+ }), (t, n) => (E(), v("div", {
697
+ class: "relative",
698
+ ref_key: "rootRef",
699
+ ref: i
700
+ }, [y("div", { class: w(["inline-flex h-7 cursor-pointer select-none items-center rounded-md border text-xs font-medium transition-all overflow-hidden", B.value ? "border-foreground/20 bg-foreground/5 hover:bg-foreground/10" : "border-input bg-background text-muted-foreground hover:bg-accent"]) }, [
701
+ y("span", {
702
+ class: "flex items-center gap-1 pl-2 pr-1.5 h-full",
703
+ onClick: W
704
+ }, [
705
+ e.option.value === "title" ? (E(), g(j(ue), {
706
+ key: 0,
707
+ class: "size-3 shrink-0 opacity-50"
708
+ })) : (E(), g(j(ie), {
709
+ key: 1,
710
+ class: "size-3 shrink-0 opacity-50"
711
+ })),
712
+ y("span", vt, A(e.option.label), 1),
713
+ B.value ? (E(), v(p, { key: 2 }, [y("span", yt, A(z.value), 1), y("span", bt, A(V.value), 1)], 64)) : _("", !0)
714
+ ]),
715
+ n[6] ||= y("span", { class: "mx-1 h-3.5 w-px bg-border/70" }, null, -1),
716
+ y("span", {
717
+ class: "flex h-full items-center px-1.5 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",
718
+ onClick: R(G, ["stop"])
719
+ }, [x(j(de), { class: "size-3" })])
720
+ ], 2), (E(), g(m, { to: "body" }, [s.value ? (E(), v("div", {
721
+ key: 0,
722
+ style: T(l.value),
723
+ class: "fixed z-[600] w-72 rounded-md border bg-popover shadow-xl",
724
+ onMousedown: n[4] ||= R(() => {}, ["stop"]),
725
+ onClick: n[5] ||= R(() => {}, ["stop"])
726
+ }, [y("div", xt, [y("span", St, A(e.option.label), 1), y("div", {
727
+ class: "relative ml-auto",
728
+ ref_key: "opRef",
729
+ ref: o
730
+ }, [y("button", {
731
+ type: "button",
732
+ onClick: n[0] ||= R((e) => c.value = !c.value, ["stop"]),
733
+ class: "inline-flex h-6 items-center gap-1 rounded border border-input bg-background px-2 text-xs hover:bg-accent"
734
+ }, [b(A(z.value) + " ", 1), x(j(ne), { class: "size-3 opacity-60" })]), c.value ? (E(), v("div", Ct, [(E(!0), v(p, null, O(S.value, (e) => (E(), v("div", {
735
+ key: e.value,
736
+ onMousedown: R((t) => K(e.value), ["prevent", "stop"]),
737
+ class: w(["flex cursor-pointer items-center px-3 py-1.5 text-xs hover:bg-accent", { "bg-accent font-medium": k.value === e.value }])
738
+ }, A(e.label), 43, wt))), 128))])) : _("", !0)], 512)]), y("div", Tt, [k.value === "empty" || k.value === "not_empty" ? (E(), v("p", Et, "No value needed for this operator")) : e.option.options?.length ? (E(), v(p, { key: 2 }, [y("div", Ot, [x(j(ce), { class: "absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground" }), I(y("input", {
739
+ "onUpdate:modelValue": n[3] ||= (e) => u.value = e,
740
+ placeholder: "Search…",
741
+ class: "w-full rounded-md border border-input bg-background py-1.5 pl-7 pr-3 text-xs outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-ring"
742
+ }, null, 512), [[N, u.value]])]), y("div", kt, [(E(!0), v(p, null, O(H.value, (e) => (E(), v("div", {
743
+ key: e.value,
744
+ class: "flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent",
745
+ onMousedown: R((t) => q(e.value), ["prevent", "stop"])
746
+ }, [y("div", { class: w(["flex size-4 shrink-0 items-center justify-center rounded border", F.value.includes(e.value) ? "border-primary bg-primary text-primary-foreground" : "border-input bg-background"]) }, [F.value.includes(e.value) ? (E(), v("svg", jt, [...n[7] ||= [y("polyline", { points: "1,6 4,10 11,2" }, null, -1)]])) : _("", !0)], 2), y("span", Mt, A(e.label), 1)], 40, At))), 128)), H.value.length === 0 ? (E(), v("p", Nt, "No option found")) : _("", !0)])], 64)) : I((E(), v("input", {
747
+ key: 1,
748
+ ref_key: "inputRef",
749
+ ref: a,
750
+ "onUpdate:modelValue": n[1] ||= (e) => M.value = e,
751
+ placeholder: `Type to filter ${e.option.label.toLowerCase()}…`,
752
+ class: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-ring",
753
+ onKeyup: n[2] ||= L((e) => s.value = !1, ["escape"])
754
+ }, null, 40, Dt)), [[N, M.value]])])], 36)) : _("", !0)]))], 512));
755
+ }
756
+ }), Ft = { class: "flex items-center gap-2 rounded-md border border-dashed px-2 py-1" }, It = { class: "flex flex-wrap items-center gap-1" }, Lt = { class: "capitalize" }, Rt = {
757
+ key: 0,
758
+ class: "text-muted-foreground"
759
+ }, zt = ["onClick"], Bt = ["onClick"], Vt = /* @__PURE__ */ S({
760
+ __name: "DataTableMultiFilter",
761
+ props: {
762
+ options: {},
763
+ allOptions: {},
764
+ selectedOptions: {},
765
+ operator: {}
766
+ },
767
+ emits: ["update:operator", "update:selectedOptions"],
768
+ setup(e, { emit: t }) {
769
+ let n = e, r = t, i = D(!1), a = D(null), o = D({}), s = D(n.operator || "and"), c = h(() => n.allOptions.filter((e) => !n.selectedOptions.some((t) => t.value === e.value)));
770
+ function l() {
771
+ s.value = s.value === "and" ? "or" : "and", r("update:operator", s.value);
772
+ }
773
+ function u(e) {
774
+ r("update:selectedOptions", n.selectedOptions.filter((t) => t.id !== e.id));
775
+ }
776
+ function d(e) {
777
+ let t = {
778
+ ...e,
779
+ id: e.value,
780
+ filterValues: [],
781
+ filterOperator: e.options?.length ? "eq" : "ilike",
782
+ isMulti: !0
783
+ };
784
+ r("update:selectedOptions", [...n.selectedOptions, t]), i.value = !1;
785
+ }
786
+ P(i, (e) => {
787
+ if (e && a.value) {
788
+ let e = a.value.getBoundingClientRect();
789
+ o.value = {
790
+ top: `${e.bottom + 4}px`,
791
+ left: `${e.left}px`
792
+ };
793
+ }
794
+ }), P(() => n.operator, (e) => {
795
+ s.value = e || "and";
796
+ });
797
+ function f(e) {
798
+ i.value && a.value && !a.value.contains(e.target) && (i.value = !1);
799
+ }
800
+ return ee(() => document.addEventListener("mousedown", f)), te(() => document.removeEventListener("mousedown", f)), (t, n) => (E(), v("div", Ft, [y("button", {
801
+ onClick: l,
802
+ class: "shrink-0 rounded border px-1.5 py-0.5 text-xs font-medium hover:bg-accent uppercase tracking-wide"
803
+ }, A(s.value), 1), y("div", It, [(E(!0), v(p, null, O(e.options, (e) => (E(), v("div", {
804
+ key: e.id,
805
+ class: "flex items-center gap-1 rounded-sm bg-accent px-1.5 py-0.5 text-xs"
806
+ }, [
807
+ y("span", Lt, A(e.label), 1),
808
+ e.filterValues?.length ? (E(), v("span", Rt, " : " + A(e.filterValues.join(", ")), 1)) : _("", !0),
809
+ y("button", {
810
+ onClick: (t) => u(e),
811
+ class: "ml-0.5 hover:text-destructive"
812
+ }, [x(j(de), { class: "size-3" })], 8, zt)
813
+ ]))), 128)), c.value.length ? (E(), v("div", {
814
+ key: 0,
815
+ class: "relative",
816
+ ref_key: "addRef",
817
+ ref: a
818
+ }, [y("button", {
819
+ onClick: n[0] ||= (e) => i.value = !i.value,
820
+ class: "inline-flex h-6 items-center gap-1 rounded-full border border-dashed px-2 text-xs hover:bg-accent"
821
+ }, [x(j(ae), { class: "size-3" }), n[1] ||= b(" Add ", -1)]), (E(), g(m, { to: "body" }, [i.value ? (E(), v("div", {
822
+ key: 0,
823
+ style: T(o.value),
824
+ class: "fixed z-[300] w-44 rounded-md border bg-popover p-1 shadow-md"
825
+ }, [(E(!0), v(p, null, O(c.value, (e) => (E(), v("button", {
826
+ key: e.id,
827
+ onClick: (t) => d(e),
828
+ class: "flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-accent capitalize"
829
+ }, A(e.label), 9, Bt))), 128))], 4)) : _("", !0)]))], 512)) : _("", !0)])]));
830
+ }
831
+ }), Ht = { class: "flex w-full flex-col overflow-x-auto" }, Ut = { class: "flex items-center justify-between gap-3 pb-0" }, Wt = { class: "flex items-center gap-2" }, Gt = ["onMousedown"], Kt = { class: "flex items-center gap-2" }, qt = {
832
+ key: 0,
833
+ class: "flex flex-wrap items-center gap-2 pt-3 min-h-[36px]"
834
+ }, Jt = {
835
+ key: 1,
836
+ class: "h-4 w-px bg-border/70"
837
+ }, Yt = {
838
+ key: 1,
839
+ class: "flex items-center gap-1.5 rounded-md border border-primary/30 bg-background px-2.5 py-1 shadow-sm"
840
+ }, Xt = {
841
+ key: 0,
842
+ class: "text-[10px] text-destructive"
843
+ }, Zt = { class: "flex items-center gap-1" }, Qt = ["disabled"], $t = ["disabled"], en = /* @__PURE__ */ S({
844
+ __name: "DataTableAdvancedToolbar",
845
+ props: {
846
+ filterFields: {},
847
+ views: {},
848
+ onCreateView: { type: Function },
849
+ onUpdateView: { type: Function },
850
+ onDeleteView: { type: Function },
851
+ defaultLabel: {}
852
+ },
853
+ setup(e) {
854
+ let t = e, n = pe(), r = fe(), { table: i, columnVisibility: a } = s(), o = D(!1), c = D(!1), l = D(""), u = D(""), d = D(!1), f = D(null), S = D(null), w = D(null), M = D({});
855
+ function F(e, t) {
856
+ if (!e) return;
857
+ let n = e.getBoundingClientRect();
858
+ t.value = {
859
+ top: `${n.bottom + 4}px`,
860
+ left: `${n.left}px`
861
+ };
862
+ }
863
+ function z() {
864
+ if (o.value) {
865
+ o.value = !1;
866
+ return;
867
+ }
868
+ F(S.value, M), o.value = !0;
869
+ }
870
+ function B(e) {
871
+ let t = e.target;
872
+ o.value && S.value && !S.value.contains(t) && (o.value = !1);
873
+ }
874
+ ee(() => document.addEventListener("mousedown", B)), te(() => document.removeEventListener("mousedown", B));
875
+ let V = h(() => t.filterFields.map((e) => ({
876
+ id: e.value,
877
+ label: e.label,
878
+ value: e.value,
879
+ options: e.options ?? []
880
+ })));
881
+ function ne(e) {
882
+ return V.value.filter((t) => !!e[t.value]).map((t) => {
883
+ let n = e[t.value].split("~"), r = n[0] ?? "", i = n[1] || (t.options?.length ? "eq" : "ilike"), a = n[2] === "multi", o = t.options?.length ? r.split(".").filter(Boolean) : i === "empty" || i === "not_empty" ? [] : r ? [r] : [];
884
+ return {
885
+ ...t,
886
+ filterValues: o,
887
+ filterOperator: i,
888
+ isMulti: a
889
+ };
890
+ });
891
+ }
892
+ let G = D(ne(r.query)), K = D(r.query.operator || "and"), q = h(() => G.value.filter((e) => !e.isMulti)), J = h(() => G.value.filter((e) => e.isMulti)), Y = h(() => V.value.filter((e) => !G.value.some((t) => t.value === e.value))), Z = h(() => t.views.find((e) => e.id === r.query.viewId) ?? null), ae = h(() => Ke(G.value, r.query)), ce = h(() => G.value.some((e) => e.filterOperator === "empty" || e.filterOperator === "not_empty" || e.filterValues && e.filterValues.length > 0)), le = h(() => i.getAllColumns().filter((e) => e.accessorFn !== void 0 && e.getCanHide()).filter((e) => a.value[e.id] !== !1).map((e) => e.id)), Q = h(() => {
893
+ if (!Z.value) return !1;
894
+ let e = JSON.stringify(ae.value) !== JSON.stringify(Z.value.filterParams), t = Z.value.columns, n = [...le.value].sort(), r;
895
+ return r = t === null ? Object.values(a.value).some((e) => e === !1) : JSON.stringify(n) !== JSON.stringify([...t].sort()), e || r;
896
+ }), me = h(() => Q.value && !!Z.value || ce.value && !Z.value);
897
+ function he(e, n) {
898
+ let i = { ...r.query };
899
+ t.filterFields.forEach((e) => delete i[e.value]), delete i.operator, i.page = 1;
900
+ for (let t of e) {
901
+ let e = t.filterOperator === "empty" || t.filterOperator === "not_empty", n = t.filterValues && t.filterValues.length > 0;
902
+ if (!e && !n) continue;
903
+ let r = e ? "" : t.options?.length ? t.filterValues.join(".") : t.filterValues[0] ?? "", a = t.filterOperator ? `~${t.filterOperator}` : "", o = t.isMulti ? "~multi" : "";
904
+ i[t.value] = `${r}${a}${o}`;
905
+ }
906
+ return e.length > 0 && (i.operator = n), i;
907
+ }
908
+ function $(e, t) {
909
+ n.replace({ query: he(e, t) });
910
+ }
911
+ function ge(e) {
912
+ o.value = !1, !G.value.some((t) => t.value === e.value) && (G.value = [...G.value, {
913
+ id: e.value,
914
+ label: e.label,
915
+ value: e.value,
916
+ options: e.options ?? [],
917
+ filterValues: [],
918
+ filterOperator: e.options?.length ? "eq" : "ilike",
919
+ isMulti: !1
920
+ }], f.value = null, C(() => {
921
+ f.value = e.value;
922
+ }));
923
+ }
924
+ function _e(e) {
925
+ G.value = G.value.map((t) => t.id === e.id ? e : t), f.value = null, $(G.value, K.value);
926
+ }
927
+ function ve(e) {
928
+ G.value = G.value.filter((t) => t.id !== e.id), f.value = null, $(G.value, K.value);
929
+ }
930
+ function ye(e) {
931
+ K.value = e, $(G.value, e);
932
+ }
933
+ function be(e) {
934
+ G.value = e, $(e, K.value);
935
+ }
936
+ function xe() {
937
+ if (Z.value && (n.replace({ query: qe(Z.value) }), Z.value.columns)) {
938
+ let e = {};
939
+ We.forEach((t) => {
940
+ e[t] = Z.value.columns.includes(t);
941
+ }), i.setColumnVisibility(e);
942
+ }
943
+ }
944
+ async function Se() {
945
+ if (!l.value.trim()) {
946
+ u.value = "Nom requis";
947
+ return;
948
+ }
949
+ d.value = !0;
950
+ let e = i.getVisibleFlatColumns().filter((e) => e.accessorFn !== void 0 && e.getCanHide()).map((e) => e.id), a = await t.onCreateView({
951
+ name: l.value.trim(),
952
+ columns: e,
953
+ filterParams: ae.value
954
+ });
955
+ if (d.value = !1, a?.status === "error") {
956
+ u.value = a.message;
957
+ return;
958
+ }
959
+ a?.view?.id && n.replace({ query: {
960
+ ...r.query,
961
+ viewId: a.view.id
962
+ } }), c.value = !1, l.value = "", u.value = "";
963
+ }
964
+ async function Ce() {
965
+ if (!Z.value) return;
966
+ d.value = !0;
967
+ let e = i.getVisibleFlatColumns().filter((e) => e.accessorFn !== void 0 && e.getCanHide()).map((e) => e.id);
968
+ await t.onUpdateView(Z.value.id, {
969
+ name: Z.value.name,
970
+ columns: e,
971
+ filterParams: ae.value
972
+ }), d.value = !1;
973
+ }
974
+ return P(() => t.filterFields.map((e) => r.query[e.value]).join("|") + (r.query.operator ?? ""), () => {
975
+ let e = ne(r.query);
976
+ JSON.stringify(e) !== JSON.stringify(G.value) && (G.value = e), K.value = r.query.operator || "and";
977
+ }), (t, n) => (E(), v("div", Ht, [y("div", Ut, [y("div", Wt, [x(_t, {
978
+ views: e.views,
979
+ filterParams: ae.value,
980
+ onCreateView: e.onCreateView,
981
+ onUpdateView: e.onUpdateView,
982
+ onDeleteView: e.onDeleteView,
983
+ defaultLabel: e.defaultLabel
984
+ }, null, 8, [
985
+ "views",
986
+ "filterParams",
987
+ "onCreateView",
988
+ "onUpdateView",
989
+ "onDeleteView",
990
+ "defaultLabel"
991
+ ]), Y.value.length > 0 ? (E(), v("div", {
992
+ key: 0,
993
+ class: "relative",
994
+ ref_key: "addFilterRef",
995
+ ref: S
996
+ }, [y("button", {
997
+ type: "button",
998
+ onClick: R(z, ["stop"]),
999
+ class: "inline-flex h-7 items-center gap-1.5 rounded-md border border-input bg-background px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground"
1000
+ }, [x(j(re), { class: "size-3.5" }), b(" " + A(G.value.length === 0 ? "Filtrer" : "Ajouter"), 1)]), (E(), g(m, { to: "body" }, [o.value ? (E(), v("div", {
1001
+ key: 0,
1002
+ style: T(M.value),
1003
+ class: "fixed z-[400] w-44 overflow-hidden rounded-md border bg-popover shadow-md",
1004
+ onMousedown: n[0] ||= R(() => {}, ["stop"])
1005
+ }, [n[5] ||= y("div", { class: "px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground" }, " Filtrer par ", -1), (E(!0), v(p, null, O(Y.value, (e) => (E(), v("div", {
1006
+ key: e.id,
1007
+ onMousedown: R((t) => ge(e), ["prevent", "stop"]),
1008
+ class: "flex cursor-pointer items-center gap-2 px-3 py-2 text-sm capitalize hover:bg-accent"
1009
+ }, [e.value === "title" ? (E(), g(j(ue), {
1010
+ key: 0,
1011
+ class: "size-3.5 shrink-0 text-muted-foreground"
1012
+ })) : (E(), g(j(ie), {
1013
+ key: 1,
1014
+ class: "size-3.5 shrink-0 text-muted-foreground"
1015
+ })), b(" " + A(e.label), 1)], 40, Gt))), 128))], 36)) : _("", !0)]))], 512)) : _("", !0)]), y("div", Kt, [
1016
+ k(t.$slots, "selection"),
1017
+ k(t.$slots, "default"),
1018
+ x(ze)
1019
+ ])]), G.value.length > 0 || me.value ? (E(), v("div", qt, [
1020
+ (E(!0), v(p, null, O(q.value, (e) => (E(), g(Pt, {
1021
+ key: e.id,
1022
+ option: e,
1023
+ autoOpen: e.id === f.value,
1024
+ onUpdate: _e,
1025
+ onRemove: ve
1026
+ }, null, 8, ["option", "autoOpen"]))), 128)),
1027
+ J.value.length > 0 ? (E(), g(Vt, {
1028
+ key: 0,
1029
+ options: J.value,
1030
+ allOptions: V.value,
1031
+ selectedOptions: G.value,
1032
+ operator: K.value,
1033
+ "onUpdate:operator": ye,
1034
+ "onUpdate:selectedOptions": be
1035
+ }, null, 8, [
1036
+ "options",
1037
+ "allOptions",
1038
+ "selectedOptions",
1039
+ "operator"
1040
+ ])) : _("", !0),
1041
+ me.value ? (E(), v("div", Jt)) : _("", !0),
1042
+ Q.value && Z.value ? (E(), v("button", {
1043
+ key: 2,
1044
+ type: "button",
1045
+ onClick: xe,
1046
+ class: "inline-flex h-7 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground"
1047
+ }, [x(j(oe), { class: "size-3" }), n[6] ||= b(" Reinitialiser ", -1)])) : _("", !0),
1048
+ ce.value && !Z.value ? (E(), v(p, { key: 3 }, [c.value ? (E(), v("div", Yt, [
1049
+ x(j(H), { class: "size-3.5 shrink-0 text-primary" }),
1050
+ I(y("input", {
1051
+ ref_key: "saveInputRef",
1052
+ ref: w,
1053
+ "onUpdate:modelValue": n[2] ||= (e) => l.value = e,
1054
+ placeholder: "Nom de la vue...",
1055
+ class: "w-32 bg-transparent text-xs outline-none placeholder:text-muted-foreground",
1056
+ onKeyup: [L(Se, ["enter"]), n[3] ||= L((e) => {
1057
+ c.value = !1, l.value = "";
1058
+ }, ["escape"])]
1059
+ }, null, 544), [[N, l.value]]),
1060
+ u.value ? (E(), v("p", Xt, A(u.value), 1)) : _("", !0),
1061
+ y("div", Zt, [y("button", {
1062
+ type: "button",
1063
+ onClick: Se,
1064
+ disabled: d.value,
1065
+ title: "Sauvegarder (Entree)",
1066
+ class: "flex h-5 items-center justify-center rounded bg-primary px-1.5 text-[10px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors"
1067
+ }, [d.value ? (E(), g(j(X), {
1068
+ key: 0,
1069
+ class: "size-3 animate-spin"
1070
+ })) : (E(), g(j(W), {
1071
+ key: 1,
1072
+ class: "size-3"
1073
+ }))], 8, Qt), y("button", {
1074
+ type: "button",
1075
+ onClick: n[4] ||= (e) => {
1076
+ c.value = !1, l.value = "";
1077
+ },
1078
+ title: "Annuler (Echap)",
1079
+ class: "flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors"
1080
+ }, [x(j(de), { class: "size-3" })])])
1081
+ ])) : (E(), v("button", {
1082
+ key: 0,
1083
+ type: "button",
1084
+ onClick: n[1] ||= (e) => {
1085
+ c.value = !0, t.$nextTick(() => w.value?.focus());
1086
+ },
1087
+ class: "inline-flex h-7 items-center gap-1.5 rounded-md border border-primary/30 bg-primary/5 px-2.5 text-xs font-medium text-primary transition-all hover:bg-primary/10 hover:border-primary/50"
1088
+ }, [x(j(U), { class: "size-3.5" }), n[7] ||= b(" Sauvegarder la vue ", -1)]))], 64)) : _("", !0),
1089
+ Q.value && Z.value ? (E(), v("button", {
1090
+ key: 4,
1091
+ type: "button",
1092
+ disabled: d.value,
1093
+ onClick: Ce,
1094
+ class: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors"
1095
+ }, [d.value ? (E(), g(j(X), {
1096
+ key: 0,
1097
+ class: "size-3.5 animate-spin"
1098
+ })) : (E(), g(j(se), {
1099
+ key: 1,
1100
+ class: "size-3.5"
1101
+ })), n[8] ||= b(" Mettre a jour ", -1)], 8, $t)) : _("", !0)
1102
+ ])) : _("", !0)]));
1103
+ }
1104
+ });
1105
+ //#endregion
1106
+ export { We as a, qe as c, ze as d, Fe as f, me as h, _t as i, Je as l, Se as m, Vt as n, Ge as o, De as p, Pt as r, Ke as s, en as t, Ue as u };