@depict-ai/react-ui 1.5.20 → 2.0.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.
Files changed (49) hide show
  1. package/ES10/index.cjs +149 -69
  2. package/ES10/index.d.ts +547 -37
  3. package/ES10/index.js +152 -74
  4. package/README.md +2 -1
  5. package/dist/main.js +293 -0
  6. package/dist/module.js +285 -0
  7. package/dist/styles/components/PLP/Buttons.scss +124 -0
  8. package/dist/styles/components/PLP/MorphingSign.scss +31 -0
  9. package/dist/styles/components/PLP/PLPResults.scss +20 -0
  10. package/dist/styles/components/PLP/ProductListingPage.scss +142 -0
  11. package/dist/styles/components/PLP/ScrollStatus.scss +24 -0
  12. package/dist/styles/components/PLP/SelectedFilters.scss +74 -0
  13. package/dist/styles/components/PLP/SlidableItems.scss +99 -0
  14. package/dist/styles/components/PLP/SortAndFilter/FloatingButtons.scss +75 -0
  15. package/dist/styles/components/PLP/SortAndFilter/SortAndFilter.scss +728 -0
  16. package/dist/styles/components/PLP/SortAndFilter/SortAndFilterModal.scss +160 -0
  17. package/dist/styles/components/PLP/SortAndFilter/WhiteSortAndFilter.scss +148 -0
  18. package/dist/styles/components/PLP/Toast.scss +54 -0
  19. package/dist/styles/components/PLP/index.scss +45 -0
  20. package/dist/styles/components/category/BreadCrumbs.scss +23 -0
  21. package/dist/styles/components/category/CategoryTitle.scss +28 -0
  22. package/dist/styles/components/category/QuickLinks.scss +71 -0
  23. package/dist/styles/components/category/index.scss +23 -0
  24. package/dist/styles/components/search/Autocomplete.scss +117 -0
  25. package/dist/styles/components/search/CategorySuggestions.scss +74 -0
  26. package/dist/styles/components/search/InstantCard.scss +117 -0
  27. package/dist/styles/components/search/InstantResults.scss +10 -0
  28. package/dist/styles/components/search/PreviousSearches.scss +77 -0
  29. package/dist/styles/components/search/QueryInput.scss +167 -0
  30. package/dist/styles/components/search/SearchModal.scss +95 -0
  31. package/dist/styles/components/search/SearchRecommendations.scss +25 -0
  32. package/dist/styles/components/search/ShowingResultsFor.scss +10 -0
  33. package/dist/styles/components/search/index.scss +40 -0
  34. package/dist/styles/default.css +1 -0
  35. package/dist/styles/helpers/custom_input.scss +162 -0
  36. package/dist/styles/helpers/supports-hover.scss +5 -0
  37. package/dist/styles/helpers/utils.scss +82 -0
  38. package/dist/styles/plain-css-fallback-styling.css +1 -1
  39. package/dist/styles/variables.scss +47 -0
  40. package/latest/index.cjs +145 -68
  41. package/latest/index.d.ts +547 -37
  42. package/latest/index.js +148 -73
  43. package/package.json +9 -9
  44. package/server/ES10/index.cjs +125 -1
  45. package/server/ES10/index.d.ts +547 -37
  46. package/server/ES10/index.js +127 -5
  47. package/server/latest/index.cjs +122 -1
  48. package/server/latest/index.d.ts +547 -37
  49. package/server/latest/index.js +124 -5
package/ES10/index.js CHANGED
@@ -1,19 +1,20 @@
1
1
  import { add_to_version_info as $jb2Oo$add_to_version_info, catchify as $jb2Oo$catchify, queueMacroTask as $jb2Oo$queueMacroTask, instant_exec_on_suspect_history_change as $jb2Oo$instant_exec_on_suspect_history_change, derror as $jb2Oo$derror } from "@depict-ai/utilishared/ES10";
2
- import { CategoryTitle as $383b6fd56bf151bd$re_export$CategoryTitle, embedded_num_products as $383b6fd56bf151bd$re_export$EmbeddedNumProducts, DepictAPI as $jb2Oo$DepictAPI, ProductCardError as $jb2Oo$ProductCardError, DepictSearch as $jb2Oo$DepictSearch, DepictCategory as $jb2Oo$DepictCategory, get_search_query_updating_blocked_signal as $jb2Oo$get_search_query_updating_blocked_signal, SearchPage as $jb2Oo$SearchPage, defaultColsAtSize as $jb2Oo$defaultColsAtSize, defaultGridSpacing as $jb2Oo$defaultGridSpacing, CategoryPage as $jb2Oo$CategoryPage, defaultCategoryTitlePlugin as $jb2Oo$defaultCategoryTitlePlugin, BreadCrumbs as $jb2Oo$BreadCrumbs, QuickLinks as $jb2Oo$QuickLinks, ImagePlaceholder as $jb2Oo$ImagePlaceholder, TextPlaceholder as $jb2Oo$TextPlaceholder, open_modal_with_alignment as $jb2Oo$open_modal_with_alignment, SearchField as $jb2Oo$SearchField, fetchDepictRecommendations as $jb2Oo$fetchDepictRecommendations } from "@depict-ai/ui/ES10";
3
- import { untrack as $jb2Oo$untrack, createRoot as $jb2Oo$createRoot, createEffect as $jb2Oo$createEffect, createMemo as $jb2Oo$createMemo, createComponent as $jb2Oo$createComponent, Show as $jb2Oo$Show, getOwner as $jb2Oo$getOwner, runWithOwner as $jb2Oo$runWithOwner, onCleanup as $jb2Oo$onCleanup, createSignal as $jb2Oo$createSignal, createComputed as $jb2Oo$createComputed } from "solid-js";
4
- import { createElement as $jb2Oo$createElement, Fragment as $jb2Oo$Fragment, useEffect as $jb2Oo$useEffect, useState as $jb2Oo$useState, useRef as $jb2Oo$useRef, Component as $jb2Oo$Component, forwardRef as $jb2Oo$forwardRef, useCallback as $jb2Oo$useCallback } from "react";
2
+ import { CategoryTitle as $383b6fd56bf151bd$re_export$CategoryTitle, embedded_num_products as $383b6fd56bf151bd$re_export$EmbeddedNumProducts, DepictAPI as $jb2Oo$DepictAPI, DepictSearch as $jb2Oo$DepictSearch, DepictCategory as $jb2Oo$DepictCategory, get_search_query_updating_blocked_signal as $jb2Oo$get_search_query_updating_blocked_signal, SearchPage as $jb2Oo$SearchPage, defaultColsAtSize as $jb2Oo$defaultColsAtSize, defaultGridSpacing as $jb2Oo$defaultGridSpacing, ProductCardError as $jb2Oo$ProductCardError, CategoryPage as $jb2Oo$CategoryPage, defaultCategoryTitlePlugin as $jb2Oo$defaultCategoryTitlePlugin, BreadCrumbs as $jb2Oo$BreadCrumbs, QuickLinks as $jb2Oo$QuickLinks, ImagePlaceholder as $jb2Oo$ImagePlaceholder, TextPlaceholder as $jb2Oo$TextPlaceholder, RecommendationSlider as $jb2Oo$RecommendationSlider, RecommendationGrid as $jb2Oo$RecommendationGrid, open_modal_with_alignment as $jb2Oo$open_modal_with_alignment, SearchField as $jb2Oo$SearchField, fetchDepictRecommendations as $jb2Oo$fetchDepictRecommendations } from "@depict-ai/ui/ES10";
3
+ import { untrack as $jb2Oo$untrack, createRoot as $jb2Oo$createRoot, createEffect as $jb2Oo$createEffect, createMemo as $jb2Oo$createMemo, createComponent as $jb2Oo$createComponent, Show as $jb2Oo$Show, createSignal as $jb2Oo$createSignal, createComputed as $jb2Oo$createComputed, onCleanup as $jb2Oo$onCleanup, getOwner as $jb2Oo$getOwner, runWithOwner as $jb2Oo$runWithOwner } from "solid-js";
4
+ import { createElement as $jb2Oo$createElement, Fragment as $jb2Oo$Fragment, useEffect as $jb2Oo$useEffect, useState as $jb2Oo$useState, useRef as $jb2Oo$useRef, forwardRef as $jb2Oo$forwardRef, Component as $jb2Oo$Component, useCallback as $jb2Oo$useCallback } from "react";
5
5
  import { defaultLocale as $jb2Oo$defaultLocale } from "@depict-ai/ui/locales/ES10";
6
- import { render as $jb2Oo$render, hydrate as $jb2Oo$hydrate } from "solid-js/web";
7
- import { jsx as $jb2Oo$jsx } from "react/jsx-runtime";
8
- import { createPortal as $jb2Oo$createPortal } from "react-dom";
6
+ import { render as $jb2Oo$render, hydrate as $jb2Oo$hydrate, isServer as $jb2Oo$isServer } from "solid-js/web";
9
7
  import { createStore as $jb2Oo$createStore, reconcile as $jb2Oo$reconcile } from "solid-js/store";
10
8
  import { DPC as $jb2Oo$DPC } from "@depict-ai/dpc/ES10";
9
+ import { jsx as $jb2Oo$jsx } from "react/jsx-runtime";
10
+ import { createPortal as $jb2Oo$createPortal } from "react-dom";
11
+ import { renderToString as $jb2Oo$renderToString } from "react-dom/server";
11
12
 
12
13
  /*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
13
14
  // Note, if you add an export here, also add one in src-server/main.ts
14
15
  import { register_es_version } from "../multi_import_deduplicator.mjs";
15
16
  register_es_version("react-ui", "ES10");
16
- const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "1.5.20";
17
+ const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "2.0.0";
17
18
  const $8c691d7f86317052$export$8e769ad4338a911e = {
18
19
  usedLocale: $jb2Oo$createSignal((0, $jb2Oo$defaultLocale)),
19
20
  search_instances: new Map(),
@@ -33,31 +34,6 @@ const $8c691d7f86317052$export$8e769ad4338a911e = {
33
34
  category_meta_title_suffix: $jb2Oo$createSignal(),
34
35
  disable_override_query_id: $jb2Oo$createSignal()
35
36
  };
36
- class $88d93ed7309e90d1$export$d0f82e3ef89b1f22 extends (0, $jb2Oo$Component) {
37
- constructor(props) {
38
- super(props);
39
- this.state = {
40
- hasError: false
41
- };
42
- }
43
- static getDerivedStateFromError() {
44
- // Update state so the next render will show the fallback UI.
45
- return {
46
- hasError: true
47
- };
48
- }
49
- componentDidCatch(error) {
50
- this.props.on_error(error);
51
- }
52
- render() {
53
- if (this.state.hasError)
54
- // You can render any custom fallback UI
55
- return $jb2Oo$createElement("div", {
56
- children: "Component failed"
57
- });
58
- return this.props.children;
59
- }
60
- }
61
37
  let $0dd9d9a9c7da4c1d$var$run_on_href_change;
62
38
  let $0dd9d9a9c7da4c1d$var$old_href = location.href;
63
39
  function $0dd9d9a9c7da4c1d$export$74f3924c5027fe1d(cb) {
@@ -134,45 +110,6 @@ function $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035(component, is_set) {
134
110
  });
135
111
  };
136
112
  }
137
- async function $0dd9d9a9c7da4c1d$export$79c79419c1ef0081(_ref2) {
138
- let {
139
- display: display,
140
- component_portals: component_portals,
141
- set_portals: set_portals,
142
- react_template: react_template
143
- } = _ref2;
144
- let set_react_has_ran_hooks;
145
- let was_cleaned_up = false;
146
- const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
147
- const solid_container = document.createElement("div");
148
- const owner = $jb2Oo$getOwner();
149
- const reactProductCard = $jb2Oo$jsx(props => {
150
- // Sneak in a hook into their product card component to know once react has finished rendering and running hooks
151
- $jb2Oo$useEffect(set_react_has_ran_hooks, []);
152
- return react_template(props);
153
- }, {
154
- display: display
155
- });
156
- const reactProductCardInErrorBoundary = $jb2Oo$jsx((0, $88d93ed7309e90d1$export$d0f82e3ef89b1f22), {
157
- children: reactProductCard,
158
- on_error: error => $jb2Oo$runWithOwner(owner, () => {
159
- if (was_cleaned_up) return; // Would infinite loop if we'd throw after we've already been cleaned up. That is because the `ErrorBoundary` won't be "registered" with the cleaned-up owner anymore so react would hear about the throw and attempt to re-render the error boundary or something which would throw again, etc.
160
- throw new (0, $jb2Oo$ProductCardError)(error);
161
- })
162
- });
163
- const portal = $jb2Oo$createPortal(reactProductCardInErrorBoundary, solid_container);
164
- component_portals.add(portal);
165
- set_portals([...component_portals]);
166
- $jb2Oo$onCleanup(() => {
167
- was_cleaned_up = true;
168
- // this will stop working after any await so be careful to not await before this, or you'll have to carry the owner over with getOwner and runWithOwner
169
- component_portals.delete(portal);
170
- // Updating i.e. the merchant will cause a setState call while rendering the DepictProvider component which is illegal because it usually infinite loops react apps. In our case it doesn't though, so we just evade detection by doing it a microtask later. See also https://github.com/facebook/react/issues/18178#issuecomment-595846312
171
- queueMicrotask(() => set_portals([...component_portals]));
172
- });
173
- await react_has_ran_hooks; // After react has created elements it still takes some time to actually connect the refs and run the hooks. We don't want to replace placeholders before then.
174
- return [solid_container];
175
- }
176
113
  let $64144f6d578fd8ac$var$set = false;
177
114
  let $64144f6d578fd8ac$var$padding_animation;
178
115
  function $64144f6d578fd8ac$export$6453cbc34515a94d() {
@@ -524,6 +461,70 @@ function $fda7a7820477f957$export$f4d89133c6985668(type, stateKey, componentName
524
461
  });
525
462
  return instance.instance;
526
463
  }
464
+ class $88d93ed7309e90d1$export$d0f82e3ef89b1f22 extends (0, $jb2Oo$Component) {
465
+ constructor(props) {
466
+ super(props);
467
+ this.state = {
468
+ hasError: false
469
+ };
470
+ }
471
+ static getDerivedStateFromError() {
472
+ // Update state so the next render will show the fallback UI.
473
+ return {
474
+ hasError: true
475
+ };
476
+ }
477
+ componentDidCatch(error) {
478
+ this.props.on_error(error);
479
+ }
480
+ render() {
481
+ if (this.state.hasError)
482
+ // You can render any custom fallback UI
483
+ return $jb2Oo$createElement("div", {
484
+ children: "Component failed"
485
+ });
486
+ return this.props.children;
487
+ }
488
+ }
489
+ async function $6593e4e126cb318f$export$79c79419c1ef0081(_ref) {
490
+ let {
491
+ display: display,
492
+ component_portals: component_portals,
493
+ set_portals: set_portals,
494
+ react_template: react_template
495
+ } = _ref;
496
+ let set_react_has_ran_hooks;
497
+ let was_cleaned_up = false;
498
+ const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
499
+ const solid_container = document.createElement("div");
500
+ const owner = $jb2Oo$getOwner();
501
+ const reactProductCard = $jb2Oo$jsx(props => {
502
+ // Sneak in a hook into their product card component to know once react has finished rendering and running hooks
503
+ $jb2Oo$useEffect(set_react_has_ran_hooks, []);
504
+ return react_template(props);
505
+ }, {
506
+ display: display
507
+ });
508
+ const reactProductCardInErrorBoundary = $jb2Oo$jsx((0, $88d93ed7309e90d1$export$d0f82e3ef89b1f22), {
509
+ children: reactProductCard,
510
+ on_error: error => $jb2Oo$runWithOwner(owner, () => {
511
+ if (was_cleaned_up) return; // Would infinite loop if we'd throw after we've already been cleaned up. That is because the `ErrorBoundary` won't be "registered" with the cleaned-up owner anymore so react would hear about the throw and attempt to re-render the error boundary or something which would throw again, etc.
512
+ throw new (0, $jb2Oo$ProductCardError)(error);
513
+ })
514
+ });
515
+ const portal = $jb2Oo$createPortal(reactProductCardInErrorBoundary, solid_container);
516
+ component_portals.add(portal);
517
+ set_portals([...component_portals]);
518
+ $jb2Oo$onCleanup(() => {
519
+ was_cleaned_up = true;
520
+ // this will stop working after any await so be careful to not await before this, or you'll have to carry the owner over with getOwner and runWithOwner
521
+ component_portals.delete(portal);
522
+ // Updating i.e. the merchant will cause a setState call while rendering the DepictProvider component which is illegal because it usually infinite loops react apps. In our case it doesn't though, so we just evade detection by doing it a microtask later. See also https://github.com/facebook/react/issues/18178#issuecomment-595846312
523
+ queueMicrotask(() => set_portals([...component_portals]));
524
+ });
525
+ await react_has_ran_hooks; // After React has created elements it still takes some time to actually connect the refs and run the hooks. We don't want to replace placeholders before then.
526
+ return [solid_container];
527
+ }
527
528
  const $d059770e7af9e2dc$var$rendered_components_with_state_key = new Set();
528
529
  function $d059770e7af9e2dc$export$a54ec244c8863715(props) {
529
530
  return $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef({
@@ -588,7 +589,7 @@ function $d059770e7af9e2dc$var$SolidSearchPage(props, set_portals) {
588
589
  return (_props$gridSpacing = props.gridSpacing) !== null && _props$gridSpacing !== void 0 ? _props$gridSpacing : (0, $jb2Oo$defaultGridSpacing);
589
590
  },
590
591
  depict_search: depict_search(),
591
- product_card_template: display => $0dd9d9a9c7da4c1d$export$79c79419c1ef0081({
592
+ product_card_template: display => $6593e4e126cb318f$export$79c79419c1ef0081({
592
593
  display: display,
593
594
  react_template: $jb2Oo$untrack(() => props.productCard),
594
595
  component_portals: component_portals,
@@ -669,7 +670,7 @@ function $e86a296a07b17ad5$var$SolidCategoryPage(props, set_portals) {
669
670
  get show_quicklinks() {
670
671
  return props.showQuicklinks;
671
672
  },
672
- product_card_template: display => $0dd9d9a9c7da4c1d$export$79c79419c1ef0081({
673
+ product_card_template: display => $6593e4e126cb318f$export$79c79419c1ef0081({
673
674
  display: display,
674
675
  react_template: $jb2Oo$untrack(() => props.productCard),
675
676
  component_portals: component_portals,
@@ -737,6 +738,83 @@ const $2c7738b65cbcac1c$export$89c6019e4baa40b1 = raw_react_props => {
737
738
  }
738
739
  });
739
740
  };
741
+ function $c02e9fd51f31a1bd$export$82cfdc85a4d15688(props) {
742
+ return $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef({
743
+ solid_component: $c02e9fd51f31a1bd$export$5abb40edfde2a843,
744
+ props: props
745
+ });
746
+ }
747
+ function $c02e9fd51f31a1bd$export$5abb40edfde2a843(props, set_portals) {
748
+ const component_portals = new Set();
749
+ return $jb2Oo$RecommendationSlider({
750
+ get recommendations() {
751
+ return props.recommendations;
752
+ },
753
+ product_card_template: display => $6593e4e126cb318f$export$79c79419c1ef0081({
754
+ display: display,
755
+ react_template: $jb2Oo$untrack(() => props.productCard),
756
+ component_portals: component_portals,
757
+ set_portals: set_portals
758
+ }),
759
+ get cols_at_size() {
760
+ return props.columnsAtSize || (0, $jb2Oo$defaultColsAtSize);
761
+ },
762
+ get grid_spacing() {
763
+ var _props$gridSpacing;
764
+ return (_props$gridSpacing = props.gridSpacing) !== null && _props$gridSpacing !== void 0 ? _props$gridSpacing : (0, $jb2Oo$defaultGridSpacing);
765
+ }
766
+ });
767
+ }
768
+ function $48b0916cc674770c$export$bd8acc07a8bae229(props, set_portals) {
769
+ const component_portals = new Set();
770
+ return $jb2Oo$RecommendationGrid({
771
+ get recommendations() {
772
+ return props.recommendations;
773
+ },
774
+ product_card_template: display => {
775
+ if (0, $jb2Oo$isServer)
776
+ // This function can't be async on the server
777
+ // @ts-ignore
778
+ return {
779
+ t: $jb2Oo$renderToString($jb2Oo$createElement(() => props.productCard({
780
+ display: display
781
+ })))
782
+ };
783
+ return $6593e4e126cb318f$export$79c79419c1ef0081({
784
+ display: display,
785
+ react_template: $jb2Oo$untrack(() => props.productCard),
786
+ component_portals: component_portals,
787
+ set_portals: set_portals
788
+ });
789
+ },
790
+ get cols_at_size() {
791
+ return props.columnsAtSize || (0, $jb2Oo$defaultColsAtSize);
792
+ },
793
+ get grid_spacing() {
794
+ var _props$gridSpacing;
795
+ return (_props$gridSpacing = props.gridSpacing) !== null && _props$gridSpacing !== void 0 ? _props$gridSpacing : (0, $jb2Oo$defaultGridSpacing);
796
+ },
797
+ get view_more_button() {
798
+ var _viewMoreButton$start;
799
+ const {
800
+ viewMoreButton: viewMoreButton
801
+ } = props;
802
+ return viewMoreButton ? {
803
+ text: viewMoreButton.text,
804
+ start_rows: (_viewMoreButton$start = viewMoreButton.startRows) !== null && _viewMoreButton$start !== void 0 ? _viewMoreButton$start : 2,
805
+ rows_per_click: viewMoreButton.rowsPerClick
806
+ } : undefined;
807
+ }
808
+ });
809
+ }
810
+ function $31abef71c0a2d3fc$export$b0a773486c1c2312(props) {
811
+ return $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef({
812
+ solid_component: (0, $48b0916cc674770c$export$bd8acc07a8bae229),
813
+ props: props,
814
+ hydrate_function_when_ssr: (0, $jb2Oo$hydrate),
815
+ wrapper_type: "section"
816
+ });
817
+ }
740
818
  const $1283ca5a3f4a4617$export$d69d8daa20eae175 = createOpenModalParams => {
741
819
  const {
742
820
  location = "centered",
@@ -854,4 +932,4 @@ const $a7dfdd84298ae791$export$b8a61e5c71402559 = {
854
932
  nextRouterNavigation: $05726fa9c7eda0a1$export$804fac5697cfbe35
855
933
  };
856
934
  $jb2Oo$add_to_version_info("react-ui", (0, $9bd9bb8700ab2ada$export$83d89fbfd8236492));
857
- export { $c61814cfb91ead09$export$466cdc317043f6cb as QuickLinks, $ec632214ac078e79$export$5646050d516e06bc as BreadCrumbs, $f6a205a95e4fdee3$export$80e99ee6b29cadd2 as ComponentAligner, $18e5b9f66c7ade8e$export$9fac37a9c21c2f3b as DepictProvider, $e86a296a07b17ad5$export$f7d2f673fc2f091d as CategoryPage, $d059770e7af9e2dc$export$a54ec244c8863715 as SearchPage, $6406849926c3f794$export$3f37af283f8fb843 as ImagePlaceholder, $2c7738b65cbcac1c$export$89c6019e4baa40b1 as TextPlaceholder, $356d18d3ed66814e$export$912994940e660d32 as useSearchModal, $4c71282d292aac6d$export$9bb30bbe003b82e0 as useSearchField, $1895644749ca8d8a$export$6501da23a2770fc as useFetchRecommendations, $b34796f5ebe3470e$export$38b98fae14bd1f64 as usePerformanceClient, $383b6fd56bf151bd$re_export$CategoryTitle as CategoryTitle, $383b6fd56bf151bd$re_export$EmbeddedNumProducts as EmbeddedNumProducts, $9bd9bb8700ab2ada$export$83d89fbfd8236492 as version, $a7dfdd84298ae791$export$b8a61e5c71402559 as Navigation };
935
+ export { $c61814cfb91ead09$export$466cdc317043f6cb as QuickLinks, $ec632214ac078e79$export$5646050d516e06bc as BreadCrumbs, $f6a205a95e4fdee3$export$80e99ee6b29cadd2 as ComponentAligner, $18e5b9f66c7ade8e$export$9fac37a9c21c2f3b as DepictProvider, $e86a296a07b17ad5$export$f7d2f673fc2f091d as CategoryPage, $d059770e7af9e2dc$export$a54ec244c8863715 as SearchPage, $6406849926c3f794$export$3f37af283f8fb843 as ImagePlaceholder, $2c7738b65cbcac1c$export$89c6019e4baa40b1 as TextPlaceholder, $31abef71c0a2d3fc$export$b0a773486c1c2312 as RecommendationGrid, $c02e9fd51f31a1bd$export$82cfdc85a4d15688 as RecommendationSlider, $356d18d3ed66814e$export$912994940e660d32 as useSearchModal, $4c71282d292aac6d$export$9bb30bbe003b82e0 as useSearchField, $1895644749ca8d8a$export$6501da23a2770fc as useFetchRecommendations, $b34796f5ebe3470e$export$38b98fae14bd1f64 as usePerformanceClient, $383b6fd56bf151bd$re_export$CategoryTitle as CategoryTitle, $383b6fd56bf151bd$re_export$EmbeddedNumProducts as EmbeddedNumProducts, $9bd9bb8700ab2ada$export$83d89fbfd8236492 as version, $a7dfdd84298ae791$export$b8a61e5c71402559 as Navigation };
package/README.md CHANGED
@@ -6,4 +6,5 @@ Breaking changes:
6
6
 
7
7
  - 1.3.0 moved `depict-filter-sort-mobile-modal-container` from being a class to being an id
8
8
  - 1.4.0 Added `brand_` translation string to Locale.
9
- - 1.5.0: Don't allow creating two `DepictProvider` instances. Don't allow two synced SearchPage and CategoryPage's to be created. Add `stateKey` property to all the components which can be used to create two instances of everything with completely different states.
9
+ - 1.5.0: Don't allow creating two `DepictProvider` instances. Don't allow two synced SearchPage and CategoryPage's to be created. Add `stateKey` property to all the components which can be used to create two instances of everything with completely different states.
10
+ - 2.0.0 Made `enableContentSearch` `true` by default. Redesigned filter counts. Added RecommendationGrid and RecommendationSlider.
package/dist/main.js ADDED
@@ -0,0 +1,293 @@
1
+ var $4GYXz$depictaiui = require("@depict-ai/ui");
2
+ var $4GYXz$depictaiutilishared = require("@depict-ai/utilishared");
3
+ var $4GYXz$solidjs = require("solid-js");
4
+ var $4GYXz$solidjsweb = require("solid-js/web");
5
+ var $4GYXz$react = require("react");
6
+ var $4GYXz$reactjsxruntime = require("react/jsx-runtime");
7
+ var $4GYXz$reactdom = require("react-dom");
8
+
9
+ function $parcel$export(e, n, v, s) {
10
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
11
+ }
12
+
13
+ $parcel$export(module.exports, "DepictSearchField", () => $a48f3b1a4abf2e0c$export$d2c02478244f91f7);
14
+ $parcel$export(module.exports, "DepictProvider", () => $18b830ef84ac138a$export$9fac37a9c21c2f3b);
15
+ $parcel$export(module.exports, "openModal", () => $20bf907adee775ba$export$a7f6cffb6b8ba11c);
16
+ $parcel$export(module.exports, "DepictSearchHeader", () => $20bf907adee775ba$export$cbcd1ecdb41b1d0a);
17
+ $parcel$export(module.exports, "DepictSearchPage", () => $a6bedbe4b4d6d027$export$210723f5a54a7028);
18
+ // This is where the actual source of your React stuff should live
19
+ // Note, if you add an export here, also add one in src-server/main.ts
20
+
21
+
22
+ const $0b7cd4fb39fc3502$export$8e769ad4338a911e = {
23
+ search: null,
24
+ header_alignment: null,
25
+ search_page_path_: (0, $4GYXz$solidjs.createSignal)(),
26
+ required_state_set_: (0, $4GYXz$solidjs.createSignal)(false)
27
+ };
28
+
29
+
30
+
31
+
32
+
33
+
34
+ let $b4d0d98857ed9934$var$run_on_href_change;
35
+ function $b4d0d98857ed9934$export$74f3924c5027fe1d(cb) {
36
+ $b4d0d98857ed9934$var$run_on_href_change = cb;
37
+ }
38
+ (async ()=>{
39
+ for await (const href of (0, $4GYXz$depictaiutilishared.href_change_ipns))$b4d0d98857ed9934$var$run_on_href_change?.(href);
40
+ })();
41
+ const $b4d0d98857ed9934$export$6cb4d3a5c1ac9b43 = (url)=>url.pathname == (0, $4GYXz$solidjs.untrack)((0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_page_path_[0]); // might have changed therefore get it from globalState
42
+ function $b4d0d98857ed9934$export$f6e64e17bd69eeef(solid_component, props) {
43
+ const [portals, set_portals] = (0, $4GYXz$react.useState)([]);
44
+ const element_ref = (0, $4GYXz$react.useRef)();
45
+ (0, $4GYXz$react.useEffect)(()=>{
46
+ const div_element = element_ref.current;
47
+ const dispose = (0, $4GYXz$solidjsweb.render)(()=>solid_component(props, set_portals), div_element);
48
+ return dispose;
49
+ }, []);
50
+ return (0, $4GYXz$reactjsxruntime.jsx)("div", {
51
+ ref: element_ref,
52
+ children: portals
53
+ });
54
+ }
55
+ function $b4d0d98857ed9934$export$e5139bbbb9a05035(component) {
56
+ return (...args)=>{
57
+ return (0, $4GYXz$solidjs.createComponent)((0, $4GYXz$solidjs.Show), {
58
+ get when () {
59
+ return (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).required_state_set_[0]();
60
+ },
61
+ get children () {
62
+ return component(...args);
63
+ }
64
+ });
65
+ };
66
+ }
67
+
68
+
69
+
70
+
71
+ function $a48f3b1a4abf2e0c$export$d2c02478244f91f7() {
72
+ return (0, $b4d0d98857ed9934$export$f6e64e17bd69eeef)((0, $b4d0d98857ed9934$export$e5139bbbb9a05035)(()=>(0, $4GYXz$depictaiui.SearchField)({
73
+ depict_search: (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search
74
+ })), {});
75
+ }
76
+
77
+
78
+
79
+
80
+
81
+ let $6319748b4f0426f0$var$set = false;
82
+ function $6319748b4f0426f0$export$6453cbc34515a94d(is_search_page) {
83
+ if ($6319748b4f0426f0$var$set) return; // Just being safe
84
+ $6319748b4f0426f0$var$set = true;
85
+ let should_use_old_scroll = false;
86
+ const old_scrollTo = window.scrollTo;
87
+ window.scrollTo = (...args)=>{
88
+ if (should_use_old_scroll || process.env.__NEXT_SCROLL_RESTORATION || !is_search_page(location)) return Reflect.apply(old_scrollTo, window, args);
89
+ else should_use_old_scroll = true;
90
+ };
91
+ addEventListener("popstate", (e)=>{
92
+ if (!is_search_page(location)) {
93
+ $6319748b4f0426f0$var$removeLotsOfPadding(); // Just making sure
94
+ return;
95
+ }
96
+ should_use_old_scroll = false;
97
+ $6319748b4f0426f0$var$addLotsOfPadding();
98
+ (0, $4GYXz$depictaiutilishared.observer).wait_for_element(".depict.plp .listing-page").then(()=>{
99
+ $6319748b4f0426f0$var$removeLotsOfPadding();
100
+ });
101
+ });
102
+ (0, $4GYXz$depictaiutilishared.history_replacer)(()=>{
103
+ (0, $4GYXz$depictaiutilishared.queueMacroTask)(()=>{
104
+ $6319748b4f0426f0$var$removeLotsOfPadding();
105
+ });
106
+ }, false);
107
+ window?.next?.router?.events?.on("routeChangeStart", ()=>{
108
+ $6319748b4f0426f0$var$addLotsOfPadding();
109
+ });
110
+ }
111
+ // TODO: Make these animations so they don't collide with whatever padding is already on the body
112
+ function $6319748b4f0426f0$var$addLotsOfPadding() {
113
+ document.body.style.paddingBottom = (history.state?.search_scroll_restoration_data?.[0]?.min_results_loaded || 150) * 500 + "px";
114
+ }
115
+ function $6319748b4f0426f0$var$removeLotsOfPadding() {
116
+ document.body.style.paddingBottom = "";
117
+ }
118
+
119
+
120
+
121
+
122
+
123
+ function $18b830ef84ac138a$export$9fac37a9c21c2f3b(props) {
124
+ if (!props.market || !props.merchant) {
125
+ (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).required_state_set_[1](false);
126
+ return (0, $4GYXz$react.createElement)((0, $4GYXz$react.Fragment), null, props.children);
127
+ }
128
+ const { children: children , search_page_path: search_page_path , url_param_name: url_param_name , ...assignable_options } = props;
129
+ const { search: search } = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e);
130
+ const [get_search_page_path, set_search_page_path] = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_page_path_;
131
+ set_search_page_path(search_page_path);
132
+ if (!search) {
133
+ (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search = new (0, $4GYXz$depictaiui.DepictSearch)({
134
+ search_query_url_param_name: url_param_name,
135
+ ...assignable_options,
136
+ enable_category_suggestions: false,
137
+ localization: {
138
+ ...(0, $4GYXz$depictaiui.swedish_search_translation),
139
+ price_formatting_: {
140
+ pre_: "kr ",
141
+ post_: "",
142
+ decimal_places_delimiter_: ",",
143
+ thousands_delimiter_: " ",
144
+ places_after_comma_: 2
145
+ }
146
+ },
147
+ on_navigation: (new_href)=>{
148
+ const shallow = (0, $b4d0d98857ed9934$export$6cb4d3a5c1ac9b43)(location);
149
+ if (window.next) window.next.router.push(new_href, undefined, {
150
+ shallow: shallow,
151
+ scroll: true
152
+ });
153
+ else location.href = new_href;
154
+ },
155
+ url_transformer: (url)=>url.pathname = (0, $4GYXz$solidjs.untrack)(get_search_page_path)
156
+ });
157
+ (0, $6319748b4f0426f0$export$6453cbc34515a94d)((0, $b4d0d98857ed9934$export$6cb4d3a5c1ac9b43));
158
+ } else Object.assign(search, assignable_options);
159
+ (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).required_state_set_[1](true);
160
+ return (0, $4GYXz$react.createElement)((0, $4GYXz$react.Fragment), null, children);
161
+ }
162
+
163
+
164
+ // PoC maybe-component
165
+ // Idea is to always give a nice "modal input in header" look with no more config than adding this component to the page header to where it can absolute-size
166
+ // and cover the entire height of the header. Then we know where to put the modal input top and bottom, and the left and right we just center.
167
+
168
+
169
+
170
+ function $20bf907adee775ba$export$cbcd1ecdb41b1d0a() {
171
+ return (0, $4GYXz$react.createElement)("div", {
172
+ className: "depict aligner",
173
+ ref: (e)=>(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).header_alignment = e
174
+ });
175
+ }
176
+ let $20bf907adee775ba$var$sheet;
177
+ function $20bf907adee775ba$export$a7f6cffb6b8ba11c() {
178
+ if (!(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search) {
179
+ console.error("No active search in the app!");
180
+ return;
181
+ }
182
+ if (!(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).header_alignment) {
183
+ console.error("No active search header aligner on the page!");
184
+ return;
185
+ }
186
+ const style_props_ = (0, $4GYXz$solidjs.createSignal)({
187
+ position: "fixed",
188
+ top: 0
189
+ });
190
+ if ((0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).header_alignment?.clientHeight) {
191
+ let styles = `.depict.plp.in-header .depict-search-modal .query-input { height: ${(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).header_alignment?.clientHeight}px; }`;
192
+ styles += `.depict.plp.in-header .depict-search-modal-backdrop { top: ${(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).header_alignment?.clientHeight}px; }`;
193
+ if (!$20bf907adee775ba$var$sheet) {
194
+ const style = document.createElement("style");
195
+ style.append(styles);
196
+ document.head.appendChild(style);
197
+ }
198
+ }
199
+ const class_list_ = (0, $4GYXz$solidjs.createMemo)(()=>({
200
+ "in-header": true
201
+ }));
202
+ (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search.modal_open = [
203
+ {
204
+ style_props_: style_props_,
205
+ class_list_: class_list_
206
+ }
207
+ ];
208
+ }
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+ function $a6bedbe4b4d6d027$export$210723f5a54a7028(opts) {
218
+ return (0, $b4d0d98857ed9934$export$f6e64e17bd69eeef)((0, $b4d0d98857ed9934$export$e5139bbbb9a05035)($a6bedbe4b4d6d027$var$SolidSearchPage), opts);
219
+ }
220
+ function $a6bedbe4b4d6d027$var$SolidSearchPage(props, set_portals) {
221
+ const depict_search = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search;
222
+ if (!depict_search) throw Error("No depict_search instance when rendering SearchPage.");
223
+ const search_query_updating_blocked_signal = (0, $4GYXz$depictaiui.get_search_query_updating_blocked_signal)(depict_search);
224
+ if (!search_query_updating_blocked_signal) throw Error("No search_query_updating_blocked_signal when rendering SearchPage");
225
+ const [, set_search_query_updating_blocked_signal] = search_query_updating_blocked_signal;
226
+ const update_updating_blocked_signal = ()=>{
227
+ set_search_query_updating_blocked_signal(!(0, $b4d0d98857ed9934$export$6cb4d3a5c1ac9b43)(location));
228
+ };
229
+ // react is really slow with disposing components, we want to avoid a flash of another search query when you click on a product and navigate away
230
+ (0, $b4d0d98857ed9934$export$74f3924c5027fe1d)(update_updating_blocked_signal); // if we navigate, re-check
231
+ (0, $4GYXz$solidjs.createComputed)(()=>{
232
+ (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_page_path_[0](); // if react defined path changes, re-check
233
+ update_updating_blocked_signal();
234
+ });
235
+ const component_portals = new Set();
236
+ return (0, $4GYXz$depictaiui.SearchPage)({
237
+ // Default config goes here
238
+ include_input_field: props.includeInputField ?? true,
239
+ cols_at_size: props.columnsAtSize ?? [
240
+ [
241
+ 4
242
+ ],
243
+ [
244
+ 3,
245
+ 1024
246
+ ],
247
+ [
248
+ 2,
249
+ 901
250
+ ]
251
+ ],
252
+ grid_spacing: props.gridSpacing ?? "2%",
253
+ // Todo: Do we need this?
254
+ get_product_id: ()=>"",
255
+ depict_search: depict_search,
256
+ product_card_template: async (display, info)=>{
257
+ const solid_container = document.createElement("div");
258
+ const react_has_rendered = new Promise((r)=>{
259
+ const m_o = new MutationObserver(()=>{
260
+ m_o.disconnect();
261
+ r();
262
+ });
263
+ m_o.observe(solid_container, {
264
+ childList: true
265
+ });
266
+ });
267
+ const is_placeholder = info.rendering_options.type === "placeholder";
268
+ const reactProductCard = (0, $4GYXz$reactjsxruntime.jsx)(props.productCard, {
269
+ display: is_placeholder ? null : display
270
+ });
271
+ const portal = $4GYXz$reactdom.createPortal(reactProductCard, solid_container);
272
+ component_portals.add(portal);
273
+ set_portals([
274
+ ...component_portals
275
+ ]);
276
+ (0, $4GYXz$solidjs.onCleanup)(()=>{
277
+ // this will stop working after any await so be careful to not await before this, or you'll have to carry the owner over with getOwner and runWithOwner
278
+ component_portals.delete(portal);
279
+ set_portals([
280
+ ...component_portals
281
+ ]);
282
+ });
283
+ await react_has_rendered; // wait for react to have finish portaling the elements so that the placeholders get removed once we have an actual result and so that the PLP code knows it has a placeholder when this is a placeholder rendering
284
+ return [
285
+ solid_container
286
+ ];
287
+ }
288
+ });
289
+ }
290
+
291
+
292
+
293
+