@katlux/block-ecommerce 0.1.0-beta.73 → 0.1.1-alpha.100

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 CHANGED
@@ -1,6 +1,8 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
1
3
  interface ModuleOptions {
2
4
  }
3
- declare const _default: any;
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
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.1.0-beta.73",
7
+ "version": "0.1.1-alpha.100",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -15,6 +15,8 @@ const module$1 = defineNuxtModule({
15
15
  path: resolver.resolve("./runtime/components"),
16
16
  pathPrefix: false,
17
17
  prefix: "",
18
+ extensions: ["vue"],
19
+ ignore: ["**/*.spec.*", "**/*.test.*"],
18
20
  global: true
19
21
  });
20
22
  }
@@ -6,27 +6,36 @@ type __VLS_Props = {
6
6
  rowActions?: KProductRowAction[];
7
7
  gridColumns?: number | string;
8
8
  gap?: string;
9
+ locale?: string;
10
+ emptyText?: string;
11
+ currentPage?: number;
12
+ pageSize?: number;
13
+ virtualScroll?: boolean;
14
+ itemHeight?: number;
15
+ viewportHeight?: number;
16
+ buffer?: number;
9
17
  };
10
- declare var __VLS_1: {
11
- item: import("@katlux/providers").TDataRow;
12
- index: number;
13
- }, __VLS_11: string, __VLS_12: any;
14
- type __VLS_Slots = {} & {
15
- [K in NonNullable<typeof __VLS_11>]?: (props: typeof __VLS_12) => any;
16
- } & {
17
- default?: (props: typeof __VLS_1) => any;
18
- };
19
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
18
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
19
+ "update:currentPage": (page: number) => any;
20
+ "update:pageSize": (size: number) => any;
21
+ "page-change": (page: number) => any;
22
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
23
+ "onUpdate:currentPage"?: ((page: number) => any) | undefined;
24
+ "onUpdate:pageSize"?: ((size: number) => any) | undefined;
25
+ "onPage-change"?: ((page: number) => any) | undefined;
26
+ }>, {
27
+ currentPage: number;
28
+ pageSize: number;
29
+ buffer: number;
20
30
  layout: "grid" | "list";
21
31
  rowActions: KProductRowAction[];
22
32
  gridColumns: number | string;
23
33
  gap: string;
34
+ locale: string;
35
+ emptyText: string;
36
+ virtualScroll: boolean;
37
+ itemHeight: number;
38
+ viewportHeight: number;
24
39
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
26
40
  declare const _default: typeof __VLS_export;
27
41
  export default _default;
28
- type __VLS_WithSlots<T, S> = T & {
29
- new (): {
30
- $slots: S;
31
- };
32
- };
@@ -1,4 +1,4 @@
1
- import type { ADataProvider, KProductRowAction } from '@katlux/providers';
1
+ import type { ADataProvider, KProductItemData, KProductRowAction } from '@katlux/providers';
2
2
  import { type PropType } from 'vue';
3
3
  export interface KProductListProps {
4
4
  dataProvider: ADataProvider;
@@ -6,7 +6,20 @@ export interface KProductListProps {
6
6
  rowActions?: KProductRowAction[];
7
7
  gridColumns?: number | string;
8
8
  gap?: string;
9
+ locale?: string;
10
+ emptyText?: string;
11
+ currentPage?: number;
12
+ pageSize?: number;
13
+ virtualScroll?: boolean;
14
+ itemHeight?: number;
15
+ viewportHeight?: number;
16
+ buffer?: number;
9
17
  }
18
+ export type KProductListEmits = {
19
+ (e: 'update:currentPage', page: number): void;
20
+ (e: 'update:pageSize', size: number): void;
21
+ (e: 'page-change', page: number): void;
22
+ };
10
23
  export declare const KProductListDefaultProps: {
11
24
  dataProvider: {
12
25
  type: PropType<ADataProvider>;
@@ -28,25 +41,47 @@ export declare const KProductListDefaultProps: {
28
41
  type: StringConstructor;
29
42
  default: string;
30
43
  };
44
+ locale: {
45
+ type: StringConstructor;
46
+ default: undefined;
47
+ };
48
+ emptyText: {
49
+ type: StringConstructor;
50
+ default: undefined;
51
+ };
52
+ currentPage: {
53
+ type: NumberConstructor;
54
+ default: undefined;
55
+ };
56
+ pageSize: {
57
+ type: NumberConstructor;
58
+ default: undefined;
59
+ };
60
+ virtualScroll: {
61
+ type: BooleanConstructor;
62
+ default: boolean;
63
+ };
64
+ itemHeight: {
65
+ type: NumberConstructor;
66
+ default: undefined;
67
+ };
68
+ viewportHeight: {
69
+ type: NumberConstructor;
70
+ default: number;
71
+ };
72
+ buffer: {
73
+ type: NumberConstructor;
74
+ default: number;
75
+ };
31
76
  };
32
- export declare function useKProductListLogic(props: KProductListProps): {
77
+ export declare function useKProductListLogic(props: KProductListProps, emit?: KProductListEmits): {
33
78
  isGrid: import("vue").ComputedRef<boolean>;
34
- gridStyles: import("vue").ComputedRef<{
35
- display?: undefined;
36
- gridTemplateColumns?: undefined;
37
- gap?: undefined;
38
- } | {
39
- display: string;
40
- gridTemplateColumns: string;
41
- gap: string | undefined;
42
- }>;
43
- listStyles: import("vue").ComputedRef<{
44
- display?: undefined;
45
- flexDirection?: undefined;
46
- gap?: undefined;
47
- } | {
48
- display: string;
49
- flexDirection: "column";
50
- gap: string | undefined;
51
- }>;
79
+ pageRows: import("vue").ComputedRef<KProductItemData[]>;
80
+ loading: import("vue").Ref<boolean, boolean>;
81
+ initialLoad: import("vue").Ref<boolean, boolean>;
82
+ rowCount: import("vue").Ref<number, number>;
83
+ currentPage: import("vue").Ref<number, number>;
84
+ pageSize: import("vue").Ref<number, number>;
85
+ setCurrentPage: (page: number) => void;
86
+ setPageSize: (size: number) => void;
52
87
  };
@@ -1,4 +1,5 @@
1
- import { computed } from "vue";
1
+ import { computed, watch } from "vue";
2
+ import { useDataProvider } from "#toolkit/composables/useDataProvider";
2
3
  export const KProductListDefaultProps = {
3
4
  dataProvider: {
4
5
  type: Object,
@@ -19,30 +20,84 @@ export const KProductListDefaultProps = {
19
20
  gap: {
20
21
  type: String,
21
22
  default: "1rem"
23
+ },
24
+ locale: {
25
+ type: String,
26
+ default: void 0
27
+ },
28
+ emptyText: {
29
+ type: String,
30
+ default: void 0
31
+ },
32
+ currentPage: {
33
+ type: Number,
34
+ default: void 0
35
+ },
36
+ pageSize: {
37
+ type: Number,
38
+ default: void 0
39
+ },
40
+ virtualScroll: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ itemHeight: {
45
+ type: Number,
46
+ default: void 0
47
+ },
48
+ viewportHeight: {
49
+ type: Number,
50
+ default: 600
51
+ },
52
+ buffer: {
53
+ type: Number,
54
+ default: 2
22
55
  }
23
56
  };
24
- export function useKProductListLogic(props) {
57
+ export function useKProductListLogic(props, emit) {
25
58
  const isGrid = computed(() => props.layout !== "list");
26
- const gridStyles = computed(() => {
27
- if (!isGrid.value) return {};
28
- const cols = props.gridColumns;
29
- return {
30
- display: "grid",
31
- gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`,
32
- gap: props.gap
33
- };
59
+ const {
60
+ pageData,
61
+ loading,
62
+ initialLoad,
63
+ rowCount,
64
+ currentPage: dpCurrentPage,
65
+ pageSize: dpPageSize,
66
+ setCurrentPage,
67
+ setPageSize
68
+ } = useDataProvider(() => props.dataProvider);
69
+ watch([() => props.currentPage, () => props.pageSize], ([page, size]) => {
70
+ if (size !== void 0 && size !== dpPageSize.value) {
71
+ const targetPage = page !== void 0 ? page : dpCurrentPage.value;
72
+ if (typeof props.dataProvider?.setPageSize === "function") {
73
+ props.dataProvider.setPageSize(size, false);
74
+ if (targetPage !== dpCurrentPage.value) {
75
+ setCurrentPage(targetPage);
76
+ }
77
+ } else {
78
+ setPageSize(size);
79
+ }
80
+ } else if (page !== void 0 && page !== dpCurrentPage.value) {
81
+ setCurrentPage(page);
82
+ }
83
+ }, { immediate: true });
84
+ watch(dpCurrentPage, (val) => {
85
+ emit?.("update:currentPage", val);
86
+ emit?.("page-change", val);
34
87
  });
35
- const listStyles = computed(() => {
36
- if (isGrid.value) return {};
37
- return {
38
- display: "flex",
39
- flexDirection: "column",
40
- gap: props.gap
41
- };
88
+ watch(dpPageSize, (val) => {
89
+ emit?.("update:pageSize", val);
42
90
  });
91
+ const pageRows = computed(() => pageData.value || []);
43
92
  return {
44
93
  isGrid,
45
- gridStyles,
46
- listStyles
94
+ pageRows,
95
+ loading,
96
+ initialLoad,
97
+ rowCount,
98
+ currentPage: dpCurrentPage,
99
+ pageSize: dpPageSize,
100
+ setCurrentPage,
101
+ setPageSize
47
102
  };
48
103
  }
@@ -1,45 +1,168 @@
1
- <template>
2
- <div class="k-product-list" :class="{ 'is-grid': isGrid, 'is-list': !isGrid }">
3
- <!-- If there's a custom template provided via default slot -->
4
- <template v-if="$slots.default">
5
- <div class="list-container" :style="isGrid ? gridStyles : listStyles">
6
- <slot v-for="(item, index) in props.dataProvider.pageData.value" :item="item" :index="index"></slot>
7
- </div>
8
- </template>
1
+ <template lang="pug">
2
+ .k-product-list(:class="{ 'is-grid': isGrid, 'is-list': !isGrid, 'is-virtual-scroll': props.virtualScroll }" :style="containerVars")
3
+ //- Loading state
4
+ .loading-container(v-if="loading")
5
+ slot(name="loading" :loading="loading")
6
+ .list-container
7
+ .k-product-skeleton-card(v-for="i in skeletonCount" :key="i")
8
+ .skeleton-image
9
+ .skeleton-details
10
+ .skeleton-line.skeleton-title
11
+ .skeleton-line.skeleton-price
9
12
 
10
- <!-- Otherwise, use the default KProductListItem -->
11
- <template v-else>
12
- <div class="list-container" :style="isGrid ? gridStyles : listStyles">
13
- <KProductListItem
14
- v-for="(item, index) in props.dataProvider.pageData.value"
13
+ //- Empty state
14
+ .empty-container(v-else-if="isEmpty")
15
+ slot(name="empty")
16
+ .k-product-empty-state
17
+ p.empty-message {{ props.emptyText || t('No products found') }}
18
+
19
+ //- Virtual scrolling mode
20
+ .k-product-virtual-container(
21
+ v-else-if="props.virtualScroll"
22
+ ref="containerRef"
23
+ tabindex="0"
24
+ role="feed"
25
+ aria-busy="false"
26
+ :style="containerCssVars"
27
+ @scroll.passive="onScroll"
28
+ @keydown.down.prevent="onKeyDownDown"
29
+ @keydown.up.prevent="onKeyDownUp"
30
+ )
31
+ .k-virtual-spacer.is-top(aria-hidden="true")
32
+ .list-container
33
+ template(v-if="$slots.default")
34
+ slot(v-for="(item, index) in displayProducts" :item="item" :index="startIndex + index")
35
+ template(v-else)
36
+ KProductListItem(
37
+ v-for="(item, index) in displayProducts"
38
+ :key="item.id || (startIndex + index)"
39
+ :item="item"
40
+ :row-actions="rowActions"
41
+ :locale="props.locale"
42
+ )
43
+ template(v-for="(_, slot) in $slots" #[slot]="scope")
44
+ slot(:name="slot" v-bind="scope")
45
+ .k-virtual-spacer.is-bottom(aria-hidden="true")
46
+
47
+ //- Traditional paginated mode
48
+ template(v-else)
49
+ .list-container(v-if="$slots.default")
50
+ slot(v-for="(item, index) in pageRows" :item="item" :index="index")
51
+ .list-container(v-else)
52
+ KProductListItem(
53
+ v-for="(item, index) in pageRows"
15
54
  :key="item.id || index"
16
55
  :item="item"
17
56
  :row-actions="rowActions"
18
- >
19
- <template v-for="(_, slot) in $slots" #[slot]="scope">
20
- <slot :name="slot" v-bind="scope"></slot>
21
- </template>
22
- </KProductListItem>
23
- </div>
24
- </template>
57
+ :locale="props.locale"
58
+ )
59
+ template(v-for="(_, slot) in $slots" #[slot]="scope")
60
+ slot(:name="slot" v-bind="scope")
25
61
 
26
- <div class="footer">
27
- <KPagination class="pagination" :dataProvider="props.dataProvider" />
28
- </div>
29
- </div>
62
+ .footer(v-if="!loading && !isEmpty && !props.virtualScroll")
63
+ KPagination.pagination(
64
+ :dataProvider="props.dataProvider"
65
+ @update:currentPage="emit('update:currentPage', $event)"
66
+ @update:pageSize="emit('update:pageSize', $event)"
67
+ )
30
68
  </template>
31
69
 
32
70
  <script setup>
71
+ import { computed } from "vue";
33
72
  import { ADataProvider } from "@katlux/providers";
73
+ import { useKatluxI18n } from "#toolkit/composables/useKatluxI18n";
74
+ import { useVirtualScroll } from "#toolkit/composables/useVirtualScroll";
34
75
  import { useKProductListLogic } from "./KProductList.logic";
76
+ const { t } = useKatluxI18n();
77
+ const emit = defineEmits(["update:currentPage", "update:pageSize", "page-change"]);
35
78
  const props = defineProps({
36
79
  dataProvider: { type: Object, required: true },
37
80
  layout: { type: String, required: false, default: "grid" },
38
81
  rowActions: { type: Array, required: false, default: () => [] },
39
82
  gridColumns: { type: [Number, String], required: false, default: 4 },
40
- gap: { type: String, required: false, default: "1rem" }
83
+ gap: { type: String, required: false, default: "1rem" },
84
+ locale: { type: String, required: false, default: void 0 },
85
+ emptyText: { type: String, required: false, default: void 0 },
86
+ currentPage: { type: Number, required: false, default: void 0 },
87
+ pageSize: { type: Number, required: false, default: void 0 },
88
+ virtualScroll: { type: Boolean, required: false, default: false },
89
+ itemHeight: { type: Number, required: false, default: void 0 },
90
+ viewportHeight: { type: Number, required: false, default: 600 },
91
+ buffer: { type: Number, required: false, default: 2 }
92
+ });
93
+ const { isGrid, pageRows, loading } = useKProductListLogic(props, emit);
94
+ const skeletonCount = computed(() => Number(props.gridColumns) || 4);
95
+ const containerVars = computed(() => ({
96
+ "--k-product-grid-cols": String(props.gridColumns),
97
+ "--k-product-gap": props.gap
98
+ }));
99
+ const productItems = computed(() => {
100
+ const currentRows = pageRows.value;
101
+ const dp = props.dataProvider;
102
+ if (props.virtualScroll) {
103
+ if (Array.isArray(dp?.rowMap)) return dp.rowMap;
104
+ if (Array.isArray(dp?.rowMap?.value)) return dp.rowMap.value;
105
+ if (Array.isArray(dp?.allVisibleRows)) return dp.allVisibleRows;
106
+ if (Array.isArray(dp?.allVisibleRows?.value)) return dp.allVisibleRows.value;
107
+ if (Array.isArray(dp?.allData?.value)) return dp.allData.value;
108
+ if (Array.isArray(dp?.allData)) return dp.allData;
109
+ if (Array.isArray(dp?.data)) return dp.data;
110
+ }
111
+ return currentRows;
112
+ });
113
+ const columnsCount = computed(() => isGrid.value ? Number(props.gridColumns) || 4 : 1);
114
+ const effectiveItemHeight = computed(() => {
115
+ if (typeof props.itemHeight === "number" && props.itemHeight > 0) return props.itemHeight;
116
+ return isGrid.value ? 350 : 140;
41
117
  });
42
- const { isGrid, gridStyles, listStyles } = useKProductListLogic(props);
118
+ const {
119
+ visibleItems,
120
+ startIndex,
121
+ endIndex,
122
+ topSpacerHeight,
123
+ bottomSpacerHeight,
124
+ containerRef,
125
+ onScroll,
126
+ scrollToIndex,
127
+ containerCssVars
128
+ } = useVirtualScroll({
129
+ items: productItems,
130
+ itemHeight: effectiveItemHeight,
131
+ containerHeight: props.viewportHeight || 600,
132
+ columns: columnsCount,
133
+ buffer: props.buffer ?? 2,
134
+ virtualScroll: computed(() => !!props.virtualScroll),
135
+ onThresholdReach: () => {
136
+ const dp = props.dataProvider;
137
+ if (typeof dp?.loadMore === "function") {
138
+ dp.loadMore();
139
+ } else if (typeof dp?.nextPage === "function" && dp.hasMore) {
140
+ dp.nextPage();
141
+ }
142
+ }
143
+ });
144
+ const displayProducts = computed(() => {
145
+ if (props.virtualScroll) {
146
+ return visibleItems.value;
147
+ }
148
+ return pageRows.value;
149
+ });
150
+ const isEmpty = computed(() => {
151
+ if (props.virtualScroll) {
152
+ return productItems.value.length === 0;
153
+ }
154
+ return pageRows.value.length === 0;
155
+ });
156
+ const onKeyDownDown = () => {
157
+ if (containerRef.value) {
158
+ containerRef.value.scrollTop += effectiveItemHeight.value;
159
+ }
160
+ };
161
+ const onKeyDownUp = () => {
162
+ if (containerRef.value) {
163
+ containerRef.value.scrollTop = Math.max(0, containerRef.value.scrollTop - effectiveItemHeight.value);
164
+ }
165
+ };
43
166
  </script>
44
167
 
45
168
  <style scoped>
@@ -49,6 +172,87 @@ const { isGrid, gridStyles, listStyles } = useKProductListLogic(props);
49
172
  .k-product-list .list-container {
50
173
  width: 100%;
51
174
  }
175
+ .k-product-list.is-grid .list-container {
176
+ display: grid;
177
+ grid-template-columns: repeat(var(--k-product-grid-cols, 4), minmax(0, 1fr));
178
+ gap: var(--k-product-gap, 1rem);
179
+ }
180
+ .k-product-list.is-list .list-container {
181
+ display: flex;
182
+ flex-direction: column;
183
+ gap: var(--k-product-gap, 1rem);
184
+ }
185
+ .k-product-list .k-product-virtual-container {
186
+ overflow-y: auto;
187
+ max-height: var(--virtual-container-height, 600px);
188
+ position: relative;
189
+ width: 100%;
190
+ }
191
+ .k-product-list .k-product-virtual-container:focus-visible {
192
+ outline: 2px solid var(--primary-color, #3b82f6);
193
+ outline-offset: -2px;
194
+ }
195
+ .k-product-list .k-product-virtual-container .k-virtual-spacer {
196
+ width: 100%;
197
+ flex-shrink: 0;
198
+ }
199
+ .k-product-list .k-product-virtual-container .k-virtual-spacer.is-top {
200
+ height: var(--virtual-spacer-top, 0px);
201
+ }
202
+ .k-product-list .k-product-virtual-container .k-virtual-spacer.is-bottom {
203
+ height: var(--virtual-spacer-bottom, 0px);
204
+ }
205
+ .k-product-list .k-product-empty-state {
206
+ display: flex;
207
+ align-items: center;
208
+ justify-content: center;
209
+ padding: 3rem 1rem;
210
+ color: var(--text-color-muted, #6c757d);
211
+ font-size: 1rem;
212
+ }
213
+ .k-product-list .k-product-skeleton-card {
214
+ border: 1px solid var(--border-color-light, #e9ecef);
215
+ border-radius: var(--border-radius-md, 8px);
216
+ overflow: hidden;
217
+ background: var(--bg-color-surface, #ffffff);
218
+ display: flex;
219
+ flex-direction: column;
220
+ }
221
+ .k-product-list .k-product-skeleton-card .skeleton-image {
222
+ width: 100%;
223
+ aspect-ratio: 1;
224
+ background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
225
+ background-size: 200% 100%;
226
+ animation: skeleton-shimmer 1.5s infinite;
227
+ }
228
+ .k-product-list .k-product-skeleton-card .skeleton-details {
229
+ padding: 1rem;
230
+ display: flex;
231
+ flex-direction: column;
232
+ gap: 0.5rem;
233
+ }
234
+ .k-product-list .k-product-skeleton-card .skeleton-details .skeleton-line {
235
+ height: 14px;
236
+ border-radius: 4px;
237
+ background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
238
+ background-size: 200% 100%;
239
+ animation: skeleton-shimmer 1.5s infinite;
240
+ }
241
+ .k-product-list .k-product-skeleton-card .skeleton-details .skeleton-line.skeleton-title {
242
+ width: 70%;
243
+ }
244
+ .k-product-list .k-product-skeleton-card .skeleton-details .skeleton-line.skeleton-price {
245
+ width: 40%;
246
+ height: 16px;
247
+ }
248
+ @keyframes skeleton-shimmer {
249
+ 0% {
250
+ background-position: 200% 0;
251
+ }
252
+ 100% {
253
+ background-position: -200% 0;
254
+ }
255
+ }
52
256
  .k-product-list .footer {
53
257
  display: flex;
54
258
  justify-content: flex-end;
@@ -6,27 +6,36 @@ type __VLS_Props = {
6
6
  rowActions?: KProductRowAction[];
7
7
  gridColumns?: number | string;
8
8
  gap?: string;
9
+ locale?: string;
10
+ emptyText?: string;
11
+ currentPage?: number;
12
+ pageSize?: number;
13
+ virtualScroll?: boolean;
14
+ itemHeight?: number;
15
+ viewportHeight?: number;
16
+ buffer?: number;
9
17
  };
10
- declare var __VLS_1: {
11
- item: import("@katlux/providers").TDataRow;
12
- index: number;
13
- }, __VLS_11: string, __VLS_12: any;
14
- type __VLS_Slots = {} & {
15
- [K in NonNullable<typeof __VLS_11>]?: (props: typeof __VLS_12) => any;
16
- } & {
17
- default?: (props: typeof __VLS_1) => any;
18
- };
19
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
18
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
19
+ "update:currentPage": (page: number) => any;
20
+ "update:pageSize": (size: number) => any;
21
+ "page-change": (page: number) => any;
22
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
23
+ "onUpdate:currentPage"?: ((page: number) => any) | undefined;
24
+ "onUpdate:pageSize"?: ((size: number) => any) | undefined;
25
+ "onPage-change"?: ((page: number) => any) | undefined;
26
+ }>, {
27
+ currentPage: number;
28
+ pageSize: number;
29
+ buffer: number;
20
30
  layout: "grid" | "list";
21
31
  rowActions: KProductRowAction[];
22
32
  gridColumns: number | string;
23
33
  gap: string;
34
+ locale: string;
35
+ emptyText: string;
36
+ virtualScroll: boolean;
37
+ itemHeight: number;
38
+ viewportHeight: number;
24
39
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
26
40
  declare const _default: typeof __VLS_export;
27
41
  export default _default;
28
- type __VLS_WithSlots<T, S> = T & {
29
- new (): {
30
- $slots: S;
31
- };
32
- };
@@ -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,65 @@ 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
+ 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
+ };
41
+ export function formatCurrencyPrice(price, rawCurrency, locale) {
42
+ if (price === void 0 || price === null || typeof price !== "number" || !Number.isFinite(price)) {
43
+ return "";
44
+ }
45
+ const cleanCurr = (rawCurrency || "USD").trim();
46
+ const isoCode = CURRENCY_MAP[cleanCurr] || cleanCurr.toUpperCase();
47
+ const activeLocale = locale || DEFAULT_CURRENCY_LOCALES[isoCode] || "en-US";
48
+ try {
49
+ return new Intl.NumberFormat(activeLocale, {
50
+ style: "currency",
51
+ currency: isoCode
52
+ }).format(price);
53
+ } catch {
54
+ try {
55
+ const formattedNumber = new Intl.NumberFormat(activeLocale, {
56
+ minimumFractionDigits: 2,
57
+ maximumFractionDigits: 2
58
+ }).format(price);
59
+ return `${rawCurrency || ""} ${formattedNumber}`.trim();
60
+ } catch {
61
+ return `${rawCurrency || ""} ${price.toFixed(2)}`.trim();
62
+ }
63
+ }
64
+ }
12
65
  export function useKProductListItemLogic(props) {
13
66
  const hasActions = computed(() => props.rowActions && props.rowActions.length > 0);
14
67
  const formattedPrice = computed(() => {
15
- if (props.item.price === void 0) return "";
16
- return new Intl.NumberFormat("en-US", {
17
- style: "currency",
18
- currency: props.item.currency || "USD"
19
- }).format(props.item.price);
68
+ return formatCurrencyPrice(props.item.price, props.item.currency, props.locale);
20
69
  });
21
70
  return {
22
71
  hasActions,
@@ -1,9 +1,9 @@
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
- KIcon(name="tabler:photo" class="placeholder-icon")
6
+ KIcon(iconname="tabler:photo" class="placeholder-icon")
7
7
  .item-details
8
8
  h3.item-title {{ item.title }}
9
9
  p.item-description(v-if="item.description") {{ item.description }}
@@ -16,15 +16,21 @@
16
16
  @click="action.action(item)"
17
17
  )
18
18
  template(v-if="action.icon" #icon)
19
- KIcon(:name="action.icon")
19
+ KIcon(:iconname="action.icon")
20
20
  | {{ action.label }}
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
- rowActions: { type: Array, required: false }
27
+ rowActions: { type: Array, required: false },
28
+ locale: { type: String, required: false }
27
29
  });
30
+ const imageFailed = ref(false);
31
+ const handleImageError = () => {
32
+ imageFailed.value = true;
33
+ };
28
34
  import { useKProductListItemLogic } from "./KProductListItem.logic";
29
35
  const { hasActions, formattedPrice } = useKProductListItemLogic(props);
30
36
  </script>
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/block-ecommerce",
3
- "version": "0.1.0-beta.73",
3
+ "version": "0.1.1-alpha.100",
4
4
  "description": "Pre-built eCommerce block components for Katlux toolkit",
5
5
  "author": "Katlux",
6
6
  "license": "Apache-2.0",
@@ -22,9 +22,14 @@
22
22
  "./package.json": "./package.json",
23
23
  "./components/*": "./dist/runtime/components/*"
24
24
  },
25
+ "sideEffects": [
26
+ "**/*.css",
27
+ "**/*.scss",
28
+ "**/*.sass"
29
+ ],
25
30
  "dependencies": {
26
- "@katlux/providers": "*",
27
- "@katlux/toolkit": "*",
31
+ "@katlux/providers": "^0.1.1-alpha.112",
32
+ "@katlux/toolkit": "^0.1.1-alpha.124",
28
33
  "@nuxt/kit": "^3.12.0",
29
34
  "pug": "^3.0.0",
30
35
  "sass": "^1.80.0"