@depict-ai/react-ui 0.0.1 → 0.0.4

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Display } from "@depict-ai/ui";
2
- import { ReactNode } from "react";
2
+ import { PropsWithChildren, ReactNode } from "react";
3
3
  export interface SearchConfig {
4
4
  merchant: string;
5
5
  market: string;
@@ -7,6 +7,5 @@ export interface SearchConfig {
7
7
  export interface SearchPageConfig {
8
8
  productCardFactory: (display: Display) => ReactNode;
9
9
  }
10
- export function DepictProvider(opts: SearchConfig): void;
10
+ export function DepictProvider({ children, merchant, market }: PropsWithChildren<SearchConfig>): ReactNode;
11
11
  export function DepictSearchPage(opts: SearchPageConfig): any;
12
- export function openModal(): void;
package/dist/main.js CHANGED
@@ -1,10 +1,8 @@
1
- var $lgFzj$reactdom = require("react-dom");
2
1
  var $lgFzj$depictaireactsolidbridge = require("@depict-ai/react-solid-bridge");
3
- var $lgFzj$depictaiui = require("@depict-ai/ui");
4
2
  var $lgFzj$react = require("react");
3
+ var $lgFzj$depictaiui = require("@depict-ai/ui");
5
4
  var $lgFzj$reactjsxruntime = require("react/jsx-runtime");
6
5
  var $lgFzj$solidjs = require("solid-js");
7
- var $lgFzj$depictaiutilishared = require("@depict-ai/utilishared");
8
6
 
9
7
  function $parcel$export(e, n, v, s) {
10
8
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
@@ -12,142 +10,34 @@ function $parcel$export(e, n, v, s) {
12
10
 
13
11
  $parcel$export(module.exports, "DepictProvider", () => $6abe21f0d440de7c$export$9fac37a9c21c2f3b);
14
12
  $parcel$export(module.exports, "DepictSearchPage", () => $6abe21f0d440de7c$export$210723f5a54a7028);
15
- $parcel$export(module.exports, "openModal", () => $6abe21f0d440de7c$export$a7f6cffb6b8ba11c);
16
-
17
-
18
13
 
19
14
 
20
15
 
21
16
 
22
- const $ed09819de7bb86d1$export$99ae278b8f3607a0 = (opts)=>{
23
- const path = "/search";
24
- const is_page_ = (url)=>url.pathname == path;
25
- const api = new (0, $lgFzj$depictaiui.DepictAPI)();
26
- const search = new (0, $lgFzj$depictaiui.Search)({
27
- depict_api_: api,
28
- page_replacer_ref_: ()=>{},
29
- url_transformer_: (url)=>{
30
- url.pathname = path;
31
- },
32
- alternative_query_submitter_for_spas_: (param_name, new_query, url_transformer)=>{
33
- const url = new URL(location.href);
34
- const was_page = is_page_(url);
35
- url.searchParams.set(param_name, new_query);
36
- url_transformer?.(url);
37
- window.next.router.push({
38
- "pathname": path,
39
- "query": {
40
- [param_name]: new_query
41
- }
42
- }, url.pathname + url.search + url.hash, {
43
- shallow: was_page,
44
- scroll: true
45
- });
46
- },
47
- modal_options_: {
48
- render_instant_card_: opts.instantCardFactory,
49
- render_instant_card_placeholder_: (0, $lgFzj$depictaiui.DefaultInstantCardPlaceholder),
50
- disable_scrolling_: false
51
- },
52
- search_page_: {
53
- get_product_id_: ()=>"",
54
- search_query_param_name_: "q",
55
- is_search_page_: is_page_,
56
- include_input_field_: true,
57
- make_category_suggestion_card_: false,
58
- slider_arrow_button_: (0, $lgFzj$depictaiutilishared.GenericSliderArrowButton)({
59
- height_: 12,
60
- width_: 6.46
61
- }),
62
- page_title_: "Search page",
63
- layout_options_: {
64
- cols_at_size: [
65
- [
66
- 4,
67
- "1024px"
68
- ],
69
- [
70
- 3,
71
- "901px",
72
- "1023px"
73
- ],
74
- [
75
- 2,
76
- "",
77
- "900px"
78
- ]
79
- ],
80
- grid_spacing: "10px"
81
- },
82
- rr_options_: {
83
- template: opts.productCardFactory
84
- }
85
- }
86
- });
87
- search.tenant_ = opts.merchant;
88
- search.market_ = opts.market;
89
- search.locale_ = {
90
- ...(0, $lgFzj$depictaiui.swedish_search_translation),
91
- price_formatting_: {
92
- pre_: "€ ",
93
- post_: "",
94
- decimal_places_delimiter_: ",",
95
- thousands_delimiter_: " ",
96
- places_after_comma_: 2
97
- }
98
- };
99
- return {
100
- search: search,
101
- controls: search.boot_()
102
- };
103
- };
104
-
105
-
106
-
107
17
 
108
- let $6abe21f0d440de7c$var$search;
109
- let $6abe21f0d440de7c$var$controls;
110
- let $6abe21f0d440de7c$var$active_render_card;
111
- const $6abe21f0d440de7c$var$wrapped_render_card = (d)=>$6abe21f0d440de7c$var$active_render_card(d);
112
- function $6abe21f0d440de7c$export$9fac37a9c21c2f3b(opts) {
113
- if (!$6abe21f0d440de7c$var$search) {
114
- const init = (0, $ed09819de7bb86d1$export$99ae278b8f3607a0)({
115
- merchant: opts.merchant,
116
- market: opts.market,
117
- productCardFactory: $6abe21f0d440de7c$var$wrapped_render_card,
118
- instantCardFactory: (0, $lgFzj$depictaiui.UniversalInstantCard)
119
- });
120
- $6abe21f0d440de7c$var$search = init.search;
121
- $6abe21f0d440de7c$var$controls = init.controls;
122
- }
18
+ function $6abe21f0d440de7c$export$9fac37a9c21c2f3b({ children: children , merchant: merchant , market: market }) {
19
+ return children;
123
20
  }
124
21
  function $6abe21f0d440de7c$var$DepictSearchPageContent(opts) {
125
22
  const [bridge, setBridge] = (0, $lgFzj$react.useState)(null);
126
- const [portals, set_portals] = (0, $lgFzj$react.useState)([]);
127
23
  (0, $lgFzj$react.useEffect)(()=>{
128
- const component_portals = [];
129
- $6abe21f0d440de7c$var$active_render_card = (display)=>{
130
- const solid_container = (0, $lgFzj$depictaiui.SolidCardContainer)();
131
- const reactProductCard = opts.productCardFactory(display);
132
- const portal = $lgFzj$reactdom.createPortal(reactProductCard, solid_container.ref);
133
- component_portals.push(portal);
134
- set_portals([
135
- ...component_portals
136
- ]);
137
- return [
138
- solid_container.el
139
- ];
140
- };
141
- const el = $6abe21f0d440de7c$var$search.render_;
142
- const solidBridge = (0, $lgFzj$reactjsxruntime.jsx)((0, $lgFzj$depictaireactsolidbridge.ReactToSolidBridge), {
143
- solidComponent: ()=>el,
144
- key: Math.random()
145
- });
146
- setBridge(solidBridge);
24
+ if (!bridge) {
25
+ const [title] = (0, $lgFzj$solidjs.createSignal)("Category");
26
+ const solid_element = (0, $lgFzj$depictaiui.CategoryTitle)({
27
+ category_title_: title,
28
+ product_count_: 0
29
+ });
30
+ const solid_bridge = (0, $lgFzj$reactjsxruntime.jsx)((0, $lgFzj$depictaireactsolidbridge.ReactToSolidBridge), {
31
+ solidComponent: ()=>solid_element,
32
+ key: Math.random()
33
+ });
34
+ setBridge(solid_bridge);
35
+ }
147
36
  }, []);
148
- return bridge ? (0, $lgFzj$react.createElement)("div", {}, [
149
- bridge,
150
- ...portals
37
+ return bridge ? (0, $lgFzj$react.createElement)("div", {
38
+ className: "solid_bridge"
39
+ }, [
40
+ bridge
151
41
  ]) : "";
152
42
  }
153
43
  function $6abe21f0d440de7c$export$210723f5a54a7028(opts) {
@@ -155,33 +45,5 @@ function $6abe21f0d440de7c$export$210723f5a54a7028(opts) {
155
45
  children: (0, $lgFzj$reactjsxruntime.jsx)($6abe21f0d440de7c$var$DepictSearchPageContent, opts)
156
46
  });
157
47
  }
158
- let $6abe21f0d440de7c$var$sheet;
159
- function $6abe21f0d440de7c$export$a7f6cffb6b8ba11c() {
160
- if (!$6abe21f0d440de7c$var$controls) {
161
- console.error("No active search header component on the page!");
162
- return;
163
- }
164
- $6abe21f0d440de7c$var$controls.then((c)=>{
165
- const style_props_ = (0, $lgFzj$solidjs.createSignal)({
166
- position: "fixed",
167
- top: 0
168
- });
169
- /*if (header?.clientHeight) {
170
- let styles = `.depict.plp.in_header .depict-search-modal .query_input { height: ${header?.clientHeight}px; }`;
171
- styles += `.depict.plp.in_header .depict-search-modal-backdrop { top: ${header?.clientHeight}px; }`;
172
- if (!sheet) {
173
- const style = document.createElement("style");
174
- style.append(styles);
175
- document.head.appendChild(style);
176
- }
177
- }*/ const class_list_ = (0, $lgFzj$solidjs.createMemo)(()=>({
178
- in_header: true
179
- }));
180
- c.open_modal_({
181
- style_props_: style_props_,
182
- class_list_: class_list_
183
- });
184
- });
185
- }
186
48
 
187
49
 
package/dist/module.js CHANGED
@@ -1 +1,44 @@
1
- import{createPortal as e}from"react-dom";import{ReactToSolidBridge as a,ReactToSolidBridgeProvider as r}from"@depict-ai/react-solid-bridge";import{UniversalInstantCard as t,SolidCardContainer as o,DepictAPI as s,Search as n,DefaultInstantCardPlaceholder as i,swedish_search_translation as c}from"@depict-ai/ui";import{useState as _,useEffect as d,createElement as p}from"react";import{jsx as l}from"react/jsx-runtime";import{createSignal as m,createMemo as h}from"solid-js";import{GenericSliderArrowButton as u}from"@depict-ai/utilishared";const f=e=>{const a="/search",r=e=>e.pathname==a,t=new s,o=new n({depict_api_:t,page_replacer_ref_:()=>{},url_transformer_:e=>{e.pathname=a},alternative_query_submitter_for_spas_:(e,t,o)=>{const s=new URL(location.href),n=r(s);s.searchParams.set(e,t),o?.(s),window.next.router.push({pathname:a,query:{[e]:t}},s.pathname+s.search+s.hash,{shallow:n,scroll:!0})},modal_options_:{render_instant_card_:e.instantCardFactory,render_instant_card_placeholder_:i,disable_scrolling_:!1},search_page_:{get_product_id_:()=>"",search_query_param_name_:"q",is_search_page_:r,include_input_field_:!0,make_category_suggestion_card_:!1,slider_arrow_button_:u({height_:12,width_:6.46}),page_title_:"Search page",layout_options_:{cols_at_size:[[4,"1024px"],[3,"901px","1023px"],[2,"","900px"]],grid_spacing:"10px"},rr_options_:{template:e.productCardFactory}}});return o.tenant_=e.merchant,o.market_=e.market,o.locale_={...c,price_formatting_:{pre_:"€ ",post_:"",decimal_places_delimiter_:",",thousands_delimiter_:" ",places_after_comma_:2}},{search:o,controls:o.boot_()}};let g,y,w;const x=e=>w(e);function C(e){if(!g){const a=f({merchant:e.merchant,market:e.market,productCardFactory:x,instantCardFactory:t});g=a.search,y=a.controls}}function S(r){const[t,s]=_(null),[n,i]=_([]);return d((()=>{const t=[];w=a=>{const s=o(),n=r.productCardFactory(a),c=e(n,s.ref);return t.push(c),i([...t]),[s.el]};const n=g.render_,c=l(a,{solidComponent:()=>n,key:Math.random()});s(c)}),[]),t?p("div",{},[t,...n]):""}function P(e){return l(r,{children:l(S,e)})}function k(){y?y.then((e=>{const a=m({position:"fixed",top:0}),r=h((()=>({in_header:!0})));e.open_modal_({style_props_:a,class_list_:r})})):console.error("No active search header component on the page!")}export{C as DepictProvider,P as DepictSearchPage,k as openModal};
1
+ import {ReactToSolidBridge as $5DrVA$ReactToSolidBridge, ReactToSolidBridgeProvider as $5DrVA$ReactToSolidBridgeProvider} from "@depict-ai/react-solid-bridge";
2
+ import {useState as $5DrVA$useState, useEffect as $5DrVA$useEffect, createElement as $5DrVA$createElement} from "react";
3
+ import {CategoryTitle as $5DrVA$CategoryTitle} from "@depict-ai/ui";
4
+ import {jsx as $5DrVA$jsx} from "react/jsx-runtime";
5
+ import {createSignal as $5DrVA$createSignal} from "solid-js";
6
+
7
+
8
+
9
+
10
+
11
+
12
+ function $ea53d4d38ca71150$export$9fac37a9c21c2f3b({ children: children , merchant: merchant , market: market }) {
13
+ return children;
14
+ }
15
+ function $ea53d4d38ca71150$var$DepictSearchPageContent(opts) {
16
+ const [bridge, setBridge] = (0, $5DrVA$useState)(null);
17
+ (0, $5DrVA$useEffect)(()=>{
18
+ if (!bridge) {
19
+ const [title] = (0, $5DrVA$createSignal)("Category");
20
+ const solid_element = (0, $5DrVA$CategoryTitle)({
21
+ category_title_: title,
22
+ product_count_: 0
23
+ });
24
+ const solid_bridge = (0, $5DrVA$jsx)((0, $5DrVA$ReactToSolidBridge), {
25
+ solidComponent: ()=>solid_element,
26
+ key: Math.random()
27
+ });
28
+ setBridge(solid_bridge);
29
+ }
30
+ }, []);
31
+ return bridge ? (0, $5DrVA$createElement)("div", {
32
+ className: "solid_bridge"
33
+ }, [
34
+ bridge
35
+ ]) : "";
36
+ }
37
+ function $ea53d4d38ca71150$export$210723f5a54a7028(opts) {
38
+ return (0, $5DrVA$jsx)((0, $5DrVA$ReactToSolidBridgeProvider), {
39
+ children: (0, $5DrVA$jsx)($ea53d4d38ca71150$var$DepictSearchPageContent, opts)
40
+ });
41
+ }
42
+
43
+
44
+ export {$ea53d4d38ca71150$export$9fac37a9c21c2f3b as DepictProvider, $ea53d4d38ca71150$export$210723f5a54a7028 as DepictSearchPage};
@@ -11,12 +11,10 @@ $parcel$export(module.exports, "openModal", () => $5767ac9f6fd2be28$export$a7f6c
11
11
 
12
12
 
13
13
  function $5767ac9f6fd2be28$export$9fac37a9c21c2f3b(props) {
14
- return (0, $4yCyN$reactjsxruntime.jsx)((0, $4yCyN$depictaireactsolidbridge.ReactToSolidBridgeProvider), {
15
- children: props.children
16
- });
14
+ return props.children;
17
15
  }
18
16
  function $5767ac9f6fd2be28$export$210723f5a54a7028() {
19
- return (0, $4yCyN$reactjsxruntime.jsx)($5767ac9f6fd2be28$export$9fac37a9c21c2f3b, {
17
+ return (0, $4yCyN$reactjsxruntime.jsx)((0, $4yCyN$depictaireactsolidbridge.ReactToSolidBridgeProvider), {
20
18
  children: ""
21
19
  });
22
20
  }
@@ -1 +1,17 @@
1
- import{ReactToSolidBridgeProvider as r}from"@depict-ai/react-solid-bridge";import{jsx as e}from"react/jsx-runtime";function i(i){return e(r,{children:i.children})}function o(){return e(i,{children:""})}function t(){}export{i as DepictProvider,o as DepictSearchPage,t as openModal};
1
+ import {ReactToSolidBridgeProvider as $8UQZK$ReactToSolidBridgeProvider} from "@depict-ai/react-solid-bridge";
2
+ import {jsx as $8UQZK$jsx} from "react/jsx-runtime";
3
+
4
+
5
+
6
+ function $7def0b56bbffc00f$export$9fac37a9c21c2f3b(props) {
7
+ return props.children;
8
+ }
9
+ function $7def0b56bbffc00f$export$210723f5a54a7028() {
10
+ return (0, $8UQZK$jsx)((0, $8UQZK$ReactToSolidBridgeProvider), {
11
+ children: ""
12
+ });
13
+ }
14
+ function $7def0b56bbffc00f$export$a7f6cffb6b8ba11c() {}
15
+
16
+
17
+ export {$7def0b56bbffc00f$export$9fac37a9c21c2f3b as DepictProvider, $7def0b56bbffc00f$export$210723f5a54a7028 as DepictSearchPage, $7def0b56bbffc00f$export$a7f6cffb6b8ba11c as openModal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/react-ui",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
4
  "packageManager": "yarn@3.2.2",
5
5
  "source": "src/main.ts",
6
6
  "main": "dist/main.js",
@@ -29,15 +29,17 @@
29
29
  "engines": {
30
30
  "browsers": "last 1 chrome version"
31
31
  },
32
- "optimize": true
32
+ "optimize": false
33
33
  }
34
34
  },
35
35
  "exports": {
36
36
  ".": {
37
37
  "node": {
38
- "import": "./dist-server/main.js"
38
+ "require": "./dist-server/main.js",
39
+ "import": "./dist-server/module.js"
39
40
  },
40
41
  "default": {
42
+ "require": "./dist/main.js",
41
43
  "import": "./dist/main.js"
42
44
  }
43
45
  }
@@ -47,7 +49,7 @@
47
49
  "/dist-server"
48
50
  ],
49
51
  "dependencies": {
50
- "@depict-ai/react-solid-bridge": "^1.0.25",
52
+ "@depict-ai/react-solid-bridge": "^1.0.26",
51
53
  "@depict-ai/ui": "^0.0.0",
52
54
  "@depict-ai/utilishared": "^0.0.0",
53
55
  "react": "^18.2.0",