@promakeai/cli 0.5.8 → 0.6.0
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/README.md +71 -71
- package/dist/index.js +259 -254
- package/dist/registry/about-page.json +3 -3
- package/dist/registry/about-section.json +4 -4
- package/dist/registry/animations.json +2 -2
- package/dist/registry/announcement-bar.json +4 -4
- package/dist/registry/api.json +1 -1
- package/dist/registry/auth-core.json +3 -3
- package/dist/registry/bento-grid-section.json +4 -4
- package/dist/registry/blog-core.json +5 -5
- package/dist/registry/blog-list-page.json +4 -4
- package/dist/registry/blog-section.json +4 -4
- package/dist/registry/cards-carousel-section.json +4 -4
- package/dist/registry/cart-drawer.json +4 -4
- package/dist/registry/cart-page.json +4 -4
- package/dist/registry/case-study-page.json +3 -3
- package/dist/registry/category-section.json +4 -4
- package/dist/registry/checkout-page.json +4 -4
- package/dist/registry/coming-soon-page-minimal.json +4 -4
- package/dist/registry/coming-soon-page.json +4 -4
- package/dist/registry/contact-info-grid.json +4 -4
- package/dist/registry/contact-page-centered.json +4 -4
- package/dist/registry/contact-page-map-overlay.json +3 -3
- package/dist/registry/contact-page-map-split.json +3 -3
- package/dist/registry/contact-page-split.json +4 -4
- package/dist/registry/contact-page.json +4 -4
- package/dist/registry/content-section.json +4 -4
- package/dist/registry/cookie-consent.json +4 -4
- package/dist/registry/cookies-page.json +3 -3
- package/dist/registry/cta-section.json +3 -3
- package/dist/registry/ecommerce-core.json +8 -8
- package/dist/registry/empty-page.json +3 -3
- package/dist/registry/faq-categorized.json +4 -4
- package/dist/registry/faq-simple.json +4 -4
- package/dist/registry/favorites-blog-block.json +1 -1
- package/dist/registry/favorites-blog-page.json +4 -4
- package/dist/registry/favorites-ecommerce-block.json +1 -1
- package/dist/registry/favorites-ecommerce-page.json +4 -4
- package/dist/registry/feature-section.json +3 -3
- package/dist/registry/featured-products.json +4 -4
- package/dist/registry/footer-detailed.json +4 -4
- package/dist/registry/footer-minimal.json +3 -3
- package/dist/registry/footer.json +3 -3
- package/dist/registry/forgot-password-page-split.json +4 -4
- package/dist/registry/forgot-password-page.json +4 -4
- package/dist/registry/google-adsense.json +4 -4
- package/dist/registry/google-map.json +2 -2
- package/dist/registry/header-centered-pill.json +4 -4
- package/dist/registry/header-ecommerce.json +4 -4
- package/dist/registry/header-mega.json +4 -4
- package/dist/registry/header-minimal.json +4 -4
- package/dist/registry/header-simple.json +3 -3
- package/dist/registry/hero-carousel.json +3 -3
- package/dist/registry/hero-cta.json +4 -4
- package/dist/registry/hero-gradient.json +4 -4
- package/dist/registry/hero-grid.json +4 -4
- package/dist/registry/hero-profile.json +3 -3
- package/dist/registry/hero.json +3 -3
- package/dist/registry/index.json +103 -103
- package/dist/registry/landing-page-app.json +3 -3
- package/dist/registry/landing-page-saas.json +3 -3
- package/dist/registry/login-page-split.json +4 -4
- package/dist/registry/login-page.json +4 -4
- package/dist/registry/logo-cloud.json +4 -4
- package/dist/registry/masonry-grid.json +3 -3
- package/dist/registry/my-orders-page.json +4 -4
- package/dist/registry/newsletter-section.json +4 -4
- package/dist/registry/order-card-compact.json +1 -1
- package/dist/registry/order-confirmation-page.json +4 -4
- package/dist/registry/order-detail-block.json +1 -1
- package/dist/registry/orders-list-block.json +1 -1
- package/dist/registry/payment-success-block.json +2 -2
- package/dist/registry/portfolio-page.json +4 -4
- package/dist/registry/post-card.json +4 -4
- package/dist/registry/post-detail-block.json +2 -2
- package/dist/registry/post-detail-page.json +4 -4
- package/dist/registry/pricing-card.json +3 -3
- package/dist/registry/pricing-page.json +4 -4
- package/dist/registry/pricing-section.json +4 -4
- package/dist/registry/privacy-page.json +3 -3
- package/dist/registry/product-card-detailed.json +4 -4
- package/dist/registry/product-card-hover.json +4 -4
- package/dist/registry/product-card.json +4 -4
- package/dist/registry/product-detail-block.json +2 -2
- package/dist/registry/product-detail-page.json +4 -4
- package/dist/registry/product-detail-section.json +4 -4
- package/dist/registry/product-quick-view.json +4 -4
- package/dist/registry/products-page.json +4 -4
- package/dist/registry/reading-progress.json +4 -4
- package/dist/registry/register-page-split.json +4 -4
- package/dist/registry/register-page.json +4 -4
- package/dist/registry/related-posts-block.json +1 -1
- package/dist/registry/related-products-block.json +2 -2
- package/dist/registry/reset-password-page-split.json +4 -4
- package/dist/registry/reset-password-page.json +4 -4
- package/dist/registry/service-card.json +1 -1
- package/dist/registry/share-buttons.json +4 -4
- package/dist/registry/skill-card.json +1 -1
- package/dist/registry/team-page.json +4 -4
- package/dist/registry/terms-page.json +3 -3
- package/dist/registry/testimonials-carousel.json +4 -4
- package/dist/registry/testimonials-grid.json +4 -4
- package/dist/registry/timeline-section.json +4 -4
- package/dist/registry/video-hero.json +4 -4
- package/dist/registry/youtube-embed.json +4 -4
- package/package.json +59 -56
- package/template/.env +6 -6
- package/template/README.md +54 -54
- package/template/eslint.config.js +41 -41
- package/template/package.json +95 -95
- package/template/public/_redirects +1 -1
- package/template/public/robots.txt +14 -14
- package/template/scripts/init-db.ts +18 -18
- package/template/src/App.tsx +19 -19
- package/template/src/components/FormField.tsx +48 -48
- package/template/src/components/FormFileInput.tsx +75 -75
- package/template/src/components/GoogleAnalytics.tsx +34 -34
- package/template/src/components/LanguageSwitcher.tsx +53 -53
- package/template/src/components/PasswordInput.tsx +60 -60
- package/template/src/components/ScriptInjector.tsx +62 -62
- package/template/src/components/Stack.tsx +39 -39
- package/template/src/constants/constants.json +67 -67
- package/template/src/db/index.ts +20 -20
- package/template/src/db/provider.tsx +78 -78
- package/template/src/db/schema.json +258 -258
- package/template/src/db/types.ts +195 -195
- package/template/src/hooks/use-debounced-value.ts +12 -12
- package/template/src/lang/index.ts +90 -90
- package/template/src/lib/api.ts +345 -345
- package/template/src/lib/env.ts +19 -19
- package/template/src/router.tsx +14 -14
- package/template/src/vite-env.d.ts +1 -1
- package/template/vite.config.ts +68 -64
- package/template/public/data/database.db-shm +0 -0
- package/template/public/data/database.db-wal +0 -0
package/template/src/db/types.ts
CHANGED
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
// Auto-generated from schemas - DO NOT EDIT
|
|
2
|
-
|
|
3
|
-
// From promake schema
|
|
4
|
-
export interface DbBlogCategory {
|
|
5
|
-
id?: number;
|
|
6
|
-
name: string;
|
|
7
|
-
slug: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
image?: string;
|
|
10
|
-
created_at?: string;
|
|
11
|
-
updated_at?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface DbBlogCategoryTranslation {
|
|
15
|
-
id: number;
|
|
16
|
-
blog_category_id: number;
|
|
17
|
-
language_code: string;
|
|
18
|
-
name: string;
|
|
19
|
-
description?: string;
|
|
20
|
-
created_at?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface DbBlogCategoryInput {
|
|
24
|
-
id?: number;
|
|
25
|
-
slug: string;
|
|
26
|
-
image?: string;
|
|
27
|
-
created_at?: string;
|
|
28
|
-
updated_at?: string;
|
|
29
|
-
translations?: Record<string, {
|
|
30
|
-
name: string;
|
|
31
|
-
description?: string;
|
|
32
|
-
}>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface DbPost {
|
|
36
|
-
id?: number;
|
|
37
|
-
title: string;
|
|
38
|
-
slug: string;
|
|
39
|
-
content: string;
|
|
40
|
-
excerpt?: string;
|
|
41
|
-
featured_image?: string;
|
|
42
|
-
images?: string[];
|
|
43
|
-
author?: string;
|
|
44
|
-
author_avatar?: string;
|
|
45
|
-
created_at?: string;
|
|
46
|
-
published_at?: string;
|
|
47
|
-
updated_at?: string;
|
|
48
|
-
tags?: string[];
|
|
49
|
-
categories?: number[];
|
|
50
|
-
read_time?: number;
|
|
51
|
-
view_count?: number;
|
|
52
|
-
featured?: boolean;
|
|
53
|
-
published?: boolean;
|
|
54
|
-
meta_description?: string;
|
|
55
|
-
meta_keywords?: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface DbPostTranslation {
|
|
59
|
-
id: number;
|
|
60
|
-
post_id: number;
|
|
61
|
-
language_code: string;
|
|
62
|
-
title: string;
|
|
63
|
-
content: string;
|
|
64
|
-
excerpt?: string;
|
|
65
|
-
author?: string;
|
|
66
|
-
meta_description?: string;
|
|
67
|
-
meta_keywords?: string;
|
|
68
|
-
created_at?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface DbPostInput {
|
|
72
|
-
id?: number;
|
|
73
|
-
slug: string;
|
|
74
|
-
featured_image?: string;
|
|
75
|
-
images?: string[];
|
|
76
|
-
author_avatar?: string;
|
|
77
|
-
created_at?: string;
|
|
78
|
-
published_at?: string;
|
|
79
|
-
updated_at?: string;
|
|
80
|
-
tags?: string[];
|
|
81
|
-
categories?: number[];
|
|
82
|
-
read_time?: number;
|
|
83
|
-
view_count?: number;
|
|
84
|
-
featured?: boolean;
|
|
85
|
-
published?: boolean;
|
|
86
|
-
translations?: Record<string, {
|
|
87
|
-
title: string;
|
|
88
|
-
content: string;
|
|
89
|
-
excerpt?: string;
|
|
90
|
-
author?: string;
|
|
91
|
-
meta_description?: string;
|
|
92
|
-
meta_keywords?: string;
|
|
93
|
-
}>;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface DbProductCategory {
|
|
97
|
-
id?: number;
|
|
98
|
-
name: string;
|
|
99
|
-
slug: string;
|
|
100
|
-
description?: string;
|
|
101
|
-
image?: string;
|
|
102
|
-
parent_id?: number;
|
|
103
|
-
created_at?: string;
|
|
104
|
-
updated_at?: string;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface DbProductCategoryTranslation {
|
|
108
|
-
id: number;
|
|
109
|
-
product_category_id: number;
|
|
110
|
-
language_code: string;
|
|
111
|
-
name: string;
|
|
112
|
-
description?: string;
|
|
113
|
-
created_at?: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface DbProductCategoryInput {
|
|
117
|
-
id?: number;
|
|
118
|
-
slug: string;
|
|
119
|
-
image?: string;
|
|
120
|
-
parent_id?: number;
|
|
121
|
-
created_at?: string;
|
|
122
|
-
updated_at?: string;
|
|
123
|
-
translations?: Record<string, {
|
|
124
|
-
name: string;
|
|
125
|
-
description?: string;
|
|
126
|
-
}>;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface DbProduct {
|
|
130
|
-
id?: number;
|
|
131
|
-
name: string;
|
|
132
|
-
slug: string;
|
|
133
|
-
description?: string;
|
|
134
|
-
price: number;
|
|
135
|
-
sale_price?: number;
|
|
136
|
-
on_sale?: boolean;
|
|
137
|
-
images?: string[];
|
|
138
|
-
brand?: string;
|
|
139
|
-
sku?: string;
|
|
140
|
-
stock?: number;
|
|
141
|
-
tags?: string[];
|
|
142
|
-
categories?: number[];
|
|
143
|
-
rating?: number;
|
|
144
|
-
review_count?: number;
|
|
145
|
-
featured?: boolean;
|
|
146
|
-
is_new?: boolean;
|
|
147
|
-
published?: boolean;
|
|
148
|
-
specifications?: Record<string, unknown>;
|
|
149
|
-
variants?: Array<{ id: string; name: string; value: string; price?: number; image?: string; stockQuantity: number }>;
|
|
150
|
-
created_at?: string;
|
|
151
|
-
updated_at?: string;
|
|
152
|
-
meta_description?: string;
|
|
153
|
-
meta_keywords?: string;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export interface DbProductTranslation {
|
|
157
|
-
id: number;
|
|
158
|
-
product_id: number;
|
|
159
|
-
language_code: string;
|
|
160
|
-
name: string;
|
|
161
|
-
description?: string;
|
|
162
|
-
brand?: string;
|
|
163
|
-
meta_description?: string;
|
|
164
|
-
meta_keywords?: string;
|
|
165
|
-
created_at?: string;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface DbProductInput {
|
|
169
|
-
id?: number;
|
|
170
|
-
slug: string;
|
|
171
|
-
price: number;
|
|
172
|
-
sale_price?: number;
|
|
173
|
-
on_sale?: boolean;
|
|
174
|
-
images?: string[];
|
|
175
|
-
sku?: string;
|
|
176
|
-
stock?: number;
|
|
177
|
-
tags?: string[];
|
|
178
|
-
categories?: number[];
|
|
179
|
-
rating?: number;
|
|
180
|
-
review_count?: number;
|
|
181
|
-
featured?: boolean;
|
|
182
|
-
is_new?: boolean;
|
|
183
|
-
published?: boolean;
|
|
184
|
-
specifications?: Record<string, unknown>;
|
|
185
|
-
variants?: Array<{ id: string; name: string; value: string; price?: number; image?: string; stockQuantity: number }>;
|
|
186
|
-
created_at?: string;
|
|
187
|
-
updated_at?: string;
|
|
188
|
-
translations?: Record<string, {
|
|
189
|
-
name: string;
|
|
190
|
-
description?: string;
|
|
191
|
-
brand?: string;
|
|
192
|
-
meta_description?: string;
|
|
193
|
-
meta_keywords?: string;
|
|
194
|
-
}>;
|
|
195
|
-
}
|
|
1
|
+
// Auto-generated from schemas - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
// From promake schema
|
|
4
|
+
export interface DbBlogCategory {
|
|
5
|
+
id?: number;
|
|
6
|
+
name: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
image?: string;
|
|
10
|
+
created_at?: string;
|
|
11
|
+
updated_at?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface DbBlogCategoryTranslation {
|
|
15
|
+
id: number;
|
|
16
|
+
blog_category_id: number;
|
|
17
|
+
language_code: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
created_at?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface DbBlogCategoryInput {
|
|
24
|
+
id?: number;
|
|
25
|
+
slug: string;
|
|
26
|
+
image?: string;
|
|
27
|
+
created_at?: string;
|
|
28
|
+
updated_at?: string;
|
|
29
|
+
translations?: Record<string, {
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface DbPost {
|
|
36
|
+
id?: number;
|
|
37
|
+
title: string;
|
|
38
|
+
slug: string;
|
|
39
|
+
content: string;
|
|
40
|
+
excerpt?: string;
|
|
41
|
+
featured_image?: string;
|
|
42
|
+
images?: string[];
|
|
43
|
+
author?: string;
|
|
44
|
+
author_avatar?: string;
|
|
45
|
+
created_at?: string;
|
|
46
|
+
published_at?: string;
|
|
47
|
+
updated_at?: string;
|
|
48
|
+
tags?: string[];
|
|
49
|
+
categories?: number[];
|
|
50
|
+
read_time?: number;
|
|
51
|
+
view_count?: number;
|
|
52
|
+
featured?: boolean;
|
|
53
|
+
published?: boolean;
|
|
54
|
+
meta_description?: string;
|
|
55
|
+
meta_keywords?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface DbPostTranslation {
|
|
59
|
+
id: number;
|
|
60
|
+
post_id: number;
|
|
61
|
+
language_code: string;
|
|
62
|
+
title: string;
|
|
63
|
+
content: string;
|
|
64
|
+
excerpt?: string;
|
|
65
|
+
author?: string;
|
|
66
|
+
meta_description?: string;
|
|
67
|
+
meta_keywords?: string;
|
|
68
|
+
created_at?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface DbPostInput {
|
|
72
|
+
id?: number;
|
|
73
|
+
slug: string;
|
|
74
|
+
featured_image?: string;
|
|
75
|
+
images?: string[];
|
|
76
|
+
author_avatar?: string;
|
|
77
|
+
created_at?: string;
|
|
78
|
+
published_at?: string;
|
|
79
|
+
updated_at?: string;
|
|
80
|
+
tags?: string[];
|
|
81
|
+
categories?: number[];
|
|
82
|
+
read_time?: number;
|
|
83
|
+
view_count?: number;
|
|
84
|
+
featured?: boolean;
|
|
85
|
+
published?: boolean;
|
|
86
|
+
translations?: Record<string, {
|
|
87
|
+
title: string;
|
|
88
|
+
content: string;
|
|
89
|
+
excerpt?: string;
|
|
90
|
+
author?: string;
|
|
91
|
+
meta_description?: string;
|
|
92
|
+
meta_keywords?: string;
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface DbProductCategory {
|
|
97
|
+
id?: number;
|
|
98
|
+
name: string;
|
|
99
|
+
slug: string;
|
|
100
|
+
description?: string;
|
|
101
|
+
image?: string;
|
|
102
|
+
parent_id?: number;
|
|
103
|
+
created_at?: string;
|
|
104
|
+
updated_at?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface DbProductCategoryTranslation {
|
|
108
|
+
id: number;
|
|
109
|
+
product_category_id: number;
|
|
110
|
+
language_code: string;
|
|
111
|
+
name: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
created_at?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface DbProductCategoryInput {
|
|
117
|
+
id?: number;
|
|
118
|
+
slug: string;
|
|
119
|
+
image?: string;
|
|
120
|
+
parent_id?: number;
|
|
121
|
+
created_at?: string;
|
|
122
|
+
updated_at?: string;
|
|
123
|
+
translations?: Record<string, {
|
|
124
|
+
name: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
}>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface DbProduct {
|
|
130
|
+
id?: number;
|
|
131
|
+
name: string;
|
|
132
|
+
slug: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
price: number;
|
|
135
|
+
sale_price?: number;
|
|
136
|
+
on_sale?: boolean;
|
|
137
|
+
images?: string[];
|
|
138
|
+
brand?: string;
|
|
139
|
+
sku?: string;
|
|
140
|
+
stock?: number;
|
|
141
|
+
tags?: string[];
|
|
142
|
+
categories?: number[];
|
|
143
|
+
rating?: number;
|
|
144
|
+
review_count?: number;
|
|
145
|
+
featured?: boolean;
|
|
146
|
+
is_new?: boolean;
|
|
147
|
+
published?: boolean;
|
|
148
|
+
specifications?: Record<string, unknown>;
|
|
149
|
+
variants?: Array<{ id: string; name: string; value: string; price?: number; image?: string; stockQuantity: number }>;
|
|
150
|
+
created_at?: string;
|
|
151
|
+
updated_at?: string;
|
|
152
|
+
meta_description?: string;
|
|
153
|
+
meta_keywords?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface DbProductTranslation {
|
|
157
|
+
id: number;
|
|
158
|
+
product_id: number;
|
|
159
|
+
language_code: string;
|
|
160
|
+
name: string;
|
|
161
|
+
description?: string;
|
|
162
|
+
brand?: string;
|
|
163
|
+
meta_description?: string;
|
|
164
|
+
meta_keywords?: string;
|
|
165
|
+
created_at?: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface DbProductInput {
|
|
169
|
+
id?: number;
|
|
170
|
+
slug: string;
|
|
171
|
+
price: number;
|
|
172
|
+
sale_price?: number;
|
|
173
|
+
on_sale?: boolean;
|
|
174
|
+
images?: string[];
|
|
175
|
+
sku?: string;
|
|
176
|
+
stock?: number;
|
|
177
|
+
tags?: string[];
|
|
178
|
+
categories?: number[];
|
|
179
|
+
rating?: number;
|
|
180
|
+
review_count?: number;
|
|
181
|
+
featured?: boolean;
|
|
182
|
+
is_new?: boolean;
|
|
183
|
+
published?: boolean;
|
|
184
|
+
specifications?: Record<string, unknown>;
|
|
185
|
+
variants?: Array<{ id: string; name: string; value: string; price?: number; image?: string; stockQuantity: number }>;
|
|
186
|
+
created_at?: string;
|
|
187
|
+
updated_at?: string;
|
|
188
|
+
translations?: Record<string, {
|
|
189
|
+
name: string;
|
|
190
|
+
description?: string;
|
|
191
|
+
brand?: string;
|
|
192
|
+
meta_description?: string;
|
|
193
|
+
meta_keywords?: string;
|
|
194
|
+
}>;
|
|
195
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
export function useDebouncedValue<T>(value: T, delay = 300): T {
|
|
4
|
-
const [debounced, setDebounced] = useState(value);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const timer = setTimeout(() => setDebounced(value), delay);
|
|
8
|
-
return () => clearTimeout(timer);
|
|
9
|
-
}, [value, delay]);
|
|
10
|
-
|
|
11
|
-
return debounced;
|
|
12
|
-
}
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
export function useDebouncedValue<T>(value: T, delay = 300): T {
|
|
4
|
+
const [debounced, setDebounced] = useState(value);
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const timer = setTimeout(() => setDebounced(value), delay);
|
|
8
|
+
return () => clearTimeout(timer);
|
|
9
|
+
}, [value, delay]);
|
|
10
|
+
|
|
11
|
+
return debounced;
|
|
12
|
+
}
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import i18n from "i18next";
|
|
2
|
-
import { initReactI18next } from "react-i18next";
|
|
3
|
-
import LanguageDetector from "i18next-browser-languagedetector";
|
|
4
|
-
|
|
5
|
-
import constants from "@/constants/constants.json";
|
|
6
|
-
|
|
7
|
-
// Auto-import translations from two locations:
|
|
8
|
-
// 1. Core: @/lang/{lang}/{namespace}.json (e.g., lang/en/header.json)
|
|
9
|
-
// 2. Modules: @/modules/{namespace}/lang/{lang}.json (e.g., modules/about-page/lang/en.json)
|
|
10
|
-
const coreLangs = import.meta.glob("@/lang/*/*.json", { eager: true });
|
|
11
|
-
const moduleLangs = import.meta.glob("@/modules/*/lang/*.json", { eager: true });
|
|
12
|
-
|
|
13
|
-
// Get available languages from config
|
|
14
|
-
const availableLanguages =
|
|
15
|
-
Object.keys(constants?.site?.availableLanguages || {}) || [];
|
|
16
|
-
|
|
17
|
-
// Build resources object: { en: { header: {...}, about-page: {...} }, tr: {...} }
|
|
18
|
-
const resources: Record<string, Record<string, any>> = {};
|
|
19
|
-
|
|
20
|
-
// Process core translations: /lang/{lang}/{namespace}.json
|
|
21
|
-
Object.entries(coreLangs).forEach(([path, module]) => {
|
|
22
|
-
const match = path.match(/\/lang\/([^/]+)\/([^/]+)\.json$/);
|
|
23
|
-
if (match) {
|
|
24
|
-
const [, lang, namespace] = match;
|
|
25
|
-
if (!availableLanguages.includes(lang)) return;
|
|
26
|
-
if (!resources[lang]) resources[lang] = {};
|
|
27
|
-
resources[lang][namespace] = (module as any).default || module;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Process module translations: /modules/{namespace}/lang/{lang}.json
|
|
32
|
-
Object.entries(moduleLangs).forEach(([path, module]) => {
|
|
33
|
-
const match = path.match(/\/modules\/([^/]+)\/lang\/([^/]+)\.json$/);
|
|
34
|
-
if (match) {
|
|
35
|
-
const [, namespace, lang] = match;
|
|
36
|
-
if (!availableLanguages.includes(lang)) return;
|
|
37
|
-
if (!resources[lang]) resources[lang] = {};
|
|
38
|
-
const moduleData = (module as any).default || module;
|
|
39
|
-
resources[lang][namespace] = {
|
|
40
|
-
...moduleData,
|
|
41
|
-
...resources[lang][namespace],
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Custom detector for cached settings
|
|
47
|
-
const settingsDetector = {
|
|
48
|
-
name: "settingsDetector",
|
|
49
|
-
lookup() {
|
|
50
|
-
if (constants.site.overrideBrowserLanguage) {
|
|
51
|
-
return constants?.site?.defaultLanguage;
|
|
52
|
-
}
|
|
53
|
-
return undefined;
|
|
54
|
-
},
|
|
55
|
-
cacheUserLanguage() {
|
|
56
|
-
// Don't cache - settings detector is read-only
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// Create detector instance and add custom detector
|
|
61
|
-
const languageDetector = new LanguageDetector();
|
|
62
|
-
languageDetector.addDetector(settingsDetector);
|
|
63
|
-
|
|
64
|
-
i18n
|
|
65
|
-
.use(languageDetector)
|
|
66
|
-
.use(initReactI18next)
|
|
67
|
-
.init({
|
|
68
|
-
resources,
|
|
69
|
-
fallbackLng: constants?.site?.defaultLanguage || "en",
|
|
70
|
-
supportedLngs: availableLanguages,
|
|
71
|
-
detection: {
|
|
72
|
-
// Priority: localStorage > settings > browser
|
|
73
|
-
order: ["localStorage", "settingsDetector", "navigator"],
|
|
74
|
-
lookupLocalStorage: "i18nextLng",
|
|
75
|
-
caches: ["localStorage"],
|
|
76
|
-
},
|
|
77
|
-
interpolation: {
|
|
78
|
-
escapeValue: false,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// Helper to change language and persist to localStorage
|
|
83
|
-
export const changeLanguage = (lang: string) => {
|
|
84
|
-
if (availableLanguages.includes(lang)) {
|
|
85
|
-
i18n.changeLanguage(lang);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export { availableLanguages };
|
|
90
|
-
export default i18n;
|
|
1
|
+
import i18n from "i18next";
|
|
2
|
+
import { initReactI18next } from "react-i18next";
|
|
3
|
+
import LanguageDetector from "i18next-browser-languagedetector";
|
|
4
|
+
|
|
5
|
+
import constants from "@/constants/constants.json";
|
|
6
|
+
|
|
7
|
+
// Auto-import translations from two locations:
|
|
8
|
+
// 1. Core: @/lang/{lang}/{namespace}.json (e.g., lang/en/header.json)
|
|
9
|
+
// 2. Modules: @/modules/{namespace}/lang/{lang}.json (e.g., modules/about-page/lang/en.json)
|
|
10
|
+
const coreLangs = import.meta.glob("@/lang/*/*.json", { eager: true });
|
|
11
|
+
const moduleLangs = import.meta.glob("@/modules/*/lang/*.json", { eager: true });
|
|
12
|
+
|
|
13
|
+
// Get available languages from config
|
|
14
|
+
const availableLanguages =
|
|
15
|
+
Object.keys(constants?.site?.availableLanguages || {}) || [];
|
|
16
|
+
|
|
17
|
+
// Build resources object: { en: { header: {...}, about-page: {...} }, tr: {...} }
|
|
18
|
+
const resources: Record<string, Record<string, any>> = {};
|
|
19
|
+
|
|
20
|
+
// Process core translations: /lang/{lang}/{namespace}.json
|
|
21
|
+
Object.entries(coreLangs).forEach(([path, module]) => {
|
|
22
|
+
const match = path.match(/\/lang\/([^/]+)\/([^/]+)\.json$/);
|
|
23
|
+
if (match) {
|
|
24
|
+
const [, lang, namespace] = match;
|
|
25
|
+
if (!availableLanguages.includes(lang)) return;
|
|
26
|
+
if (!resources[lang]) resources[lang] = {};
|
|
27
|
+
resources[lang][namespace] = (module as any).default || module;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Process module translations: /modules/{namespace}/lang/{lang}.json
|
|
32
|
+
Object.entries(moduleLangs).forEach(([path, module]) => {
|
|
33
|
+
const match = path.match(/\/modules\/([^/]+)\/lang\/([^/]+)\.json$/);
|
|
34
|
+
if (match) {
|
|
35
|
+
const [, namespace, lang] = match;
|
|
36
|
+
if (!availableLanguages.includes(lang)) return;
|
|
37
|
+
if (!resources[lang]) resources[lang] = {};
|
|
38
|
+
const moduleData = (module as any).default || module;
|
|
39
|
+
resources[lang][namespace] = {
|
|
40
|
+
...moduleData,
|
|
41
|
+
...resources[lang][namespace],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Custom detector for cached settings
|
|
47
|
+
const settingsDetector = {
|
|
48
|
+
name: "settingsDetector",
|
|
49
|
+
lookup() {
|
|
50
|
+
if (constants.site.overrideBrowserLanguage) {
|
|
51
|
+
return constants?.site?.defaultLanguage;
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
},
|
|
55
|
+
cacheUserLanguage() {
|
|
56
|
+
// Don't cache - settings detector is read-only
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Create detector instance and add custom detector
|
|
61
|
+
const languageDetector = new LanguageDetector();
|
|
62
|
+
languageDetector.addDetector(settingsDetector);
|
|
63
|
+
|
|
64
|
+
i18n
|
|
65
|
+
.use(languageDetector)
|
|
66
|
+
.use(initReactI18next)
|
|
67
|
+
.init({
|
|
68
|
+
resources,
|
|
69
|
+
fallbackLng: constants?.site?.defaultLanguage || "en",
|
|
70
|
+
supportedLngs: availableLanguages,
|
|
71
|
+
detection: {
|
|
72
|
+
// Priority: localStorage > settings > browser
|
|
73
|
+
order: ["localStorage", "settingsDetector", "navigator"],
|
|
74
|
+
lookupLocalStorage: "i18nextLng",
|
|
75
|
+
caches: ["localStorage"],
|
|
76
|
+
},
|
|
77
|
+
interpolation: {
|
|
78
|
+
escapeValue: false,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Helper to change language and persist to localStorage
|
|
83
|
+
export const changeLanguage = (lang: string) => {
|
|
84
|
+
if (availableLanguages.includes(lang)) {
|
|
85
|
+
i18n.changeLanguage(lang);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { availableLanguages };
|
|
90
|
+
export default i18n;
|