@katlux/block-ecommerce 0.1.1-alpha.88 → 0.1.1-alpha.89
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/module.d.mts +3 -1
- package/dist/module.json +1 -1
- package/dist/runtime/components/KProductList/KProductList.d.vue.ts +2 -0
- package/dist/runtime/components/KProductList/KProductList.logic.d.ts +1 -0
- package/dist/runtime/components/KProductList/KProductList.vue +21 -4
- package/dist/runtime/components/KProductList/KProductList.vue.d.ts +2 -0
- package/dist/runtime/components/KProductListItem/KProductListItem.d.vue.ts +1 -0
- package/dist/runtime/components/KProductListItem/KProductListItem.logic.d.ts +6 -0
- package/dist/runtime/components/KProductListItem/KProductListItem.logic.js +56 -5
- package/dist/runtime/components/KProductListItem/KProductListItem.vue +2 -1
- package/dist/runtime/components/KProductListItem/KProductListItem.vue.d.ts +1 -0
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
1
3
|
interface ModuleOptions {
|
|
2
4
|
}
|
|
3
|
-
declare const _default:
|
|
5
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
4
6
|
|
|
5
7
|
export { _default as default };
|
|
6
8
|
export type { ModuleOptions };
|
package/dist/module.json
CHANGED
|
@@ -6,6 +6,7 @@ type __VLS_Props = {
|
|
|
6
6
|
rowActions?: KProductRowAction[];
|
|
7
7
|
gridColumns?: number | string;
|
|
8
8
|
gap?: string;
|
|
9
|
+
locale?: string;
|
|
9
10
|
};
|
|
10
11
|
declare var __VLS_1: {
|
|
11
12
|
item: import("@katlux/providers").TDataRow;
|
|
@@ -21,6 +22,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
21
22
|
rowActions: KProductRowAction[];
|
|
22
23
|
gridColumns: number | string;
|
|
23
24
|
gap: string;
|
|
25
|
+
locale: string;
|
|
24
26
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
27
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
28
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="k-product-list" :class="{ 'is-grid': isGrid, 'is-list': !isGrid }">
|
|
2
|
+
<div class="k-product-list" :class="{ 'is-grid': isGrid, 'is-list': !isGrid }" :style="containerVars">
|
|
3
3
|
<!-- If there's a custom template provided via default slot -->
|
|
4
4
|
<template v-if="$slots.default">
|
|
5
|
-
<div class="list-container"
|
|
5
|
+
<div class="list-container">
|
|
6
6
|
<slot v-for="(item, index) in props.dataProvider.pageData.value" :item="item" :index="index"></slot>
|
|
7
7
|
</div>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<!-- Otherwise, use the default KProductListItem -->
|
|
11
11
|
<template v-else>
|
|
12
|
-
<div class="list-container"
|
|
12
|
+
<div class="list-container">
|
|
13
13
|
<KProductListItem
|
|
14
14
|
v-for="(item, index) in props.dataProvider.pageData.value"
|
|
15
15
|
:key="item.id || index"
|
|
16
16
|
:item="item"
|
|
17
17
|
:row-actions="rowActions"
|
|
18
|
+
:locale="props.locale"
|
|
18
19
|
>
|
|
19
20
|
<template v-for="(_, slot) in $slots" #[slot]="scope">
|
|
20
21
|
<slot :name="slot" v-bind="scope"></slot>
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
</template>
|
|
31
32
|
|
|
32
33
|
<script setup>
|
|
34
|
+
import { computed } from "vue";
|
|
33
35
|
import { ADataProvider } from "@katlux/providers";
|
|
34
36
|
import { useKProductListLogic } from "./KProductList.logic";
|
|
35
37
|
const props = defineProps({
|
|
@@ -37,9 +39,14 @@ const props = defineProps({
|
|
|
37
39
|
layout: { type: String, required: false, default: "grid" },
|
|
38
40
|
rowActions: { type: Array, required: false, default: () => [] },
|
|
39
41
|
gridColumns: { type: [Number, String], required: false, default: 4 },
|
|
40
|
-
gap: { type: String, required: false, default: "1rem" }
|
|
42
|
+
gap: { type: String, required: false, default: "1rem" },
|
|
43
|
+
locale: { type: String, required: false, default: void 0 }
|
|
41
44
|
});
|
|
42
45
|
const { isGrid, gridStyles, listStyles } = useKProductListLogic(props);
|
|
46
|
+
const containerVars = computed(() => ({
|
|
47
|
+
"--k-product-grid-cols": String(props.gridColumns),
|
|
48
|
+
"--k-product-gap": props.gap
|
|
49
|
+
}));
|
|
43
50
|
</script>
|
|
44
51
|
|
|
45
52
|
<style scoped>
|
|
@@ -49,6 +56,16 @@ const { isGrid, gridStyles, listStyles } = useKProductListLogic(props);
|
|
|
49
56
|
.k-product-list .list-container {
|
|
50
57
|
width: 100%;
|
|
51
58
|
}
|
|
59
|
+
.k-product-list.is-grid .list-container {
|
|
60
|
+
display: grid;
|
|
61
|
+
grid-template-columns: repeat(var(--k-product-grid-cols, 4), minmax(0, 1fr));
|
|
62
|
+
gap: var(--k-product-gap, 1rem);
|
|
63
|
+
}
|
|
64
|
+
.k-product-list.is-list .list-container {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
gap: var(--k-product-gap, 1rem);
|
|
68
|
+
}
|
|
52
69
|
.k-product-list .footer {
|
|
53
70
|
display: flex;
|
|
54
71
|
justify-content: flex-end;
|
|
@@ -6,6 +6,7 @@ type __VLS_Props = {
|
|
|
6
6
|
rowActions?: KProductRowAction[];
|
|
7
7
|
gridColumns?: number | string;
|
|
8
8
|
gap?: string;
|
|
9
|
+
locale?: string;
|
|
9
10
|
};
|
|
10
11
|
declare var __VLS_1: {
|
|
11
12
|
item: import("@katlux/providers").TDataRow;
|
|
@@ -21,6 +22,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
21
22
|
rowActions: KProductRowAction[];
|
|
22
23
|
gridColumns: number | string;
|
|
23
24
|
gap: string;
|
|
25
|
+
locale: string;
|
|
24
26
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
27
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
28
|
declare const _default: typeof __VLS_export;
|
|
@@ -2,6 +2,7 @@ import type { KProductItemData, KProductRowAction } from '@katlux/providers';
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
item: KProductItemData;
|
|
4
4
|
rowActions?: KProductRowAction[];
|
|
5
|
+
locale?: string;
|
|
5
6
|
};
|
|
6
7
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
8
|
declare const _default: typeof __VLS_export;
|
|
@@ -3,6 +3,7 @@ import type { KProductItemData, KProductRowAction } from '@katlux/providers';
|
|
|
3
3
|
export interface KProductListItemProps {
|
|
4
4
|
item: KProductItemData;
|
|
5
5
|
rowActions?: KProductRowAction[];
|
|
6
|
+
locale?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare const KProductListItemDefaultProps: {
|
|
8
9
|
item: {
|
|
@@ -13,7 +14,12 @@ export declare const KProductListItemDefaultProps: {
|
|
|
13
14
|
type: PropType<KProductRowAction[]>;
|
|
14
15
|
default: () => never[];
|
|
15
16
|
};
|
|
17
|
+
locale: {
|
|
18
|
+
type: PropType<string>;
|
|
19
|
+
default: undefined;
|
|
20
|
+
};
|
|
16
21
|
};
|
|
22
|
+
export declare function formatCurrencyPrice(price: number | undefined | null, rawCurrency?: string, locale?: string): string;
|
|
17
23
|
export declare function useKProductListItemLogic(props: KProductListItemProps): {
|
|
18
24
|
hasActions: import("vue").ComputedRef<boolean | undefined>;
|
|
19
25
|
formattedPrice: import("vue").ComputedRef<string>;
|
|
@@ -7,16 +7,67 @@ export const KProductListItemDefaultProps = {
|
|
|
7
7
|
rowActions: {
|
|
8
8
|
type: Array,
|
|
9
9
|
default: () => []
|
|
10
|
+
},
|
|
11
|
+
locale: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: void 0
|
|
10
14
|
}
|
|
11
15
|
};
|
|
16
|
+
const CURRENCY_MAP = {
|
|
17
|
+
TL: "TRY",
|
|
18
|
+
tl: "TRY",
|
|
19
|
+
"\u20BA": "TRY",
|
|
20
|
+
TRY: "TRY",
|
|
21
|
+
USD: "USD",
|
|
22
|
+
usd: "USD",
|
|
23
|
+
"$": "USD",
|
|
24
|
+
EUR: "EUR",
|
|
25
|
+
eur: "EUR",
|
|
26
|
+
"\u20AC": "EUR",
|
|
27
|
+
GBP: "GBP",
|
|
28
|
+
gbp: "GBP",
|
|
29
|
+
"\xA3": "GBP",
|
|
30
|
+
JPY: "JPY",
|
|
31
|
+
jpy: "JPY",
|
|
32
|
+
"\xA5": "JPY"
|
|
33
|
+
};
|
|
34
|
+
export function formatCurrencyPrice(price, rawCurrency, locale) {
|
|
35
|
+
if (price === void 0 || price === null || typeof price !== "number" || !Number.isFinite(price)) {
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
const cleanCurr = (rawCurrency || "USD").trim();
|
|
39
|
+
const isoCode = CURRENCY_MAP[cleanCurr] || cleanCurr.toUpperCase();
|
|
40
|
+
let activeLocale = locale;
|
|
41
|
+
if (!activeLocale) {
|
|
42
|
+
if (isoCode === "TRY") {
|
|
43
|
+
activeLocale = "tr-TR";
|
|
44
|
+
} else if (typeof navigator !== "undefined" && navigator.language) {
|
|
45
|
+
activeLocale = navigator.language;
|
|
46
|
+
} else {
|
|
47
|
+
activeLocale = "en-US";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
return new Intl.NumberFormat(activeLocale, {
|
|
52
|
+
style: "currency",
|
|
53
|
+
currency: isoCode
|
|
54
|
+
}).format(price);
|
|
55
|
+
} catch {
|
|
56
|
+
try {
|
|
57
|
+
const formattedNumber = new Intl.NumberFormat(activeLocale, {
|
|
58
|
+
minimumFractionDigits: 2,
|
|
59
|
+
maximumFractionDigits: 2
|
|
60
|
+
}).format(price);
|
|
61
|
+
return `${rawCurrency || ""} ${formattedNumber}`.trim();
|
|
62
|
+
} catch {
|
|
63
|
+
return `${rawCurrency || ""} ${price.toFixed(2)}`.trim();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
12
67
|
export function useKProductListItemLogic(props) {
|
|
13
68
|
const hasActions = computed(() => props.rowActions && props.rowActions.length > 0);
|
|
14
69
|
const formattedPrice = computed(() => {
|
|
15
|
-
|
|
16
|
-
return new Intl.NumberFormat("en-US", {
|
|
17
|
-
style: "currency",
|
|
18
|
-
currency: props.item.currency || "USD"
|
|
19
|
-
}).format(props.item.price);
|
|
70
|
+
return formatCurrencyPrice(props.item.price, props.item.currency, props.locale);
|
|
20
71
|
});
|
|
21
72
|
return {
|
|
22
73
|
hasActions,
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
<script setup>
|
|
24
24
|
const props = defineProps({
|
|
25
25
|
item: { type: Object, required: true },
|
|
26
|
-
rowActions: { type: Array, required: false }
|
|
26
|
+
rowActions: { type: Array, required: false },
|
|
27
|
+
locale: { type: String, required: false }
|
|
27
28
|
});
|
|
28
29
|
import { useKProductListItemLogic } from "./KProductListItem.logic";
|
|
29
30
|
const { hasActions, formattedPrice } = useKProductListItemLogic(props);
|
|
@@ -2,6 +2,7 @@ import type { KProductItemData, KProductRowAction } from '@katlux/providers';
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
item: KProductItemData;
|
|
4
4
|
rowActions?: KProductRowAction[];
|
|
5
|
+
locale?: string;
|
|
5
6
|
};
|
|
6
7
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
8
|
declare const _default: typeof __VLS_export;
|