@depict-ai/react-ui 4.1.2 → 4.1.3
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/ES10/index.cjs +28 -12
- package/ES10/index.d.ts +2 -0
- package/ES10/index.js +28 -12
- package/latest/index.cjs +25 -12
- package/latest/index.d.ts +2 -0
- package/latest/index.js +25 -12
- package/package.json +1 -1
- package/server/ES10/index.cjs +17 -5
- package/server/ES10/index.d.ts +2 -0
- package/server/ES10/index.js +18 -6
- package/server/latest/index.cjs +14 -5
- package/server/latest/index.d.ts +2 -0
- package/server/latest/index.js +15 -6
package/ES10/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ $parcel$export(module.exports, "version", () => $efbdd2dab4314170$export$83d89fb
|
|
|
42
42
|
$parcel$export(module.exports, "Navigation", () => $0d3a2413fdeb34b9$export$b8a61e5c71402559);
|
|
43
43
|
/*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
|
|
44
44
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
45
|
-
const $efbdd2dab4314170$export$83d89fbfd8236492 = "4.1.
|
|
45
|
+
const $efbdd2dab4314170$export$83d89fbfd8236492 = "4.1.3";
|
|
46
46
|
const $ef516b1f92253963$export$8e769ad4338a911e = {
|
|
47
47
|
usedLocale: $2kiy7$solidjs.createSignal((0, $2kiy7$depictaiuilocales.defaultLocale)),
|
|
48
48
|
search_instances: new Map(),
|
|
@@ -512,20 +512,27 @@ async function $3441d987b5ea85cb$export$32024253978abdc7(_ref) {
|
|
|
512
512
|
component_props: component_props,
|
|
513
513
|
component_portals: component_portals,
|
|
514
514
|
set_portals: set_portals,
|
|
515
|
-
get_react_template: get_react_template
|
|
515
|
+
get_react_template: get_react_template,
|
|
516
|
+
set_on_index_change_: set_on_index_change_
|
|
516
517
|
} = _ref;
|
|
517
518
|
let set_react_has_ran_hooks;
|
|
518
519
|
let was_cleaned_up = false;
|
|
519
520
|
const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
|
|
520
521
|
const solid_container = document.createElement("div");
|
|
522
|
+
const [setIndexFunctionAccessor, setIndexFunctionSetter] = $2kiy7$solidjs.createSignal();
|
|
521
523
|
let call_when_template_changes;
|
|
522
524
|
const owner = $2kiy7$solidjs.getOwner();
|
|
523
525
|
const reactProductCard = $2kiy7$reactjsxruntime.jsx(props => {
|
|
524
526
|
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
525
527
|
$2kiy7$react.useEffect(set_react_has_ran_hooks, []);
|
|
526
528
|
const [react_template, set_react_template] = $2kiy7$react.useState(() => $2kiy7$solidjs.untrack(get_react_template));
|
|
529
|
+
const [index, setIndex] = $2kiy7$react.useState(0);
|
|
530
|
+
setIndexFunctionSetter(() => setIndex);
|
|
527
531
|
call_when_template_changes = set_react_template;
|
|
528
|
-
return react_template(
|
|
532
|
+
return react_template(set_on_index_change_ ? {
|
|
533
|
+
...props,
|
|
534
|
+
index: index
|
|
535
|
+
} : props);
|
|
529
536
|
}, component_props);
|
|
530
537
|
const reactProductCardInErrorBoundary = $2kiy7$reactjsxruntime.jsx((0, $e9048b15cf1e8792$export$d0f82e3ef89b1f22), {
|
|
531
538
|
children: reactProductCard,
|
|
@@ -537,6 +544,10 @@ async function $3441d987b5ea85cb$export$32024253978abdc7(_ref) {
|
|
|
537
544
|
const portal = $2kiy7$reactdom.createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
538
545
|
component_portals.add(portal);
|
|
539
546
|
set_portals([...component_portals]);
|
|
547
|
+
set_on_index_change_ === null || set_on_index_change_ === void 0 || set_on_index_change_(newIndex => {
|
|
548
|
+
var _setIndexFunctionAcce;
|
|
549
|
+
return (_setIndexFunctionAcce = setIndexFunctionAccessor()) === null || _setIndexFunctionAcce === void 0 ? void 0 : _setIndexFunctionAcce(newIndex);
|
|
550
|
+
});
|
|
540
551
|
$2kiy7$solidjs.createEffect($2kiy7$solidjs.on(get_react_template, new_template => queueMicrotask(() => {
|
|
541
552
|
var _call_when_template_c;
|
|
542
553
|
return (
|
|
@@ -676,13 +687,14 @@ function $a81b3f46133355c5$var$SolidSearchPage(props, set_portals) {
|
|
|
676
687
|
return (_props$gridSpacing = props.gridSpacing) !== null && _props$gridSpacing !== void 0 ? _props$gridSpacing : (0, $2kiy7$depictaiui.defaultGridSpacing);
|
|
677
688
|
},
|
|
678
689
|
depict_search: depict_search(),
|
|
679
|
-
product_card_template: display => $3441d987b5ea85cb$export$32024253978abdc7({
|
|
690
|
+
product_card_template: (display, info) => $3441d987b5ea85cb$export$32024253978abdc7({
|
|
680
691
|
component_props: {
|
|
681
692
|
display: display
|
|
682
693
|
},
|
|
683
694
|
get_react_template: () => props.productCard,
|
|
684
695
|
component_portals: component_portals,
|
|
685
|
-
set_portals: set_portals
|
|
696
|
+
set_portals: set_portals,
|
|
697
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
686
698
|
}),
|
|
687
699
|
get content_blocks_by_row() {
|
|
688
700
|
return transformed_content_blocks();
|
|
@@ -779,13 +791,15 @@ function $b0f04d11b78e06c3$var$SolidCategoryPage(props, set_portals) {
|
|
|
779
791
|
get layout() {
|
|
780
792
|
return props.layout;
|
|
781
793
|
},
|
|
782
|
-
product_card_template: display => $3441d987b5ea85cb$export$32024253978abdc7({
|
|
794
|
+
product_card_template: (display, info) => $3441d987b5ea85cb$export$32024253978abdc7({
|
|
783
795
|
component_props: {
|
|
784
|
-
display: display
|
|
796
|
+
display: display,
|
|
797
|
+
info: info
|
|
785
798
|
},
|
|
786
799
|
get_react_template: () => props.productCard,
|
|
787
800
|
component_portals: component_portals,
|
|
788
|
-
set_portals: set_portals
|
|
801
|
+
set_portals: set_portals,
|
|
802
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
789
803
|
})
|
|
790
804
|
});
|
|
791
805
|
});
|
|
@@ -886,13 +900,14 @@ function $745b83c12baac3c0$export$5abb40edfde2a843(props, set_portals) {
|
|
|
886
900
|
get recommendations() {
|
|
887
901
|
return props.recommendations;
|
|
888
902
|
},
|
|
889
|
-
product_card_template: display => $3441d987b5ea85cb$export$32024253978abdc7({
|
|
903
|
+
product_card_template: (display, info) => $3441d987b5ea85cb$export$32024253978abdc7({
|
|
890
904
|
component_props: {
|
|
891
905
|
display: display
|
|
892
906
|
},
|
|
893
907
|
get_react_template: () => props.productCard,
|
|
894
908
|
component_portals: component_portals,
|
|
895
|
-
set_portals: set_portals
|
|
909
|
+
set_portals: set_portals,
|
|
910
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
896
911
|
}),
|
|
897
912
|
get cols_at_size() {
|
|
898
913
|
return props.columnsAtSize || (0, $2kiy7$depictaiui.defaultColsAtSize);
|
|
@@ -912,7 +927,7 @@ function $3b36cc844440a979$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
912
927
|
get recommendations() {
|
|
913
928
|
return props.recommendations;
|
|
914
929
|
},
|
|
915
|
-
product_card_template: display => {
|
|
930
|
+
product_card_template: (display, info) => {
|
|
916
931
|
if (0, $2kiy7$solidjsweb.isServer) {
|
|
917
932
|
// This function can't be async on the server
|
|
918
933
|
// @ts-ignore emulate the wrapper div that we need in prod here too for consistency
|
|
@@ -927,7 +942,8 @@ function $3b36cc844440a979$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
927
942
|
},
|
|
928
943
|
get_react_template: () => props.productCard,
|
|
929
944
|
component_portals: component_portals,
|
|
930
|
-
set_portals: set_portals
|
|
945
|
+
set_portals: set_portals,
|
|
946
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
931
947
|
});
|
|
932
948
|
},
|
|
933
949
|
get cols_at_size() {
|
package/ES10/index.d.ts
CHANGED
|
@@ -162,6 +162,8 @@ interface PLPConfig<T extends Display> extends BaseProductListingConfig {
|
|
|
162
162
|
export interface DepictProductCardProps<T extends Display> {
|
|
163
163
|
/** The display data to render. */
|
|
164
164
|
display: T | null;
|
|
165
|
+
/** The index of the product card. Please note that product cards may stay at the same place (not get re-rendered) or move around as the results change. */
|
|
166
|
+
index: number;
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
167
169
|
* Depict product card to use for rendering products.
|
package/ES10/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { renderToString as $jb2Oo$renderToString } from "react-dom/server";
|
|
|
15
15
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
16
16
|
import { register_es_version } from "../multi_import_deduplicator.mjs";
|
|
17
17
|
register_es_version("react-ui", "ES10");
|
|
18
|
-
const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "4.1.
|
|
18
|
+
const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "4.1.3";
|
|
19
19
|
const $8c691d7f86317052$export$8e769ad4338a911e = {
|
|
20
20
|
usedLocale: $jb2Oo$createSignal((0, $jb2Oo$defaultLocale)),
|
|
21
21
|
search_instances: new Map(),
|
|
@@ -485,20 +485,27 @@ async function $cce08f18e2476cbf$export$32024253978abdc7(_ref) {
|
|
|
485
485
|
component_props: component_props,
|
|
486
486
|
component_portals: component_portals,
|
|
487
487
|
set_portals: set_portals,
|
|
488
|
-
get_react_template: get_react_template
|
|
488
|
+
get_react_template: get_react_template,
|
|
489
|
+
set_on_index_change_: set_on_index_change_
|
|
489
490
|
} = _ref;
|
|
490
491
|
let set_react_has_ran_hooks;
|
|
491
492
|
let was_cleaned_up = false;
|
|
492
493
|
const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
|
|
493
494
|
const solid_container = document.createElement("div");
|
|
495
|
+
const [setIndexFunctionAccessor, setIndexFunctionSetter] = $jb2Oo$createSignal();
|
|
494
496
|
let call_when_template_changes;
|
|
495
497
|
const owner = $jb2Oo$getOwner();
|
|
496
498
|
const reactProductCard = $jb2Oo$jsx(props => {
|
|
497
499
|
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
498
500
|
$jb2Oo$useEffect(set_react_has_ran_hooks, []);
|
|
499
501
|
const [react_template, set_react_template] = $jb2Oo$useState(() => $jb2Oo$untrack(get_react_template));
|
|
502
|
+
const [index, setIndex] = $jb2Oo$useState(0);
|
|
503
|
+
setIndexFunctionSetter(() => setIndex);
|
|
500
504
|
call_when_template_changes = set_react_template;
|
|
501
|
-
return react_template(
|
|
505
|
+
return react_template(set_on_index_change_ ? {
|
|
506
|
+
...props,
|
|
507
|
+
index: index
|
|
508
|
+
} : props);
|
|
502
509
|
}, component_props);
|
|
503
510
|
const reactProductCardInErrorBoundary = $jb2Oo$jsx((0, $88d93ed7309e90d1$export$d0f82e3ef89b1f22), {
|
|
504
511
|
children: reactProductCard,
|
|
@@ -510,6 +517,10 @@ async function $cce08f18e2476cbf$export$32024253978abdc7(_ref) {
|
|
|
510
517
|
const portal = $jb2Oo$createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
511
518
|
component_portals.add(portal);
|
|
512
519
|
set_portals([...component_portals]);
|
|
520
|
+
set_on_index_change_ === null || set_on_index_change_ === void 0 || set_on_index_change_(newIndex => {
|
|
521
|
+
var _setIndexFunctionAcce;
|
|
522
|
+
return (_setIndexFunctionAcce = setIndexFunctionAccessor()) === null || _setIndexFunctionAcce === void 0 ? void 0 : _setIndexFunctionAcce(newIndex);
|
|
523
|
+
});
|
|
513
524
|
$jb2Oo$createEffect($jb2Oo$on(get_react_template, new_template => queueMicrotask(() => {
|
|
514
525
|
var _call_when_template_c;
|
|
515
526
|
return (
|
|
@@ -649,13 +660,14 @@ function $f33e2dee70c97da3$var$SolidSearchPage(props, set_portals) {
|
|
|
649
660
|
return (_props$gridSpacing = props.gridSpacing) !== null && _props$gridSpacing !== void 0 ? _props$gridSpacing : (0, $jb2Oo$defaultGridSpacing);
|
|
650
661
|
},
|
|
651
662
|
depict_search: depict_search(),
|
|
652
|
-
product_card_template: display => $cce08f18e2476cbf$export$32024253978abdc7({
|
|
663
|
+
product_card_template: (display, info) => $cce08f18e2476cbf$export$32024253978abdc7({
|
|
653
664
|
component_props: {
|
|
654
665
|
display: display
|
|
655
666
|
},
|
|
656
667
|
get_react_template: () => props.productCard,
|
|
657
668
|
component_portals: component_portals,
|
|
658
|
-
set_portals: set_portals
|
|
669
|
+
set_portals: set_portals,
|
|
670
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
659
671
|
}),
|
|
660
672
|
get content_blocks_by_row() {
|
|
661
673
|
return transformed_content_blocks();
|
|
@@ -752,13 +764,15 @@ function $710dda89475e8c05$var$SolidCategoryPage(props, set_portals) {
|
|
|
752
764
|
get layout() {
|
|
753
765
|
return props.layout;
|
|
754
766
|
},
|
|
755
|
-
product_card_template: display => $cce08f18e2476cbf$export$32024253978abdc7({
|
|
767
|
+
product_card_template: (display, info) => $cce08f18e2476cbf$export$32024253978abdc7({
|
|
756
768
|
component_props: {
|
|
757
|
-
display: display
|
|
769
|
+
display: display,
|
|
770
|
+
info: info
|
|
758
771
|
},
|
|
759
772
|
get_react_template: () => props.productCard,
|
|
760
773
|
component_portals: component_portals,
|
|
761
|
-
set_portals: set_portals
|
|
774
|
+
set_portals: set_portals,
|
|
775
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
762
776
|
})
|
|
763
777
|
});
|
|
764
778
|
});
|
|
@@ -859,13 +873,14 @@ function $c02e9fd51f31a1bd$export$5abb40edfde2a843(props, set_portals) {
|
|
|
859
873
|
get recommendations() {
|
|
860
874
|
return props.recommendations;
|
|
861
875
|
},
|
|
862
|
-
product_card_template: display => $cce08f18e2476cbf$export$32024253978abdc7({
|
|
876
|
+
product_card_template: (display, info) => $cce08f18e2476cbf$export$32024253978abdc7({
|
|
863
877
|
component_props: {
|
|
864
878
|
display: display
|
|
865
879
|
},
|
|
866
880
|
get_react_template: () => props.productCard,
|
|
867
881
|
component_portals: component_portals,
|
|
868
|
-
set_portals: set_portals
|
|
882
|
+
set_portals: set_portals,
|
|
883
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
869
884
|
}),
|
|
870
885
|
get cols_at_size() {
|
|
871
886
|
return props.columnsAtSize || (0, $jb2Oo$defaultColsAtSize);
|
|
@@ -885,7 +900,7 @@ function $cd68097a7ee08669$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
885
900
|
get recommendations() {
|
|
886
901
|
return props.recommendations;
|
|
887
902
|
},
|
|
888
|
-
product_card_template: display => {
|
|
903
|
+
product_card_template: (display, info) => {
|
|
889
904
|
if (0, $jb2Oo$isServer) {
|
|
890
905
|
// This function can't be async on the server
|
|
891
906
|
// @ts-ignore emulate the wrapper div that we need in prod here too for consistency
|
|
@@ -900,7 +915,8 @@ function $cd68097a7ee08669$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
900
915
|
},
|
|
901
916
|
get_react_template: () => props.productCard,
|
|
902
917
|
component_portals: component_portals,
|
|
903
|
-
set_portals: set_portals
|
|
918
|
+
set_portals: set_portals,
|
|
919
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
904
920
|
});
|
|
905
921
|
},
|
|
906
922
|
get cols_at_size() {
|
package/latest/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ $parcel$export(module.exports, "version", () => $db7b67857900028b$export$83d89fb
|
|
|
42
42
|
$parcel$export(module.exports, "Navigation", () => $b742053c966024b4$export$b8a61e5c71402559);
|
|
43
43
|
/*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
|
|
44
44
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
45
|
-
const $db7b67857900028b$export$83d89fbfd8236492 = "4.1.
|
|
45
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "4.1.3";
|
|
46
46
|
const $0b7cd4fb39fc3502$export$8e769ad4338a911e = {
|
|
47
47
|
usedLocale: $2IzJs$solidjs.createSignal((0, $2IzJs$depictaiuilocales.defaultLocale)),
|
|
48
48
|
search_instances: new Map(),
|
|
@@ -488,20 +488,27 @@ async function $6081519c185fcf70$export$32024253978abdc7({
|
|
|
488
488
|
component_props: component_props,
|
|
489
489
|
component_portals: component_portals,
|
|
490
490
|
set_portals: set_portals,
|
|
491
|
-
get_react_template: get_react_template
|
|
491
|
+
get_react_template: get_react_template,
|
|
492
|
+
set_on_index_change_: set_on_index_change_
|
|
492
493
|
}) {
|
|
493
494
|
let set_react_has_ran_hooks;
|
|
494
495
|
let was_cleaned_up = false;
|
|
495
496
|
const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
|
|
496
497
|
const solid_container = document.createElement("div");
|
|
498
|
+
const [setIndexFunctionAccessor, setIndexFunctionSetter] = $2IzJs$solidjs.createSignal();
|
|
497
499
|
let call_when_template_changes;
|
|
498
500
|
const owner = $2IzJs$solidjs.getOwner();
|
|
499
501
|
const reactProductCard = $2IzJs$reactjsxruntime.jsx(props => {
|
|
500
502
|
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
501
503
|
$2IzJs$react.useEffect(set_react_has_ran_hooks, []);
|
|
502
504
|
const [react_template, set_react_template] = $2IzJs$react.useState(() => $2IzJs$solidjs.untrack(get_react_template));
|
|
505
|
+
const [index, setIndex] = $2IzJs$react.useState(0);
|
|
506
|
+
setIndexFunctionSetter(() => setIndex);
|
|
503
507
|
call_when_template_changes = set_react_template;
|
|
504
|
-
return react_template(
|
|
508
|
+
return react_template(set_on_index_change_ ? {
|
|
509
|
+
...props,
|
|
510
|
+
index: index
|
|
511
|
+
} : props);
|
|
505
512
|
}, component_props);
|
|
506
513
|
const reactProductCardInErrorBoundary = $2IzJs$reactjsxruntime.jsx((0, $d7a14567b529586f$export$d0f82e3ef89b1f22), {
|
|
507
514
|
children: reactProductCard,
|
|
@@ -513,6 +520,7 @@ async function $6081519c185fcf70$export$32024253978abdc7({
|
|
|
513
520
|
const portal = $2IzJs$reactdom.createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
514
521
|
component_portals.add(portal);
|
|
515
522
|
set_portals([...component_portals]);
|
|
523
|
+
set_on_index_change_?.(newIndex => setIndexFunctionAccessor()?.(newIndex));
|
|
516
524
|
$2IzJs$solidjs.createEffect($2IzJs$solidjs.on(get_react_template, new_template => queueMicrotask(() =>
|
|
517
525
|
// When the parent react component re-executes and provides a new product card, we want our react portal to also re-render
|
|
518
526
|
// if we update the state inside the portal synchronously from the parent call react gets confused with "Warning: Cannot update a component (`Unknown`) while rendering a different component (`$48d7f568740a317d$export$f7d2f673fc2f091d`). To locate the bad setState() call inside `$48d7f568740a317d$export$f7d2f673fc2f091d`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render"
|
|
@@ -642,13 +650,14 @@ function $4e47e1e003da166e$var$SolidSearchPage(props, set_portals) {
|
|
|
642
650
|
return props.gridSpacing ?? (0, $2IzJs$depictaiui.defaultGridSpacing);
|
|
643
651
|
},
|
|
644
652
|
depict_search: depict_search(),
|
|
645
|
-
product_card_template: display => $6081519c185fcf70$export$32024253978abdc7({
|
|
653
|
+
product_card_template: (display, info) => $6081519c185fcf70$export$32024253978abdc7({
|
|
646
654
|
component_props: {
|
|
647
655
|
display: display
|
|
648
656
|
},
|
|
649
657
|
get_react_template: () => props.productCard,
|
|
650
658
|
component_portals: component_portals,
|
|
651
|
-
set_portals: set_portals
|
|
659
|
+
set_portals: set_portals,
|
|
660
|
+
set_on_index_change_: info?.set_on_index_change
|
|
652
661
|
}),
|
|
653
662
|
get content_blocks_by_row() {
|
|
654
663
|
return transformed_content_blocks();
|
|
@@ -742,13 +751,15 @@ function $03d75efbc2476217$var$SolidCategoryPage(props, set_portals) {
|
|
|
742
751
|
get layout() {
|
|
743
752
|
return props.layout;
|
|
744
753
|
},
|
|
745
|
-
product_card_template: display => $6081519c185fcf70$export$32024253978abdc7({
|
|
754
|
+
product_card_template: (display, info) => $6081519c185fcf70$export$32024253978abdc7({
|
|
746
755
|
component_props: {
|
|
747
|
-
display: display
|
|
756
|
+
display: display,
|
|
757
|
+
info: info
|
|
748
758
|
},
|
|
749
759
|
get_react_template: () => props.productCard,
|
|
750
760
|
component_portals: component_portals,
|
|
751
|
-
set_portals: set_portals
|
|
761
|
+
set_portals: set_portals,
|
|
762
|
+
set_on_index_change_: info?.set_on_index_change
|
|
752
763
|
})
|
|
753
764
|
});
|
|
754
765
|
});
|
|
@@ -847,13 +858,14 @@ function $8ffd7da37fdd46be$export$5abb40edfde2a843(props, set_portals) {
|
|
|
847
858
|
get recommendations() {
|
|
848
859
|
return props.recommendations;
|
|
849
860
|
},
|
|
850
|
-
product_card_template: display => $6081519c185fcf70$export$32024253978abdc7({
|
|
861
|
+
product_card_template: (display, info) => $6081519c185fcf70$export$32024253978abdc7({
|
|
851
862
|
component_props: {
|
|
852
863
|
display: display
|
|
853
864
|
},
|
|
854
865
|
get_react_template: () => props.productCard,
|
|
855
866
|
component_portals: component_portals,
|
|
856
|
-
set_portals: set_portals
|
|
867
|
+
set_portals: set_portals,
|
|
868
|
+
set_on_index_change_: info?.set_on_index_change
|
|
857
869
|
}),
|
|
858
870
|
get cols_at_size() {
|
|
859
871
|
return props.columnsAtSize || (0, $2IzJs$depictaiui.defaultColsAtSize);
|
|
@@ -872,7 +884,7 @@ function $c6b960f2a07285c8$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
872
884
|
get recommendations() {
|
|
873
885
|
return props.recommendations;
|
|
874
886
|
},
|
|
875
|
-
product_card_template: display => {
|
|
887
|
+
product_card_template: (display, info) => {
|
|
876
888
|
if (0, $2IzJs$solidjsweb.isServer) {
|
|
877
889
|
// This function can't be async on the server
|
|
878
890
|
// @ts-ignore emulate the wrapper div that we need in prod here too for consistency
|
|
@@ -887,7 +899,8 @@ function $c6b960f2a07285c8$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
887
899
|
},
|
|
888
900
|
get_react_template: () => props.productCard,
|
|
889
901
|
component_portals: component_portals,
|
|
890
|
-
set_portals: set_portals
|
|
902
|
+
set_portals: set_portals,
|
|
903
|
+
set_on_index_change_: info?.set_on_index_change
|
|
891
904
|
});
|
|
892
905
|
},
|
|
893
906
|
get cols_at_size() {
|
package/latest/index.d.ts
CHANGED
|
@@ -162,6 +162,8 @@ interface PLPConfig<T extends Display> extends BaseProductListingConfig {
|
|
|
162
162
|
export interface DepictProductCardProps<T extends Display> {
|
|
163
163
|
/** The display data to render. */
|
|
164
164
|
display: T | null;
|
|
165
|
+
/** The index of the product card. Please note that product cards may stay at the same place (not get re-rendered) or move around as the results change. */
|
|
166
|
+
index: number;
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
167
169
|
* Depict product card to use for rendering products.
|
package/latest/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { renderToString as $2GFvs$renderToString } from "react-dom/server";
|
|
|
15
15
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
16
16
|
import { register_es_version } from "../multi_import_deduplicator.mjs";
|
|
17
17
|
register_es_version("react-ui", "latest");
|
|
18
|
-
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "4.1.
|
|
18
|
+
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "4.1.3";
|
|
19
19
|
const $42858f023ef23dab$export$8e769ad4338a911e = {
|
|
20
20
|
usedLocale: $2GFvs$createSignal((0, $2GFvs$defaultLocale)),
|
|
21
21
|
search_instances: new Map(),
|
|
@@ -461,20 +461,27 @@ async function $bcf84a32dc612a43$export$32024253978abdc7({
|
|
|
461
461
|
component_props: component_props,
|
|
462
462
|
component_portals: component_portals,
|
|
463
463
|
set_portals: set_portals,
|
|
464
|
-
get_react_template: get_react_template
|
|
464
|
+
get_react_template: get_react_template,
|
|
465
|
+
set_on_index_change_: set_on_index_change_
|
|
465
466
|
}) {
|
|
466
467
|
let set_react_has_ran_hooks;
|
|
467
468
|
let was_cleaned_up = false;
|
|
468
469
|
const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
|
|
469
470
|
const solid_container = document.createElement("div");
|
|
471
|
+
const [setIndexFunctionAccessor, setIndexFunctionSetter] = $2GFvs$createSignal();
|
|
470
472
|
let call_when_template_changes;
|
|
471
473
|
const owner = $2GFvs$getOwner();
|
|
472
474
|
const reactProductCard = $2GFvs$jsx(props => {
|
|
473
475
|
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
474
476
|
$2GFvs$useEffect(set_react_has_ran_hooks, []);
|
|
475
477
|
const [react_template, set_react_template] = $2GFvs$useState(() => $2GFvs$untrack(get_react_template));
|
|
478
|
+
const [index, setIndex] = $2GFvs$useState(0);
|
|
479
|
+
setIndexFunctionSetter(() => setIndex);
|
|
476
480
|
call_when_template_changes = set_react_template;
|
|
477
|
-
return react_template(
|
|
481
|
+
return react_template(set_on_index_change_ ? {
|
|
482
|
+
...props,
|
|
483
|
+
index: index
|
|
484
|
+
} : props);
|
|
478
485
|
}, component_props);
|
|
479
486
|
const reactProductCardInErrorBoundary = $2GFvs$jsx((0, $d5c9e1f3545b4984$export$d0f82e3ef89b1f22), {
|
|
480
487
|
children: reactProductCard,
|
|
@@ -486,6 +493,7 @@ async function $bcf84a32dc612a43$export$32024253978abdc7({
|
|
|
486
493
|
const portal = $2GFvs$createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
487
494
|
component_portals.add(portal);
|
|
488
495
|
set_portals([...component_portals]);
|
|
496
|
+
set_on_index_change_?.(newIndex => setIndexFunctionAccessor()?.(newIndex));
|
|
489
497
|
$2GFvs$createEffect($2GFvs$on(get_react_template, new_template => queueMicrotask(() =>
|
|
490
498
|
// When the parent react component re-executes and provides a new product card, we want our react portal to also re-render
|
|
491
499
|
// if we update the state inside the portal synchronously from the parent call react gets confused with "Warning: Cannot update a component (`Unknown`) while rendering a different component (`$48d7f568740a317d$export$f7d2f673fc2f091d`). To locate the bad setState() call inside `$48d7f568740a317d$export$f7d2f673fc2f091d`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render"
|
|
@@ -615,13 +623,14 @@ function $2f377099d56e566c$var$SolidSearchPage(props, set_portals) {
|
|
|
615
623
|
return props.gridSpacing ?? (0, $2GFvs$defaultGridSpacing);
|
|
616
624
|
},
|
|
617
625
|
depict_search: depict_search(),
|
|
618
|
-
product_card_template: display => $bcf84a32dc612a43$export$32024253978abdc7({
|
|
626
|
+
product_card_template: (display, info) => $bcf84a32dc612a43$export$32024253978abdc7({
|
|
619
627
|
component_props: {
|
|
620
628
|
display: display
|
|
621
629
|
},
|
|
622
630
|
get_react_template: () => props.productCard,
|
|
623
631
|
component_portals: component_portals,
|
|
624
|
-
set_portals: set_portals
|
|
632
|
+
set_portals: set_portals,
|
|
633
|
+
set_on_index_change_: info?.set_on_index_change
|
|
625
634
|
}),
|
|
626
635
|
get content_blocks_by_row() {
|
|
627
636
|
return transformed_content_blocks();
|
|
@@ -715,13 +724,15 @@ function $6e2ebc6b1506f2c7$var$SolidCategoryPage(props, set_portals) {
|
|
|
715
724
|
get layout() {
|
|
716
725
|
return props.layout;
|
|
717
726
|
},
|
|
718
|
-
product_card_template: display => $bcf84a32dc612a43$export$32024253978abdc7({
|
|
727
|
+
product_card_template: (display, info) => $bcf84a32dc612a43$export$32024253978abdc7({
|
|
719
728
|
component_props: {
|
|
720
|
-
display: display
|
|
729
|
+
display: display,
|
|
730
|
+
info: info
|
|
721
731
|
},
|
|
722
732
|
get_react_template: () => props.productCard,
|
|
723
733
|
component_portals: component_portals,
|
|
724
|
-
set_portals: set_portals
|
|
734
|
+
set_portals: set_portals,
|
|
735
|
+
set_on_index_change_: info?.set_on_index_change
|
|
725
736
|
})
|
|
726
737
|
});
|
|
727
738
|
});
|
|
@@ -820,13 +831,14 @@ function $4fd5dc0e231a60d9$export$5abb40edfde2a843(props, set_portals) {
|
|
|
820
831
|
get recommendations() {
|
|
821
832
|
return props.recommendations;
|
|
822
833
|
},
|
|
823
|
-
product_card_template: display => $bcf84a32dc612a43$export$32024253978abdc7({
|
|
834
|
+
product_card_template: (display, info) => $bcf84a32dc612a43$export$32024253978abdc7({
|
|
824
835
|
component_props: {
|
|
825
836
|
display: display
|
|
826
837
|
},
|
|
827
838
|
get_react_template: () => props.productCard,
|
|
828
839
|
component_portals: component_portals,
|
|
829
|
-
set_portals: set_portals
|
|
840
|
+
set_portals: set_portals,
|
|
841
|
+
set_on_index_change_: info?.set_on_index_change
|
|
830
842
|
}),
|
|
831
843
|
get cols_at_size() {
|
|
832
844
|
return props.columnsAtSize || (0, $2GFvs$defaultColsAtSize);
|
|
@@ -845,7 +857,7 @@ function $4d5c3f13a5ae62a7$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
845
857
|
get recommendations() {
|
|
846
858
|
return props.recommendations;
|
|
847
859
|
},
|
|
848
|
-
product_card_template: display => {
|
|
860
|
+
product_card_template: (display, info) => {
|
|
849
861
|
if (0, $2GFvs$isServer) {
|
|
850
862
|
// This function can't be async on the server
|
|
851
863
|
// @ts-ignore emulate the wrapper div that we need in prod here too for consistency
|
|
@@ -860,7 +872,8 @@ function $4d5c3f13a5ae62a7$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
860
872
|
},
|
|
861
873
|
get_react_template: () => props.productCard,
|
|
862
874
|
component_portals: component_portals,
|
|
863
|
-
set_portals: set_portals
|
|
875
|
+
set_portals: set_portals,
|
|
876
|
+
set_on_index_change_: info?.set_on_index_change
|
|
864
877
|
});
|
|
865
878
|
},
|
|
866
879
|
get cols_at_size() {
|
package/package.json
CHANGED
package/server/ES10/index.cjs
CHANGED
|
@@ -96,20 +96,27 @@ async function $3441d987b5ea85cb$export$32024253978abdc7(_ref) {
|
|
|
96
96
|
component_props: component_props,
|
|
97
97
|
component_portals: component_portals,
|
|
98
98
|
set_portals: set_portals,
|
|
99
|
-
get_react_template: get_react_template
|
|
99
|
+
get_react_template: get_react_template,
|
|
100
|
+
set_on_index_change_: set_on_index_change_
|
|
100
101
|
} = _ref;
|
|
101
102
|
let set_react_has_ran_hooks;
|
|
102
103
|
let was_cleaned_up = false;
|
|
103
104
|
const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
|
|
104
105
|
const solid_container = document.createElement("div");
|
|
106
|
+
const [setIndexFunctionAccessor, setIndexFunctionSetter] = $aNCHr$solidjs.createSignal();
|
|
105
107
|
let call_when_template_changes;
|
|
106
108
|
const owner = $aNCHr$solidjs.getOwner();
|
|
107
109
|
const reactProductCard = $aNCHr$reactjsxruntime.jsx(props => {
|
|
108
110
|
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
109
111
|
$aNCHr$react.useEffect(set_react_has_ran_hooks, []);
|
|
110
112
|
const [react_template, set_react_template] = $aNCHr$react.useState(() => $aNCHr$solidjs.untrack(get_react_template));
|
|
113
|
+
const [index, setIndex] = $aNCHr$react.useState(0);
|
|
114
|
+
setIndexFunctionSetter(() => setIndex);
|
|
111
115
|
call_when_template_changes = set_react_template;
|
|
112
|
-
return react_template(
|
|
116
|
+
return react_template(set_on_index_change_ ? {
|
|
117
|
+
...props,
|
|
118
|
+
index: index
|
|
119
|
+
} : props);
|
|
113
120
|
}, component_props);
|
|
114
121
|
const reactProductCardInErrorBoundary = $aNCHr$reactjsxruntime.jsx((0, $e9048b15cf1e8792$export$d0f82e3ef89b1f22), {
|
|
115
122
|
children: reactProductCard,
|
|
@@ -121,6 +128,10 @@ async function $3441d987b5ea85cb$export$32024253978abdc7(_ref) {
|
|
|
121
128
|
const portal = $aNCHr$reactdom.createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
122
129
|
component_portals.add(portal);
|
|
123
130
|
set_portals([...component_portals]);
|
|
131
|
+
set_on_index_change_ === null || set_on_index_change_ === void 0 || set_on_index_change_(newIndex => {
|
|
132
|
+
var _setIndexFunctionAcce;
|
|
133
|
+
return (_setIndexFunctionAcce = setIndexFunctionAccessor()) === null || _setIndexFunctionAcce === void 0 ? void 0 : _setIndexFunctionAcce(newIndex);
|
|
134
|
+
});
|
|
124
135
|
$aNCHr$solidjs.createEffect($aNCHr$solidjs.on(get_react_template, new_template => queueMicrotask(() => {
|
|
125
136
|
var _call_when_template_c;
|
|
126
137
|
return (
|
|
@@ -147,7 +158,7 @@ function $3b36cc844440a979$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
147
158
|
get recommendations() {
|
|
148
159
|
return props.recommendations;
|
|
149
160
|
},
|
|
150
|
-
product_card_template: display => {
|
|
161
|
+
product_card_template: (display, info) => {
|
|
151
162
|
if (0, $aNCHr$solidjsweb.isServer) {
|
|
152
163
|
// This function can't be async on the server
|
|
153
164
|
// @ts-ignore emulate the wrapper div that we need in prod here too for consistency
|
|
@@ -162,7 +173,8 @@ function $3b36cc844440a979$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
162
173
|
},
|
|
163
174
|
get_react_template: () => props.productCard,
|
|
164
175
|
component_portals: component_portals,
|
|
165
|
-
set_portals: set_portals
|
|
176
|
+
set_portals: set_portals,
|
|
177
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
166
178
|
});
|
|
167
179
|
},
|
|
168
180
|
get cols_at_size() {
|
|
@@ -191,7 +203,7 @@ function $3b36cc844440a979$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
191
203
|
}
|
|
192
204
|
});
|
|
193
205
|
}
|
|
194
|
-
const $efbdd2dab4314170$export$83d89fbfd8236492 = "4.1.
|
|
206
|
+
const $efbdd2dab4314170$export$83d89fbfd8236492 = "4.1.3";
|
|
195
207
|
function $202459d454907b31$export$9fac37a9c21c2f3b(props) {
|
|
196
208
|
return props.children;
|
|
197
209
|
}
|
package/server/ES10/index.d.ts
CHANGED
|
@@ -162,6 +162,8 @@ interface PLPConfig<T extends Display> extends BaseProductListingConfig {
|
|
|
162
162
|
export interface DepictProductCardProps<T extends Display> {
|
|
163
163
|
/** The display data to render. */
|
|
164
164
|
display: T | null;
|
|
165
|
+
/** The index of the product card. Please note that product cards may stay at the same place (not get re-rendered) or move around as the results change. */
|
|
166
|
+
index: number;
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
167
169
|
* Depict product card to use for rendering products.
|
package/server/ES10/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ImagePlaceholder as $7h5e1$ImagePlaceholder, TextPlaceholder as $7h5e1$
|
|
|
4
4
|
import { generateHydrationScript as $7h5e1$generateHydrationScript, renderToString as $7h5e1$renderToString, isServer as $7h5e1$isServer, ssr as $7h5e1$ssr, ssrHydrationKey as $7h5e1$ssrHydrationKey } from "solid-js/web";
|
|
5
5
|
import { dwarn as $7h5e1$dwarn } from "@depict-ai/utilishared/ES10";
|
|
6
6
|
import { renderToString as $7h5e1$renderToString1 } from "react-dom/server";
|
|
7
|
-
import { getOwner as $7h5e1$getOwner, untrack as $7h5e1$untrack, runWithOwner as $7h5e1$runWithOwner, createEffect as $7h5e1$createEffect, on as $7h5e1$on, onCleanup as $7h5e1$onCleanup } from "solid-js";
|
|
7
|
+
import { createSignal as $7h5e1$createSignal, getOwner as $7h5e1$getOwner, untrack as $7h5e1$untrack, runWithOwner as $7h5e1$runWithOwner, createEffect as $7h5e1$createEffect, on as $7h5e1$on, onCleanup as $7h5e1$onCleanup } from "solid-js";
|
|
8
8
|
import { jsx as $7h5e1$jsx } from "react/jsx-runtime";
|
|
9
9
|
import { createPortal as $7h5e1$createPortal } from "react-dom";
|
|
10
10
|
|
|
@@ -72,20 +72,27 @@ async function $cce08f18e2476cbf$export$32024253978abdc7(_ref) {
|
|
|
72
72
|
component_props: component_props,
|
|
73
73
|
component_portals: component_portals,
|
|
74
74
|
set_portals: set_portals,
|
|
75
|
-
get_react_template: get_react_template
|
|
75
|
+
get_react_template: get_react_template,
|
|
76
|
+
set_on_index_change_: set_on_index_change_
|
|
76
77
|
} = _ref;
|
|
77
78
|
let set_react_has_ran_hooks;
|
|
78
79
|
let was_cleaned_up = false;
|
|
79
80
|
const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
|
|
80
81
|
const solid_container = document.createElement("div");
|
|
82
|
+
const [setIndexFunctionAccessor, setIndexFunctionSetter] = $7h5e1$createSignal();
|
|
81
83
|
let call_when_template_changes;
|
|
82
84
|
const owner = $7h5e1$getOwner();
|
|
83
85
|
const reactProductCard = $7h5e1$jsx(props => {
|
|
84
86
|
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
85
87
|
$7h5e1$useEffect(set_react_has_ran_hooks, []);
|
|
86
88
|
const [react_template, set_react_template] = $7h5e1$useState(() => $7h5e1$untrack(get_react_template));
|
|
89
|
+
const [index, setIndex] = $7h5e1$useState(0);
|
|
90
|
+
setIndexFunctionSetter(() => setIndex);
|
|
87
91
|
call_when_template_changes = set_react_template;
|
|
88
|
-
return react_template(
|
|
92
|
+
return react_template(set_on_index_change_ ? {
|
|
93
|
+
...props,
|
|
94
|
+
index: index
|
|
95
|
+
} : props);
|
|
89
96
|
}, component_props);
|
|
90
97
|
const reactProductCardInErrorBoundary = $7h5e1$jsx((0, $88d93ed7309e90d1$export$d0f82e3ef89b1f22), {
|
|
91
98
|
children: reactProductCard,
|
|
@@ -97,6 +104,10 @@ async function $cce08f18e2476cbf$export$32024253978abdc7(_ref) {
|
|
|
97
104
|
const portal = $7h5e1$createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
98
105
|
component_portals.add(portal);
|
|
99
106
|
set_portals([...component_portals]);
|
|
107
|
+
set_on_index_change_ === null || set_on_index_change_ === void 0 || set_on_index_change_(newIndex => {
|
|
108
|
+
var _setIndexFunctionAcce;
|
|
109
|
+
return (_setIndexFunctionAcce = setIndexFunctionAccessor()) === null || _setIndexFunctionAcce === void 0 ? void 0 : _setIndexFunctionAcce(newIndex);
|
|
110
|
+
});
|
|
100
111
|
$7h5e1$createEffect($7h5e1$on(get_react_template, new_template => queueMicrotask(() => {
|
|
101
112
|
var _call_when_template_c;
|
|
102
113
|
return (
|
|
@@ -123,7 +134,7 @@ function $cd68097a7ee08669$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
123
134
|
get recommendations() {
|
|
124
135
|
return props.recommendations;
|
|
125
136
|
},
|
|
126
|
-
product_card_template: display => {
|
|
137
|
+
product_card_template: (display, info) => {
|
|
127
138
|
if (0, $7h5e1$isServer) {
|
|
128
139
|
// This function can't be async on the server
|
|
129
140
|
// @ts-ignore emulate the wrapper div that we need in prod here too for consistency
|
|
@@ -138,7 +149,8 @@ function $cd68097a7ee08669$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
138
149
|
},
|
|
139
150
|
get_react_template: () => props.productCard,
|
|
140
151
|
component_portals: component_portals,
|
|
141
|
-
set_portals: set_portals
|
|
152
|
+
set_portals: set_portals,
|
|
153
|
+
set_on_index_change_: info === null || info === void 0 ? void 0 : info.set_on_index_change
|
|
142
154
|
});
|
|
143
155
|
},
|
|
144
156
|
get cols_at_size() {
|
|
@@ -167,7 +179,7 @@ function $cd68097a7ee08669$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
167
179
|
}
|
|
168
180
|
});
|
|
169
181
|
}
|
|
170
|
-
const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "4.1.
|
|
182
|
+
const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "4.1.3";
|
|
171
183
|
function $5c4add0a8fe94894$export$9fac37a9c21c2f3b(props) {
|
|
172
184
|
return props.children;
|
|
173
185
|
}
|
package/server/latest/index.cjs
CHANGED
|
@@ -93,20 +93,27 @@ async function $6081519c185fcf70$export$32024253978abdc7({
|
|
|
93
93
|
component_props: component_props,
|
|
94
94
|
component_portals: component_portals,
|
|
95
95
|
set_portals: set_portals,
|
|
96
|
-
get_react_template: get_react_template
|
|
96
|
+
get_react_template: get_react_template,
|
|
97
|
+
set_on_index_change_: set_on_index_change_
|
|
97
98
|
}) {
|
|
98
99
|
let set_react_has_ran_hooks;
|
|
99
100
|
let was_cleaned_up = false;
|
|
100
101
|
const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
|
|
101
102
|
const solid_container = document.createElement("div");
|
|
103
|
+
const [setIndexFunctionAccessor, setIndexFunctionSetter] = $7QqFM$solidjs.createSignal();
|
|
102
104
|
let call_when_template_changes;
|
|
103
105
|
const owner = $7QqFM$solidjs.getOwner();
|
|
104
106
|
const reactProductCard = $7QqFM$reactjsxruntime.jsx(props => {
|
|
105
107
|
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
106
108
|
$7QqFM$react.useEffect(set_react_has_ran_hooks, []);
|
|
107
109
|
const [react_template, set_react_template] = $7QqFM$react.useState(() => $7QqFM$solidjs.untrack(get_react_template));
|
|
110
|
+
const [index, setIndex] = $7QqFM$react.useState(0);
|
|
111
|
+
setIndexFunctionSetter(() => setIndex);
|
|
108
112
|
call_when_template_changes = set_react_template;
|
|
109
|
-
return react_template(
|
|
113
|
+
return react_template(set_on_index_change_ ? {
|
|
114
|
+
...props,
|
|
115
|
+
index: index
|
|
116
|
+
} : props);
|
|
110
117
|
}, component_props);
|
|
111
118
|
const reactProductCardInErrorBoundary = $7QqFM$reactjsxruntime.jsx((0, $d7a14567b529586f$export$d0f82e3ef89b1f22), {
|
|
112
119
|
children: reactProductCard,
|
|
@@ -118,6 +125,7 @@ async function $6081519c185fcf70$export$32024253978abdc7({
|
|
|
118
125
|
const portal = $7QqFM$reactdom.createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
119
126
|
component_portals.add(portal);
|
|
120
127
|
set_portals([...component_portals]);
|
|
128
|
+
set_on_index_change_?.(newIndex => setIndexFunctionAccessor()?.(newIndex));
|
|
121
129
|
$7QqFM$solidjs.createEffect($7QqFM$solidjs.on(get_react_template, new_template => queueMicrotask(() =>
|
|
122
130
|
// When the parent react component re-executes and provides a new product card, we want our react portal to also re-render
|
|
123
131
|
// if we update the state inside the portal synchronously from the parent call react gets confused with "Warning: Cannot update a component (`Unknown`) while rendering a different component (`$48d7f568740a317d$export$f7d2f673fc2f091d`). To locate the bad setState() call inside `$48d7f568740a317d$export$f7d2f673fc2f091d`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render"
|
|
@@ -141,7 +149,7 @@ function $c6b960f2a07285c8$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
141
149
|
get recommendations() {
|
|
142
150
|
return props.recommendations;
|
|
143
151
|
},
|
|
144
|
-
product_card_template: display => {
|
|
152
|
+
product_card_template: (display, info) => {
|
|
145
153
|
if (0, $7QqFM$solidjsweb.isServer) {
|
|
146
154
|
// This function can't be async on the server
|
|
147
155
|
// @ts-ignore emulate the wrapper div that we need in prod here too for consistency
|
|
@@ -156,7 +164,8 @@ function $c6b960f2a07285c8$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
156
164
|
},
|
|
157
165
|
get_react_template: () => props.productCard,
|
|
158
166
|
component_portals: component_portals,
|
|
159
|
-
set_portals: set_portals
|
|
167
|
+
set_portals: set_portals,
|
|
168
|
+
set_on_index_change_: info?.set_on_index_change
|
|
160
169
|
});
|
|
161
170
|
},
|
|
162
171
|
get cols_at_size() {
|
|
@@ -183,7 +192,7 @@ function $c6b960f2a07285c8$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
183
192
|
}
|
|
184
193
|
});
|
|
185
194
|
}
|
|
186
|
-
const $db7b67857900028b$export$83d89fbfd8236492 = "4.1.
|
|
195
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "4.1.3";
|
|
187
196
|
function $41e7e5d85b5e0d49$export$9fac37a9c21c2f3b(props) {
|
|
188
197
|
return props.children;
|
|
189
198
|
}
|
package/server/latest/index.d.ts
CHANGED
|
@@ -162,6 +162,8 @@ interface PLPConfig<T extends Display> extends BaseProductListingConfig {
|
|
|
162
162
|
export interface DepictProductCardProps<T extends Display> {
|
|
163
163
|
/** The display data to render. */
|
|
164
164
|
display: T | null;
|
|
165
|
+
/** The index of the product card. Please note that product cards may stay at the same place (not get re-rendered) or move around as the results change. */
|
|
166
|
+
index: number;
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
167
169
|
* Depict product card to use for rendering products.
|
package/server/latest/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ImagePlaceholder as $eOXet$ImagePlaceholder, TextPlaceholder as $eOXet$
|
|
|
4
4
|
import { generateHydrationScript as $eOXet$generateHydrationScript, renderToString as $eOXet$renderToString, isServer as $eOXet$isServer, ssr as $eOXet$ssr, ssrHydrationKey as $eOXet$ssrHydrationKey } from "solid-js/web";
|
|
5
5
|
import { dwarn as $eOXet$dwarn } from "@depict-ai/utilishared/latest";
|
|
6
6
|
import { renderToString as $eOXet$renderToString1 } from "react-dom/server";
|
|
7
|
-
import { getOwner as $eOXet$getOwner, untrack as $eOXet$untrack, runWithOwner as $eOXet$runWithOwner, createEffect as $eOXet$createEffect, on as $eOXet$on, onCleanup as $eOXet$onCleanup } from "solid-js";
|
|
7
|
+
import { createSignal as $eOXet$createSignal, getOwner as $eOXet$getOwner, untrack as $eOXet$untrack, runWithOwner as $eOXet$runWithOwner, createEffect as $eOXet$createEffect, on as $eOXet$on, onCleanup as $eOXet$onCleanup } from "solid-js";
|
|
8
8
|
import { jsx as $eOXet$jsx } from "react/jsx-runtime";
|
|
9
9
|
import { createPortal as $eOXet$createPortal } from "react-dom";
|
|
10
10
|
|
|
@@ -69,20 +69,27 @@ async function $bcf84a32dc612a43$export$32024253978abdc7({
|
|
|
69
69
|
component_props: component_props,
|
|
70
70
|
component_portals: component_portals,
|
|
71
71
|
set_portals: set_portals,
|
|
72
|
-
get_react_template: get_react_template
|
|
72
|
+
get_react_template: get_react_template,
|
|
73
|
+
set_on_index_change_: set_on_index_change_
|
|
73
74
|
}) {
|
|
74
75
|
let set_react_has_ran_hooks;
|
|
75
76
|
let was_cleaned_up = false;
|
|
76
77
|
const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
|
|
77
78
|
const solid_container = document.createElement("div");
|
|
79
|
+
const [setIndexFunctionAccessor, setIndexFunctionSetter] = $eOXet$createSignal();
|
|
78
80
|
let call_when_template_changes;
|
|
79
81
|
const owner = $eOXet$getOwner();
|
|
80
82
|
const reactProductCard = $eOXet$jsx(props => {
|
|
81
83
|
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
82
84
|
$eOXet$useEffect(set_react_has_ran_hooks, []);
|
|
83
85
|
const [react_template, set_react_template] = $eOXet$useState(() => $eOXet$untrack(get_react_template));
|
|
86
|
+
const [index, setIndex] = $eOXet$useState(0);
|
|
87
|
+
setIndexFunctionSetter(() => setIndex);
|
|
84
88
|
call_when_template_changes = set_react_template;
|
|
85
|
-
return react_template(
|
|
89
|
+
return react_template(set_on_index_change_ ? {
|
|
90
|
+
...props,
|
|
91
|
+
index: index
|
|
92
|
+
} : props);
|
|
86
93
|
}, component_props);
|
|
87
94
|
const reactProductCardInErrorBoundary = $eOXet$jsx((0, $d5c9e1f3545b4984$export$d0f82e3ef89b1f22), {
|
|
88
95
|
children: reactProductCard,
|
|
@@ -94,6 +101,7 @@ async function $bcf84a32dc612a43$export$32024253978abdc7({
|
|
|
94
101
|
const portal = $eOXet$createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
95
102
|
component_portals.add(portal);
|
|
96
103
|
set_portals([...component_portals]);
|
|
104
|
+
set_on_index_change_?.(newIndex => setIndexFunctionAccessor()?.(newIndex));
|
|
97
105
|
$eOXet$createEffect($eOXet$on(get_react_template, new_template => queueMicrotask(() =>
|
|
98
106
|
// When the parent react component re-executes and provides a new product card, we want our react portal to also re-render
|
|
99
107
|
// if we update the state inside the portal synchronously from the parent call react gets confused with "Warning: Cannot update a component (`Unknown`) while rendering a different component (`$48d7f568740a317d$export$f7d2f673fc2f091d`). To locate the bad setState() call inside `$48d7f568740a317d$export$f7d2f673fc2f091d`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render"
|
|
@@ -117,7 +125,7 @@ function $4d5c3f13a5ae62a7$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
117
125
|
get recommendations() {
|
|
118
126
|
return props.recommendations;
|
|
119
127
|
},
|
|
120
|
-
product_card_template: display => {
|
|
128
|
+
product_card_template: (display, info) => {
|
|
121
129
|
if (0, $eOXet$isServer) {
|
|
122
130
|
// This function can't be async on the server
|
|
123
131
|
// @ts-ignore emulate the wrapper div that we need in prod here too for consistency
|
|
@@ -132,7 +140,8 @@ function $4d5c3f13a5ae62a7$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
132
140
|
},
|
|
133
141
|
get_react_template: () => props.productCard,
|
|
134
142
|
component_portals: component_portals,
|
|
135
|
-
set_portals: set_portals
|
|
143
|
+
set_portals: set_portals,
|
|
144
|
+
set_on_index_change_: info?.set_on_index_change
|
|
136
145
|
});
|
|
137
146
|
},
|
|
138
147
|
get cols_at_size() {
|
|
@@ -159,7 +168,7 @@ function $4d5c3f13a5ae62a7$export$e46079a2793e9ec7(props, set_portals) {
|
|
|
159
168
|
}
|
|
160
169
|
});
|
|
161
170
|
}
|
|
162
|
-
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "4.1.
|
|
171
|
+
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "4.1.3";
|
|
163
172
|
function $2b1fdeb83610500f$export$9fac37a9c21c2f3b(props) {
|
|
164
173
|
return props.children;
|
|
165
174
|
}
|