@bagelink/vue 0.0.560 → 0.0.564
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/TableSchema.vue.d.ts.map +1 -1
- package/dist/index.cjs +13 -7
- package/dist/index.mjs +13 -7
- package/dist/style.css +25 -25
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/TableSchema.vue +15 -4
- package/src/utils/index.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableSchema.vue.d.ts","sourceRoot":"","sources":["../../src/components/TableSchema.vue"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"TableSchema.vue.d.ts","sourceRoot":"","sources":["../../src/components/TableSchema.vue"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,cAAc,EAInB,MAAM,eAAe,CAAA;AAkItB,iBAAS,cAAc;;;MA6O+D,GAAG,GAIxF;AAyBD,QAAA,MAAM,eAAe;oBAMJ,MAAM,EAAE;UAClB,GAAG,EAAE;aACF,cAAc,GAAG,CAAC,MAAM,cAAc,CAAC;iBACnC,MAAM,EAAE;;;;;;oBAHL,MAAM,EAAE;UAClB,GAAG,EAAE;aACF,cAAc,GAAG,CAAC,MAAM,cAAc,CAAC;iBACnC,MAAM,EAAE;;;;;UAGpB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAAvG,wBAAwG;AACxG,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAO;QAClD,MAAM,EAAE,CAAC,CAAC;KACT,CAAA;CAAE,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -2568,7 +2568,7 @@ const isPlainObject$1 = (val) => {
|
|
|
2568
2568
|
const prototype2 = getPrototypeOf(val);
|
|
2569
2569
|
return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
|
2570
2570
|
};
|
|
2571
|
-
const isDate$
|
|
2571
|
+
const isDate$2 = kindOfTest("Date");
|
|
2572
2572
|
const isFile = kindOfTest("File");
|
|
2573
2573
|
const isBlob = kindOfTest("Blob");
|
|
2574
2574
|
const isFileList = kindOfTest("FileList");
|
|
@@ -2843,7 +2843,7 @@ const utils$1 = {
|
|
|
2843
2843
|
isResponse,
|
|
2844
2844
|
isHeaders,
|
|
2845
2845
|
isUndefined,
|
|
2846
|
-
isDate: isDate$
|
|
2846
|
+
isDate: isDate$2,
|
|
2847
2847
|
isFile,
|
|
2848
2848
|
isBlob,
|
|
2849
2849
|
isRegExp: isRegExp$1,
|
|
@@ -5285,6 +5285,7 @@ function iffer(field, itemData) {
|
|
|
5285
5285
|
return true;
|
|
5286
5286
|
}
|
|
5287
5287
|
const denullify = (itemData, fieldID) => fieldID && itemData ? itemData[fieldID] : null;
|
|
5288
|
+
const isDate$1 = (dateToTest) => !Number.isNaN(Date.parse(dateToTest));
|
|
5288
5289
|
const bagelInjectionKey = Symbol("bagel");
|
|
5289
5290
|
const i18nTInjectionKey = Symbol("bagel");
|
|
5290
5291
|
function useBagel() {
|
|
@@ -6068,10 +6069,14 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
|
|
|
6068
6069
|
const dta = [...props2.data].map(transform);
|
|
6069
6070
|
if (sortField.value) {
|
|
6070
6071
|
return dta.sort((a2, b2) => {
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6072
|
+
let aValue = a2[computedSortField.value] ?? a2[sortField.value] ?? "";
|
|
6073
|
+
let bValue = b2[computedSortField.value] ?? b2[sortField.value] ?? "";
|
|
6074
|
+
if (isDate$1(aValue) && isDate$1(bValue)) {
|
|
6075
|
+
aValue = new Date(aValue).getTime();
|
|
6076
|
+
bValue = new Date(bValue).getTime();
|
|
6077
|
+
}
|
|
6078
|
+
const numAValue = Number.parseInt(`${aValue}`.replace(/[^\d.-]/g, ""), 10);
|
|
6079
|
+
const numBValue = Number.parseInt(`${bValue}`.replace(/[^\d.-]/g, ""), 10);
|
|
6075
6080
|
if (!Number.isNaN(numAValue) && !Number.isNaN(numBValue)) {
|
|
6076
6081
|
if (sortDirection.value === "ASC") return numAValue - numBValue;
|
|
6077
6082
|
return numBValue - numAValue;
|
|
@@ -6157,7 +6162,7 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
|
|
|
6157
6162
|
};
|
|
6158
6163
|
}
|
|
6159
6164
|
});
|
|
6160
|
-
const TableSchema = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-
|
|
6165
|
+
const TableSchema = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-1628cf1a"]]);
|
|
6161
6166
|
const _sfc_main$E = {};
|
|
6162
6167
|
const _hoisted_1$B = { class: "flex space-between" };
|
|
6163
6168
|
function _sfc_render$1(_ctx, _cache) {
|
|
@@ -62912,6 +62917,7 @@ exports.formatString = formatString;
|
|
|
62912
62917
|
exports.i18nTInjectionKey = i18nTInjectionKey;
|
|
62913
62918
|
exports.iffer = iffer;
|
|
62914
62919
|
exports.initials = initials;
|
|
62920
|
+
exports.isDate = isDate$1;
|
|
62915
62921
|
exports.keyToLabel = keyToLabel;
|
|
62916
62922
|
exports.useBagel = useBagel;
|
|
62917
62923
|
exports.useEscape = useEscape;
|
package/dist/index.mjs
CHANGED
|
@@ -2566,7 +2566,7 @@ const isPlainObject$1 = (val) => {
|
|
|
2566
2566
|
const prototype2 = getPrototypeOf(val);
|
|
2567
2567
|
return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
|
2568
2568
|
};
|
|
2569
|
-
const isDate$
|
|
2569
|
+
const isDate$2 = kindOfTest("Date");
|
|
2570
2570
|
const isFile = kindOfTest("File");
|
|
2571
2571
|
const isBlob = kindOfTest("Blob");
|
|
2572
2572
|
const isFileList = kindOfTest("FileList");
|
|
@@ -2841,7 +2841,7 @@ const utils$1 = {
|
|
|
2841
2841
|
isResponse,
|
|
2842
2842
|
isHeaders,
|
|
2843
2843
|
isUndefined,
|
|
2844
|
-
isDate: isDate$
|
|
2844
|
+
isDate: isDate$2,
|
|
2845
2845
|
isFile,
|
|
2846
2846
|
isBlob,
|
|
2847
2847
|
isRegExp: isRegExp$1,
|
|
@@ -5283,6 +5283,7 @@ function iffer(field, itemData) {
|
|
|
5283
5283
|
return true;
|
|
5284
5284
|
}
|
|
5285
5285
|
const denullify = (itemData, fieldID) => fieldID && itemData ? itemData[fieldID] : null;
|
|
5286
|
+
const isDate$1 = (dateToTest) => !Number.isNaN(Date.parse(dateToTest));
|
|
5286
5287
|
const bagelInjectionKey = Symbol("bagel");
|
|
5287
5288
|
const i18nTInjectionKey = Symbol("bagel");
|
|
5288
5289
|
function useBagel() {
|
|
@@ -6066,10 +6067,14 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
6066
6067
|
const dta = [...props2.data].map(transform);
|
|
6067
6068
|
if (sortField.value) {
|
|
6068
6069
|
return dta.sort((a2, b2) => {
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6070
|
+
let aValue = a2[computedSortField.value] ?? a2[sortField.value] ?? "";
|
|
6071
|
+
let bValue = b2[computedSortField.value] ?? b2[sortField.value] ?? "";
|
|
6072
|
+
if (isDate$1(aValue) && isDate$1(bValue)) {
|
|
6073
|
+
aValue = new Date(aValue).getTime();
|
|
6074
|
+
bValue = new Date(bValue).getTime();
|
|
6075
|
+
}
|
|
6076
|
+
const numAValue = Number.parseInt(`${aValue}`.replace(/[^\d.-]/g, ""), 10);
|
|
6077
|
+
const numBValue = Number.parseInt(`${bValue}`.replace(/[^\d.-]/g, ""), 10);
|
|
6073
6078
|
if (!Number.isNaN(numAValue) && !Number.isNaN(numBValue)) {
|
|
6074
6079
|
if (sortDirection.value === "ASC") return numAValue - numBValue;
|
|
6075
6080
|
return numBValue - numAValue;
|
|
@@ -6155,7 +6160,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
6155
6160
|
};
|
|
6156
6161
|
}
|
|
6157
6162
|
});
|
|
6158
|
-
const TableSchema = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-
|
|
6163
|
+
const TableSchema = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-1628cf1a"]]);
|
|
6159
6164
|
const _sfc_main$E = {};
|
|
6160
6165
|
const _hoisted_1$B = { class: "flex space-between" };
|
|
6161
6166
|
function _sfc_render$1(_ctx, _cache) {
|
|
@@ -62911,6 +62916,7 @@ export {
|
|
|
62911
62916
|
i18nTInjectionKey,
|
|
62912
62917
|
iffer,
|
|
62913
62918
|
initials,
|
|
62919
|
+
isDate$1 as isDate,
|
|
62914
62920
|
keyToLabel,
|
|
62915
62921
|
useBagel,
|
|
62916
62922
|
useEscape,
|
package/dist/style.css
CHANGED
|
@@ -640,41 +640,41 @@ a[data-v-65a6e961] {
|
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
642
|
|
|
643
|
-
.list-arrows[data-v-
|
|
643
|
+
.list-arrows[data-v-1628cf1a] {
|
|
644
644
|
opacity: 0;
|
|
645
645
|
}
|
|
646
|
-
.list-arrows .bgl_icon-font[data-v-
|
|
646
|
+
.list-arrows .bgl_icon-font[data-v-1628cf1a] {
|
|
647
647
|
transition: all ease-in-out 0.2s;
|
|
648
648
|
}
|
|
649
|
-
.list-arrows.sorted[data-v-
|
|
649
|
+
.list-arrows.sorted[data-v-1628cf1a] {
|
|
650
650
|
opacity: 1;
|
|
651
651
|
}
|
|
652
|
-
.col img[data-v-
|
|
652
|
+
.col img[data-v-1628cf1a] {
|
|
653
653
|
height: 35px;
|
|
654
654
|
margin-top: -14px;
|
|
655
655
|
margin-bottom: -14px;
|
|
656
656
|
border-radius: 5px;
|
|
657
657
|
}
|
|
658
|
-
.list-arrows.sorted .desc[data-v-
|
|
658
|
+
.list-arrows.sorted .desc[data-v-1628cf1a] {
|
|
659
659
|
transform: rotate(180deg);
|
|
660
660
|
}
|
|
661
|
-
table[data-v-
|
|
661
|
+
table[data-v-1628cf1a] {
|
|
662
662
|
border-collapse: separate;
|
|
663
663
|
border-spacing: 0 15px;
|
|
664
664
|
border-collapse: collapse;
|
|
665
665
|
}
|
|
666
|
-
th[data-v-
|
|
666
|
+
th[data-v-1628cf1a] {
|
|
667
667
|
font-weight: 400;
|
|
668
668
|
}
|
|
669
|
-
.embedded-field[data-v-
|
|
669
|
+
.embedded-field[data-v-1628cf1a] {
|
|
670
670
|
margin-bottom: -0.2rem;
|
|
671
671
|
margin-top: -0.2rem;
|
|
672
672
|
}
|
|
673
|
-
.row[data-v-
|
|
673
|
+
.row[data-v-1628cf1a] {
|
|
674
674
|
border-bottom: 1px solid var(--border-color);
|
|
675
675
|
cursor: pointer;
|
|
676
676
|
}
|
|
677
|
-
.row.first-row[data-v-
|
|
677
|
+
.row.first-row[data-v-1628cf1a] {
|
|
678
678
|
font-size: 0.8rem;
|
|
679
679
|
color: var(--bgl-black-tint);
|
|
680
680
|
position: sticky;
|
|
@@ -684,10 +684,10 @@ th[data-v-9d32d080] {
|
|
|
684
684
|
/* height: 50px; */
|
|
685
685
|
vertical-align: bottom;
|
|
686
686
|
}
|
|
687
|
-
.row.first-row input[type=checkbox][data-v-
|
|
687
|
+
.row.first-row input[type=checkbox][data-v-1628cf1a]{
|
|
688
688
|
margin-bottom: 0.7rem;
|
|
689
689
|
}
|
|
690
|
-
.row.first-row[data-v-
|
|
690
|
+
.row.first-row[data-v-1628cf1a]::after {
|
|
691
691
|
content: '';
|
|
692
692
|
border-bottom: 1px solid var(--border-color);
|
|
693
693
|
position: absolute;
|
|
@@ -695,30 +695,30 @@ th[data-v-9d32d080] {
|
|
|
695
695
|
right: 0;
|
|
696
696
|
bottom: -1px;
|
|
697
697
|
}
|
|
698
|
-
.first-row .col[data-v-
|
|
698
|
+
.first-row .col[data-v-1628cf1a] {
|
|
699
699
|
cursor: pointer;
|
|
700
700
|
background: var(--bgl-white);
|
|
701
701
|
}
|
|
702
|
-
.col[data-v-
|
|
702
|
+
.col[data-v-1628cf1a] {
|
|
703
703
|
white-space: nowrap;
|
|
704
704
|
padding: 0.75rem 1rem;
|
|
705
705
|
transition: var(--bgl-transition);
|
|
706
706
|
line-height: 1;
|
|
707
707
|
align-items: center;
|
|
708
708
|
}
|
|
709
|
-
.col[data-v-
|
|
709
|
+
.col[data-v-1628cf1a]:has(.bagel-input) {
|
|
710
710
|
padding: 0rem 0.25rem;
|
|
711
711
|
}
|
|
712
|
-
.col > div[data-v-
|
|
712
|
+
.col > div[data-v-1628cf1a] {
|
|
713
713
|
display: flex;
|
|
714
714
|
gap: 0.5rem;
|
|
715
715
|
}
|
|
716
|
-
.max-col-width[data-v-
|
|
716
|
+
.max-col-width[data-v-1628cf1a] {
|
|
717
717
|
max-width: 30vw;
|
|
718
718
|
overflow: hidden;
|
|
719
719
|
text-overflow: ellipsis;
|
|
720
720
|
}
|
|
721
|
-
.col.check .bgl_icon-font[data-v-
|
|
721
|
+
.col.check .bgl_icon-font[data-v-1628cf1a] {
|
|
722
722
|
border-radius: 100%;
|
|
723
723
|
background: var(--bgl-blue-20);
|
|
724
724
|
color: var(--bgl-primary);
|
|
@@ -729,31 +729,31 @@ th[data-v-9d32d080] {
|
|
|
729
729
|
justify-content: center;
|
|
730
730
|
margin-top: -2px;
|
|
731
731
|
}
|
|
732
|
-
.rows[data-v-
|
|
732
|
+
.rows[data-v-1628cf1a] {
|
|
733
733
|
font-size: 0.88em;
|
|
734
734
|
}
|
|
735
|
-
.table-list[data-v-
|
|
735
|
+
.table-list[data-v-1628cf1a] {
|
|
736
736
|
height: 100%;
|
|
737
737
|
position: relative;
|
|
738
738
|
padding-left: 0 !important;
|
|
739
739
|
padding-right: 0 !important;
|
|
740
740
|
overflow: auto;
|
|
741
741
|
}
|
|
742
|
-
.BagelTable .table-list[data-v-
|
|
742
|
+
.BagelTable .table-list[data-v-1628cf1a] {
|
|
743
743
|
overflow: unset;
|
|
744
744
|
}
|
|
745
|
-
.row-item[data-v-
|
|
745
|
+
.row-item[data-v-1628cf1a] {
|
|
746
746
|
height: 50px;
|
|
747
747
|
transition: all 200ms ease;
|
|
748
748
|
}
|
|
749
|
-
.row-item[data-v-
|
|
749
|
+
.row-item[data-v-1628cf1a]:hover {
|
|
750
750
|
background: var(--bgl-gray-light);
|
|
751
751
|
}
|
|
752
|
-
.row-item input[type=checkbox][data-v-
|
|
752
|
+
.row-item input[type=checkbox][data-v-1628cf1a]{
|
|
753
753
|
margin-top: 0.45rem !important;
|
|
754
754
|
accent-color: var(--bgl-primary);
|
|
755
755
|
}
|
|
756
|
-
.infinite-wrapper[data-v-
|
|
756
|
+
.infinite-wrapper[data-v-1628cf1a] {
|
|
757
757
|
overflow-y: auto;
|
|
758
758
|
width: 100%;
|
|
759
759
|
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare function classify(fieldVal?: any, row?: any, ...classes: any[]):
|
|
|
9
9
|
export declare function bindAttrs<T = Record<string, any>>(attrs?: Attributes, fieldVal?: any, row?: T): any;
|
|
10
10
|
export declare function iffer(field: any, itemData: any): any;
|
|
11
11
|
export declare const denullify: (itemData?: Record<string, any>, fieldID?: string) => any;
|
|
12
|
+
export declare const isDate: (dateToTest: any) => boolean;
|
|
12
13
|
export { formatString } from './strings';
|
|
13
14
|
export * as bagelFormUtils from './BagelFormUtils';
|
|
14
15
|
export { useLang } from './lang';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG1C,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,KAAK,SAAM,QAGnD;AAED,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI3D;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,iBAGtE;AAED,wBAAgB,QAAQ,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,UAG3C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,IAAI,QAIrE;AAED,wBAAgB,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,UAKpE;AAED,wBAAgB,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,OAU7F;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,OAM9C;AAED,eAAO,MAAM,SAAS,cAAe,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,MAAM,QAAqD,CAAA;AAE/H,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG1C,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,KAAK,SAAM,QAGnD;AAED,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI3D;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,iBAGtE;AAED,wBAAgB,QAAQ,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,UAG3C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,IAAI,QAIrE;AAED,wBAAgB,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,UAKpE;AAED,wBAAgB,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,OAU7F;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,OAM9C;AAED,eAAO,MAAM,SAAS,cAAe,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,MAAM,QAAqD,CAAA;AAE/H,eAAO,MAAM,MAAM,eAAgB,GAAG,YAA0C,CAAA;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA"}
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
BglField,
|
|
4
4
|
type BglFormSchemaT,
|
|
5
5
|
MaterialIcon,
|
|
6
|
+
isDate,
|
|
6
7
|
keyToLabel,
|
|
7
8
|
} from '@bagelink/vue'
|
|
8
9
|
import { useSlots } from 'vue'
|
|
@@ -80,18 +81,28 @@ const computedData = $computed(() => {
|
|
|
80
81
|
const dta = [...props.data].map(transform)
|
|
81
82
|
if (sortField as string) {
|
|
82
83
|
return dta.sort((a, b) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
let aValue = a[computedSortField] ?? a[sortField] ?? ''
|
|
85
|
+
let bValue = b[computedSortField] ?? b[sortField] ?? ''
|
|
86
|
+
|
|
87
|
+
if (isDate(aValue) && isDate(bValue)) {
|
|
88
|
+
// ? now we can sort by as number
|
|
89
|
+
aValue = new Date(aValue).getTime()
|
|
90
|
+
bValue = new Date(bValue).getTime()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const numAValue = Number.parseInt(`${aValue}`.replace(/[^\d.-]/g, ''), 10)
|
|
94
|
+
const numBValue = Number.parseInt(`${bValue}`.replace(/[^\d.-]/g, ''), 10)
|
|
95
|
+
|
|
87
96
|
if (!Number.isNaN(numAValue) && !Number.isNaN(numBValue)) {
|
|
88
97
|
if (sortDirection === 'ASC') return numAValue - numBValue
|
|
89
98
|
return numBValue - numAValue
|
|
90
99
|
}
|
|
100
|
+
|
|
91
101
|
if (typeof aValue === 'string') {
|
|
92
102
|
if (sortDirection === 'ASC') return aValue.localeCompare(bValue)
|
|
93
103
|
return bValue.localeCompare(aValue)
|
|
94
104
|
}
|
|
105
|
+
|
|
95
106
|
if (sortDirection === 'ASC') return aValue < bValue ? -1 : 1
|
|
96
107
|
return aValue < bValue ? 1 : -1
|
|
97
108
|
})
|
package/src/utils/index.ts
CHANGED
|
@@ -57,6 +57,8 @@ export function iffer(field: any, itemData: any) {
|
|
|
57
57
|
|
|
58
58
|
export const denullify = (itemData?: Record<string, any>, fieldID?: string) => (fieldID && itemData ? itemData[fieldID] : null)
|
|
59
59
|
|
|
60
|
+
export const isDate = (dateToTest: any) => !Number.isNaN(Date.parse(dateToTest))
|
|
61
|
+
|
|
60
62
|
export { formatString } from './strings'
|
|
61
63
|
|
|
62
64
|
export * as bagelFormUtils from './BagelFormUtils'
|