@foxpixel/react 0.2.1 → 0.2.2
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/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -352,11 +352,33 @@ function withAuth(Component, options = {}) {
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
// src/components/Editable.tsx
|
|
355
|
-
import { createElement, useCallback as useCallback3, useState as useState7 } from "react";
|
|
355
|
+
import { createElement, useCallback as useCallback3, useState as useState7, useEffect as useEffect7 } from "react";
|
|
356
356
|
|
|
357
357
|
// src/hooks/useEditMode.ts
|
|
358
358
|
import { useEffect as useEffect5, useState as useState5, useCallback as useCallback2 } from "react";
|
|
359
359
|
var SITE_CONTENT_QUERY_KEY = "siteContent";
|
|
360
|
+
var contentKeysOnPage = /* @__PURE__ */ new Set();
|
|
361
|
+
var flushTimer = null;
|
|
362
|
+
function scheduleFlushContentKeys() {
|
|
363
|
+
if (flushTimer) return;
|
|
364
|
+
flushTimer = setTimeout(() => {
|
|
365
|
+
flushTimer = null;
|
|
366
|
+
if (typeof window !== "undefined" && window.parent !== window) {
|
|
367
|
+
window.parent.postMessage(
|
|
368
|
+
{ type: "FOXPIXEL_READY", payload: { contentKeys: Array.from(contentKeysOnPage) } },
|
|
369
|
+
"*"
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
}, 150);
|
|
373
|
+
}
|
|
374
|
+
function registerContentKey(key) {
|
|
375
|
+
contentKeysOnPage.add(key);
|
|
376
|
+
scheduleFlushContentKeys();
|
|
377
|
+
}
|
|
378
|
+
function unregisterContentKey(key) {
|
|
379
|
+
contentKeysOnPage.delete(key);
|
|
380
|
+
scheduleFlushContentKeys();
|
|
381
|
+
}
|
|
360
382
|
function useEditMode() {
|
|
361
383
|
const [isEditMode, setIsEditMode] = useState5(false);
|
|
362
384
|
useEffect5(() => {
|
|
@@ -588,6 +610,12 @@ function Editable({
|
|
|
588
610
|
defaultValue
|
|
589
611
|
});
|
|
590
612
|
const section = contentKey.includes(".") ? contentKey.split(".")[0] : void 0;
|
|
613
|
+
useEffect7(() => {
|
|
614
|
+
if (isEditMode) {
|
|
615
|
+
registerContentKey(contentKey);
|
|
616
|
+
return () => unregisterContentKey(contentKey);
|
|
617
|
+
}
|
|
618
|
+
}, [isEditMode, contentKey]);
|
|
591
619
|
const handleClick = useCallback3(
|
|
592
620
|
(e) => {
|
|
593
621
|
if (isEditMode) {
|
|
@@ -683,6 +711,12 @@ function EditableHTML({
|
|
|
683
711
|
defaultValue
|
|
684
712
|
});
|
|
685
713
|
const section = contentKey.includes(".") ? contentKey.split(".")[0] : void 0;
|
|
714
|
+
useEffect7(() => {
|
|
715
|
+
if (isEditMode) {
|
|
716
|
+
registerContentKey(contentKey);
|
|
717
|
+
return () => unregisterContentKey(contentKey);
|
|
718
|
+
}
|
|
719
|
+
}, [isEditMode, contentKey]);
|
|
686
720
|
const handleClick = useCallback3(
|
|
687
721
|
(e) => {
|
|
688
722
|
if (isEditMode) {
|
|
@@ -749,6 +783,12 @@ function EditableImage({
|
|
|
749
783
|
defaultValue
|
|
750
784
|
});
|
|
751
785
|
const section = contentKey.includes(".") ? contentKey.split(".")[0] : void 0;
|
|
786
|
+
useEffect7(() => {
|
|
787
|
+
if (isEditMode) {
|
|
788
|
+
registerContentKey(contentKey);
|
|
789
|
+
return () => unregisterContentKey(contentKey);
|
|
790
|
+
}
|
|
791
|
+
}, [isEditMode, contentKey]);
|
|
752
792
|
const handleClick = useCallback3(
|
|
753
793
|
(e) => {
|
|
754
794
|
if (isEditMode) {
|
|
@@ -812,7 +852,7 @@ function EditableImage({
|
|
|
812
852
|
}
|
|
813
853
|
|
|
814
854
|
// src/hooks/useServices.ts
|
|
815
|
-
import { useState as useState8, useEffect as
|
|
855
|
+
import { useState as useState8, useEffect as useEffect8 } from "react";
|
|
816
856
|
function useServices(options = {}) {
|
|
817
857
|
const { client } = useFoxPixelContext();
|
|
818
858
|
const [services, setServices] = useState8(null);
|
|
@@ -835,7 +875,7 @@ function useServices(options = {}) {
|
|
|
835
875
|
setIsLoading(false);
|
|
836
876
|
}
|
|
837
877
|
};
|
|
838
|
-
|
|
878
|
+
useEffect8(() => {
|
|
839
879
|
fetchServices();
|
|
840
880
|
}, [options.category, options.active]);
|
|
841
881
|
return {
|
|
@@ -901,7 +941,7 @@ function useContactCapture() {
|
|
|
901
941
|
}
|
|
902
942
|
|
|
903
943
|
// src/hooks/useSiteContent.ts
|
|
904
|
-
import { useState as useState11, useEffect as
|
|
944
|
+
import { useState as useState11, useEffect as useEffect9, useCallback as useCallback4 } from "react";
|
|
905
945
|
function useSiteContent(contentKey, options = {}) {
|
|
906
946
|
const { defaultValue = "", fetchOnMount = true } = options;
|
|
907
947
|
const { client } = useFoxPixelContext();
|
|
@@ -941,7 +981,7 @@ function useSiteContent(contentKey, options = {}) {
|
|
|
941
981
|
throw err;
|
|
942
982
|
}
|
|
943
983
|
}, [client, contentKey]);
|
|
944
|
-
|
|
984
|
+
useEffect9(() => {
|
|
945
985
|
if (fetchOnMount) {
|
|
946
986
|
fetchContent();
|
|
947
987
|
}
|
|
@@ -983,7 +1023,7 @@ function useSiteContents(contentKeys, options = {}) {
|
|
|
983
1023
|
setIsLoading(false);
|
|
984
1024
|
}
|
|
985
1025
|
}, [client, contentKeys.join(",")]);
|
|
986
|
-
|
|
1026
|
+
useEffect9(() => {
|
|
987
1027
|
fetchContents();
|
|
988
1028
|
}, [fetchContents]);
|
|
989
1029
|
const getValue = useCallback4((key, defaultValue) => {
|
|
@@ -1020,7 +1060,7 @@ function useSiteContentSection(section) {
|
|
|
1020
1060
|
setIsLoading(false);
|
|
1021
1061
|
}
|
|
1022
1062
|
}, [client, section]);
|
|
1023
|
-
|
|
1063
|
+
useEffect9(() => {
|
|
1024
1064
|
fetchContents();
|
|
1025
1065
|
}, [fetchContents]);
|
|
1026
1066
|
return {
|
|
@@ -1062,7 +1102,7 @@ async function prefetchSiteContent(queryClient, options) {
|
|
|
1062
1102
|
}
|
|
1063
1103
|
|
|
1064
1104
|
// src/blog/hooks.ts
|
|
1065
|
-
import { useState as useState12, useEffect as
|
|
1105
|
+
import { useState as useState12, useEffect as useEffect10 } from "react";
|
|
1066
1106
|
function useBlogPosts(options = {}) {
|
|
1067
1107
|
const { client } = useFoxPixelContext();
|
|
1068
1108
|
const [data, setData] = useState12(null);
|
|
@@ -1087,7 +1127,7 @@ function useBlogPosts(options = {}) {
|
|
|
1087
1127
|
setIsLoading(false);
|
|
1088
1128
|
}
|
|
1089
1129
|
};
|
|
1090
|
-
|
|
1130
|
+
useEffect10(() => {
|
|
1091
1131
|
fetchPosts();
|
|
1092
1132
|
}, [page, limit]);
|
|
1093
1133
|
return {
|
|
@@ -1120,7 +1160,7 @@ function useBlogPost(slug) {
|
|
|
1120
1160
|
setIsLoading(false);
|
|
1121
1161
|
}
|
|
1122
1162
|
};
|
|
1123
|
-
|
|
1163
|
+
useEffect10(() => {
|
|
1124
1164
|
fetchPost();
|
|
1125
1165
|
}, [slug]);
|
|
1126
1166
|
return {
|
|
@@ -1148,7 +1188,7 @@ function useBlogCategories() {
|
|
|
1148
1188
|
setIsLoading(false);
|
|
1149
1189
|
}
|
|
1150
1190
|
};
|
|
1151
|
-
|
|
1191
|
+
useEffect10(() => {
|
|
1152
1192
|
fetchCategories();
|
|
1153
1193
|
}, []);
|
|
1154
1194
|
return {
|
|
@@ -1176,7 +1216,7 @@ function useBlogTags() {
|
|
|
1176
1216
|
setIsLoading(false);
|
|
1177
1217
|
}
|
|
1178
1218
|
};
|
|
1179
|
-
|
|
1219
|
+
useEffect10(() => {
|
|
1180
1220
|
fetchTags();
|
|
1181
1221
|
}, []);
|
|
1182
1222
|
return {
|
|
@@ -1211,7 +1251,7 @@ function useBlogComments(slug) {
|
|
|
1211
1251
|
setIsLoading(false);
|
|
1212
1252
|
}
|
|
1213
1253
|
};
|
|
1214
|
-
|
|
1254
|
+
useEffect10(() => {
|
|
1215
1255
|
fetchComments();
|
|
1216
1256
|
}, [slug]);
|
|
1217
1257
|
return {
|
|
@@ -1272,7 +1312,7 @@ function useBlogFeaturedPosts(limit = 6) {
|
|
|
1272
1312
|
setIsLoading(false);
|
|
1273
1313
|
}
|
|
1274
1314
|
};
|
|
1275
|
-
|
|
1315
|
+
useEffect10(() => {
|
|
1276
1316
|
fetchFeatured();
|
|
1277
1317
|
}, [limit]);
|
|
1278
1318
|
return {
|
|
@@ -1366,7 +1406,7 @@ function useNewsletterUnsubscribe() {
|
|
|
1366
1406
|
}
|
|
1367
1407
|
|
|
1368
1408
|
// src/blog/admin-hooks.ts
|
|
1369
|
-
import { useState as useState13, useEffect as
|
|
1409
|
+
import { useState as useState13, useEffect as useEffect11, useCallback as useCallback5 } from "react";
|
|
1370
1410
|
function useAdminBlogPosts(options = {}) {
|
|
1371
1411
|
const { client } = useFoxPixelContext();
|
|
1372
1412
|
const [data, setData] = useState13(null);
|
|
@@ -1389,7 +1429,7 @@ function useAdminBlogPosts(options = {}) {
|
|
|
1389
1429
|
setIsLoading(false);
|
|
1390
1430
|
}
|
|
1391
1431
|
}, [client, page, size]);
|
|
1392
|
-
|
|
1432
|
+
useEffect11(() => {
|
|
1393
1433
|
fetchPosts();
|
|
1394
1434
|
}, [fetchPosts]);
|
|
1395
1435
|
return { data, isLoading, error, refetch: fetchPosts };
|
|
@@ -1416,7 +1456,7 @@ function useAdminBlogPost(id) {
|
|
|
1416
1456
|
setIsLoading(false);
|
|
1417
1457
|
}
|
|
1418
1458
|
}, [client, id]);
|
|
1419
|
-
|
|
1459
|
+
useEffect11(() => {
|
|
1420
1460
|
fetchPost();
|
|
1421
1461
|
}, [fetchPost]);
|
|
1422
1462
|
return { data, isLoading, error, refetch: fetchPost };
|
|
@@ -1483,7 +1523,7 @@ function useAdminBlogCategories() {
|
|
|
1483
1523
|
setIsLoading(false);
|
|
1484
1524
|
}
|
|
1485
1525
|
}, [client]);
|
|
1486
|
-
|
|
1526
|
+
useEffect11(() => {
|
|
1487
1527
|
fetchCategories();
|
|
1488
1528
|
}, [fetchCategories]);
|
|
1489
1529
|
const create = async (payload) => {
|
|
@@ -1535,7 +1575,7 @@ function useAdminBlogTags() {
|
|
|
1535
1575
|
setIsLoading(false);
|
|
1536
1576
|
}
|
|
1537
1577
|
}, [client]);
|
|
1538
|
-
|
|
1578
|
+
useEffect11(() => {
|
|
1539
1579
|
fetchTags();
|
|
1540
1580
|
}, [fetchTags]);
|
|
1541
1581
|
const create = async (payload) => {
|
|
@@ -1593,7 +1633,7 @@ function useAdminBlogComments(options = {}) {
|
|
|
1593
1633
|
setIsLoading(false);
|
|
1594
1634
|
}
|
|
1595
1635
|
}, [client, status, postId, page, size]);
|
|
1596
|
-
|
|
1636
|
+
useEffect11(() => {
|
|
1597
1637
|
fetchComments();
|
|
1598
1638
|
}, [fetchComments]);
|
|
1599
1639
|
const updateStatus = async (id, newStatus) => {
|
|
@@ -1640,7 +1680,7 @@ function useAdminNewsletterSubscribers(options = {}) {
|
|
|
1640
1680
|
setIsLoading(false);
|
|
1641
1681
|
}
|
|
1642
1682
|
}, [client, status, page, size]);
|
|
1643
|
-
|
|
1683
|
+
useEffect11(() => {
|
|
1644
1684
|
fetchSubscribers();
|
|
1645
1685
|
}, [fetchSubscribers]);
|
|
1646
1686
|
const remove = async (id) => {
|
|
@@ -1672,7 +1712,7 @@ function useAdminNewsletterStats() {
|
|
|
1672
1712
|
setIsLoading(false);
|
|
1673
1713
|
}
|
|
1674
1714
|
}, [client]);
|
|
1675
|
-
|
|
1715
|
+
useEffect11(() => {
|
|
1676
1716
|
fetchStats();
|
|
1677
1717
|
}, [fetchStats]);
|
|
1678
1718
|
return { data, isLoading, error, refetch: fetchStats };
|
|
@@ -1694,7 +1734,7 @@ function useAdminBlogSettings() {
|
|
|
1694
1734
|
setIsLoading(false);
|
|
1695
1735
|
}
|
|
1696
1736
|
}, [client]);
|
|
1697
|
-
|
|
1737
|
+
useEffect11(() => {
|
|
1698
1738
|
fetchSettings();
|
|
1699
1739
|
}, [fetchSettings]);
|
|
1700
1740
|
const update = async (settings) => {
|
|
@@ -1726,7 +1766,7 @@ function useAdminBlogAnalytics() {
|
|
|
1726
1766
|
setIsLoading(false);
|
|
1727
1767
|
}
|
|
1728
1768
|
}, [client]);
|
|
1729
|
-
|
|
1769
|
+
useEffect11(() => {
|
|
1730
1770
|
fetchAnalytics();
|
|
1731
1771
|
}, [fetchAnalytics]);
|
|
1732
1772
|
return { data, isLoading, error, refetch: fetchAnalytics };
|