@katlux/block-ecommerce 0.1.1-alpha.93 → 0.1.1-alpha.94
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.json +1 -1
- package/dist/runtime/components/KProductList/KProductList.d.vue.ts +13 -5
- package/dist/runtime/components/KProductList/KProductList.logic.d.ts +0 -18
- package/dist/runtime/components/KProductList/KProductList.logic.js +1 -20
- package/dist/runtime/components/KProductList/KProductList.vue +83 -4
- package/dist/runtime/components/KProductList/KProductList.vue.d.ts +13 -5
- package/dist/runtime/components/KProductListItem/KProductListItem.logic.js +8 -10
- package/dist/runtime/components/KProductListItem/KProductListItem.vue +7 -2
- package/package.json +3 -3
package/dist/module.json
CHANGED
|
@@ -7,22 +7,30 @@ type __VLS_Props = {
|
|
|
7
7
|
gridColumns?: number | string;
|
|
8
8
|
gap?: string;
|
|
9
9
|
locale?: string;
|
|
10
|
+
emptyText?: string;
|
|
10
11
|
};
|
|
11
12
|
declare var __VLS_1: {
|
|
13
|
+
loading: true;
|
|
14
|
+
}, __VLS_3: {}, __VLS_5: {
|
|
12
15
|
item: KProductItemData;
|
|
13
16
|
index: number;
|
|
14
|
-
},
|
|
17
|
+
}, __VLS_15: string, __VLS_16: any;
|
|
15
18
|
type __VLS_Slots = {} & {
|
|
16
|
-
[K in NonNullable<typeof
|
|
19
|
+
[K in NonNullable<typeof __VLS_15>]?: (props: typeof __VLS_16) => any;
|
|
17
20
|
} & {
|
|
18
|
-
|
|
21
|
+
loading?: (props: typeof __VLS_1) => any;
|
|
22
|
+
} & {
|
|
23
|
+
empty?: (props: typeof __VLS_3) => any;
|
|
24
|
+
} & {
|
|
25
|
+
default?: (props: typeof __VLS_5) => any;
|
|
19
26
|
};
|
|
20
27
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
21
|
-
layout: "grid" | "list";
|
|
22
28
|
rowActions: KProductRowAction[];
|
|
29
|
+
locale: string;
|
|
30
|
+
layout: "grid" | "list";
|
|
23
31
|
gridColumns: number | string;
|
|
24
32
|
gap: string;
|
|
25
|
-
|
|
33
|
+
emptyText: string;
|
|
26
34
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
35
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
28
36
|
declare const _default: typeof __VLS_export;
|
|
@@ -32,24 +32,6 @@ export declare const KProductListDefaultProps: {
|
|
|
32
32
|
};
|
|
33
33
|
export declare function useKProductListLogic(props: KProductListProps): {
|
|
34
34
|
isGrid: import("vue").ComputedRef<boolean>;
|
|
35
|
-
gridStyles: import("vue").ComputedRef<{
|
|
36
|
-
display?: undefined;
|
|
37
|
-
gridTemplateColumns?: undefined;
|
|
38
|
-
gap?: undefined;
|
|
39
|
-
} | {
|
|
40
|
-
display: string;
|
|
41
|
-
gridTemplateColumns: string;
|
|
42
|
-
gap: string | undefined;
|
|
43
|
-
}>;
|
|
44
|
-
listStyles: import("vue").ComputedRef<{
|
|
45
|
-
display?: undefined;
|
|
46
|
-
flexDirection?: undefined;
|
|
47
|
-
gap?: undefined;
|
|
48
|
-
} | {
|
|
49
|
-
display: string;
|
|
50
|
-
flexDirection: "column";
|
|
51
|
-
gap: string | undefined;
|
|
52
|
-
}>;
|
|
53
35
|
pageRows: import("vue").ComputedRef<KProductItemData[]>;
|
|
54
36
|
loading: import("vue").Ref<boolean, boolean>;
|
|
55
37
|
initialLoad: import("vue").Ref<boolean, boolean>;
|
|
@@ -24,29 +24,10 @@ export const KProductListDefaultProps = {
|
|
|
24
24
|
};
|
|
25
25
|
export function useKProductListLogic(props) {
|
|
26
26
|
const isGrid = computed(() => props.layout !== "list");
|
|
27
|
-
const { pageData, loading, initialLoad, rowCount } = useDataProvider(props.dataProvider);
|
|
27
|
+
const { pageData, loading, initialLoad, rowCount } = useDataProvider(() => props.dataProvider);
|
|
28
28
|
const pageRows = computed(() => pageData.value || []);
|
|
29
|
-
const gridStyles = computed(() => {
|
|
30
|
-
if (!isGrid.value) return {};
|
|
31
|
-
const cols = props.gridColumns;
|
|
32
|
-
return {
|
|
33
|
-
display: "grid",
|
|
34
|
-
gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`,
|
|
35
|
-
gap: props.gap
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
const listStyles = computed(() => {
|
|
39
|
-
if (isGrid.value) return {};
|
|
40
|
-
return {
|
|
41
|
-
display: "flex",
|
|
42
|
-
flexDirection: "column",
|
|
43
|
-
gap: props.gap
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
29
|
return {
|
|
47
30
|
isGrid,
|
|
48
|
-
gridStyles,
|
|
49
|
-
listStyles,
|
|
50
31
|
pageRows,
|
|
51
32
|
loading,
|
|
52
33
|
initialLoad,
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="k-product-list" :class="{ 'is-grid': isGrid, 'is-list': !isGrid }" :style="containerVars">
|
|
3
|
+
<!-- Loading state -->
|
|
4
|
+
<div v-if="loading" class="loading-container">
|
|
5
|
+
<slot name="loading" :loading="loading">
|
|
6
|
+
<div class="list-container">
|
|
7
|
+
<div v-for="i in skeletonCount" :key="i" class="k-product-skeleton-card">
|
|
8
|
+
<div class="skeleton-image"></div>
|
|
9
|
+
<div class="skeleton-details">
|
|
10
|
+
<div class="skeleton-line skeleton-title"></div>
|
|
11
|
+
<div class="skeleton-line skeleton-price"></div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
</slot>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<!-- Empty state -->
|
|
19
|
+
<div v-else-if="pageRows.length === 0" class="empty-container">
|
|
20
|
+
<slot name="empty">
|
|
21
|
+
<div class="k-product-empty-state">
|
|
22
|
+
<p class="empty-message">{{ props.emptyText || t("No products found") }}</p>
|
|
23
|
+
</div>
|
|
24
|
+
</slot>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
3
27
|
<!-- If there's a custom template provided via default slot -->
|
|
4
|
-
<template v-if="$slots.default">
|
|
28
|
+
<template v-else-if="$slots.default">
|
|
5
29
|
<div class="list-container">
|
|
6
30
|
<slot v-for="(item, index) in pageRows" :item="item" :index="index"></slot>
|
|
7
31
|
</div>
|
|
@@ -24,7 +48,7 @@
|
|
|
24
48
|
</div>
|
|
25
49
|
</template>
|
|
26
50
|
|
|
27
|
-
<div class="footer">
|
|
51
|
+
<div class="footer" v-if="!loading && pageRows.length > 0">
|
|
28
52
|
<KPagination class="pagination" :dataProvider="props.dataProvider" />
|
|
29
53
|
</div>
|
|
30
54
|
</div>
|
|
@@ -33,16 +57,20 @@
|
|
|
33
57
|
<script setup>
|
|
34
58
|
import { computed } from "vue";
|
|
35
59
|
import { ADataProvider } from "@katlux/providers";
|
|
60
|
+
import { useKatluxI18n } from "#toolkit/composables/useKatluxI18n";
|
|
36
61
|
import { useKProductListLogic } from "./KProductList.logic";
|
|
62
|
+
const { t } = useKatluxI18n();
|
|
37
63
|
const props = defineProps({
|
|
38
64
|
dataProvider: { type: Object, required: true },
|
|
39
65
|
layout: { type: String, required: false, default: "grid" },
|
|
40
66
|
rowActions: { type: Array, required: false, default: () => [] },
|
|
41
67
|
gridColumns: { type: [Number, String], required: false, default: 4 },
|
|
42
68
|
gap: { type: String, required: false, default: "1rem" },
|
|
43
|
-
locale: { type: String, required: false, default: void 0 }
|
|
69
|
+
locale: { type: String, required: false, default: void 0 },
|
|
70
|
+
emptyText: { type: String, required: false, default: void 0 }
|
|
44
71
|
});
|
|
45
|
-
const { isGrid,
|
|
72
|
+
const { isGrid, pageRows, loading } = useKProductListLogic(props);
|
|
73
|
+
const skeletonCount = computed(() => Number(props.gridColumns) || 4);
|
|
46
74
|
const containerVars = computed(() => ({
|
|
47
75
|
"--k-product-grid-cols": String(props.gridColumns),
|
|
48
76
|
"--k-product-gap": props.gap
|
|
@@ -66,6 +94,57 @@ const containerVars = computed(() => ({
|
|
|
66
94
|
flex-direction: column;
|
|
67
95
|
gap: var(--k-product-gap, 1rem);
|
|
68
96
|
}
|
|
97
|
+
.k-product-list .k-product-empty-state {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
padding: 3rem 1rem;
|
|
102
|
+
color: var(--text-color-muted, #6c757d);
|
|
103
|
+
font-size: 1rem;
|
|
104
|
+
}
|
|
105
|
+
.k-product-list .k-product-skeleton-card {
|
|
106
|
+
border: 1px solid var(--border-color-light, #e9ecef);
|
|
107
|
+
border-radius: var(--border-radius-md, 8px);
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
background: var(--bg-color-surface, #ffffff);
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
}
|
|
113
|
+
.k-product-list .k-product-skeleton-card .skeleton-image {
|
|
114
|
+
width: 100%;
|
|
115
|
+
aspect-ratio: 1;
|
|
116
|
+
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
|
117
|
+
background-size: 200% 100%;
|
|
118
|
+
animation: skeleton-shimmer 1.5s infinite;
|
|
119
|
+
}
|
|
120
|
+
.k-product-list .k-product-skeleton-card .skeleton-details {
|
|
121
|
+
padding: 1rem;
|
|
122
|
+
display: flex;
|
|
123
|
+
flex-direction: column;
|
|
124
|
+
gap: 0.5rem;
|
|
125
|
+
}
|
|
126
|
+
.k-product-list .k-product-skeleton-card .skeleton-details .skeleton-line {
|
|
127
|
+
height: 14px;
|
|
128
|
+
border-radius: 4px;
|
|
129
|
+
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
|
130
|
+
background-size: 200% 100%;
|
|
131
|
+
animation: skeleton-shimmer 1.5s infinite;
|
|
132
|
+
}
|
|
133
|
+
.k-product-list .k-product-skeleton-card .skeleton-details .skeleton-line.skeleton-title {
|
|
134
|
+
width: 70%;
|
|
135
|
+
}
|
|
136
|
+
.k-product-list .k-product-skeleton-card .skeleton-details .skeleton-line.skeleton-price {
|
|
137
|
+
width: 40%;
|
|
138
|
+
height: 16px;
|
|
139
|
+
}
|
|
140
|
+
@keyframes skeleton-shimmer {
|
|
141
|
+
0% {
|
|
142
|
+
background-position: 200% 0;
|
|
143
|
+
}
|
|
144
|
+
100% {
|
|
145
|
+
background-position: -200% 0;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
69
148
|
.k-product-list .footer {
|
|
70
149
|
display: flex;
|
|
71
150
|
justify-content: flex-end;
|
|
@@ -7,22 +7,30 @@ type __VLS_Props = {
|
|
|
7
7
|
gridColumns?: number | string;
|
|
8
8
|
gap?: string;
|
|
9
9
|
locale?: string;
|
|
10
|
+
emptyText?: string;
|
|
10
11
|
};
|
|
11
12
|
declare var __VLS_1: {
|
|
13
|
+
loading: true;
|
|
14
|
+
}, __VLS_3: {}, __VLS_5: {
|
|
12
15
|
item: KProductItemData;
|
|
13
16
|
index: number;
|
|
14
|
-
},
|
|
17
|
+
}, __VLS_15: string, __VLS_16: any;
|
|
15
18
|
type __VLS_Slots = {} & {
|
|
16
|
-
[K in NonNullable<typeof
|
|
19
|
+
[K in NonNullable<typeof __VLS_15>]?: (props: typeof __VLS_16) => any;
|
|
17
20
|
} & {
|
|
18
|
-
|
|
21
|
+
loading?: (props: typeof __VLS_1) => any;
|
|
22
|
+
} & {
|
|
23
|
+
empty?: (props: typeof __VLS_3) => any;
|
|
24
|
+
} & {
|
|
25
|
+
default?: (props: typeof __VLS_5) => any;
|
|
19
26
|
};
|
|
20
27
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
21
|
-
layout: "grid" | "list";
|
|
22
28
|
rowActions: KProductRowAction[];
|
|
29
|
+
locale: string;
|
|
30
|
+
layout: "grid" | "list";
|
|
23
31
|
gridColumns: number | string;
|
|
24
32
|
gap: string;
|
|
25
|
-
|
|
33
|
+
emptyText: string;
|
|
26
34
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
35
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
28
36
|
declare const _default: typeof __VLS_export;
|
|
@@ -31,22 +31,20 @@ const CURRENCY_MAP = {
|
|
|
31
31
|
jpy: "JPY",
|
|
32
32
|
"\xA5": "JPY"
|
|
33
33
|
};
|
|
34
|
+
const DEFAULT_CURRENCY_LOCALES = {
|
|
35
|
+
TRY: "tr-TR",
|
|
36
|
+
EUR: "de-DE",
|
|
37
|
+
GBP: "en-GB",
|
|
38
|
+
JPY: "ja-JP",
|
|
39
|
+
USD: "en-US"
|
|
40
|
+
};
|
|
34
41
|
export function formatCurrencyPrice(price, rawCurrency, locale) {
|
|
35
42
|
if (price === void 0 || price === null || typeof price !== "number" || !Number.isFinite(price)) {
|
|
36
43
|
return "";
|
|
37
44
|
}
|
|
38
45
|
const cleanCurr = (rawCurrency || "USD").trim();
|
|
39
46
|
const isoCode = CURRENCY_MAP[cleanCurr] || cleanCurr.toUpperCase();
|
|
40
|
-
|
|
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
|
-
}
|
|
47
|
+
const activeLocale = locale || DEFAULT_CURRENCY_LOCALES[isoCode] || "en-US";
|
|
50
48
|
try {
|
|
51
49
|
return new Intl.NumberFormat(activeLocale, {
|
|
52
50
|
style: "currency",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.k-product-list-item
|
|
3
|
-
.item-image(v-if="item.image")
|
|
4
|
-
img(:src="item.image" :alt="item.title")
|
|
3
|
+
.item-image(v-if="item.image && !imageFailed")
|
|
4
|
+
img(:src="item.image" :alt="item.title" @error="handleImageError")
|
|
5
5
|
.item-image-placeholder(v-else)
|
|
6
6
|
KIcon(iconname="tabler:photo" class="placeholder-icon")
|
|
7
7
|
.item-details
|
|
@@ -21,11 +21,16 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script setup>
|
|
24
|
+
import { ref } from "vue";
|
|
24
25
|
const props = defineProps({
|
|
25
26
|
item: { type: Object, required: true },
|
|
26
27
|
rowActions: { type: Array, required: false },
|
|
27
28
|
locale: { type: String, required: false }
|
|
28
29
|
});
|
|
30
|
+
const imageFailed = ref(false);
|
|
31
|
+
const handleImageError = () => {
|
|
32
|
+
imageFailed.value = true;
|
|
33
|
+
};
|
|
29
34
|
import { useKProductListItemLogic } from "./KProductListItem.logic";
|
|
30
35
|
const { hasActions, formattedPrice } = useKProductListItemLogic(props);
|
|
31
36
|
</script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@katlux/block-ecommerce",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.94",
|
|
4
4
|
"description": "Pre-built eCommerce block components for Katlux toolkit",
|
|
5
5
|
"author": "Katlux",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"./components/*": "./dist/runtime/components/*"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@katlux/providers": "
|
|
27
|
-
"@katlux/toolkit": "
|
|
26
|
+
"@katlux/providers": "^0.1.1-alpha.100",
|
|
27
|
+
"@katlux/toolkit": "^0.1.1-alpha.111",
|
|
28
28
|
"@nuxt/kit": "^3.12.0",
|
|
29
29
|
"pug": "^3.0.0",
|
|
30
30
|
"sass": "^1.80.0"
|