@bagelink/vue 1.0.41 → 1.0.43
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.
- package/dist/components/DataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/DataTable/useTableData.d.ts +1 -0
- package/dist/components/DataTable/useTableData.d.ts.map +1 -1
- package/dist/components/form/FieldArray.vue.d.ts.map +1 -1
- package/dist/index.cjs +77 -50
- package/dist/index.mjs +77 -50
- package/dist/style.css +47 -47
- package/package.json +1 -1
- package/src/components/DataTable/DataTable.vue +7 -3
- package/src/components/DataTable/useTableData.ts +66 -36
- package/src/components/form/FieldArray.vue +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.vue.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/DataTable.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DataTable.vue.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/DataTable.vue"],"names":[],"mappings":"AA+dA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAY/D,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,CAAA;AAC5C,MAAM,MAAM,UAAU,GAAG,GAAG,MAAM,IAAI,eAAe,EAAE,CAAA;yBAEtC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,eAChC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WAiV1D,mBAAmB,CAAC;;;;;;;;;;wBA7NV,MAAM,EAAE;0CA6NoE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;;UApD0E,GAAG;UAsDjF,2TAAoC;OAG/B,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA3VzE,wBA2V4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
|
@@ -22,6 +22,7 @@ export declare function useTableData<T extends Record<string, any>>(options: Use
|
|
|
22
22
|
sortDirection: ComputedRef<SortDirectionsT>;
|
|
23
23
|
toggleSort: (fieldname: string) => void;
|
|
24
24
|
cleanTransformedData: <T_1 extends Record<string, any>>(data: TransformedData<T_1>) => T_1;
|
|
25
|
+
schemaState: ComputedRef<"error" | "loading" | "loaded">;
|
|
25
26
|
};
|
|
26
27
|
export {};
|
|
27
28
|
//# sourceMappingURL=useTableData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableData.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/useTableData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAahF,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACrC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACnF,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,MAAM,EAAE,CAAA;IACtD,aAAa,CAAC,EAAE,WAAW,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,OAAO,GAAG,SAAS,CAAA;IACtE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,KAAK,IAAI,CAAA;CAC5D;AAED,UAAU,mBAAmB;IAC5B,CAAC,GAAG,EAAE,gBAAgB,MAAM,EAAE,GAAG,GAAG,CAAA;IACpC,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAA;IACjC,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,OAAO,CAAA;IAChC,CAAC,GAAG,EAAE,aAAa,MAAM,EAAE,GAAG,GAAG,CAAA;CACjC;AAED,KAAK,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAA;AAEjD,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;;;
|
|
1
|
+
{"version":3,"file":"useTableData.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/useTableData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAahF,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACrC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACnF,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,MAAM,EAAE,CAAA;IACtD,aAAa,CAAC,EAAE,WAAW,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,OAAO,GAAG,SAAS,CAAA;IACtE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,KAAK,IAAI,CAAA;CAC5D;AAED,UAAU,mBAAmB;IAC5B,CAAC,GAAG,EAAE,gBAAgB,MAAM,EAAE,GAAG,GAAG,CAAA;IACpC,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAA;IACjC,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,OAAO,CAAA;IAChC,CAAC,GAAG,EAAE,aAAa,MAAM,EAAE,GAAG,GAAG,CAAA;CACjC;AAED,KAAK,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAA;AAEjD,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;;;yBA6F9D,CAAC,KAAG,eAAe,CAAC,CAAC,CAAC;;;4BA2FnB,MAAM;uCAzDG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,eAAe,CAAC,GAAC,CAAC,KAAG,GAAC;;EAiFzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldArray.vue.d.ts","sourceRoot":"","sources":["../../../src/components/form/FieldArray.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldArray.vue.d.ts","sourceRoot":"","sources":["../../../src/components/form/FieldArray.vue"],"names":[],"mappings":"AAgOA,OAAO,KAAK,EACX,WAAW,EACX,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,MAAM,eAAe,CAAA;yBAIL,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,eAChC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WAoV1D,mBAAmB,CAAC;;;aAjVrB,GAAG;YACJ,MAAM;gBACF,MAAM;sBACA,MAAM;mBACT,KAAK,CAAC,CAAC,CAAC,EAAE;gBACb,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC;gBAC/B,UAAU,CAAC,CAAC,CAAC;mBACV,OAAO;mBACP,OAAO;mBACP,MAAM;kBACP,iBAAiB,CAAC,CAAC,CAAC;uBACf,GAAG;cACZ,OAAO;iBACJ,OAAO;oBACJ,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC;gBACnB,gBAAgB;oBACZ,CAAC,EAAE;mBAiU6E,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;OAKC,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA9VzE,wBA8V4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1628,7 +1628,7 @@ const _hoisted_10$7 = {
|
|
|
1628
1628
|
key: 4,
|
|
1629
1629
|
class: "event-flyout__row is-topic"
|
|
1630
1630
|
};
|
|
1631
|
-
const _hoisted_11$
|
|
1631
|
+
const _hoisted_11$7 = {
|
|
1632
1632
|
key: 5,
|
|
1633
1633
|
class: "event-flyout__row is-description"
|
|
1634
1634
|
};
|
|
@@ -1855,7 +1855,7 @@ const _sfc_main$1c = /* @__PURE__ */ vue.defineComponent({
|
|
|
1855
1855
|
}, null, 8, ["icon"]),
|
|
1856
1856
|
vue.createTextVNode(" " + vue.toDisplayString(calendarEvent.value.topic), 1)
|
|
1857
1857
|
])) : vue.createCommentVNode("", true),
|
|
1858
|
-
calendarEvent.value.description ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_11$
|
|
1858
|
+
calendarEvent.value.description ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_11$7, [
|
|
1859
1859
|
vue.createVNode(vue.unref(_sfc_main$s), {
|
|
1860
1860
|
icon: icons.description
|
|
1861
1861
|
}, null, 8, ["icon"]),
|
|
@@ -10688,6 +10688,8 @@ const SRC_VALUE_COMPONENTS = /* @__PURE__ */ new Set(["img", "iframe"]);
|
|
|
10688
10688
|
function useTableData(options) {
|
|
10689
10689
|
const sortField = vue.ref("");
|
|
10690
10690
|
const sortDirection = vue.ref("ASC");
|
|
10691
|
+
const schemaState = vue.ref("loading");
|
|
10692
|
+
const resolvedSchema = vue.ref([]);
|
|
10691
10693
|
function getValue(value) {
|
|
10692
10694
|
if (value === void 0 || value === null) {
|
|
10693
10695
|
return void 0;
|
|
@@ -10702,31 +10704,50 @@ function useTableData(options) {
|
|
|
10702
10704
|
return void 0;
|
|
10703
10705
|
}
|
|
10704
10706
|
}
|
|
10705
|
-
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
id
|
|
10719
|
-
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10707
|
+
async function resolveSchemaAsync() {
|
|
10708
|
+
try {
|
|
10709
|
+
schemaState.value = "loading";
|
|
10710
|
+
const dataValue = options.data.value || [];
|
|
10711
|
+
const schema = await useBglSchema({
|
|
10712
|
+
schema: getValue(options.schema),
|
|
10713
|
+
columns: getValue(options.columns),
|
|
10714
|
+
data: dataValue
|
|
10715
|
+
});
|
|
10716
|
+
if (Array.isArray(schema) && schema.length > 0) {
|
|
10717
|
+
resolvedSchema.value = schema.filter((field) => field && field.id);
|
|
10718
|
+
} else if (Array.isArray(dataValue) && dataValue.length > 0) {
|
|
10719
|
+
const firstItem = dataValue[0];
|
|
10720
|
+
resolvedSchema.value = Object.keys(firstItem || {}).filter((key) => key !== "id" && !key.startsWith("_")).map((key) => ({
|
|
10721
|
+
id: key,
|
|
10722
|
+
label: keyToLabel(key),
|
|
10723
|
+
$el: "div",
|
|
10724
|
+
transform: (val) => {
|
|
10725
|
+
const dateFields = ["created_at", "updated_at"];
|
|
10726
|
+
if (dateFields.includes(key)) return val ? new Date(val).toLocaleString() : val;
|
|
10727
|
+
return val;
|
|
10728
|
+
}
|
|
10729
|
+
}));
|
|
10730
|
+
} else {
|
|
10731
|
+
resolvedSchema.value = [];
|
|
10732
|
+
}
|
|
10733
|
+
schemaState.value = "loaded";
|
|
10734
|
+
} catch (error) {
|
|
10735
|
+
console.error("Error resolving schema:", error);
|
|
10736
|
+
schemaState.value = "error";
|
|
10737
|
+
resolvedSchema.value = [];
|
|
10727
10738
|
}
|
|
10728
|
-
|
|
10739
|
+
}
|
|
10740
|
+
vue.watch([
|
|
10741
|
+
() => getValue(options.schema),
|
|
10742
|
+
() => getValue(options.columns),
|
|
10743
|
+
() => options.data.value
|
|
10744
|
+
], () => {
|
|
10745
|
+
resolveSchemaAsync();
|
|
10746
|
+
}, { immediate: true });
|
|
10747
|
+
vue.onMounted(() => {
|
|
10748
|
+
resolveSchemaAsync();
|
|
10729
10749
|
});
|
|
10750
|
+
const computedSchema = vue.computed(() => resolvedSchema.value);
|
|
10730
10751
|
function transform(rowData) {
|
|
10731
10752
|
const transformed = { ...rowData };
|
|
10732
10753
|
const schemaFields = computedSchema.value.filter((f2) => f2.id);
|
|
@@ -10808,7 +10829,8 @@ function useTableData(options) {
|
|
|
10808
10829
|
sortField: vue.computed(() => sortField.value),
|
|
10809
10830
|
sortDirection: vue.computed(() => sortDirection.value),
|
|
10810
10831
|
toggleSort,
|
|
10811
|
-
cleanTransformedData
|
|
10832
|
+
cleanTransformedData,
|
|
10833
|
+
schemaState: vue.computed(() => schemaState.value)
|
|
10812
10834
|
};
|
|
10813
10835
|
}
|
|
10814
10836
|
const _hoisted_1$P = { class: "data-preview" };
|
|
@@ -11512,15 +11534,19 @@ const _hoisted_1$O = {
|
|
|
11512
11534
|
key: 0,
|
|
11513
11535
|
class: "loading-table-wrapper z-99 h-100 w-100 absolute inset"
|
|
11514
11536
|
};
|
|
11515
|
-
const _hoisted_2$A = {
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
const
|
|
11520
|
-
const
|
|
11521
|
-
const
|
|
11522
|
-
const
|
|
11523
|
-
const
|
|
11537
|
+
const _hoisted_2$A = {
|
|
11538
|
+
key: 1,
|
|
11539
|
+
class: "flex-center h-300px txt-red"
|
|
11540
|
+
};
|
|
11541
|
+
const _hoisted_3$u = { class: "infinite-wrapper" };
|
|
11542
|
+
const _hoisted_4$k = { class: "row first-row" };
|
|
11543
|
+
const _hoisted_5$j = { key: 0 };
|
|
11544
|
+
const _hoisted_6$g = ["onClick"];
|
|
11545
|
+
const _hoisted_7$c = { class: "flex" };
|
|
11546
|
+
const _hoisted_8$7 = ["onClick"];
|
|
11547
|
+
const _hoisted_9$6 = { key: 0 };
|
|
11548
|
+
const _hoisted_10$6 = ["value"];
|
|
11549
|
+
const _hoisted_11$6 = { key: 1 };
|
|
11524
11550
|
const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
11525
11551
|
__name: "DataTable",
|
|
11526
11552
|
props: /* @__PURE__ */ vue.mergeModels({
|
|
@@ -11541,7 +11567,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
|
11541
11567
|
emits: /* @__PURE__ */ vue.mergeModels(["orderBy", "select", "lastItemVisible"], ["update:loading", "update:itemHeight", "update:selectedItems"]),
|
|
11542
11568
|
setup(__props, { emit: __emit }) {
|
|
11543
11569
|
vue.useCssVars((_ctx) => ({
|
|
11544
|
-
"
|
|
11570
|
+
"03db8ce0": vue.unref(computedItemHeight)
|
|
11545
11571
|
}));
|
|
11546
11572
|
const props2 = __props;
|
|
11547
11573
|
const emit2 = __emit;
|
|
@@ -11559,7 +11585,8 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
|
11559
11585
|
sortField,
|
|
11560
11586
|
sortDirection,
|
|
11561
11587
|
toggleSort,
|
|
11562
|
-
cleanTransformedData
|
|
11588
|
+
cleanTransformedData,
|
|
11589
|
+
schemaState
|
|
11563
11590
|
} = useTableData({ data: data2, schema, columns, useServerSort, onSort: (field, direction) => {
|
|
11564
11591
|
emit2("orderBy", `${field} ${direction}`.trim());
|
|
11565
11592
|
} });
|
|
@@ -11630,14 +11657,14 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
|
11630
11657
|
);
|
|
11631
11658
|
return (_ctx, _cache) => {
|
|
11632
11659
|
return vue.openBlock(), vue.createElementBlock("div", vue.mergeProps({ class: "table-list-wrap h-100" }, vue.unref(containerProps), {
|
|
11633
|
-
class: { "loading-table": loading.value }
|
|
11660
|
+
class: { "loading-table": loading.value || vue.unref(schemaState) === "loading" }
|
|
11634
11661
|
}), [
|
|
11635
|
-
loading.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$O, _cache[4] || (_cache[4] = [
|
|
11662
|
+
loading.value || vue.unref(schemaState) === "loading" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$O, _cache[4] || (_cache[4] = [
|
|
11636
11663
|
vue.createElementVNode("div", { class: "loading-table-animation absolute oval" }, null, -1)
|
|
11637
|
-
]))) : (vue.openBlock(), vue.createElementBlock("div", vue.normalizeProps(vue.mergeProps({ key:
|
|
11638
|
-
vue.createElementVNode("table",
|
|
11639
|
-
vue.createElementVNode("thead",
|
|
11640
|
-
vue.unref(isSelectable) ? (vue.openBlock(), vue.createElementBlock("th",
|
|
11664
|
+
]))) : vue.unref(schemaState) === "error" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$A, " Error loading table schema ")) : (vue.openBlock(), vue.createElementBlock("div", vue.normalizeProps(vue.mergeProps({ key: 2 }, vue.unref(wrapperProps))), [
|
|
11665
|
+
vue.createElementVNode("table", _hoisted_3$u, [
|
|
11666
|
+
vue.createElementVNode("thead", _hoisted_4$k, [
|
|
11667
|
+
vue.unref(isSelectable) ? (vue.openBlock(), vue.createElementBlock("th", _hoisted_5$j, [
|
|
11641
11668
|
vue.createElementVNode("input", {
|
|
11642
11669
|
ref_key: "allSelectorEl",
|
|
11643
11670
|
ref: allSelectorEl,
|
|
@@ -11654,7 +11681,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
|
11654
11681
|
class: "col",
|
|
11655
11682
|
onClick: ($event) => vue.unref(toggleSort)((field == null ? void 0 : field.id) || "")
|
|
11656
11683
|
}, [
|
|
11657
|
-
vue.createElementVNode("div",
|
|
11684
|
+
vue.createElementVNode("div", _hoisted_7$c, [
|
|
11658
11685
|
vue.createTextVNode(vue.toDisplayString(field.label || vue.unref(keyToLabel)(field == null ? void 0 : field.id)) + " ", 1),
|
|
11659
11686
|
vue.createElementVNode("div", {
|
|
11660
11687
|
class: vue.normalizeClass(["list-arrows", { sorted: vue.unref(sortField) === (field == null ? void 0 : field.id) }])
|
|
@@ -11665,7 +11692,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
|
11665
11692
|
}, null, 8, ["class"])
|
|
11666
11693
|
], 2)
|
|
11667
11694
|
])
|
|
11668
|
-
], 8,
|
|
11695
|
+
], 8, _hoisted_6$g);
|
|
11669
11696
|
}), 128))
|
|
11670
11697
|
]),
|
|
11671
11698
|
vue.createElementVNode("tbody", null, [
|
|
@@ -11675,7 +11702,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
|
11675
11702
|
class: vue.normalizeClass(["row row-item position-relative", { selected: (row == null ? void 0 : row.id) && vue.unref(computedSelectedItems).includes(row.id) }]),
|
|
11676
11703
|
onClick: ($event) => vue.unref(toggleSelectItem)(row)
|
|
11677
11704
|
}, [
|
|
11678
|
-
vue.unref(isSelectable) ? (vue.openBlock(), vue.createElementBlock("td",
|
|
11705
|
+
vue.unref(isSelectable) ? (vue.openBlock(), vue.createElementBlock("td", _hoisted_9$6, [
|
|
11679
11706
|
vue.createElementVNode("div", {
|
|
11680
11707
|
onClick: _cache[3] || (_cache[3] = vue.withModifiers(() => {
|
|
11681
11708
|
}, ["stop"]))
|
|
@@ -11684,7 +11711,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
|
11684
11711
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => selectedItems.value = $event),
|
|
11685
11712
|
type: "checkbox",
|
|
11686
11713
|
value: (row == null ? void 0 : row.id) || ""
|
|
11687
|
-
}, null, 8,
|
|
11714
|
+
}, null, 8, _hoisted_10$6), [
|
|
11688
11715
|
[vue.vModelCheckbox, selectedItems.value]
|
|
11689
11716
|
])
|
|
11690
11717
|
])
|
|
@@ -11698,12 +11725,12 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
|
11698
11725
|
key: 0,
|
|
11699
11726
|
row,
|
|
11700
11727
|
field
|
|
11701
|
-
}, void 0, true) : (vue.openBlock(), vue.createElementBlock("div",
|
|
11728
|
+
}, void 0, true) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_11$6, [
|
|
11702
11729
|
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(renderFieldForRow(field, row))))
|
|
11703
11730
|
]))
|
|
11704
11731
|
]);
|
|
11705
11732
|
}), 128))
|
|
11706
|
-
], 10,
|
|
11733
|
+
], 10, _hoisted_8$7);
|
|
11707
11734
|
}), 128)),
|
|
11708
11735
|
props2.onLastItemVisible !== void 0 ? (vue.openBlock(), vue.createElementBlock("tr", {
|
|
11709
11736
|
key: 0,
|
|
@@ -11718,7 +11745,7 @@ const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
|
|
|
11718
11745
|
};
|
|
11719
11746
|
}
|
|
11720
11747
|
});
|
|
11721
|
-
const DataTable = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["__scopeId", "data-v-
|
|
11748
|
+
const DataTable = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["__scopeId", "data-v-30ec790f"]]);
|
|
11722
11749
|
function useDraggable(options = {}) {
|
|
11723
11750
|
const isDragging = vue.ref(false);
|
|
11724
11751
|
const dragElement = vue.ref(null);
|
package/dist/index.mjs
CHANGED
|
@@ -1626,7 +1626,7 @@ const _hoisted_10$7 = {
|
|
|
1626
1626
|
key: 4,
|
|
1627
1627
|
class: "event-flyout__row is-topic"
|
|
1628
1628
|
};
|
|
1629
|
-
const _hoisted_11$
|
|
1629
|
+
const _hoisted_11$7 = {
|
|
1630
1630
|
key: 5,
|
|
1631
1631
|
class: "event-flyout__row is-description"
|
|
1632
1632
|
};
|
|
@@ -1853,7 +1853,7 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
|
|
|
1853
1853
|
}, null, 8, ["icon"]),
|
|
1854
1854
|
createTextVNode(" " + toDisplayString(calendarEvent.value.topic), 1)
|
|
1855
1855
|
])) : createCommentVNode("", true),
|
|
1856
|
-
calendarEvent.value.description ? (openBlock(), createElementBlock("div", _hoisted_11$
|
|
1856
|
+
calendarEvent.value.description ? (openBlock(), createElementBlock("div", _hoisted_11$7, [
|
|
1857
1857
|
createVNode(unref(_sfc_main$s), {
|
|
1858
1858
|
icon: icons.description
|
|
1859
1859
|
}, null, 8, ["icon"]),
|
|
@@ -10686,6 +10686,8 @@ const SRC_VALUE_COMPONENTS = /* @__PURE__ */ new Set(["img", "iframe"]);
|
|
|
10686
10686
|
function useTableData(options) {
|
|
10687
10687
|
const sortField = ref("");
|
|
10688
10688
|
const sortDirection = ref("ASC");
|
|
10689
|
+
const schemaState = ref("loading");
|
|
10690
|
+
const resolvedSchema = ref([]);
|
|
10689
10691
|
function getValue(value) {
|
|
10690
10692
|
if (value === void 0 || value === null) {
|
|
10691
10693
|
return void 0;
|
|
@@ -10700,31 +10702,50 @@ function useTableData(options) {
|
|
|
10700
10702
|
return void 0;
|
|
10701
10703
|
}
|
|
10702
10704
|
}
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
id
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10705
|
+
async function resolveSchemaAsync() {
|
|
10706
|
+
try {
|
|
10707
|
+
schemaState.value = "loading";
|
|
10708
|
+
const dataValue = options.data.value || [];
|
|
10709
|
+
const schema = await useBglSchema({
|
|
10710
|
+
schema: getValue(options.schema),
|
|
10711
|
+
columns: getValue(options.columns),
|
|
10712
|
+
data: dataValue
|
|
10713
|
+
});
|
|
10714
|
+
if (Array.isArray(schema) && schema.length > 0) {
|
|
10715
|
+
resolvedSchema.value = schema.filter((field) => field && field.id);
|
|
10716
|
+
} else if (Array.isArray(dataValue) && dataValue.length > 0) {
|
|
10717
|
+
const firstItem = dataValue[0];
|
|
10718
|
+
resolvedSchema.value = Object.keys(firstItem || {}).filter((key) => key !== "id" && !key.startsWith("_")).map((key) => ({
|
|
10719
|
+
id: key,
|
|
10720
|
+
label: keyToLabel(key),
|
|
10721
|
+
$el: "div",
|
|
10722
|
+
transform: (val) => {
|
|
10723
|
+
const dateFields = ["created_at", "updated_at"];
|
|
10724
|
+
if (dateFields.includes(key)) return val ? new Date(val).toLocaleString() : val;
|
|
10725
|
+
return val;
|
|
10726
|
+
}
|
|
10727
|
+
}));
|
|
10728
|
+
} else {
|
|
10729
|
+
resolvedSchema.value = [];
|
|
10730
|
+
}
|
|
10731
|
+
schemaState.value = "loaded";
|
|
10732
|
+
} catch (error) {
|
|
10733
|
+
console.error("Error resolving schema:", error);
|
|
10734
|
+
schemaState.value = "error";
|
|
10735
|
+
resolvedSchema.value = [];
|
|
10725
10736
|
}
|
|
10726
|
-
|
|
10737
|
+
}
|
|
10738
|
+
watch([
|
|
10739
|
+
() => getValue(options.schema),
|
|
10740
|
+
() => getValue(options.columns),
|
|
10741
|
+
() => options.data.value
|
|
10742
|
+
], () => {
|
|
10743
|
+
resolveSchemaAsync();
|
|
10744
|
+
}, { immediate: true });
|
|
10745
|
+
onMounted(() => {
|
|
10746
|
+
resolveSchemaAsync();
|
|
10727
10747
|
});
|
|
10748
|
+
const computedSchema = computed(() => resolvedSchema.value);
|
|
10728
10749
|
function transform(rowData) {
|
|
10729
10750
|
const transformed = { ...rowData };
|
|
10730
10751
|
const schemaFields = computedSchema.value.filter((f2) => f2.id);
|
|
@@ -10806,7 +10827,8 @@ function useTableData(options) {
|
|
|
10806
10827
|
sortField: computed(() => sortField.value),
|
|
10807
10828
|
sortDirection: computed(() => sortDirection.value),
|
|
10808
10829
|
toggleSort,
|
|
10809
|
-
cleanTransformedData
|
|
10830
|
+
cleanTransformedData,
|
|
10831
|
+
schemaState: computed(() => schemaState.value)
|
|
10810
10832
|
};
|
|
10811
10833
|
}
|
|
10812
10834
|
const _hoisted_1$P = { class: "data-preview" };
|
|
@@ -11510,15 +11532,19 @@ const _hoisted_1$O = {
|
|
|
11510
11532
|
key: 0,
|
|
11511
11533
|
class: "loading-table-wrapper z-99 h-100 w-100 absolute inset"
|
|
11512
11534
|
};
|
|
11513
|
-
const _hoisted_2$A = {
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
const
|
|
11518
|
-
const
|
|
11519
|
-
const
|
|
11520
|
-
const
|
|
11521
|
-
const
|
|
11535
|
+
const _hoisted_2$A = {
|
|
11536
|
+
key: 1,
|
|
11537
|
+
class: "flex-center h-300px txt-red"
|
|
11538
|
+
};
|
|
11539
|
+
const _hoisted_3$u = { class: "infinite-wrapper" };
|
|
11540
|
+
const _hoisted_4$k = { class: "row first-row" };
|
|
11541
|
+
const _hoisted_5$j = { key: 0 };
|
|
11542
|
+
const _hoisted_6$g = ["onClick"];
|
|
11543
|
+
const _hoisted_7$c = { class: "flex" };
|
|
11544
|
+
const _hoisted_8$7 = ["onClick"];
|
|
11545
|
+
const _hoisted_9$6 = { key: 0 };
|
|
11546
|
+
const _hoisted_10$6 = ["value"];
|
|
11547
|
+
const _hoisted_11$6 = { key: 1 };
|
|
11522
11548
|
const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
11523
11549
|
__name: "DataTable",
|
|
11524
11550
|
props: /* @__PURE__ */ mergeModels({
|
|
@@ -11539,7 +11565,7 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
11539
11565
|
emits: /* @__PURE__ */ mergeModels(["orderBy", "select", "lastItemVisible"], ["update:loading", "update:itemHeight", "update:selectedItems"]),
|
|
11540
11566
|
setup(__props, { emit: __emit }) {
|
|
11541
11567
|
useCssVars((_ctx) => ({
|
|
11542
|
-
"
|
|
11568
|
+
"03db8ce0": unref(computedItemHeight)
|
|
11543
11569
|
}));
|
|
11544
11570
|
const props2 = __props;
|
|
11545
11571
|
const emit2 = __emit;
|
|
@@ -11557,7 +11583,8 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
11557
11583
|
sortField,
|
|
11558
11584
|
sortDirection,
|
|
11559
11585
|
toggleSort,
|
|
11560
|
-
cleanTransformedData
|
|
11586
|
+
cleanTransformedData,
|
|
11587
|
+
schemaState
|
|
11561
11588
|
} = useTableData({ data: data2, schema, columns, useServerSort, onSort: (field, direction) => {
|
|
11562
11589
|
emit2("orderBy", `${field} ${direction}`.trim());
|
|
11563
11590
|
} });
|
|
@@ -11628,14 +11655,14 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
11628
11655
|
);
|
|
11629
11656
|
return (_ctx, _cache) => {
|
|
11630
11657
|
return openBlock(), createElementBlock("div", mergeProps({ class: "table-list-wrap h-100" }, unref(containerProps), {
|
|
11631
|
-
class: { "loading-table": loading.value }
|
|
11658
|
+
class: { "loading-table": loading.value || unref(schemaState) === "loading" }
|
|
11632
11659
|
}), [
|
|
11633
|
-
loading.value ? (openBlock(), createElementBlock("div", _hoisted_1$O, _cache[4] || (_cache[4] = [
|
|
11660
|
+
loading.value || unref(schemaState) === "loading" ? (openBlock(), createElementBlock("div", _hoisted_1$O, _cache[4] || (_cache[4] = [
|
|
11634
11661
|
createElementVNode("div", { class: "loading-table-animation absolute oval" }, null, -1)
|
|
11635
|
-
]))) : (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key:
|
|
11636
|
-
createElementVNode("table",
|
|
11637
|
-
createElementVNode("thead",
|
|
11638
|
-
unref(isSelectable) ? (openBlock(), createElementBlock("th",
|
|
11662
|
+
]))) : unref(schemaState) === "error" ? (openBlock(), createElementBlock("div", _hoisted_2$A, " Error loading table schema ")) : (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 2 }, unref(wrapperProps))), [
|
|
11663
|
+
createElementVNode("table", _hoisted_3$u, [
|
|
11664
|
+
createElementVNode("thead", _hoisted_4$k, [
|
|
11665
|
+
unref(isSelectable) ? (openBlock(), createElementBlock("th", _hoisted_5$j, [
|
|
11639
11666
|
createElementVNode("input", {
|
|
11640
11667
|
ref_key: "allSelectorEl",
|
|
11641
11668
|
ref: allSelectorEl,
|
|
@@ -11652,7 +11679,7 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
11652
11679
|
class: "col",
|
|
11653
11680
|
onClick: ($event) => unref(toggleSort)((field == null ? void 0 : field.id) || "")
|
|
11654
11681
|
}, [
|
|
11655
|
-
createElementVNode("div",
|
|
11682
|
+
createElementVNode("div", _hoisted_7$c, [
|
|
11656
11683
|
createTextVNode(toDisplayString(field.label || unref(keyToLabel)(field == null ? void 0 : field.id)) + " ", 1),
|
|
11657
11684
|
createElementVNode("div", {
|
|
11658
11685
|
class: normalizeClass(["list-arrows", { sorted: unref(sortField) === (field == null ? void 0 : field.id) }])
|
|
@@ -11663,7 +11690,7 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
11663
11690
|
}, null, 8, ["class"])
|
|
11664
11691
|
], 2)
|
|
11665
11692
|
])
|
|
11666
|
-
], 8,
|
|
11693
|
+
], 8, _hoisted_6$g);
|
|
11667
11694
|
}), 128))
|
|
11668
11695
|
]),
|
|
11669
11696
|
createElementVNode("tbody", null, [
|
|
@@ -11673,7 +11700,7 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
11673
11700
|
class: normalizeClass(["row row-item position-relative", { selected: (row == null ? void 0 : row.id) && unref(computedSelectedItems).includes(row.id) }]),
|
|
11674
11701
|
onClick: ($event) => unref(toggleSelectItem)(row)
|
|
11675
11702
|
}, [
|
|
11676
|
-
unref(isSelectable) ? (openBlock(), createElementBlock("td",
|
|
11703
|
+
unref(isSelectable) ? (openBlock(), createElementBlock("td", _hoisted_9$6, [
|
|
11677
11704
|
createElementVNode("div", {
|
|
11678
11705
|
onClick: _cache[3] || (_cache[3] = withModifiers(() => {
|
|
11679
11706
|
}, ["stop"]))
|
|
@@ -11682,7 +11709,7 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
11682
11709
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => selectedItems.value = $event),
|
|
11683
11710
|
type: "checkbox",
|
|
11684
11711
|
value: (row == null ? void 0 : row.id) || ""
|
|
11685
|
-
}, null, 8,
|
|
11712
|
+
}, null, 8, _hoisted_10$6), [
|
|
11686
11713
|
[vModelCheckbox, selectedItems.value]
|
|
11687
11714
|
])
|
|
11688
11715
|
])
|
|
@@ -11696,12 +11723,12 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
11696
11723
|
key: 0,
|
|
11697
11724
|
row,
|
|
11698
11725
|
field
|
|
11699
|
-
}, void 0, true) : (openBlock(), createElementBlock("div",
|
|
11726
|
+
}, void 0, true) : (openBlock(), createElementBlock("div", _hoisted_11$6, [
|
|
11700
11727
|
(openBlock(), createBlock(resolveDynamicComponent(renderFieldForRow(field, row))))
|
|
11701
11728
|
]))
|
|
11702
11729
|
]);
|
|
11703
11730
|
}), 128))
|
|
11704
|
-
], 10,
|
|
11731
|
+
], 10, _hoisted_8$7);
|
|
11705
11732
|
}), 128)),
|
|
11706
11733
|
props2.onLastItemVisible !== void 0 ? (openBlock(), createElementBlock("tr", {
|
|
11707
11734
|
key: 0,
|
|
@@ -11716,7 +11743,7 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
11716
11743
|
};
|
|
11717
11744
|
}
|
|
11718
11745
|
});
|
|
11719
|
-
const DataTable = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["__scopeId", "data-v-
|
|
11746
|
+
const DataTable = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["__scopeId", "data-v-30ec790f"]]);
|
|
11720
11747
|
function useDraggable(options = {}) {
|
|
11721
11748
|
const isDragging = ref(false);
|
|
11722
11749
|
const dragElement = ref(null);
|
package/dist/style.css
CHANGED
|
@@ -1021,22 +1021,22 @@ display: block;
|
|
|
1021
1021
|
text-align: center;
|
|
1022
1022
|
}
|
|
1023
1023
|
|
|
1024
|
-
.table-list-wrap[data-v-
|
|
1024
|
+
.table-list-wrap[data-v-30ec790f] {
|
|
1025
1025
|
min-height: 150px;
|
|
1026
1026
|
}
|
|
1027
|
-
.selected[data-v-
|
|
1027
|
+
.selected[data-v-30ec790f] {
|
|
1028
1028
|
background: var(--bgl-primary-tint);
|
|
1029
1029
|
}
|
|
1030
|
-
tbody tr.selected[data-v-
|
|
1030
|
+
tbody tr.selected[data-v-30ec790f]:hover {
|
|
1031
1031
|
background: var(--bgl-primary-light);
|
|
1032
1032
|
}
|
|
1033
|
-
.loading-table[data-v-
|
|
1033
|
+
.loading-table[data-v-30ec790f] {
|
|
1034
1034
|
position: relative;
|
|
1035
1035
|
}
|
|
1036
|
-
.inset[data-v-
|
|
1036
|
+
.inset[data-v-30ec790f] {
|
|
1037
1037
|
inset: 0;
|
|
1038
1038
|
}
|
|
1039
|
-
.loading-table-animation[data-v-
|
|
1039
|
+
.loading-table-animation[data-v-30ec790f] {
|
|
1040
1040
|
--size: 60px;
|
|
1041
1041
|
top: 30vh;
|
|
1042
1042
|
inset-inline-start: calc(50% - var(--size));
|
|
@@ -1044,9 +1044,9 @@ tbody tr.selected[data-v-43f28baa]:hover {
|
|
|
1044
1044
|
border-top: 4px solid var(--bgl-primary);
|
|
1045
1045
|
width: var(--size);
|
|
1046
1046
|
height: var(--size);
|
|
1047
|
-
animation: loading-table-
|
|
1047
|
+
animation: loading-table-30ec790f 1s linear infinite;
|
|
1048
1048
|
}
|
|
1049
|
-
@keyframes loading-table-
|
|
1049
|
+
@keyframes loading-table-30ec790f {
|
|
1050
1050
|
0% {
|
|
1051
1051
|
transform: translate(-50%, -50%) rotate(0deg);
|
|
1052
1052
|
}
|
|
@@ -1054,55 +1054,55 @@ tbody tr.selected[data-v-43f28baa]:hover {
|
|
|
1054
1054
|
transform: translate(-50%, -50%) rotate(360deg);
|
|
1055
1055
|
}
|
|
1056
1056
|
}
|
|
1057
|
-
.list-arrows[data-v-
|
|
1057
|
+
.list-arrows[data-v-30ec790f] {
|
|
1058
1058
|
opacity: 0;
|
|
1059
1059
|
}
|
|
1060
|
-
.list-arrows .bgl_icon-font[data-v-
|
|
1060
|
+
.list-arrows .bgl_icon-font[data-v-30ec790f] {
|
|
1061
1061
|
transition: all ease-in-out 0.2s;
|
|
1062
1062
|
}
|
|
1063
|
-
.list-arrows.sorted[data-v-
|
|
1063
|
+
.list-arrows.sorted[data-v-30ec790f] {
|
|
1064
1064
|
opacity: 1;
|
|
1065
1065
|
}
|
|
1066
|
-
.col img[data-v-
|
|
1066
|
+
.col img[data-v-30ec790f] {
|
|
1067
1067
|
height: 35px;
|
|
1068
1068
|
margin-top: -14px;
|
|
1069
1069
|
margin-bottom: -14px;
|
|
1070
1070
|
border-radius: 5px;
|
|
1071
1071
|
object-fit: cover;
|
|
1072
1072
|
}
|
|
1073
|
-
.col[data-v-
|
|
1073
|
+
.col[data-v-30ec790f]:has(img) {
|
|
1074
1074
|
padding-inline-end: 0.5rem;
|
|
1075
1075
|
}
|
|
1076
|
-
.list-arrows.sorted .desc[data-v-
|
|
1076
|
+
.list-arrows.sorted .desc[data-v-30ec790f] {
|
|
1077
1077
|
transform: rotate(180deg);
|
|
1078
1078
|
display: inline-block;
|
|
1079
1079
|
}
|
|
1080
|
-
table[data-v-
|
|
1080
|
+
table[data-v-30ec790f] {
|
|
1081
1081
|
border-spacing: 0 15px;
|
|
1082
1082
|
border-collapse: collapse;
|
|
1083
1083
|
width: 100%;
|
|
1084
1084
|
}
|
|
1085
|
-
th[data-v-
|
|
1085
|
+
th[data-v-30ec790f] {
|
|
1086
1086
|
font-size: 0.8rem;
|
|
1087
1087
|
color: var(--bgl-black-tint);
|
|
1088
1088
|
position: sticky;
|
|
1089
1089
|
top: 0;
|
|
1090
1090
|
z-index: 2;
|
|
1091
1091
|
background: var(--bgl-box-bg);
|
|
1092
|
-
height: var(--
|
|
1092
|
+
height: var(--03db8ce0);
|
|
1093
1093
|
vertical-align: bottom;
|
|
1094
1094
|
font-weight: 400;
|
|
1095
1095
|
text-align: start;
|
|
1096
1096
|
}
|
|
1097
|
-
.embedded-field[data-v-
|
|
1097
|
+
.embedded-field[data-v-30ec790f] {
|
|
1098
1098
|
margin-bottom: -0.2rem;
|
|
1099
1099
|
margin-top: -0.2rem;
|
|
1100
1100
|
}
|
|
1101
|
-
.row[data-v-
|
|
1101
|
+
.row[data-v-30ec790f] {
|
|
1102
1102
|
border-bottom: 1px solid var(--border-color);
|
|
1103
1103
|
cursor: pointer;
|
|
1104
1104
|
}
|
|
1105
|
-
.row.first-row[data-v-
|
|
1105
|
+
.row.first-row[data-v-30ec790f] {
|
|
1106
1106
|
font-size: 0.8rem;
|
|
1107
1107
|
color: var(--bgl-black-tint);
|
|
1108
1108
|
position: sticky;
|
|
@@ -1111,7 +1111,7 @@ th[data-v-43f28baa] {
|
|
|
1111
1111
|
background: var(--bgl-box-bg);
|
|
1112
1112
|
vertical-align: bottom;
|
|
1113
1113
|
}
|
|
1114
|
-
.row.first-row[data-v-
|
|
1114
|
+
.row.first-row[data-v-30ec790f]::after {
|
|
1115
1115
|
content: '';
|
|
1116
1116
|
border-bottom: 1px solid var(--border-color);
|
|
1117
1117
|
position: absolute;
|
|
@@ -1119,11 +1119,11 @@ th[data-v-43f28baa] {
|
|
|
1119
1119
|
right: 0;
|
|
1120
1120
|
bottom: -1px;
|
|
1121
1121
|
}
|
|
1122
|
-
.first-row .col[data-v-
|
|
1122
|
+
.first-row .col[data-v-30ec790f] {
|
|
1123
1123
|
cursor: pointer;
|
|
1124
1124
|
background: var(--bgl-box-bg);
|
|
1125
1125
|
}
|
|
1126
|
-
.col[data-v-
|
|
1126
|
+
.col[data-v-30ec790f] {
|
|
1127
1127
|
white-space: nowrap;
|
|
1128
1128
|
padding: 0.75rem 1rem;
|
|
1129
1129
|
transition: var(--bgl-transition);
|
|
@@ -1133,19 +1133,19 @@ th[data-v-43f28baa] {
|
|
|
1133
1133
|
overflow: hidden;
|
|
1134
1134
|
max-width: 30vw;
|
|
1135
1135
|
}
|
|
1136
|
-
.col[data-v-
|
|
1136
|
+
.col[data-v-30ec790f]:has(.bagel-input) {
|
|
1137
1137
|
padding: 0rem 0.25rem;
|
|
1138
1138
|
}
|
|
1139
|
-
.col > div[data-v-
|
|
1139
|
+
.col > div[data-v-30ec790f] {
|
|
1140
1140
|
display: flex;
|
|
1141
1141
|
gap: 0.5rem;
|
|
1142
1142
|
}
|
|
1143
|
-
.max-col-width[data-v-
|
|
1143
|
+
.max-col-width[data-v-30ec790f] {
|
|
1144
1144
|
max-width: 30vw;
|
|
1145
1145
|
overflow: hidden;
|
|
1146
1146
|
text-overflow: ellipsis;
|
|
1147
1147
|
}
|
|
1148
|
-
.col.check .bgl_icon-font[data-v-
|
|
1148
|
+
.col.check .bgl_icon-font[data-v-30ec790f] {
|
|
1149
1149
|
border-radius: 100%;
|
|
1150
1150
|
background: var(--bgl-blue-20);
|
|
1151
1151
|
color: var(--bgl-primary);
|
|
@@ -1156,35 +1156,35 @@ th[data-v-43f28baa] {
|
|
|
1156
1156
|
justify-content: center;
|
|
1157
1157
|
margin-top: -2px;
|
|
1158
1158
|
}
|
|
1159
|
-
.rows[data-v-
|
|
1159
|
+
.rows[data-v-30ec790f] {
|
|
1160
1160
|
font-size: 0.88em;
|
|
1161
1161
|
}
|
|
1162
|
-
.table-list[data-v-
|
|
1162
|
+
.table-list[data-v-30ec790f] {
|
|
1163
1163
|
height: 100%;
|
|
1164
1164
|
position: relative;
|
|
1165
1165
|
padding-left: 0 !important;
|
|
1166
1166
|
padding-right: 0 !important;
|
|
1167
1167
|
overflow: auto;
|
|
1168
1168
|
}
|
|
1169
|
-
.BagelTable .table-list[data-v-
|
|
1169
|
+
.BagelTable .table-list[data-v-30ec790f] {
|
|
1170
1170
|
overflow: unset;
|
|
1171
1171
|
}
|
|
1172
|
-
.row-item[data-v-
|
|
1173
|
-
height: var(--
|
|
1172
|
+
.row-item[data-v-30ec790f] {
|
|
1173
|
+
height: var(--03db8ce0);
|
|
1174
1174
|
transition: all 200ms ease;
|
|
1175
1175
|
}
|
|
1176
|
-
.row-item[data-v-
|
|
1176
|
+
.row-item[data-v-30ec790f]:hover {
|
|
1177
1177
|
background: var(--bgl-gray-light);
|
|
1178
1178
|
}
|
|
1179
|
-
.row-item input[type='checkbox'][data-v-
|
|
1179
|
+
.row-item input[type='checkbox'][data-v-30ec790f] {
|
|
1180
1180
|
margin-top: 0.45rem !important;
|
|
1181
1181
|
accent-color: var(--bgl-accent-color);
|
|
1182
1182
|
}
|
|
1183
|
-
.infinite-wrapper[data-v-
|
|
1183
|
+
.infinite-wrapper[data-v-30ec790f] {
|
|
1184
1184
|
overflow-y: auto;
|
|
1185
1185
|
width: 100%;
|
|
1186
1186
|
}
|
|
1187
|
-
input[type='checkbox'][data-v-
|
|
1187
|
+
input[type='checkbox'][data-v-30ec790f] {
|
|
1188
1188
|
margin-top: 0.3rem !important;
|
|
1189
1189
|
accent-color: var(--bgl-accent-color);
|
|
1190
1190
|
transform: scale(1.2);
|
|
@@ -1196,7 +1196,7 @@ input[type='checkbox'][data-v-43f28baa] {
|
|
|
1196
1196
|
height: 0.85rem;
|
|
1197
1197
|
width: 0.85rem;
|
|
1198
1198
|
}
|
|
1199
|
-
input[type='checkbox'][data-v-
|
|
1199
|
+
input[type='checkbox'][data-v-30ec790f]::before {
|
|
1200
1200
|
content: '';
|
|
1201
1201
|
height: 0.85rem;
|
|
1202
1202
|
width: 0.85rem;
|
|
@@ -1209,18 +1209,18 @@ input[type='checkbox'][data-v-43f28baa]::before {
|
|
|
1209
1209
|
transform: scale(1);
|
|
1210
1210
|
position: absolute;
|
|
1211
1211
|
}
|
|
1212
|
-
input[type='checkbox'][data-v-
|
|
1212
|
+
input[type='checkbox'][data-v-30ec790f]:hover::before {
|
|
1213
1213
|
opacity: 0.2;
|
|
1214
1214
|
transform: scale(2);
|
|
1215
1215
|
}
|
|
1216
|
-
[lang='he'] [dir='ltr'][data-v-
|
|
1216
|
+
[lang='he'] [dir='ltr'][data-v-30ec790f] {
|
|
1217
1217
|
text-align: right;
|
|
1218
1218
|
}
|
|
1219
|
-
th input[type='checkbox'][data-v-
|
|
1219
|
+
th input[type='checkbox'][data-v-30ec790f] {
|
|
1220
1220
|
transform: translateY(0.2rem) scale(1.2);
|
|
1221
1221
|
accent-color: var(--bgl-accent-color);
|
|
1222
1222
|
}
|
|
1223
|
-
th[data-v-
|
|
1223
|
+
th[data-v-30ec790f]::after {
|
|
1224
1224
|
content: '';
|
|
1225
1225
|
border-bottom: 1px solid var(--border-color);
|
|
1226
1226
|
position: absolute;
|
|
@@ -1228,24 +1228,24 @@ th[data-v-43f28baa]::after {
|
|
|
1228
1228
|
right: 0;
|
|
1229
1229
|
bottom: -1px;
|
|
1230
1230
|
}
|
|
1231
|
-
tr[data-v-
|
|
1231
|
+
tr[data-v-30ec790f] {
|
|
1232
1232
|
border-bottom: 1px solid var(--border-color);
|
|
1233
1233
|
cursor: pointer;
|
|
1234
1234
|
align-items: center;
|
|
1235
1235
|
}
|
|
1236
|
-
td[data-v-
|
|
1237
|
-
th[data-v-
|
|
1236
|
+
td[data-v-30ec790f],
|
|
1237
|
+
th[data-v-30ec790f] {
|
|
1238
1238
|
white-space: nowrap;
|
|
1239
1239
|
padding: 0.75rem 0.65rem;
|
|
1240
1240
|
transition: var(--bgl-transition);
|
|
1241
1241
|
line-height: 1;
|
|
1242
1242
|
}
|
|
1243
|
-
tbody tr[data-v-
|
|
1243
|
+
tbody tr[data-v-30ec790f] {
|
|
1244
1244
|
font-size: 0.88em;
|
|
1245
|
-
height: var(--
|
|
1245
|
+
height: var(--03db8ce0);
|
|
1246
1246
|
transition: all 200ms ease;
|
|
1247
1247
|
}
|
|
1248
|
-
tbody tr[data-v-
|
|
1248
|
+
tbody tr[data-v-30ec790f]:hover {
|
|
1249
1249
|
background: var(--bgl-gray-light);
|
|
1250
1250
|
}
|
|
1251
1251
|
|
package/package.json
CHANGED
|
@@ -41,7 +41,8 @@ const {
|
|
|
41
41
|
sortField,
|
|
42
42
|
sortDirection,
|
|
43
43
|
toggleSort,
|
|
44
|
-
cleanTransformedData
|
|
44
|
+
cleanTransformedData,
|
|
45
|
+
schemaState
|
|
45
46
|
} = useTableData<T>({ data, schema, columns, useServerSort, onSort: (field, direction) => {
|
|
46
47
|
emit('orderBy', `${field} ${direction}`.trim() as EmitOrderT)
|
|
47
48
|
} })
|
|
@@ -118,14 +119,17 @@ watch(
|
|
|
118
119
|
<div
|
|
119
120
|
class="table-list-wrap h-100"
|
|
120
121
|
v-bind="containerProps"
|
|
121
|
-
:class="{ 'loading-table': loading }"
|
|
122
|
+
:class="{ 'loading-table': loading || schemaState === 'loading' }"
|
|
122
123
|
>
|
|
123
124
|
<div
|
|
124
|
-
v-if="loading"
|
|
125
|
+
v-if="loading || schemaState === 'loading'"
|
|
125
126
|
class="loading-table-wrapper z-99 h-100 w-100 absolute inset"
|
|
126
127
|
>
|
|
127
128
|
<div class="loading-table-animation absolute oval" />
|
|
128
129
|
</div>
|
|
130
|
+
<div v-else-if="schemaState === 'error'" class="flex-center h-300px txt-red">
|
|
131
|
+
Error loading table schema
|
|
132
|
+
</div>
|
|
129
133
|
<div v-else v-bind="wrapperProps">
|
|
130
134
|
<table class="infinite-wrapper">
|
|
131
135
|
<thead class="row first-row">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComputedRef } from 'vue'
|
|
2
2
|
import type { TableDataOptions, SortDirectionsT } from '../../types/TableSchema'
|
|
3
3
|
import { useBglSchema, isDate, keyToLabel } from '@bagelink/vue'
|
|
4
|
-
import { computed, ref } from 'vue'
|
|
4
|
+
import { computed, ref, onMounted, watch } from 'vue'
|
|
5
5
|
|
|
6
6
|
const NON_DIGIT_REGEX = /[^\d.-]/g
|
|
7
7
|
|
|
@@ -33,6 +33,10 @@ export function useTableData<T extends Record<string, any>>(options: UseTableDat
|
|
|
33
33
|
// Sorting state
|
|
34
34
|
const sortField = ref('')
|
|
35
35
|
const sortDirection = ref<SortDirectionsT>('ASC')
|
|
36
|
+
// Schema loading state
|
|
37
|
+
const schemaState = ref<'loading' | 'loaded' | 'error'>('loading')
|
|
38
|
+
const resolvedSchema = ref<any[]>([])
|
|
39
|
+
|
|
36
40
|
// Helper function to get the value from a possibly computed ref
|
|
37
41
|
function getValue<V>(value: ComputedRef<V> | V | undefined): V | undefined {
|
|
38
42
|
if (value === undefined || value === null) {
|
|
@@ -52,47 +56,72 @@ export function useTableData<T extends Record<string, any>>(options: UseTableDat
|
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
// Function to resolve schema asynchronously
|
|
60
|
+
async function resolveSchemaAsync() {
|
|
61
|
+
try {
|
|
62
|
+
schemaState.value = 'loading'
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
schema: getValue(options.schema),
|
|
63
|
-
columns: getValue(options.columns),
|
|
64
|
-
data: dataValue,
|
|
65
|
-
})
|
|
64
|
+
// Get the data safely
|
|
65
|
+
const dataValue = options.data.value || []
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
// Get the schema from useBglSchema (now async)
|
|
68
|
+
const schema = await useBglSchema<T>({
|
|
69
|
+
schema: getValue(options.schema),
|
|
70
|
+
columns: getValue(options.columns),
|
|
71
|
+
data: dataValue,
|
|
72
|
+
})
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
// If we have a valid schema with fields, filter out fields without an ID
|
|
75
|
+
if (Array.isArray(schema) && schema.length > 0) {
|
|
76
|
+
resolvedSchema.value = schema.filter(field => field && field.id)
|
|
77
|
+
} else if (Array.isArray(dataValue) && dataValue.length > 0) {
|
|
78
|
+
// If no schema is provided or it's empty, generate a default schema from the data
|
|
79
|
+
const firstItem = dataValue[0]
|
|
80
|
+
|
|
81
|
+
// Create a schema based on the keys of the first item
|
|
82
|
+
resolvedSchema.value = Object.keys(firstItem || {})
|
|
83
|
+
.filter(key => key !== 'id' && !key.startsWith('_')) // Exclude id and internal fields
|
|
84
|
+
.map(key => ({
|
|
85
|
+
id: key,
|
|
86
|
+
label: keyToLabel(key),
|
|
87
|
+
$el: 'div',
|
|
88
|
+
transform: (val?: any) => {
|
|
89
|
+
// Handle date fields
|
|
90
|
+
const dateFields = ['created_at', 'updated_at']
|
|
91
|
+
if (dateFields.includes(key)) return val ? new Date(val).toLocaleString() : val
|
|
92
|
+
return val
|
|
93
|
+
}
|
|
94
|
+
}))
|
|
95
|
+
} else {
|
|
96
|
+
// Return an empty array if no data or schema
|
|
97
|
+
resolvedSchema.value = []
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
schemaState.value = 'loaded'
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('Error resolving schema:', error)
|
|
103
|
+
schemaState.value = 'error'
|
|
104
|
+
resolvedSchema.value = []
|
|
90
105
|
}
|
|
106
|
+
}
|
|
91
107
|
|
|
92
|
-
|
|
93
|
-
|
|
108
|
+
// Watch for changes in schema or columns and resolve schema
|
|
109
|
+
watch([
|
|
110
|
+
() => getValue(options.schema),
|
|
111
|
+
() => getValue(options.columns),
|
|
112
|
+
() => options.data.value
|
|
113
|
+
], () => {
|
|
114
|
+
resolveSchemaAsync()
|
|
115
|
+
}, { immediate: true })
|
|
116
|
+
|
|
117
|
+
// Initialize schema on mount
|
|
118
|
+
onMounted(() => {
|
|
119
|
+
resolveSchemaAsync()
|
|
94
120
|
})
|
|
95
121
|
|
|
122
|
+
// Create a computed property for the schema
|
|
123
|
+
const computedSchema = computed(() => resolvedSchema.value)
|
|
124
|
+
|
|
96
125
|
function transform(rowData: T): TransformedData<T> {
|
|
97
126
|
const transformed = { ...rowData } as TransformedData<T>
|
|
98
127
|
const schemaFields = computedSchema.value.filter((f: any) => f.id)
|
|
@@ -205,6 +234,7 @@ export function useTableData<T extends Record<string, any>>(options: UseTableDat
|
|
|
205
234
|
sortField: computed(() => sortField.value),
|
|
206
235
|
sortDirection: computed(() => sortDirection.value),
|
|
207
236
|
toggleSort,
|
|
208
|
-
cleanTransformedData
|
|
237
|
+
cleanTransformedData,
|
|
238
|
+
schemaState: computed(() => schemaState.value)
|
|
209
239
|
}
|
|
210
240
|
}
|