cisse-vue-ui 0.5.12 → 0.5.14

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.
@@ -70,20 +70,29 @@ const _hoisted_5$3 = {
70
70
  key: 0,
71
71
  class: "w-12 px-3 py-3"
72
72
  };
73
- const _hoisted_6$3 = {
73
+ const _hoisted_6$3 = ["onClick"];
74
+ const _hoisted_7$3 = {
75
+ key: 0,
76
+ d: "M7 14l5-5 5 5H7z"
77
+ };
78
+ const _hoisted_8$3 = {
79
+ key: 1,
80
+ d: "M7 10l5 5 5-5H7z"
81
+ };
82
+ const _hoisted_9$3 = {
74
83
  key: 1,
75
84
  class: "px-3 py-3 text-right"
76
85
  };
77
- const _hoisted_7$3 = { class: "divide-y divide-black/10 font-medium dark:divide-white/10" };
78
- const _hoisted_8$3 = {
86
+ const _hoisted_10$2 = { class: "divide-y divide-black/10 font-medium dark:divide-white/10" };
87
+ const _hoisted_11$1 = {
79
88
  key: 0,
80
89
  class: "px-3 py-4"
81
90
  };
82
- const _hoisted_9$3 = {
91
+ const _hoisted_12$1 = {
83
92
  key: 1,
84
93
  class: "flex items-center justify-end gap-2 px-3 py-4"
85
94
  };
86
- const _hoisted_10$2 = { key: 0 };
95
+ const _hoisted_13 = { key: 0 };
87
96
  const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
88
97
  __name: "TableComponent",
89
98
  props: {
@@ -92,9 +101,11 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
92
101
  selectable: { type: Boolean, default: false },
93
102
  selectedItems: {},
94
103
  selectableFilter: {},
95
- keyField: { default: "id" }
104
+ keyField: { default: "id" },
105
+ sortBy: {},
106
+ sortDirection: {}
96
107
  },
97
- emits: ["select", "selectAll"],
108
+ emits: ["select", "selectAll", "sort"],
98
109
  setup(__props, { emit: __emit }) {
99
110
  const slots = vue.useSlots();
100
111
  const props = __props;
@@ -172,6 +183,14 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
172
183
  emit("select", getKey(item));
173
184
  };
174
185
  const hasActionSlot = vue.computed(() => !!slots.action);
186
+ const handleSort = (property) => {
187
+ if (!property.sortable) return;
188
+ const newDirection = props.sortBy === property.name && props.sortDirection === "asc" ? "desc" : "asc";
189
+ emit("sort", property.name, newDirection);
190
+ };
191
+ const isSortedColumn = (property) => {
192
+ return props.sortBy === property.name;
193
+ };
175
194
  return (_ctx, _cache) => {
176
195
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
177
196
  vue.createElementVNode("div", _hoisted_2$8, [
@@ -189,23 +208,55 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
189
208
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(visibleProperties.value, (property) => {
190
209
  return vue.openBlock(), vue.createElementBlock("th", {
191
210
  key: property.name,
192
- class: vue.normalizeClass([getAlignmentClass(property.align), "px-3 py-3"])
211
+ class: vue.normalizeClass([
212
+ getAlignmentClass(property.align),
213
+ "px-3 py-3",
214
+ property.sortable ? "cursor-pointer select-none hover:bg-black/5 dark:hover:bg-white/5" : ""
215
+ ]),
216
+ onClick: ($event) => handleSort(property)
193
217
  }, [
194
- vue.renderSlot(_ctx.$slots, "header-" + property.name, { property }, () => [
195
- vue.createTextVNode(vue.toDisplayString(property.label ?? property.name), 1)
196
- ])
197
- ], 2);
218
+ vue.createElementVNode("div", {
219
+ class: vue.normalizeClass(["flex items-center gap-1", {
220
+ "justify-center": property.align === "center",
221
+ "justify-end": property.align === "right"
222
+ }])
223
+ }, [
224
+ vue.renderSlot(_ctx.$slots, "header-" + property.name, { property }, () => [
225
+ vue.createTextVNode(vue.toDisplayString(property.label ?? property.name), 1)
226
+ ]),
227
+ property.sortable ? (vue.openBlock(), vue.createElementBlock("svg", {
228
+ key: 0,
229
+ class: vue.normalizeClass([
230
+ "w-4 h-4 transition-colors",
231
+ isSortedColumn(property) ? "text-primary-500" : "text-gray-400"
232
+ ]),
233
+ viewBox: "0 0 24 24",
234
+ fill: "currentColor"
235
+ }, [
236
+ isSortedColumn(property) && __props.sortDirection === "asc" ? (vue.openBlock(), vue.createElementBlock("path", _hoisted_7$3)) : isSortedColumn(property) && __props.sortDirection === "desc" ? (vue.openBlock(), vue.createElementBlock("path", _hoisted_8$3)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
237
+ _cache[1] || (_cache[1] = vue.createElementVNode("path", {
238
+ d: "M7 14l5-5 5 5H7z",
239
+ class: "opacity-40"
240
+ }, null, -1)),
241
+ _cache[2] || (_cache[2] = vue.createElementVNode("path", {
242
+ d: "M7 10l5 5 5-5H7z",
243
+ class: "opacity-40"
244
+ }, null, -1))
245
+ ], 64))
246
+ ], 2)) : vue.createCommentVNode("", true)
247
+ ], 2)
248
+ ], 10, _hoisted_6$3);
198
249
  }), 128)),
199
- hasActionSlot.value ? (vue.openBlock(), vue.createElementBlock("th", _hoisted_6$3)) : vue.createCommentVNode("", true)
250
+ hasActionSlot.value ? (vue.openBlock(), vue.createElementBlock("th", _hoisted_9$3)) : vue.createCommentVNode("", true)
200
251
  ])
201
252
  ]),
202
- vue.createElementVNode("tbody", _hoisted_7$3, [
253
+ vue.createElementVNode("tbody", _hoisted_10$2, [
203
254
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.items, (item) => {
204
255
  return vue.openBlock(), vue.createElementBlock("tr", {
205
256
  key: getKey(item),
206
257
  class: vue.normalizeClass(["hover:bg-black/5 dark:hover:bg-white/5 transition-colors", { "bg-primary/5 dark:bg-primary/10": isSelected(item) }])
207
258
  }, [
208
- __props.selectable ? (vue.openBlock(), vue.createElementBlock("td", _hoisted_8$3, [
259
+ __props.selectable ? (vue.openBlock(), vue.createElementBlock("td", _hoisted_11$1, [
209
260
  isSelectable(item) ? (vue.openBlock(), vue.createBlock(Checkbox_vue_vue_type_script_setup_true_lang._sfc_main, {
210
261
  key: 0,
211
262
  "model-value": isSelected(item),
@@ -233,7 +284,7 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
233
284
  ])
234
285
  ], 2);
235
286
  }), 128)),
236
- hasActionSlot.value ? (vue.openBlock(), vue.createElementBlock("td", _hoisted_9$3, [
287
+ hasActionSlot.value ? (vue.openBlock(), vue.createElementBlock("td", _hoisted_12$1, [
237
288
  vue.renderSlot(_ctx.$slots, "action", { item })
238
289
  ])) : vue.createCommentVNode("", true)
239
290
  ], 2);
@@ -241,7 +292,7 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
241
292
  ])
242
293
  ])
243
294
  ]),
244
- !__props.items || __props.items.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_10$2, [
295
+ !__props.items || __props.items.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_13, [
245
296
  vue.renderSlot(_ctx.$slots, "empty")
246
297
  ])) : vue.createCommentVNode("", true)
247
298
  ]);
@@ -574,9 +625,11 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
574
625
  selectable: { type: Boolean, default: false },
575
626
  selectedItems: {},
576
627
  selectableFilter: {},
577
- breakpoint: { default: "lg" }
628
+ breakpoint: { default: "lg" },
629
+ sortBy: {},
630
+ sortDirection: {}
578
631
  },
579
- emits: ["select", "selectAll"],
632
+ emits: ["select", "selectAll", "sort"],
580
633
  setup(__props, { emit: __emit }) {
581
634
  const props = __props;
582
635
  const emit = __emit;
@@ -654,8 +707,11 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
654
707
  selectable: __props.selectable,
655
708
  "selected-items": __props.selectedItems,
656
709
  "selectable-filter": __props.selectableFilter,
710
+ "sort-by": __props.sortBy,
711
+ "sort-direction": __props.sortDirection,
657
712
  onSelect: _cache[2] || (_cache[2] = ($event) => emit("select", $event)),
658
- onSelectAll: _cache[3] || (_cache[3] = ($event) => emit("selectAll"))
713
+ onSelectAll: _cache[3] || (_cache[3] = ($event) => emit("selectAll")),
714
+ onSort: _cache[4] || (_cache[4] = (col, dir) => emit("sort", col, dir))
659
715
  }, vue.createSlots({
660
716
  empty: vue.withCtx(() => [
661
717
  vue.renderSlot(_ctx.$slots, "empty")
@@ -683,7 +739,7 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
683
739
  ]),
684
740
  key: "0"
685
741
  } : void 0
686
- ]), 1032, ["items", "properties", "key-field", "selectable", "selected-items", "selectable-filter"])
742
+ ]), 1032, ["items", "properties", "key-field", "selectable", "selected-items", "selectable-filter", "sort-by", "sort-direction"])
687
743
  ]),
688
744
  _: 3
689
745
  }))
@@ -2082,4 +2138,4 @@ exports._sfc_main$6 = _sfc_main$c;
2082
2138
  exports._sfc_main$7 = _sfc_main$b;
2083
2139
  exports._sfc_main$8 = _sfc_main$a;
2084
2140
  exports._sfc_main$9 = _sfc_main$9;
2085
- //# sourceMappingURL=Timeline.vue_vue_type_script_setup_true_lang-5MnyzOrB.cjs.map
2141
+ //# sourceMappingURL=Timeline.vue_vue_type_script_setup_true_lang-CqeiZOID.cjs.map