@depict-ai/react-ui 0.0.1

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.
@@ -0,0 +1,12 @@
1
+ import { Display } from "@depict-ai/ui";
2
+ import { ReactNode } from "react";
3
+ export interface SearchConfig {
4
+ merchant: string;
5
+ market: string;
6
+ }
7
+ export interface SearchPageConfig {
8
+ productCardFactory: (display: Display) => ReactNode;
9
+ }
10
+ export function DepictProvider(opts: SearchConfig): void;
11
+ export function DepictSearchPage(opts: SearchPageConfig): any;
12
+ export function openModal(): void;
package/dist/main.js ADDED
@@ -0,0 +1,187 @@
1
+ var $lgFzj$reactdom = require("react-dom");
2
+ var $lgFzj$depictaireactsolidbridge = require("@depict-ai/react-solid-bridge");
3
+ var $lgFzj$depictaiui = require("@depict-ai/ui");
4
+ var $lgFzj$react = require("react");
5
+ var $lgFzj$reactjsxruntime = require("react/jsx-runtime");
6
+ var $lgFzj$solidjs = require("solid-js");
7
+ var $lgFzj$depictaiutilishared = require("@depict-ai/utilishared");
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, "DepictProvider", () => $6abe21f0d440de7c$export$9fac37a9c21c2f3b);
14
+ $parcel$export(module.exports, "DepictSearchPage", () => $6abe21f0d440de7c$export$210723f5a54a7028);
15
+ $parcel$export(module.exports, "openModal", () => $6abe21f0d440de7c$export$a7f6cffb6b8ba11c);
16
+
17
+
18
+
19
+
20
+
21
+
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
+
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
+ }
123
+ }
124
+ function $6abe21f0d440de7c$var$DepictSearchPageContent(opts) {
125
+ const [bridge, setBridge] = (0, $lgFzj$react.useState)(null);
126
+ const [portals, set_portals] = (0, $lgFzj$react.useState)([]);
127
+ (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);
147
+ }, []);
148
+ return bridge ? (0, $lgFzj$react.createElement)("div", {}, [
149
+ bridge,
150
+ ...portals
151
+ ]) : "";
152
+ }
153
+ function $6abe21f0d440de7c$export$210723f5a54a7028(opts) {
154
+ return (0, $lgFzj$reactjsxruntime.jsx)((0, $lgFzj$depictaireactsolidbridge.ReactToSolidBridgeProvider), {
155
+ children: (0, $lgFzj$reactjsxruntime.jsx)($6abe21f0d440de7c$var$DepictSearchPageContent, opts)
156
+ });
157
+ }
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
+
187
+
package/dist/module.js ADDED
@@ -0,0 +1 @@
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};
@@ -0,0 +1,3 @@
1
+ export function DepictProvider(props: any): any;
2
+ export function DepictSearchPage(): any;
3
+ export function openModal(): void;
@@ -0,0 +1,25 @@
1
+ var $4yCyN$depictaireactsolidbridge = require("@depict-ai/react-solid-bridge");
2
+ var $4yCyN$reactjsxruntime = require("react/jsx-runtime");
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "DepictProvider", () => $5767ac9f6fd2be28$export$9fac37a9c21c2f3b);
9
+ $parcel$export(module.exports, "DepictSearchPage", () => $5767ac9f6fd2be28$export$210723f5a54a7028);
10
+ $parcel$export(module.exports, "openModal", () => $5767ac9f6fd2be28$export$a7f6cffb6b8ba11c);
11
+
12
+
13
+ function $5767ac9f6fd2be28$export$9fac37a9c21c2f3b(props) {
14
+ return (0, $4yCyN$reactjsxruntime.jsx)((0, $4yCyN$depictaireactsolidbridge.ReactToSolidBridgeProvider), {
15
+ children: props.children
16
+ });
17
+ }
18
+ function $5767ac9f6fd2be28$export$210723f5a54a7028() {
19
+ return (0, $4yCyN$reactjsxruntime.jsx)($5767ac9f6fd2be28$export$9fac37a9c21c2f3b, {
20
+ children: ""
21
+ });
22
+ }
23
+ function $5767ac9f6fd2be28$export$a7f6cffb6b8ba11c() {}
24
+
25
+
@@ -0,0 +1 @@
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};
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@depict-ai/react-ui",
3
+ "version": "0.0.1",
4
+ "packageManager": "yarn@3.2.2",
5
+ "source": "src/main.ts",
6
+ "main": "dist/main.js",
7
+ "module": "dist/module.js",
8
+ "types": "dist/index.d.ts",
9
+ "license": "MIT",
10
+ "scripts": {
11
+ "clear-dist": "rm -r -f ./dist",
12
+ "build": "yarn build-server && parcel build --no-source-maps",
13
+ "build-server": "yarn clear-dist && parcel build --no-source-maps ./src-server/main.ts && cp -r ./dist/ ./dist-server && yarn clear-dist",
14
+ "print-included-package-files": "yarn pack --dry-run",
15
+ "typecheck": "yarn g:tsc --build tsconfig.json"
16
+ },
17
+ "targets": {
18
+ "main": {
19
+ "isLibrary": true,
20
+ "context": "browser",
21
+ "engines": {
22
+ "browsers": "last 1 chrome version"
23
+ },
24
+ "optimize": false
25
+ },
26
+ "module": {
27
+ "isLibrary": true,
28
+ "context": "browser",
29
+ "engines": {
30
+ "browsers": "last 1 chrome version"
31
+ },
32
+ "optimize": true
33
+ }
34
+ },
35
+ "exports": {
36
+ ".": {
37
+ "node": {
38
+ "import": "./dist-server/main.js"
39
+ },
40
+ "default": {
41
+ "import": "./dist/main.js"
42
+ }
43
+ }
44
+ },
45
+ "files": [
46
+ "/dist",
47
+ "/dist-server"
48
+ ],
49
+ "dependencies": {
50
+ "@depict-ai/react-solid-bridge": "^1.0.25",
51
+ "@depict-ai/ui": "^0.0.0",
52
+ "@depict-ai/utilishared": "^0.0.0",
53
+ "react": "^18.2.0",
54
+ "react-dom": "^18.2.0",
55
+ "solid-js": "^1.6.2"
56
+ },
57
+ "devDependencies": {
58
+ "@babel/core": "latest",
59
+ "@babel/preset-env": "latest",
60
+ "@babel/preset-typescript": "latest",
61
+ "@babel/runtime": "latest",
62
+ "@babel/runtime-corejs3": "latest",
63
+ "@parcel/babel-preset-env": "latest",
64
+ "@parcel/resolver-default": "^2.8.0",
65
+ "@types/node": "^18.11.11",
66
+ "@types/react": "^18.0.26",
67
+ "@types/react-dom": "^18.0.9",
68
+ "babel-preset-solid": "latest",
69
+ "parcel": "latest"
70
+ }
71
+ }