@askdialog/dialog-react 2.9.0 → 2.10.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.
- package/README.md +2 -1
- package/dist/components/DialogSearch/DialogSearchCollections.d.ts +2 -2
- package/dist/components/DialogSearch/searchCollections.d.ts +3 -3
- package/dist/components/DialogSearch/searchDisplay.d.ts +4 -7
- package/dist/components/DialogSearch/useDialogSearch.d.ts +2 -0
- package/dist/dialog-react.css +1 -1
- package/dist/dialog-react.js +197 -202
- package/dist/dialog-react.umd.cjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -138,6 +138,7 @@ Creates one search controller per hook instance and disposes it on unmount.
|
|
|
138
138
|
- `country` (string, required) - Shopper's ISO 3166-1 alpha-2 country, e.g. `BE`; prices follow its market
|
|
139
139
|
- `surface` (SearchSurface, optional) - Where results are displayed, for analytics (default: `'search_page'`)
|
|
140
140
|
- `navigate` ((url, hit: SearchProductHit) => void, optional) - Router adapter called after selection attribution (e.g. `(url) => router.push(url)`). Omit it to let the cards' plain `<a href>` links navigate natively.
|
|
141
|
+
- `buildProductUrl` ((hit: SearchProductHit) => string | undefined, optional) - Builds a card's link when its hit has no `url`, e.g. ``(hit) => `/products/${hit.handle}` ``. With neither, the card has no link.
|
|
141
142
|
- `debounceMs` (number, optional) - Keystroke debounce (default: 250)
|
|
142
143
|
- `hitsPerPage` (number, optional) - Results per page (default: 12)
|
|
143
144
|
- `sections` (SearchSection[], optional) - Extra indices searched alongside the products; `collections` fills the collections column of `DialogSearchResults`. Only request an index the catalog exposes: a missing one fails the whole search.
|
|
@@ -169,7 +170,7 @@ Search input: typing runs a debounced search, submitting (Enter) searches immedi
|
|
|
169
170
|
|
|
170
171
|
#### DialogSearchResults
|
|
171
172
|
|
|
172
|
-
Floating results panel overlaying the page content: portaled to `document.body` in `position: fixed`, centered on the bar (up to 1440px wide, filling the viewport) and anchored under the spot where the component is rendered (place it right after the bar), so no ancestor stacking context or `overflow: hidden` can hide it. It shows the same layout as the Shopify search overlay: a collections column on the left when `sections` requests them, the products on the right as a list or a 3-column grid, the query match emphasized in every title, and either a "See all results" button or the pagination controls. Below 768px the panel stacks, collections in a horizontal rail above the products. Colors, radii and font follow the SDK theme (dark palette when `backgroundColor` is dark, straight or rounded corners from `ctaBorderType`). Each product card reads the hit, Algolia's Shopify record: its `product_image` (the variant's `image` when absent), its `title`, its lowest variant price (`variants_min_price`, formatted with `currency`, the base currency of the shopper's market) and its `url`; a hit without a price shows none. Each card links to the product page and records search attribution (viewport impressions, select on click and middle-click) automatically. Clicking outside the panel (and outside the bar) closes it; typing again or re-focusing the bar reopens it with the results kept.
|
|
173
|
+
Floating results panel overlaying the page content: portaled to `document.body` in `position: fixed`, centered on the bar (up to 1440px wide, filling the viewport) and anchored under the spot where the component is rendered (place it right after the bar), so no ancestor stacking context or `overflow: hidden` can hide it. It shows the same layout as the Shopify search overlay: a collections column on the left when `sections` requests them, the products on the right as a list or a 3-column grid, the query match emphasized in every title, and either a "See all results" button or the pagination controls. Below 768px the panel stacks, collections in a horizontal rail above the products. Colors, radii and font follow the SDK theme (dark palette when `backgroundColor` is dark, straight or rounded corners from `ctaBorderType`). Each product card reads the hit, Algolia's Shopify record: its `product_image` (the variant's `image` when absent), its `title`, its lowest variant price (`variants_min_price`, formatted with `currency`, the base currency of the shopper's market), struck through next to it the lowest compare-at price (`variants_compare_at_price_min`, formatted the same way) when it is higher, and its `url`; a hit without a price shows none. Each card links to the product page and records search attribution (viewport impressions, select on click and middle-click) automatically. Clicking outside the panel (and outside the bar) closes it; typing again or re-focusing the bar reopens it with the results kept.
|
|
173
174
|
|
|
174
175
|
**Props:**
|
|
175
176
|
- `controller` (SearchController) - From `useDialogSearch` (required)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SearchCollectionHit } from '@askdialog/dialog-sdk';
|
|
3
3
|
import { SearchMessages } from './searchMessages';
|
|
4
4
|
interface DialogSearchCollectionsProps {
|
|
5
|
-
collections:
|
|
5
|
+
collections: SearchCollectionHit[];
|
|
6
6
|
query: string;
|
|
7
7
|
messages: SearchMessages;
|
|
8
8
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchCollectionHit } from '@askdialog/dialog-sdk';
|
|
2
2
|
/** Collections without a link cannot navigate on selection and are not rendered. */
|
|
3
|
-
export declare const navigableCollections: (collections:
|
|
4
|
-
collection:
|
|
3
|
+
export declare const navigableCollections: (collections: SearchCollectionHit[] | undefined) => {
|
|
4
|
+
collection: SearchCollectionHit;
|
|
5
5
|
href: string;
|
|
6
6
|
}[];
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* The lowest variant price only, as on the Shopify storefront search.
|
|
4
|
-
* Hide a missing or invalid price; show a bare amount when currency is absent.
|
|
5
|
-
*/
|
|
6
|
-
export declare const formatSearchPrice: ({ variants_min_price: amount, currency }: SearchProductHit, locale?: string) => string;
|
|
1
|
+
import { SearchHitByIndex, SearchIndex, SearchProductHit } from '@askdialog/dialog-sdk';
|
|
2
|
+
type SearchHit = SearchHitByIndex[SearchIndex];
|
|
7
3
|
/** The product's image, as Algolia's cards in distinct mode; else the variant's. */
|
|
8
4
|
export declare const hitImage: (hit: SearchProductHit) => string | undefined;
|
|
9
|
-
export declare const safeHref: (url: string) => string | undefined;
|
|
5
|
+
export declare const safeHref: (url: string | undefined) => string | undefined;
|
|
10
6
|
export declare const hitHref: (hit: SearchHit) => string | undefined;
|
|
11
7
|
export declare const hitTitle: (hit: SearchHit) => string;
|
|
8
|
+
export {};
|
|
@@ -9,6 +9,8 @@ export interface UseDialogSearchOptions {
|
|
|
9
9
|
surface?: SearchSurface;
|
|
10
10
|
/** Navigate after recording selection; omit to use native links. */
|
|
11
11
|
navigate?: (url: string, hit: SearchProductHit) => void;
|
|
12
|
+
/** Build a product's link when its hit has no `url`, e.g. `/products/${hit.handle}`. */
|
|
13
|
+
buildProductUrl?: (hit: SearchProductHit) => string | undefined;
|
|
12
14
|
debounceMs?: number;
|
|
13
15
|
hitsPerPage?: number;
|
|
14
16
|
/**
|
package/dist/dialog-react.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.dialog-ask-something-else{padding:12px 16px;min-height:50px;width:fit-content;display:flex;align-items:center;font-family:var(--dialog-theme-font-family);font-size:var(--dialog-theme-content-font-size, 14px);font-weight:500;cursor:pointer;border:unset;border-radius:var(--dialog-theme-cta-border-type, 24px);background-color:var(--dialog-theme-primary-color);color:var(--dialog-theme-cta-text-color)}.dialog-ask-something-else:hover:not(:disabled){transform:scale(1.02)}.dialog-ask-something-else:disabled{cursor:default;opacity:.5}.dialog-block-header-container{display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start}.dialog-block-title{color:var(--dialog-theme-title-color, #272727);font-family:var(--dialog-theme-font-family);font-size:var(--dialog-theme-title-font-size);font-style:normal;font-weight:500;line-height:20px;letter-spacing:1.3px;text-transform:uppercase}.dialog-block-description{color:var(--dialog-theme-description-color, #6c6c6c);font-family:var(--dialog-theme-font-family);font-size:var(--dialog-theme-description-font-size);font-style:normal;font-weight:500;line-height:20px}.dialog-block-suggestions-item{background-color:#f1f1f1;border:none;outline:none;padding:12px 16px;width:fit-content;cursor:pointer;display:flex;justify-content:flex-start;background-color:#fff;align-items:center;gap:8px;border:1px solid #dddce2;border-radius:24px}.dialog-block-suggestions-item:hover{transform:scale(1.01)}.dialog-block-suggestions-item-label{color:var(--dialog-theme-content-color, #575665);font-size:var(--dialog-theme-content-font-size, 14px);font-weight:500;text-align:start;flex:1}.dialog-block-suggestions-item-icon path{stroke:var(--dialog-theme-primary-color)}.dialog-block-suggestions-skeleton-item,.dialog-block-suggestions-skeleton-item:empty{display:block;width:100%;width:90%;height:18px;border-radius:18px;padding:12px 16px;background-color:#f1f1f1;animation:pulse 1.5s ease-in-out infinite}@keyframes pulse{0%{background-color:#f1f1f1}50%{background-color:#fff}to{background-color:#f1f1f1}}.dialog-block-suggestions-container{display:flex;flex-direction:column;gap:12px;width:100%}.dialog-input-wrapper{position:relative;width:100%;height:50px;max-height:50px;padding:16px 20px;border:1px solid #d9d9d9;border-radius:var(--dialog-theme-cta-border-type, 24px);background:#fff;display:flex;align-items:center;box-sizing:border-box}.dialog-input-container{display:flex;flex-direction:column;gap:8px;width:100%}.dialog-ask-anything-input-ai-input{outline:unset;box-shadow:unset;border:unset;width:100%;font-size:16px;background:transparent;padding-inline-end:35px}.dialog-input-submit{width:40px;height:40px;border-radius:100%;display:flex;align-items:center;justify-content:center;background-color:var(--dialog-theme-primary-color);position:absolute;cursor:pointer;top:calc(50% - 20px);inset-inline-end:4px;border:unset}.dialog-input-submit:disabled{opacity:.5}.dialog-input-ai-disclosure{margin:0;font-size:12px;line-height:1.4;font-family:var(--dialog-theme-font-family);color:var(--dialog-theme-description-color, #6b6b6b)}.dialog-block-container{position:relative;display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;padding:24px 0;width:fit-content;gap:24px}.dialog-block-container>*{box-sizing:border-box}.dialog-search-bar{box-sizing:border-box;display:flex;align-items:center;gap:8px;width:100%;margin:0;padding:10px 10px 10px 14px;background:#fffc;backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border:1px solid rgba(0,0,0,.05);border-radius:24px;box-shadow:0 6px 20px -6px #0000001a}.dialog-search-bar:focus-within{border-color:#00000026;box-shadow:0 6px 20px -6px #0000001a,0 0 0 2px #1717171f}.dialog-search-bar-field{display:flex;flex:1 0 0;min-width:0;align-items:center;gap:6px;padding:2px 0}.dialog-search-bar-icon{display:inline-flex;flex-shrink:0;color:#737373}.dialog-search-bar-input{flex:1 0 0;min-width:0;margin:0;padding:0;border:none;outline:none;background:transparent;font-family:Inter,sans-serif;font-weight:500;font-size:16px;line-height:24px;color:#171717;text-overflow:ellipsis;box-shadow:none;-moz-appearance:none;appearance:none;-webkit-appearance:none}.dialog-search-bar-input::placeholder{color:#a3a3a3;opacity:1}.dialog-search-bar-input:focus,.dialog-search-bar-input:focus-visible{outline:none;box-shadow:none;border:none}.dialog-search-bar-submit{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:28px;height:28px;padding:6px;border:none;border-radius:9999px;background:#171717;color:#fff;box-shadow:0 1px 1px #1717170d;cursor:pointer}.dialog-search-bar-submit:focus-visible{outline:2px solid #171717;outline-offset:2px}.dialog-search-pagination{display:flex;align-items:center;justify-content:center;gap:12px;padding:4px 0;font-size:12px;color:var(--dso-text-sec, #737373)}.dialog-search-pagination button{margin:0;padding:6px 14px;border:1px solid var(--dso-border, rgba(0, 0, 0, .1));border-radius:var(--dso-r-btn, 10px);background:transparent;font:inherit;color:var(--dso-text, #171717);cursor:pointer;transition:background-color .12s ease}.dialog-search-pagination button:hover:not(:disabled){background-color:var(--dso-hover, rgba(0, 0, 0, .04))}.dialog-search-pagination button:disabled{opacity:.4;cursor:default}.dialog-search-card{width:100%}.dialog-search-product{display:grid;grid-template-columns:56px minmax(0,1fr) auto;gap:16px;align-items:center;padding:8px;border-radius:var(--dso-r-item);color:inherit;text-decoration:none}a.dialog-search-product:hover{background:var(--dso-hover)}.dialog-search-product-thumb{flex:none;width:56px;height:56px;overflow:hidden;border:1px solid var(--dso-border);border-radius:var(--dso-r-thumb);background:var(--dso-thumb)}.dialog-search-product-thumb img{display:block;width:100%;height:100%;object-fit:cover}.dialog-search-product-title{flex:1;min-width:0;font-size:14px;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}.dialog-search-product-price{font-size:15px;font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}.dialog-search-match{font-weight:600}.dialog-search-muted{opacity:.55}@media(min-width:768px){.dialog-search-panel--grid .dialog-search-product{display:flex;flex-direction:column;align-items:stretch;gap:10px;padding:12px;border:1px solid var(--dso-border)}.dialog-search-panel--grid .dialog-search-product-thumb{width:100%;height:auto;aspect-ratio:4 / 3;border:0}}@media(max-width:767px){.dialog-search-product{grid-template-columns:52px minmax(0,1fr) auto;gap:12px}.dialog-search-product-thumb{width:52px;height:52px}.dialog-search-product-price{font-size:14px}}.dialog-search-collections{display:flex;flex-direction:column;gap:4px;min-height:0;padding:20px 12px 20px 24px;border-right:1px solid var(--dso-border);background:var(--dso-side);overflow-y:auto}.dialog-search-collection-list{display:flex;flex-direction:column;gap:4px;margin:0;padding:0;list-style:none}.dialog-search-collection{display:flex;align-items:center;gap:12px;padding:8px 12px;border-radius:var(--dso-r-item);color:inherit;text-decoration:none}.dialog-search-collection:hover{background:var(--dso-hover)}.dialog-search-collection-thumb{flex:none;width:40px;height:40px;overflow:hidden;border-radius:var(--dso-r-thumb);background:var(--dso-thumb)}.dialog-search-collection-thumb img{display:block;width:100%;height:100%;object-fit:cover}.dialog-search-collection-title{flex:1;min-width:0;font-size:14px;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}.dialog-search-caret{display:inline-flex;flex:none;color:var(--dso-text-sec)}@media(max-width:767px){.dialog-search-collections{flex:none;gap:10px;padding:0;border-right:0;background:transparent;overflow:visible}.dialog-search-collections .dialog-search-section-head{padding:0 16px}.dialog-search-collection-list{flex-direction:row;gap:10px;padding:0 16px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}.dialog-search-collection-list::-webkit-scrollbar{display:none}.dialog-search-collection{flex:none;flex-direction:column;align-items:stretch;gap:8px;width:80px;padding:0}.dialog-search-collection-thumb{width:80px;height:50px;border-radius:var(--dso-r-item)}.dialog-search-collection-title{font-size:13px}.dialog-search-caret{display:none}}.dialog-search-panel{position:fixed;z-index:9999;box-sizing:border-box;display:flex;flex-direction:column;margin:0;padding:0;background:var(--dso-panel);border-radius:var(--dso-r-panel);box-shadow:0 24px 64px #00000047;overflow:hidden;font-family:var(--dso-font, inherit);font-size:14px;line-height:1.35;color:var(--dso-text);-webkit-font-smoothing:antialiased}.dialog-search-panel *,.dialog-search-panel *:before,.dialog-search-panel *:after{box-sizing:border-box}.dialog-search-status{margin:0;padding:16px 24px;color:var(--dso-text-sec)}.dialog-search-status-error{color:#b3261e}.dialog-search-error{display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding-bottom:16px}.dialog-search-retry{margin:0 24px;padding:6px 14px;border:1px solid var(--dso-border);border-radius:var(--dso-r-btn);background:transparent;font:inherit;font-size:13px;color:var(--dso-text);cursor:pointer;transition:background-color .12s ease}.dialog-search-retry:hover{background-color:var(--dso-hover)}.dialog-search-body{display:grid;grid-template-columns:340px minmax(0,1fr);flex:1;min-height:0}.dialog-search-body--no-collections{grid-template-columns:minmax(0,1fr)}.dialog-search-section-head{display:flex;justify-content:space-between;align-items:baseline;padding:0 12px 8px}.dialog-search-label{margin:0;font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--dso-text-sec)}.dialog-search-label-count{font-size:12px;font-weight:500;letter-spacing:0;text-transform:none}.dialog-search-count{font-size:12px;color:var(--dso-text-sec)}.dialog-search-products{display:flex;flex-direction:column;gap:14px;min-height:0;padding:20px 24px 12px;overflow-y:auto}.dialog-search-products .dialog-search-section-head{padding:0 8px}.dialog-search-results{display:flex;flex-direction:column;margin:0;padding:0;list-style:none}.dialog-search-empty{padding:8px;color:var(--dso-text-sec)}.dialog-search-footer{display:flex;justify-content:flex-end;align-items:center;flex:none;padding:14px 24px;border-top:1px solid var(--dso-border)}.dialog-search-cta{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 20px;border:1px solid var(--dso-primary);border-radius:var(--dso-r-btn);background:var(--dso-primary);color:var(--dso-cta-text);font-size:14px;font-weight:500;text-decoration:none}.dialog-search-cta:hover{filter:brightness(.95)}.dialog-search-footer .dialog-search-pagination{flex:1}@media(min-width:768px){.dialog-search-panel--grid .dialog-search-results{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}}@media(max-width:767px){.dialog-search-body{display:flex;flex-direction:column;gap:18px;padding-top:16px;overflow-y:auto}.dialog-search-products{gap:6px;padding:0 8px 8px;overflow:visible}.dialog-search-footer{padding:12px 16px}.dialog-search-cta{width:100%;height:44px}.dialog-search-cta svg{display:none}}
|
|
1
|
+
.dialog-ask-something-else{padding:12px 16px;min-height:50px;width:fit-content;display:flex;align-items:center;font-family:var(--dialog-theme-font-family);font-size:var(--dialog-theme-content-font-size, 14px);font-weight:500;cursor:pointer;border:unset;border-radius:var(--dialog-theme-cta-border-type, 24px);background-color:var(--dialog-theme-primary-color);color:var(--dialog-theme-cta-text-color)}.dialog-ask-something-else:hover:not(:disabled){transform:scale(1.02)}.dialog-ask-something-else:disabled{cursor:default;opacity:.5}.dialog-block-header-container{display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start}.dialog-block-title{color:var(--dialog-theme-title-color, #272727);font-family:var(--dialog-theme-font-family);font-size:var(--dialog-theme-title-font-size);font-style:normal;font-weight:500;line-height:20px;letter-spacing:1.3px;text-transform:uppercase}.dialog-block-description{color:var(--dialog-theme-description-color, #6c6c6c);font-family:var(--dialog-theme-font-family);font-size:var(--dialog-theme-description-font-size);font-style:normal;font-weight:500;line-height:20px}.dialog-block-suggestions-item{background-color:#f1f1f1;border:none;outline:none;padding:12px 16px;width:fit-content;cursor:pointer;display:flex;justify-content:flex-start;background-color:#fff;align-items:center;gap:8px;border:1px solid #dddce2;border-radius:24px}.dialog-block-suggestions-item:hover{transform:scale(1.01)}.dialog-block-suggestions-item-label{color:var(--dialog-theme-content-color, #575665);font-size:var(--dialog-theme-content-font-size, 14px);font-weight:500;text-align:start;flex:1}.dialog-block-suggestions-item-icon path{stroke:var(--dialog-theme-primary-color)}.dialog-block-suggestions-skeleton-item,.dialog-block-suggestions-skeleton-item:empty{display:block;width:100%;width:90%;height:18px;border-radius:18px;padding:12px 16px;background-color:#f1f1f1;animation:pulse 1.5s ease-in-out infinite}@keyframes pulse{0%{background-color:#f1f1f1}50%{background-color:#fff}to{background-color:#f1f1f1}}.dialog-block-suggestions-container{display:flex;flex-direction:column;gap:12px;width:100%}.dialog-input-wrapper{position:relative;width:100%;height:50px;max-height:50px;padding:16px 20px;border:1px solid #d9d9d9;border-radius:var(--dialog-theme-cta-border-type, 24px);background:#fff;display:flex;align-items:center;box-sizing:border-box}.dialog-input-container{display:flex;flex-direction:column;gap:8px;width:100%}.dialog-ask-anything-input-ai-input{outline:unset;box-shadow:unset;border:unset;width:100%;font-size:16px;background:transparent;padding-inline-end:35px}.dialog-input-submit{width:40px;height:40px;border-radius:100%;display:flex;align-items:center;justify-content:center;background-color:var(--dialog-theme-primary-color);position:absolute;cursor:pointer;top:calc(50% - 20px);inset-inline-end:4px;border:unset}.dialog-input-submit:disabled{opacity:.5}.dialog-input-ai-disclosure{margin:0;font-size:12px;line-height:1.4;font-family:var(--dialog-theme-font-family);color:var(--dialog-theme-description-color, #6b6b6b)}.dialog-block-container{position:relative;display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;padding:24px 0;width:fit-content;gap:24px}.dialog-block-container>*{box-sizing:border-box}.dialog-search-bar{box-sizing:border-box;display:flex;align-items:center;gap:8px;width:100%;margin:0;padding:10px 10px 10px 14px;background:#fffc;backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border:1px solid rgba(0,0,0,.05);border-radius:24px;box-shadow:0 6px 20px -6px #0000001a}.dialog-search-bar:focus-within{border-color:#00000026;box-shadow:0 6px 20px -6px #0000001a,0 0 0 2px #1717171f}.dialog-search-bar-field{display:flex;flex:1 0 0;min-width:0;align-items:center;gap:6px;padding:2px 0}.dialog-search-bar-icon{display:inline-flex;flex-shrink:0;color:#737373}.dialog-search-bar-input{flex:1 0 0;min-width:0;margin:0;padding:0;border:none;outline:none;background:transparent;font-family:Inter,sans-serif;font-weight:500;font-size:16px;line-height:24px;color:#171717;text-overflow:ellipsis;box-shadow:none;-moz-appearance:none;appearance:none;-webkit-appearance:none}.dialog-search-bar-input::placeholder{color:#a3a3a3;opacity:1}.dialog-search-bar-input:focus,.dialog-search-bar-input:focus-visible{outline:none;box-shadow:none;border:none}.dialog-search-bar-submit{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:28px;height:28px;padding:6px;border:none;border-radius:9999px;background:#171717;color:#fff;box-shadow:0 1px 1px #1717170d;cursor:pointer}.dialog-search-bar-submit:focus-visible{outline:2px solid #171717;outline-offset:2px}.dialog-search-pagination{display:flex;align-items:center;justify-content:center;gap:12px;padding:4px 0;font-size:12px;color:var(--dso-text-sec, #737373)}.dialog-search-pagination button{margin:0;padding:6px 14px;border:1px solid var(--dso-border, rgba(0, 0, 0, .1));border-radius:var(--dso-r-btn, 10px);background:transparent;font:inherit;color:var(--dso-text, #171717);cursor:pointer;transition:background-color .12s ease}.dialog-search-pagination button:hover:not(:disabled){background-color:var(--dso-hover, rgba(0, 0, 0, .04))}.dialog-search-pagination button:disabled{opacity:.4;cursor:default}.dialog-search-card{width:100%}.dialog-search-product{display:grid;grid-template-columns:56px minmax(0,1fr) auto;gap:16px;align-items:center;padding:8px;border-radius:var(--dso-r-item);color:inherit;text-decoration:none}a.dialog-search-product:hover{background:var(--dso-hover)}.dialog-search-product-thumb{flex:none;width:56px;height:56px;overflow:hidden;border:1px solid var(--dso-border);border-radius:var(--dso-r-thumb);background:var(--dso-thumb)}.dialog-search-product-thumb img{display:block;width:100%;height:100%;object-fit:cover}.dialog-search-product-title{flex:1;min-width:0;font-size:14px;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}.dialog-search-product-price{font-size:15px;font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}.dialog-search-product-compare-at{margin-inline-end:6px;font-weight:400;opacity:.55}.dialog-search-match{font-weight:600}.dialog-search-muted{opacity:.55}@media(min-width:768px){.dialog-search-panel--grid .dialog-search-product{display:flex;flex-direction:column;align-items:stretch;gap:10px;padding:12px;border:1px solid var(--dso-border)}.dialog-search-panel--grid .dialog-search-product-thumb{width:100%;height:auto;aspect-ratio:4 / 3;border:0}}@media(max-width:767px){.dialog-search-product{grid-template-columns:52px minmax(0,1fr) auto;gap:12px}.dialog-search-product-thumb{width:52px;height:52px}.dialog-search-product-price{font-size:14px}}.dialog-search-collections{display:flex;flex-direction:column;gap:4px;min-height:0;padding:20px 12px 20px 24px;border-right:1px solid var(--dso-border);background:var(--dso-side);overflow-y:auto}.dialog-search-collection-list{display:flex;flex-direction:column;gap:4px;margin:0;padding:0;list-style:none}.dialog-search-collection{display:flex;align-items:center;gap:12px;padding:8px 12px;border-radius:var(--dso-r-item);color:inherit;text-decoration:none}.dialog-search-collection:hover{background:var(--dso-hover)}.dialog-search-collection-thumb{flex:none;width:40px;height:40px;overflow:hidden;border-radius:var(--dso-r-thumb);background:var(--dso-thumb)}.dialog-search-collection-thumb img{display:block;width:100%;height:100%;object-fit:cover}.dialog-search-collection-title{flex:1;min-width:0;font-size:14px;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}.dialog-search-caret{display:inline-flex;flex:none;color:var(--dso-text-sec)}@media(max-width:767px){.dialog-search-collections{flex:none;gap:10px;padding:0;border-right:0;background:transparent;overflow:visible}.dialog-search-collections .dialog-search-section-head{padding:0 16px}.dialog-search-collection-list{flex-direction:row;gap:10px;padding:0 16px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}.dialog-search-collection-list::-webkit-scrollbar{display:none}.dialog-search-collection{flex:none;flex-direction:column;align-items:stretch;gap:8px;width:80px;padding:0}.dialog-search-collection-thumb{width:80px;height:50px;border-radius:var(--dso-r-item)}.dialog-search-collection-title{font-size:13px}.dialog-search-caret{display:none}}.dialog-search-panel{position:fixed;z-index:9999;box-sizing:border-box;display:flex;flex-direction:column;margin:0;padding:0;background:var(--dso-panel);border-radius:var(--dso-r-panel);box-shadow:0 24px 64px #00000047;overflow:hidden;font-family:var(--dso-font, inherit);font-size:14px;line-height:1.35;color:var(--dso-text);-webkit-font-smoothing:antialiased}.dialog-search-panel *,.dialog-search-panel *:before,.dialog-search-panel *:after{box-sizing:border-box}.dialog-search-status{margin:0;padding:16px 24px;color:var(--dso-text-sec)}.dialog-search-status-error{color:#b3261e}.dialog-search-error{display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding-bottom:16px}.dialog-search-retry{margin:0 24px;padding:6px 14px;border:1px solid var(--dso-border);border-radius:var(--dso-r-btn);background:transparent;font:inherit;font-size:13px;color:var(--dso-text);cursor:pointer;transition:background-color .12s ease}.dialog-search-retry:hover{background-color:var(--dso-hover)}.dialog-search-body{display:grid;grid-template-columns:340px minmax(0,1fr);flex:1;min-height:0}.dialog-search-body--no-collections{grid-template-columns:minmax(0,1fr)}.dialog-search-section-head{display:flex;justify-content:space-between;align-items:baseline;padding:0 12px 8px}.dialog-search-label{margin:0;font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--dso-text-sec)}.dialog-search-label-count{font-size:12px;font-weight:500;letter-spacing:0;text-transform:none}.dialog-search-count{font-size:12px;color:var(--dso-text-sec)}.dialog-search-products{display:flex;flex-direction:column;gap:14px;min-height:0;padding:20px 24px 12px;overflow-y:auto}.dialog-search-products .dialog-search-section-head{padding:0 8px}.dialog-search-results{display:flex;flex-direction:column;margin:0;padding:0;list-style:none}.dialog-search-empty{padding:8px;color:var(--dso-text-sec)}.dialog-search-footer{display:flex;justify-content:flex-end;align-items:center;flex:none;padding:14px 24px;border-top:1px solid var(--dso-border)}.dialog-search-cta{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 20px;border:1px solid var(--dso-primary);border-radius:var(--dso-r-btn);background:var(--dso-primary);color:var(--dso-cta-text);font-size:14px;font-weight:500;text-decoration:none}.dialog-search-cta:hover{filter:brightness(.95)}.dialog-search-footer .dialog-search-pagination{flex:1}@media(min-width:768px){.dialog-search-panel--grid .dialog-search-results{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}}@media(max-width:767px){.dialog-search-body{display:flex;flex-direction:column;gap:18px;padding-top:16px;overflow-y:auto}.dialog-search-products{gap:6px;padding:0 8px 8px;overflow:visible}.dialog-search-footer{padding:12px 16px}.dialog-search-cta{width:100%;height:44px}.dialog-search-cta svg{display:none}}
|
package/dist/dialog-react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { registerDialogInstallation as M, addAuditCapability as F, resolveTextDirection as U, SearchStatus as L,
|
|
4
|
-
import { createPortal as
|
|
1
|
+
import { jsx as n, jsxs as g, Fragment as S } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as v, useState as C, useEffect as b, useMemo as y, useLayoutEffect as V, useCallback as P, useSyncExternalStore as K } from "react";
|
|
3
|
+
import { registerDialogInstallation as M, addAuditCapability as F, resolveTextDirection as U, SearchStatus as L, formatSearchPrice as Q, formatSearchCompareAtPrice as W, DialogSearchError as Z, createSearchController as X } from "@askdialog/dialog-sdk";
|
|
4
|
+
import { createPortal as G } from "react-dom";
|
|
5
5
|
const R = {
|
|
6
6
|
en: {
|
|
7
7
|
placeholder: "Ask the AI a question",
|
|
@@ -18,11 +18,11 @@ const R = {
|
|
|
18
18
|
aiDisclosure: "Estás chateando con un asistente de IA. Puede cometer errores, así que verifica la información importante",
|
|
19
19
|
askSomethingElse: "Pregunta otra cosa"
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, T = (e) => {
|
|
22
22
|
var o;
|
|
23
23
|
const t = ((o = e == null ? void 0 : e.split("-")[0]) == null ? void 0 : o.toLowerCase()) ?? "en";
|
|
24
24
|
return R[t] ?? R.en;
|
|
25
|
-
},
|
|
25
|
+
}, Y = ({
|
|
26
26
|
client: e,
|
|
27
27
|
questions: t,
|
|
28
28
|
disabled: o,
|
|
@@ -45,15 +45,15 @@ const R = {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
},
|
|
48
|
-
children:
|
|
48
|
+
children: T(e.locale).askSomethingElse
|
|
49
49
|
}
|
|
50
|
-
),
|
|
50
|
+
), J = ({
|
|
51
51
|
title: e = "Your expert",
|
|
52
52
|
description: t = "A question about this product?"
|
|
53
|
-
}) => /* @__PURE__ */
|
|
53
|
+
}) => /* @__PURE__ */ g("div", { className: "dialog-block-header-container", children: [
|
|
54
54
|
/* @__PURE__ */ n("div", { className: "dialog-block-title", children: e }),
|
|
55
55
|
/* @__PURE__ */ n("div", { className: "dialog-block-description", children: t })
|
|
56
|
-
] }),
|
|
56
|
+
] }), ee = ({ color: e = "#181825" }) => /* @__PURE__ */ g(
|
|
57
57
|
"svg",
|
|
58
58
|
{
|
|
59
59
|
width: "20",
|
|
@@ -62,7 +62,7 @@ const R = {
|
|
|
62
62
|
fill: "none",
|
|
63
63
|
xmlns: "http://www.w3.org/2000/svg",
|
|
64
64
|
children: [
|
|
65
|
-
/* @__PURE__ */
|
|
65
|
+
/* @__PURE__ */ g("g", { clipPath: "url(#clip0_466_934)", children: [
|
|
66
66
|
/* @__PURE__ */ n(
|
|
67
67
|
"path",
|
|
68
68
|
{
|
|
@@ -87,7 +87,7 @@ const R = {
|
|
|
87
87
|
/* @__PURE__ */ n("defs", { children: /* @__PURE__ */ n("clipPath", { id: "clip0_466_934", children: /* @__PURE__ */ n("rect", { width: "20", height: "20", fill: "white" }) }) })
|
|
88
88
|
]
|
|
89
89
|
}
|
|
90
|
-
),
|
|
90
|
+
), te = ({
|
|
91
91
|
client: e,
|
|
92
92
|
questions: t,
|
|
93
93
|
productId: o,
|
|
@@ -103,31 +103,31 @@ const R = {
|
|
|
103
103
|
fromQuestionSuggestion: !0
|
|
104
104
|
});
|
|
105
105
|
};
|
|
106
|
-
return /* @__PURE__ */ n(
|
|
106
|
+
return /* @__PURE__ */ n(S, { children: t.map((l) => /* @__PURE__ */ g(
|
|
107
107
|
"button",
|
|
108
108
|
{
|
|
109
109
|
className: "dialog-block-suggestions-item",
|
|
110
110
|
onClick: () => a(l.question),
|
|
111
111
|
children: [
|
|
112
|
-
/* @__PURE__ */ n(
|
|
112
|
+
/* @__PURE__ */ n(ee, { color: e.theme.primaryColor }),
|
|
113
113
|
/* @__PURE__ */ n("span", { className: "dialog-block-suggestions-item-label", children: l.question })
|
|
114
114
|
]
|
|
115
115
|
},
|
|
116
116
|
l.question
|
|
117
117
|
)) });
|
|
118
|
-
},
|
|
118
|
+
}, se = () => /* @__PURE__ */ g(S, { children: [
|
|
119
119
|
/* @__PURE__ */ n("div", { className: "dialog-block-suggestions-skeleton-item" }),
|
|
120
120
|
/* @__PURE__ */ n("div", { className: "dialog-block-suggestions-skeleton-item" }),
|
|
121
121
|
/* @__PURE__ */ n("div", { className: "dialog-block-suggestions-skeleton-item" })
|
|
122
|
-
] }),
|
|
122
|
+
] }), oe = ({
|
|
123
123
|
client: e,
|
|
124
124
|
questions: t,
|
|
125
125
|
isLoading: o,
|
|
126
126
|
productId: s,
|
|
127
127
|
productTitle: r,
|
|
128
128
|
selectedVariantId: a
|
|
129
|
-
}) => /* @__PURE__ */ n("div", { className: "dialog-block-suggestions-container", children: o || !t ? /* @__PURE__ */ n(
|
|
130
|
-
|
|
129
|
+
}) => /* @__PURE__ */ n("div", { className: "dialog-block-suggestions-container", children: o || !t ? /* @__PURE__ */ n(se, {}) : /* @__PURE__ */ n(
|
|
130
|
+
te,
|
|
131
131
|
{
|
|
132
132
|
client: e,
|
|
133
133
|
questions: t,
|
|
@@ -135,7 +135,7 @@ const R = {
|
|
|
135
135
|
productTitle: r,
|
|
136
136
|
selectedVariantId: a
|
|
137
137
|
}
|
|
138
|
-
) }),
|
|
138
|
+
) }), ne = ({ color: e = "#ffffff" }) => /* @__PURE__ */ n(
|
|
139
139
|
"svg",
|
|
140
140
|
{
|
|
141
141
|
width: "20",
|
|
@@ -154,16 +154,16 @@ const R = {
|
|
|
154
154
|
}
|
|
155
155
|
)
|
|
156
156
|
}
|
|
157
|
-
),
|
|
157
|
+
), re = ({
|
|
158
158
|
client: e,
|
|
159
159
|
productId: t,
|
|
160
160
|
productTitle: o,
|
|
161
161
|
selectedVariantId: s
|
|
162
162
|
}) => {
|
|
163
|
-
const r =
|
|
163
|
+
const r = v(null), [a, l] = C(""), i = T(e.locale), c = () => {
|
|
164
164
|
var d;
|
|
165
165
|
(d = r.current) == null || d.focus();
|
|
166
|
-
},
|
|
166
|
+
}, h = () => {
|
|
167
167
|
const d = a;
|
|
168
168
|
d.trim() && (e.sendProductMessage({
|
|
169
169
|
productId: t,
|
|
@@ -172,11 +172,11 @@ const R = {
|
|
|
172
172
|
question: d,
|
|
173
173
|
fromQuestionSuggestion: !0
|
|
174
174
|
}), l(""));
|
|
175
|
-
},
|
|
176
|
-
d.key === "Enter" &&
|
|
175
|
+
}, p = (d) => {
|
|
176
|
+
d.key === "Enter" && h();
|
|
177
177
|
};
|
|
178
|
-
return /* @__PURE__ */
|
|
179
|
-
/* @__PURE__ */
|
|
178
|
+
return /* @__PURE__ */ g("div", { className: "dialog-input-container", children: [
|
|
179
|
+
/* @__PURE__ */ g("div", { className: "dialog-input-wrapper", onClick: c, children: [
|
|
180
180
|
/* @__PURE__ */ n(
|
|
181
181
|
"input",
|
|
182
182
|
{
|
|
@@ -187,7 +187,7 @@ const R = {
|
|
|
187
187
|
className: "dialog-ask-anything-input-ai-input",
|
|
188
188
|
placeholder: i.placeholder,
|
|
189
189
|
"aria-describedby": "dialog-input-ai-disclosure",
|
|
190
|
-
onKeyDown:
|
|
190
|
+
onKeyDown: p
|
|
191
191
|
}
|
|
192
192
|
),
|
|
193
193
|
/* @__PURE__ */ n(
|
|
@@ -196,18 +196,18 @@ const R = {
|
|
|
196
196
|
id: "send-message-button-ai-input",
|
|
197
197
|
className: "dialog-input-submit",
|
|
198
198
|
disabled: !a.trim(),
|
|
199
|
-
onClick:
|
|
200
|
-
children: /* @__PURE__ */ n(
|
|
199
|
+
onClick: h,
|
|
200
|
+
children: /* @__PURE__ */ n(ne, { color: e.theme.ctaTextColor })
|
|
201
201
|
}
|
|
202
202
|
)
|
|
203
203
|
] }),
|
|
204
204
|
/* @__PURE__ */ n("p", { id: "dialog-input-ai-disclosure", className: "dialog-input-ai-disclosure", children: i.aiDisclosure })
|
|
205
205
|
] });
|
|
206
|
-
},
|
|
206
|
+
}, $ = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), ie = (e) => {
|
|
207
207
|
if (!e) return;
|
|
208
208
|
const t = document.body;
|
|
209
209
|
Object.keys(e).forEach((o) => {
|
|
210
|
-
const s = o, r =
|
|
210
|
+
const s = o, r = $(o);
|
|
211
211
|
if (e[s] !== void 0) {
|
|
212
212
|
if (typeof e[s] == "object") {
|
|
213
213
|
Object.keys(e[s]).forEach(
|
|
@@ -215,10 +215,10 @@ const R = {
|
|
|
215
215
|
var i;
|
|
216
216
|
const l = a;
|
|
217
217
|
if (l !== void 0) {
|
|
218
|
-
const c =
|
|
218
|
+
const c = $(a), h = e[s];
|
|
219
219
|
t.style.setProperty(
|
|
220
220
|
`--dialog-theme-${r}-${c}`,
|
|
221
|
-
(i =
|
|
221
|
+
(i = h[l]) == null ? void 0 : i.toString()
|
|
222
222
|
);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
@@ -236,71 +236,71 @@ const R = {
|
|
|
236
236
|
);
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
|
-
},
|
|
240
|
-
e &&
|
|
241
|
-
}, [e]), /* @__PURE__ */ n(
|
|
239
|
+
}, ae = ({ theme: e, children: t }) => (b(() => {
|
|
240
|
+
e && ie(e);
|
|
241
|
+
}, [e]), /* @__PURE__ */ n(S, { children: t })), ce = 2, le = 5, Xe = ({
|
|
242
242
|
client: e,
|
|
243
243
|
productId: t,
|
|
244
244
|
productTitle: o,
|
|
245
245
|
selectedVariantId: s,
|
|
246
246
|
enableInput: r = !1
|
|
247
247
|
}) => {
|
|
248
|
-
var
|
|
249
|
-
const [a, l] =
|
|
248
|
+
var u;
|
|
249
|
+
const [a, l] = C(!0), [i, c] = C(
|
|
250
250
|
void 0
|
|
251
251
|
);
|
|
252
|
-
|
|
252
|
+
b(() => {
|
|
253
253
|
M({
|
|
254
254
|
method: "react",
|
|
255
|
-
version: "2.
|
|
255
|
+
version: "2.10.1"
|
|
256
256
|
}), F("pdp-block");
|
|
257
257
|
}, []);
|
|
258
|
-
const
|
|
258
|
+
const h = y(
|
|
259
259
|
() => a ? "" : i == null ? void 0 : i.assistantName,
|
|
260
260
|
[i, a]
|
|
261
|
-
),
|
|
261
|
+
), p = y(
|
|
262
262
|
() => a ? "" : i == null ? void 0 : i.description,
|
|
263
263
|
[i, a]
|
|
264
|
-
), d =
|
|
264
|
+
), d = y(
|
|
265
265
|
() => a ? "" : i == null ? void 0 : i.inputPlaceholder,
|
|
266
266
|
[i, a]
|
|
267
|
-
),
|
|
267
|
+
), m = y(
|
|
268
268
|
() => {
|
|
269
|
-
var
|
|
270
|
-
return U((
|
|
269
|
+
var f;
|
|
270
|
+
return U((f = e.getLocalizationInformations()) == null ? void 0 : f.languageCode);
|
|
271
271
|
},
|
|
272
272
|
[e]
|
|
273
273
|
);
|
|
274
|
-
return
|
|
275
|
-
let
|
|
274
|
+
return b(() => {
|
|
275
|
+
let f = !0;
|
|
276
276
|
return (async () => {
|
|
277
277
|
l(!0), c(void 0);
|
|
278
278
|
try {
|
|
279
279
|
const E = await e.getSuggestions(t, {
|
|
280
|
-
limit:
|
|
280
|
+
limit: le
|
|
281
281
|
});
|
|
282
|
-
|
|
282
|
+
f && c(E);
|
|
283
283
|
} catch (E) {
|
|
284
284
|
console.error("error", E);
|
|
285
285
|
} finally {
|
|
286
|
-
|
|
286
|
+
f && l(!1);
|
|
287
287
|
}
|
|
288
288
|
})(), () => {
|
|
289
|
-
|
|
289
|
+
f = !1;
|
|
290
290
|
};
|
|
291
|
-
}, [e, t]), /* @__PURE__ */ n(
|
|
291
|
+
}, [e, t]), /* @__PURE__ */ n(ae, { theme: e.theme, children: /* @__PURE__ */ g(
|
|
292
292
|
"div",
|
|
293
293
|
{
|
|
294
294
|
id: "dialog-instant",
|
|
295
295
|
className: "dialog-block-container",
|
|
296
|
-
dir:
|
|
296
|
+
dir: m,
|
|
297
297
|
children: [
|
|
298
|
-
/* @__PURE__ */ n(
|
|
298
|
+
/* @__PURE__ */ n(J, { title: h, description: p }),
|
|
299
299
|
/* @__PURE__ */ n(
|
|
300
|
-
|
|
300
|
+
oe,
|
|
301
301
|
{
|
|
302
302
|
client: e,
|
|
303
|
-
questions: (
|
|
303
|
+
questions: (u = i == null ? void 0 : i.questions) == null ? void 0 : u.slice(0, ce),
|
|
304
304
|
isLoading: a,
|
|
305
305
|
productId: t,
|
|
306
306
|
productTitle: o,
|
|
@@ -308,7 +308,7 @@ const R = {
|
|
|
308
308
|
}
|
|
309
309
|
),
|
|
310
310
|
r ? /* @__PURE__ */ n(
|
|
311
|
-
|
|
311
|
+
re,
|
|
312
312
|
{
|
|
313
313
|
client: e,
|
|
314
314
|
placeholder: d,
|
|
@@ -317,7 +317,7 @@ const R = {
|
|
|
317
317
|
selectedVariantId: s
|
|
318
318
|
}
|
|
319
319
|
) : /* @__PURE__ */ n(
|
|
320
|
-
|
|
320
|
+
Y,
|
|
321
321
|
{
|
|
322
322
|
client: e,
|
|
323
323
|
questions: i == null ? void 0 : i.questions,
|
|
@@ -330,7 +330,7 @@ const R = {
|
|
|
330
330
|
]
|
|
331
331
|
}
|
|
332
332
|
) });
|
|
333
|
-
},
|
|
333
|
+
}, de = () => /* @__PURE__ */ n(
|
|
334
334
|
"svg",
|
|
335
335
|
{
|
|
336
336
|
width: 16,
|
|
@@ -350,7 +350,7 @@ const R = {
|
|
|
350
350
|
}
|
|
351
351
|
)
|
|
352
352
|
}
|
|
353
|
-
),
|
|
353
|
+
), ue = "M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z", he = ({
|
|
354
354
|
color: e = "currentColor"
|
|
355
355
|
}) => /* @__PURE__ */ n(
|
|
356
356
|
"svg",
|
|
@@ -361,20 +361,20 @@ const R = {
|
|
|
361
361
|
fill: "none",
|
|
362
362
|
xmlns: "http://www.w3.org/2000/svg",
|
|
363
363
|
"aria-hidden": "true",
|
|
364
|
-
children: /* @__PURE__ */ n("path", { d:
|
|
364
|
+
children: /* @__PURE__ */ n("path", { d: ue, fill: e })
|
|
365
365
|
}
|
|
366
|
-
),
|
|
366
|
+
), Ge = ({
|
|
367
367
|
controller: e,
|
|
368
368
|
placeholder: t = "Search products...",
|
|
369
369
|
autoFocus: o = !1,
|
|
370
370
|
submitAriaLabel: s = "Search"
|
|
371
371
|
}) => {
|
|
372
|
-
const [r, a] =
|
|
373
|
-
return /* @__PURE__ */
|
|
372
|
+
const [r, a] = C("");
|
|
373
|
+
return /* @__PURE__ */ g("form", { className: "dialog-search-bar", role: "search", onSubmit: (i) => {
|
|
374
374
|
i.preventDefault(), e.submit(r);
|
|
375
375
|
}, children: [
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-bar-icon", children: /* @__PURE__ */ n(
|
|
376
|
+
/* @__PURE__ */ g("div", { className: "dialog-search-bar-field", children: [
|
|
377
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-bar-icon", children: /* @__PURE__ */ n(he, {}) }),
|
|
378
378
|
/* @__PURE__ */ n(
|
|
379
379
|
"input",
|
|
380
380
|
{
|
|
@@ -397,17 +397,17 @@ const R = {
|
|
|
397
397
|
type: "submit",
|
|
398
398
|
className: "dialog-search-bar-submit",
|
|
399
399
|
"aria-label": s,
|
|
400
|
-
children: /* @__PURE__ */ n(
|
|
400
|
+
children: /* @__PURE__ */ n(de, {})
|
|
401
401
|
}
|
|
402
402
|
)
|
|
403
403
|
] });
|
|
404
|
-
},
|
|
404
|
+
}, ge = (e, t) => {
|
|
405
405
|
try {
|
|
406
406
|
return new Intl.NumberFormat(t).format(e);
|
|
407
407
|
} catch {
|
|
408
408
|
return String(e);
|
|
409
409
|
}
|
|
410
|
-
},
|
|
410
|
+
}, I = {
|
|
411
411
|
en: (e) => ({
|
|
412
412
|
searching: (t) => `Searching “${t}”…`,
|
|
413
413
|
noResults: "No matching products",
|
|
@@ -473,11 +473,11 @@ const R = {
|
|
|
473
473
|
next: "Successivo",
|
|
474
474
|
pageOf: (t, o) => `Pagina ${e(t)} / ${e(o)}`
|
|
475
475
|
})
|
|
476
|
-
},
|
|
476
|
+
}, _ = (e) => {
|
|
477
477
|
var s;
|
|
478
478
|
const t = ((s = e == null ? void 0 : e.split("-")[0]) == null ? void 0 : s.toLowerCase()) ?? "en";
|
|
479
|
-
return (
|
|
480
|
-
}, O = (e) => e.status !== L.LOADING && e.response !== void 0 && e.response.nbPages > 1,
|
|
479
|
+
return (I[t] ?? I.en)((r) => ge(r, e));
|
|
480
|
+
}, O = (e) => e.status !== L.LOADING && e.response !== void 0 && e.response.nbPages > 1, pe = ({
|
|
481
481
|
controller: e,
|
|
482
482
|
state: t,
|
|
483
483
|
locale: o
|
|
@@ -485,8 +485,8 @@ const R = {
|
|
|
485
485
|
const s = t.response;
|
|
486
486
|
if (s === void 0 || !O(t))
|
|
487
487
|
return null;
|
|
488
|
-
const r =
|
|
489
|
-
return /* @__PURE__ */
|
|
488
|
+
const r = _(o);
|
|
489
|
+
return /* @__PURE__ */ g("nav", { "aria-label": "Search results pages", className: "dialog-search-pagination", children: [
|
|
490
490
|
/* @__PURE__ */ n(
|
|
491
491
|
"button",
|
|
492
492
|
{
|
|
@@ -507,86 +507,80 @@ const R = {
|
|
|
507
507
|
}
|
|
508
508
|
)
|
|
509
509
|
] });
|
|
510
|
-
}, D = (e) => e.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").replace(/ẞ/gu, "ß").toUpperCase().toLowerCase().replace(/ς/g, "σ"),
|
|
510
|
+
}, D = (e) => e.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").replace(/ẞ/gu, "ß").toUpperCase().toLowerCase().replace(/ς/g, "σ"), me = (e, t) => {
|
|
511
511
|
const o = { before: "", match: e, after: "" }, s = D(t.trim());
|
|
512
512
|
if (s === "")
|
|
513
513
|
return o;
|
|
514
514
|
const r = [...e], a = [];
|
|
515
515
|
let l = "";
|
|
516
|
-
r.forEach((
|
|
517
|
-
const
|
|
518
|
-
for (let
|
|
516
|
+
r.forEach((p, d) => {
|
|
517
|
+
const m = D(p);
|
|
518
|
+
for (let u = 0; u < m.length; u += 1)
|
|
519
519
|
a.push(d);
|
|
520
|
-
l +=
|
|
520
|
+
l += m;
|
|
521
521
|
});
|
|
522
522
|
const i = l.indexOf(s);
|
|
523
523
|
if (i === -1)
|
|
524
524
|
return o;
|
|
525
|
-
const c = a[i],
|
|
525
|
+
const c = a[i], h = a[i + s.length - 1] + 1;
|
|
526
526
|
return {
|
|
527
527
|
before: r.slice(0, c).join(""),
|
|
528
|
-
match: r.slice(c,
|
|
529
|
-
after: r.slice(
|
|
528
|
+
match: r.slice(c, h).join(""),
|
|
529
|
+
after: r.slice(h).join("")
|
|
530
530
|
};
|
|
531
531
|
}, H = ({
|
|
532
532
|
title: e,
|
|
533
533
|
query: t
|
|
534
534
|
}) => {
|
|
535
|
-
const { before: o, match: s, after: r } =
|
|
536
|
-
return /* @__PURE__ */
|
|
535
|
+
const { before: o, match: s, after: r } = me(e, t);
|
|
536
|
+
return /* @__PURE__ */ g(S, { children: [
|
|
537
537
|
o !== "" && /* @__PURE__ */ n("span", { className: "dialog-search-muted", children: o }),
|
|
538
538
|
/* @__PURE__ */ n("span", { className: "dialog-search-match", children: s }),
|
|
539
539
|
r !== "" && /* @__PURE__ */ n("span", { className: "dialog-search-muted", children: r })
|
|
540
540
|
] });
|
|
541
|
-
},
|
|
542
|
-
if (e === void 0)
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
}, me = (e) => e.product_image || e.image || void 0, fe = (e) => {
|
|
552
|
-
try {
|
|
553
|
-
const { protocol: t } = new URL(e, window.location.href);
|
|
554
|
-
return t === "http:" || t === "https:" ? e : void 0;
|
|
555
|
-
} catch {
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
}, q = (e) => e.url === void 0 || e.url === "" ? void 0 : fe(e.url), B = (e) => e.title ?? e.handle ?? e.objectID, be = ({
|
|
541
|
+
}, fe = (e) => e.product_image || e.image || void 0, q = (e) => {
|
|
542
|
+
if (!(e === void 0 || e === ""))
|
|
543
|
+
try {
|
|
544
|
+
const { protocol: t } = new URL(e, window.location.href);
|
|
545
|
+
return t === "http:" || t === "https:" ? e : void 0;
|
|
546
|
+
} catch {
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
}, be = (e) => q(e.url), B = (e) => e.title ?? e.handle ?? e.objectID, ve = ({
|
|
559
550
|
controller: e,
|
|
560
551
|
hit: t,
|
|
561
552
|
index: o,
|
|
562
553
|
locale: s,
|
|
563
554
|
query: r = ""
|
|
564
555
|
}) => {
|
|
565
|
-
const a =
|
|
566
|
-
|
|
556
|
+
const a = v(null);
|
|
557
|
+
b(() => {
|
|
567
558
|
a.current !== null && e.observeResult(a.current, o);
|
|
568
559
|
}, [e, t, o]);
|
|
569
|
-
const l = (
|
|
570
|
-
const
|
|
571
|
-
e.selectResult(o, { navigate: !
|
|
572
|
-
}, i = (
|
|
573
|
-
|
|
574
|
-
}, c =
|
|
575
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-product-thumb", "aria-hidden": !0, children:
|
|
560
|
+
const l = (u) => {
|
|
561
|
+
const f = u.metaKey || u.ctrlKey || u.shiftKey || u.altKey;
|
|
562
|
+
e.selectResult(o, { navigate: !f }) && u.preventDefault();
|
|
563
|
+
}, i = (u) => {
|
|
564
|
+
u.button === 1 && e.selectResult(o, { navigate: !1 });
|
|
565
|
+
}, c = Q(t, s), h = W(t, s), p = q(e.productUrl(t)), d = fe(t), m = /* @__PURE__ */ g(S, { children: [
|
|
566
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-product-thumb", "aria-hidden": !0, children: d !== void 0 && /* @__PURE__ */ n("img", { src: d, alt: "", loading: "lazy" }) }),
|
|
576
567
|
/* @__PURE__ */ n("span", { className: "dialog-search-product-title", children: /* @__PURE__ */ n(H, { title: B(t), query: r }) }),
|
|
577
|
-
c !== "" && /* @__PURE__ */
|
|
568
|
+
c !== "" && /* @__PURE__ */ g("span", { className: "dialog-search-product-price", children: [
|
|
569
|
+
h !== "" && /* @__PURE__ */ n("s", { className: "dialog-search-product-compare-at", children: h }),
|
|
570
|
+
c
|
|
571
|
+
] })
|
|
578
572
|
] });
|
|
579
|
-
return /* @__PURE__ */ n("li", { ref: a, className: "dialog-search-card", children:
|
|
573
|
+
return /* @__PURE__ */ n("li", { ref: a, className: "dialog-search-card", children: p === void 0 ? /* @__PURE__ */ n("div", { className: "dialog-search-product", children: m }) : /* @__PURE__ */ n(
|
|
580
574
|
"a",
|
|
581
575
|
{
|
|
582
576
|
className: "dialog-search-product",
|
|
583
|
-
href:
|
|
577
|
+
href: p,
|
|
584
578
|
onClick: l,
|
|
585
579
|
onAuxClick: i,
|
|
586
|
-
children:
|
|
580
|
+
children: m
|
|
587
581
|
}
|
|
588
582
|
) });
|
|
589
|
-
},
|
|
583
|
+
}, Ce = () => /* @__PURE__ */ n(
|
|
590
584
|
"svg",
|
|
591
585
|
{
|
|
592
586
|
width: 16,
|
|
@@ -597,7 +591,7 @@ const R = {
|
|
|
597
591
|
"aria-hidden": "true",
|
|
598
592
|
children: /* @__PURE__ */ n("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" })
|
|
599
593
|
}
|
|
600
|
-
),
|
|
594
|
+
), Se = () => /* @__PURE__ */ n(
|
|
601
595
|
"svg",
|
|
602
596
|
{
|
|
603
597
|
width: 12,
|
|
@@ -609,7 +603,7 @@ const R = {
|
|
|
609
603
|
children: /* @__PURE__ */ n("path", { d: "M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z" })
|
|
610
604
|
}
|
|
611
605
|
), j = (e) => (e ?? []).flatMap((t) => {
|
|
612
|
-
const o =
|
|
606
|
+
const o = be(t);
|
|
613
607
|
return o === void 0 ? [] : [{ collection: t, href: o }];
|
|
614
608
|
}), ye = ({
|
|
615
609
|
collections: e,
|
|
@@ -617,29 +611,29 @@ const R = {
|
|
|
617
611
|
messages: o
|
|
618
612
|
}) => {
|
|
619
613
|
const s = j(e);
|
|
620
|
-
return s.length === 0 ? null : /* @__PURE__ */
|
|
621
|
-
/* @__PURE__ */
|
|
614
|
+
return s.length === 0 ? null : /* @__PURE__ */ g("aside", { className: "dialog-search-collections", children: [
|
|
615
|
+
/* @__PURE__ */ g("div", { className: "dialog-search-section-head", children: [
|
|
622
616
|
/* @__PURE__ */ n("p", { className: "dialog-search-label", children: o.collectionsLabel }),
|
|
623
617
|
/* @__PURE__ */ n("span", { className: "dialog-search-count", children: o.collectionsCount(s.length) })
|
|
624
618
|
] }),
|
|
625
|
-
/* @__PURE__ */ n("ul", { className: "dialog-search-collection-list", children: s.map(({ collection: r, href: a }) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */
|
|
626
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-collection-thumb", "aria-hidden": !0, children: r.
|
|
619
|
+
/* @__PURE__ */ n("ul", { className: "dialog-search-collection-list", children: s.map(({ collection: r, href: a }) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ g("a", { className: "dialog-search-collection", href: a, children: [
|
|
620
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-collection-thumb", "aria-hidden": !0, children: r.image ? /* @__PURE__ */ n("img", { src: r.image, alt: "", loading: "lazy" }) : null }),
|
|
627
621
|
/* @__PURE__ */ n("span", { className: "dialog-search-collection-title", children: /* @__PURE__ */ n(H, { title: B(r), query: t }) }),
|
|
628
|
-
/* @__PURE__ */ n("span", { className: "dialog-search-caret", children: /* @__PURE__ */ n(
|
|
622
|
+
/* @__PURE__ */ n("span", { className: "dialog-search-caret", children: /* @__PURE__ */ n(Se, {}) })
|
|
629
623
|
] }) }, r.objectID)) })
|
|
630
624
|
] });
|
|
631
|
-
},
|
|
625
|
+
}, we = ({
|
|
632
626
|
controller: e,
|
|
633
627
|
response: t,
|
|
634
628
|
locale: o,
|
|
635
629
|
messages: s
|
|
636
|
-
}) => /* @__PURE__ */
|
|
637
|
-
/* @__PURE__ */ n("div", { className: "dialog-search-section-head", children: /* @__PURE__ */
|
|
630
|
+
}) => /* @__PURE__ */ g("section", { className: "dialog-search-products", children: [
|
|
631
|
+
/* @__PURE__ */ n("div", { className: "dialog-search-section-head", children: /* @__PURE__ */ g("p", { className: "dialog-search-label", children: [
|
|
638
632
|
s.productsLabel,
|
|
639
633
|
t.nbHits > 0 && /* @__PURE__ */ n("span", { className: "dialog-search-label-count", children: ` · ${s.resultsCount(t.nbHits)}` })
|
|
640
634
|
] }) }),
|
|
641
635
|
/* @__PURE__ */ n("ul", { className: "dialog-search-results", children: t.hits.length === 0 ? /* @__PURE__ */ n("li", { className: "dialog-search-empty", role: "status", children: s.noResults }) : t.hits.map((r, a) => /* @__PURE__ */ n(
|
|
642
|
-
|
|
636
|
+
ve,
|
|
643
637
|
{
|
|
644
638
|
controller: e,
|
|
645
639
|
hit: r,
|
|
@@ -649,18 +643,18 @@ const R = {
|
|
|
649
643
|
},
|
|
650
644
|
r.objectID
|
|
651
645
|
)) })
|
|
652
|
-
] }), k = 8, w = 16,
|
|
646
|
+
] }), k = 8, w = 16, Le = 200, ke = 1440, Ne = (e, t) => e.bottom > 0 && e.top < t, Ee = (e, t) => {
|
|
653
647
|
const o = Math.min(
|
|
654
|
-
|
|
648
|
+
ke,
|
|
655
649
|
t - 2 * w
|
|
656
650
|
), s = e.left + e.width / 2 - o / 2;
|
|
657
651
|
return { left: Math.min(
|
|
658
652
|
Math.max(s, w),
|
|
659
653
|
t - w - o
|
|
660
654
|
), width: o };
|
|
661
|
-
},
|
|
662
|
-
const s = o - e.bottom - k - w, r = e.top - k - w, a =
|
|
663
|
-
return s <
|
|
655
|
+
}, Pe = (e, t, o) => {
|
|
656
|
+
const s = o - e.bottom - k - w, r = e.top - k - w, a = Ee(e, t);
|
|
657
|
+
return s < Le && r > s ? {
|
|
664
658
|
...a,
|
|
665
659
|
bottom: o - e.top + k,
|
|
666
660
|
maxHeight: Math.max(r, 0)
|
|
@@ -669,7 +663,7 @@ const R = {
|
|
|
669
663
|
top: e.bottom + k,
|
|
670
664
|
maxHeight: Math.max(s, 0)
|
|
671
665
|
};
|
|
672
|
-
},
|
|
666
|
+
}, Ae = (e) => {
|
|
673
667
|
const t = e.trim().replace(/^#/, "");
|
|
674
668
|
if (!/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t))
|
|
675
669
|
return;
|
|
@@ -677,29 +671,29 @@ const R = {
|
|
|
677
671
|
return [0, 2, 4].map(
|
|
678
672
|
(s) => Number.parseInt(o.slice(s, s + 2), 16)
|
|
679
673
|
);
|
|
680
|
-
},
|
|
674
|
+
}, xe = (e) => {
|
|
681
675
|
const t = /^rgba?\((\d+), (\d+), (\d+)(?:, [\d.]+)?\)$/.exec(e);
|
|
682
676
|
if (t !== null)
|
|
683
677
|
return [t[1], t[2], t[3]].map(Number);
|
|
684
|
-
},
|
|
678
|
+
}, Re = (e) => {
|
|
685
679
|
if (typeof document > "u")
|
|
686
680
|
return;
|
|
687
681
|
const t = document.createElement("span");
|
|
688
682
|
if (t.style.color = e, t.style.color === "")
|
|
689
683
|
return;
|
|
690
684
|
document.body.appendChild(t);
|
|
691
|
-
const o =
|
|
685
|
+
const o = xe(getComputedStyle(t).color);
|
|
692
686
|
return t.remove(), o;
|
|
693
|
-
},
|
|
687
|
+
}, $e = (e) => Ae(e) ?? Re(e), Ie = (e) => {
|
|
694
688
|
const t = e / 255;
|
|
695
689
|
return t <= 0.03928 ? t / 12.92 : ((t + 0.055) / 1.055) ** 2.4;
|
|
696
690
|
}, z = (e) => {
|
|
697
|
-
const t =
|
|
691
|
+
const t = $e(e);
|
|
698
692
|
if (t === void 0)
|
|
699
693
|
return;
|
|
700
694
|
const [o, s, r] = t.map(Ie);
|
|
701
695
|
return 0.2126 * o + 0.7152 * s + 0.0722 * r;
|
|
702
|
-
},
|
|
696
|
+
}, De = "#181825", Me = "#ffffff", Te = "straight", A = 0.5, x = {
|
|
703
697
|
light: {
|
|
704
698
|
panel: "#ffffff",
|
|
705
699
|
side: "#fafbfc",
|
|
@@ -731,26 +725,26 @@ const R = {
|
|
|
731
725
|
"r-thumb": "8px",
|
|
732
726
|
"r-btn": "10px"
|
|
733
727
|
}
|
|
734
|
-
}, N = (e) => e === void 0 || e.trim() === "" ? void 0 : e.trim(),
|
|
728
|
+
}, N = (e) => e === void 0 || e.trim() === "" ? void 0 : e.trim(), Oe = (e) => {
|
|
735
729
|
const t = e === void 0 ? void 0 : z(e);
|
|
736
730
|
return t === void 0 ? "light" : t < A ? "dark" : "light";
|
|
737
|
-
},
|
|
731
|
+
}, He = (e, t) => {
|
|
738
732
|
const o = z(e);
|
|
739
733
|
return o === void 0 ? x[t].text : (t === "light" ? o < A : o >= A) ? e : x[t].text;
|
|
740
|
-
},
|
|
741
|
-
const t =
|
|
734
|
+
}, qe = (e) => {
|
|
735
|
+
const t = Oe(N(e == null ? void 0 : e.backgroundColor)), o = (e == null ? void 0 : e.ctaBorderType) === Te ? "rectangle" : "rectangle-rounded", s = N(e == null ? void 0 : e.primaryColor) ?? De, r = N(e == null ? void 0 : e.fontFamily), a = {
|
|
742
736
|
...x[t],
|
|
743
737
|
..._e[o],
|
|
744
738
|
primary: s,
|
|
745
|
-
accent:
|
|
746
|
-
"cta-text": N(e == null ? void 0 : e.ctaTextColor) ??
|
|
739
|
+
accent: He(s, t),
|
|
740
|
+
"cta-text": N(e == null ? void 0 : e.ctaTextColor) ?? Me,
|
|
747
741
|
...r === void 0 ? {} : { font: r }
|
|
748
742
|
};
|
|
749
743
|
return Object.fromEntries(
|
|
750
744
|
Object.entries(a).map(([l, i]) => [`--dso-${l}`, i])
|
|
751
745
|
);
|
|
752
|
-
},
|
|
753
|
-
const t =
|
|
746
|
+
}, Be = (e) => {
|
|
747
|
+
const t = v(null), [o, s] = C(void 0), [r, a] = C({ width: 0, height: 0 });
|
|
754
748
|
return V(() => {
|
|
755
749
|
if (!e)
|
|
756
750
|
return;
|
|
@@ -758,34 +752,34 @@ const R = {
|
|
|
758
752
|
const i = t.current;
|
|
759
753
|
if (i === null)
|
|
760
754
|
return;
|
|
761
|
-
const c = i.previousElementSibling ?? i, { top:
|
|
755
|
+
const c = i.previousElementSibling ?? i, { top: h, bottom: p, left: d, width: m } = c.getBoundingClientRect();
|
|
762
756
|
a(
|
|
763
|
-
(
|
|
757
|
+
(u) => u.width === window.innerWidth && u.height === window.innerHeight ? u : { width: window.innerWidth, height: window.innerHeight }
|
|
764
758
|
), s(
|
|
765
|
-
(
|
|
759
|
+
(u) => u !== void 0 && u.top === h && u.bottom === p && u.left === d && u.width === m ? u : { top: h, bottom: p, left: d, width: m }
|
|
766
760
|
);
|
|
767
761
|
};
|
|
768
762
|
return l(), window.addEventListener("scroll", l, !0), window.addEventListener("resize", l), () => {
|
|
769
763
|
window.removeEventListener("scroll", l, !0), window.removeEventListener("resize", l);
|
|
770
764
|
};
|
|
771
765
|
}, [e]), { anchorRef: t, rect: o, viewport: r };
|
|
772
|
-
},
|
|
773
|
-
const [o, s] =
|
|
774
|
-
return
|
|
766
|
+
}, je = (e, t) => {
|
|
767
|
+
const [o, s] = C(!1), r = v(null), a = e.status !== L.IDLE && !o;
|
|
768
|
+
return b(() => {
|
|
775
769
|
s(!1);
|
|
776
|
-
}, [e.query]),
|
|
770
|
+
}, [e.query]), b(() => {
|
|
777
771
|
if (!a)
|
|
778
772
|
return;
|
|
779
773
|
const l = (i) => {
|
|
780
|
-
var
|
|
774
|
+
var m, u;
|
|
781
775
|
const c = i.target;
|
|
782
776
|
if (!(c instanceof Node))
|
|
783
777
|
return;
|
|
784
|
-
const
|
|
785
|
-
!
|
|
778
|
+
const h = (m = t.current) == null ? void 0 : m.previousElementSibling, p = ((u = r.current) == null ? void 0 : u.contains(c)) ?? !1, d = (h == null ? void 0 : h.contains(c)) ?? !1;
|
|
779
|
+
!p && !d && s(!0);
|
|
786
780
|
};
|
|
787
781
|
return document.addEventListener("pointerdown", l), () => document.removeEventListener("pointerdown", l);
|
|
788
|
-
}, [a, t]),
|
|
782
|
+
}, [a, t]), b(() => {
|
|
789
783
|
var c;
|
|
790
784
|
const l = (c = t.current) == null ? void 0 : c.previousElementSibling;
|
|
791
785
|
if (l == null)
|
|
@@ -793,17 +787,17 @@ const R = {
|
|
|
793
787
|
const i = () => s(!1);
|
|
794
788
|
return l.addEventListener("focusin", i), () => l.removeEventListener("focusin", i);
|
|
795
789
|
}, [t]), { isOpen: a, panelRef: r };
|
|
796
|
-
},
|
|
797
|
-
var
|
|
790
|
+
}, ze = (e) => e instanceof Z ? `Search failed (${e.status}${e.code ? ` ${e.code}` : ""}): ${e.message}` : "Search failed: network error. Check your connection and try again.", Ve = (e, t) => {
|
|
791
|
+
var m, u;
|
|
798
792
|
const { controller: o, state: s, locale: r, seeAllHref: a } = e, { status: l, response: i } = s;
|
|
799
793
|
if (l === L.ERROR)
|
|
800
|
-
return /* @__PURE__ */
|
|
794
|
+
return /* @__PURE__ */ g("div", { className: "dialog-search-error", children: [
|
|
801
795
|
/* @__PURE__ */ n(
|
|
802
796
|
"p",
|
|
803
797
|
{
|
|
804
798
|
role: "alert",
|
|
805
799
|
className: "dialog-search-status dialog-search-status-error",
|
|
806
|
-
children:
|
|
800
|
+
children: ze(s.error)
|
|
807
801
|
}
|
|
808
802
|
),
|
|
809
803
|
/* @__PURE__ */ n(
|
|
@@ -818,12 +812,12 @@ const R = {
|
|
|
818
812
|
] });
|
|
819
813
|
if (i === void 0)
|
|
820
814
|
return /* @__PURE__ */ n("p", { role: "status", className: "dialog-search-status", children: t.searching(s.query) });
|
|
821
|
-
const c = ((
|
|
822
|
-
return /* @__PURE__ */
|
|
823
|
-
/* @__PURE__ */
|
|
815
|
+
const c = ((u = (m = s.sections) == null ? void 0 : m.collections) == null ? void 0 : u.hits) ?? [], h = j(c).length > 0, p = a !== void 0 && i.nbHits > 0, d = !p && O(s);
|
|
816
|
+
return /* @__PURE__ */ g(S, { children: [
|
|
817
|
+
/* @__PURE__ */ g(
|
|
824
818
|
"div",
|
|
825
819
|
{
|
|
826
|
-
className: `dialog-search-body${
|
|
820
|
+
className: `dialog-search-body${h ? "" : " dialog-search-body--no-collections"}`,
|
|
827
821
|
children: [
|
|
828
822
|
/* @__PURE__ */ n(
|
|
829
823
|
ye,
|
|
@@ -834,7 +828,7 @@ const R = {
|
|
|
834
828
|
}
|
|
835
829
|
),
|
|
836
830
|
/* @__PURE__ */ n(
|
|
837
|
-
|
|
831
|
+
we,
|
|
838
832
|
{
|
|
839
833
|
controller: o,
|
|
840
834
|
response: i,
|
|
@@ -845,11 +839,11 @@ const R = {
|
|
|
845
839
|
]
|
|
846
840
|
}
|
|
847
841
|
),
|
|
848
|
-
(
|
|
842
|
+
(p || d) && /* @__PURE__ */ n("div", { className: "dialog-search-footer", children: p ? /* @__PURE__ */ g("a", { className: "dialog-search-cta", href: a(i.query), children: [
|
|
849
843
|
t.seeAllLabel(i.nbHits),
|
|
850
|
-
/* @__PURE__ */ n(
|
|
844
|
+
/* @__PURE__ */ n(Ce, {})
|
|
851
845
|
] }) : /* @__PURE__ */ n(
|
|
852
|
-
|
|
846
|
+
pe,
|
|
853
847
|
{
|
|
854
848
|
controller: o,
|
|
855
849
|
state: s,
|
|
@@ -857,58 +851,59 @@ const R = {
|
|
|
857
851
|
}
|
|
858
852
|
) })
|
|
859
853
|
] });
|
|
860
|
-
},
|
|
861
|
-
const { state: t, locale: o, theme: s, layout: r = "list" } = e, a = t.status !== L.IDLE, { anchorRef: l, rect: i, viewport: c } =
|
|
862
|
-
() =>
|
|
854
|
+
}, Ye = (e) => {
|
|
855
|
+
const { state: t, locale: o, theme: s, layout: r = "list" } = e, a = t.status !== L.IDLE, { anchorRef: l, rect: i, viewport: c } = Be(a), { isOpen: h, panelRef: p } = je(t, l), d = _(o), m = y(
|
|
856
|
+
() => qe(s),
|
|
863
857
|
[s]
|
|
864
858
|
);
|
|
865
|
-
return /* @__PURE__ */
|
|
859
|
+
return /* @__PURE__ */ g(S, { children: [
|
|
866
860
|
/* @__PURE__ */ n("div", { ref: l }),
|
|
867
|
-
|
|
861
|
+
h && i !== void 0 && Ne(i, c.height) && G(
|
|
868
862
|
/* @__PURE__ */ n(
|
|
869
863
|
"div",
|
|
870
864
|
{
|
|
871
|
-
ref:
|
|
865
|
+
ref: p,
|
|
872
866
|
className: `dialog-search-panel dialog-search-panel--${r}`,
|
|
873
867
|
style: {
|
|
874
|
-
...
|
|
875
|
-
...
|
|
868
|
+
...Pe(i, c.width, c.height),
|
|
869
|
+
...m
|
|
876
870
|
},
|
|
877
|
-
children:
|
|
871
|
+
children: Ve(e, d)
|
|
878
872
|
}
|
|
879
873
|
),
|
|
880
874
|
document.body
|
|
881
875
|
)
|
|
882
876
|
] });
|
|
883
|
-
},
|
|
877
|
+
}, Ke = {
|
|
884
878
|
status: L.IDLE,
|
|
885
879
|
query: "",
|
|
886
880
|
page: 0
|
|
887
|
-
},
|
|
888
|
-
const t =
|
|
881
|
+
}, Je = (e) => {
|
|
882
|
+
const t = v(e);
|
|
889
883
|
t.current = e;
|
|
890
|
-
const o =
|
|
884
|
+
const o = v(void 0), s = P(() => {
|
|
891
885
|
if (o.current === void 0) {
|
|
892
|
-
const { client: c, surface:
|
|
893
|
-
o.current =
|
|
894
|
-
search: (d,
|
|
886
|
+
const { client: c, surface: h = "search_page", ...p } = t.current;
|
|
887
|
+
o.current = X({
|
|
888
|
+
search: (d, m) => c.search(d, m),
|
|
895
889
|
analytics: {
|
|
896
|
-
surface:
|
|
890
|
+
surface: h,
|
|
897
891
|
trackViewSearchResults: (d) => c.trackViewSearchResults(d),
|
|
898
892
|
trackSelectSearchResult: (d) => c.trackSelectSearchResult(d)
|
|
899
893
|
},
|
|
900
|
-
...
|
|
894
|
+
...p
|
|
901
895
|
});
|
|
902
896
|
}
|
|
903
897
|
return o.current;
|
|
904
|
-
}, []), r =
|
|
898
|
+
}, []), r = v(void 0);
|
|
905
899
|
r.current ?? (r.current = {
|
|
906
900
|
setQuery: (c) => s().setQuery(c),
|
|
907
901
|
submit: (c) => s().submit(c),
|
|
908
902
|
setPage: (c) => s().setPage(c),
|
|
909
903
|
retry: () => s().retry(),
|
|
910
|
-
observeResult: (c,
|
|
911
|
-
selectResult: (c,
|
|
904
|
+
observeResult: (c, h) => s().observeResult(c, h),
|
|
905
|
+
selectResult: (c, h) => s().selectResult(c, h),
|
|
906
|
+
productUrl: (c) => s().productUrl(c),
|
|
912
907
|
subscribe: (c) => s().subscribe(c),
|
|
913
908
|
getState: () => s().getState(),
|
|
914
909
|
// Create a replacement on next access after disposal.
|
|
@@ -916,10 +911,10 @@ const R = {
|
|
|
916
911
|
var c;
|
|
917
912
|
(c = o.current) == null || c.dispose(), o.current = void 0;
|
|
918
913
|
}
|
|
919
|
-
}),
|
|
914
|
+
}), b(() => {
|
|
920
915
|
M({
|
|
921
916
|
method: "react",
|
|
922
|
-
version: "2.
|
|
917
|
+
version: "2.10.1"
|
|
923
918
|
});
|
|
924
919
|
const c = s();
|
|
925
920
|
return () => {
|
|
@@ -935,16 +930,16 @@ const R = {
|
|
|
935
930
|
), i = K(
|
|
936
931
|
a,
|
|
937
932
|
l,
|
|
938
|
-
() =>
|
|
933
|
+
() => Ke
|
|
939
934
|
);
|
|
940
935
|
return { controller: r.current, state: i, theme: e.client.theme };
|
|
941
936
|
};
|
|
942
937
|
export {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
938
|
+
re as DialogInput,
|
|
939
|
+
Xe as DialogProductBlock,
|
|
940
|
+
Ge as DialogSearchBar,
|
|
941
|
+
pe as DialogSearchPagination,
|
|
942
|
+
ve as DialogSearchProductCard,
|
|
943
|
+
Ye as DialogSearchResults,
|
|
944
|
+
Je as useDialogSearch
|
|
950
945
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(b,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("react"),require("@askdialog/dialog-sdk"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@askdialog/dialog-sdk","react-dom"],t):(b=typeof globalThis<"u"?globalThis:b||self,t(b["dialog-react"]={},b["react/jsx-runtime"],b.React,b.dialogSdk,b.ReactDOM))})(this,(function(b,t,d,v,F){"use strict";const k={en:{placeholder:"Ask the AI a question",aiDisclosure:"You're chatting with an AI assistant. It can make mistakes, so please double-check important information",askSomethingElse:"Ask something else"},fr:{placeholder:"Posez une question à l'IA",aiDisclosure:"Vous discutez avec un assistant IA. Il peut se tromper, pensez à vérifier les informations importantes",askSomethingElse:"Posez une autre question"},es:{placeholder:"Haz una pregunta a la IA",aiDisclosure:"Estás chateando con un asistente de IA. Puede cometer errores, así que verifica la información importante",askSomethingElse:"Pregunta otra cosa"}},E=e=>{var r;const s=((r=e==null?void 0:e.split("-")[0])==null?void 0:r.toLowerCase())??"en";return k[s]??k.en},z=({client:e,questions:s,disabled:r,productId:o,productTitle:a,selectedVariantId:c})=>{const i=()=>{e.openAssistantWithSuggestions({questions:s??[],product:{id:o,title:a,selectedVariantId:c}})};return t.jsx("button",{type:"button",className:"dialog-ask-something-else",disabled:r,onClick:i,children:E(e.locale).askSomethingElse})},V=({title:e="Your expert",description:s="A question about this product?"})=>t.jsxs("div",{className:"dialog-block-header-container",children:[t.jsx("div",{className:"dialog-block-title",children:e}),t.jsx("div",{className:"dialog-block-description",children:s})]}),K=({color:e="#181825"})=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsxs("g",{clipPath:"url(#clip0_466_934)",children:[t.jsx("path",{d:"M5.41675 10.8333L6.07046 12.1408C6.2917 12.5832 6.40232 12.8045 6.55011 12.9962C6.68124 13.1663 6.83375 13.3188 7.00388 13.45C7.19559 13.5977 7.41684 13.7084 7.85932 13.9296L9.16675 14.5833L7.85932 15.237C7.41684 15.4583 7.19559 15.5689 7.00388 15.7167C6.83375 15.8478 6.68124 16.0003 6.55011 16.1704C6.40232 16.3622 6.2917 16.5834 6.07046 17.0259L5.41675 18.3333L4.76303 17.0259C4.54179 16.5834 4.43117 16.3622 4.28339 16.1704C4.15225 16.0003 3.99974 15.8478 3.82962 15.7167C3.6379 15.5689 3.41666 15.4583 2.97418 15.237L1.66675 14.5833L2.97418 13.9296C3.41666 13.7084 3.6379 13.5977 3.82962 13.45C3.99974 13.3188 4.15225 13.1663 4.28339 12.9962C4.43117 12.8045 4.54179 12.5832 4.76303 12.1408L5.41675 10.8333Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M12.5001 1.66666L13.4823 4.22034C13.7173 4.83136 13.8348 5.13688 14.0175 5.39386C14.1795 5.62162 14.3785 5.82061 14.6062 5.98256C14.8632 6.16529 15.1687 6.2828 15.7797 6.5178L18.3334 7.49999L15.7797 8.48217C15.1687 8.71718 14.8632 8.83469 14.6062 9.01742C14.3785 9.17937 14.1795 9.37836 14.0175 9.60612C13.8348 9.8631 13.7173 10.1686 13.4823 10.7796L12.5001 13.3333L11.5179 10.7796C11.2829 10.1686 11.1654 9.8631 10.9827 9.60612C10.8207 9.37836 10.6217 9.17937 10.3939 9.01742C10.137 8.83469 9.83145 8.71718 9.22043 8.48217L6.66675 7.49999L9.22043 6.5178C9.83145 6.28279 10.137 6.16529 10.3939 5.98256C10.6217 5.82061 10.8207 5.62162 10.9827 5.39386C11.1654 5.13688 11.2829 4.83136 11.5179 4.22034L12.5001 1.66666Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),t.jsx("defs",{children:t.jsx("clipPath",{id:"clip0_466_934",children:t.jsx("rect",{width:"20",height:"20",fill:"white"})})})]}),j=({client:e,questions:s,productId:r,productTitle:o,selectedVariantId:a})=>{const c=i=>{e.sendProductMessage({productId:r,productTitle:o,selectedVariantId:a,question:i,fromQuestionSuggestion:!0})};return t.jsx(t.Fragment,{children:s.map(i=>t.jsxs("button",{className:"dialog-block-suggestions-item",onClick:()=>c(i.question),children:[t.jsx(K,{color:e.theme.primaryColor}),t.jsx("span",{className:"dialog-block-suggestions-item-label",children:i.question})]},i.question))})},U=()=>t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"dialog-block-suggestions-skeleton-item"}),t.jsx("div",{className:"dialog-block-suggestions-skeleton-item"}),t.jsx("div",{className:"dialog-block-suggestions-skeleton-item"})]}),Q=({client:e,questions:s,isLoading:r,productId:o,productTitle:a,selectedVariantId:c})=>t.jsx("div",{className:"dialog-block-suggestions-container",children:r||!s?t.jsx(U,{}):t.jsx(j,{client:e,questions:s,productId:o,productTitle:a,selectedVariantId:c})}),W=({color:e="#ffffff"})=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),P=({client:e,productId:s,productTitle:r,selectedVariantId:o})=>{const a=d.useRef(null),[c,i]=d.useState(""),n=E(e.locale),l=()=>{var u;(u=a.current)==null||u.focus()},h=()=>{const u=c;u.trim()&&(e.sendProductMessage({productId:s,productTitle:r,selectedVariantId:o,question:u,fromQuestionSuggestion:!0}),i(""))},f=u=>{u.key==="Enter"&&h()};return t.jsxs("div",{className:"dialog-input-container",children:[t.jsxs("div",{className:"dialog-input-wrapper",onClick:l,children:[t.jsx("input",{id:"dialog-ask-anything-input-ai-input",ref:a,value:c,onChange:u=>i(u.target.value),className:"dialog-ask-anything-input-ai-input",placeholder:n.placeholder,"aria-describedby":"dialog-input-ai-disclosure",onKeyDown:f}),t.jsx("button",{id:"send-message-button-ai-input",className:"dialog-input-submit",disabled:!c.trim(),onClick:h,children:t.jsx(W,{color:e.theme.ctaTextColor})})]}),t.jsx("p",{id:"dialog-input-ai-disclosure",className:"dialog-input-ai-disclosure",children:n.aiDisclosure})]})},A=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),Z=e=>{if(!e)return;const s=document.body;Object.keys(e).forEach(r=>{const o=r,a=A(r);if(e[o]!==void 0){if(typeof e[o]=="object"){Object.keys(e[o]).forEach(c=>{var n;const i=c;if(i!==void 0){const l=A(c),h=e[o];s.style.setProperty(`--dialog-theme-${a}-${l}`,(n=h[i])==null?void 0:n.toString())}});return}if(o==="ctaBorderType"){const c=e[o]==="rounded"?"24px":"0";s.style.setProperty(`--dialog-theme-${a}`,c);return}s.style.setProperty(`--dialog-theme-${a}`,e[o].toString())}})},X=({theme:e,children:s})=>(d.useEffect(()=>{e&&Z(e)},[e]),t.jsx(t.Fragment,{children:s})),G=2,Y=5,J=({client:e,productId:s,productTitle:r,selectedVariantId:o,enableInput:a=!1})=>{var p;const[c,i]=d.useState(!0),[n,l]=d.useState(void 0);d.useEffect(()=>{v.registerDialogInstallation({method:"react",version:"2.9.0"}),v.addAuditCapability("pdp-block")},[]);const h=d.useMemo(()=>c?"":n==null?void 0:n.assistantName,[n,c]),f=d.useMemo(()=>c?"":n==null?void 0:n.description,[n,c]),u=d.useMemo(()=>c?"":n==null?void 0:n.inputPlaceholder,[n,c]),g=d.useMemo(()=>{var C;return v.resolveTextDirection((C=e.getLocalizationInformations())==null?void 0:C.languageCode)},[e]);return d.useEffect(()=>{let C=!0;return(async()=>{i(!0),l(void 0);try{const N=await e.getSuggestions(s,{limit:Y});C&&l(N)}catch(N){console.error("error",N)}finally{C&&i(!1)}})(),()=>{C=!1}},[e,s]),t.jsx(X,{theme:e.theme,children:t.jsxs("div",{id:"dialog-instant",className:"dialog-block-container",dir:g,children:[t.jsx(V,{title:h,description:f}),t.jsx(Q,{client:e,questions:(p=n==null?void 0:n.questions)==null?void 0:p.slice(0,G),isLoading:c,productId:s,productTitle:r,selectedVariantId:o}),a?t.jsx(P,{client:e,placeholder:u,productId:s,productTitle:r,selectedVariantId:o}):t.jsx(z,{client:e,questions:n==null?void 0:n.questions,disabled:c,productId:s,productTitle:r,selectedVariantId:o})]})})},R=()=>t.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M8 13V3M8 3L3 8M8 3L13 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),ee="M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z",se=({color:e="currentColor"})=>t.jsx("svg",{width:16,height:16,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:ee,fill:e})}),te=({controller:e,placeholder:s="Search products...",autoFocus:r=!1,submitAriaLabel:o="Search"})=>{const[a,c]=d.useState(""),i=n=>{n.preventDefault(),e.submit(a)};return t.jsxs("form",{className:"dialog-search-bar",role:"search",onSubmit:i,children:[t.jsxs("div",{className:"dialog-search-bar-field",children:[t.jsx("span",{className:"dialog-search-bar-icon",children:t.jsx(se,{})}),t.jsx("input",{type:"text",name:"dialog-search-query",className:"dialog-search-bar-input",value:a,"aria-label":s,placeholder:s,autoFocus:r,onChange:n=>{c(n.target.value),e.setQuery(n.target.value)}})]}),t.jsx("button",{type:"submit",className:"dialog-search-bar-submit","aria-label":o,children:t.jsx(R,{})})]})},oe=(e,s)=>{try{return new Intl.NumberFormat(s).format(e)}catch{return String(e)}},I={en:e=>({searching:s=>`Searching “${s}”…`,noResults:"No matching products",retry:"Retry",collectionsLabel:"Collections",productsLabel:"Products",collectionsCount:s=>s===1?"1 collection":`${e(s)} collections`,resultsCount:s=>s===1?"1 result":`${e(s)} results`,seeAllLabel:s=>s===1?"See the result":`See all ${e(s)} results`,previous:"Previous",next:"Next",pageOf:(s,r)=>`Page ${e(s)} / ${e(r)}`}),fr:e=>({searching:s=>`Recherche de « ${s} »…`,noResults:"Aucun produit correspondant",retry:"Réessayer",collectionsLabel:"Collections",productsLabel:"Produits",collectionsCount:s=>s===1?"1 collection":`${e(s)} collections`,resultsCount:s=>s===1?"1 résultat":`${e(s)} résultats`,seeAllLabel:s=>s===1?"Voir le résultat":`Voir les ${e(s)} résultats`,previous:"Précédent",next:"Suivant",pageOf:(s,r)=>`Page ${e(s)} / ${e(r)}`}),de:e=>({searching:s=>`Suche nach „${s}“…`,noResults:"Keine passenden Produkte",retry:"Erneut versuchen",collectionsLabel:"Kollektionen",productsLabel:"Produkte",collectionsCount:s=>s===1?"1 Kollektion":`${e(s)} Kollektionen`,resultsCount:s=>s===1?"1 Ergebnis":`${e(s)} Ergebnisse`,seeAllLabel:s=>s===1?"Das Ergebnis anzeigen":`Alle ${e(s)} Ergebnisse anzeigen`,previous:"Zurück",next:"Weiter",pageOf:(s,r)=>`Seite ${e(s)} / ${e(r)}`}),es:e=>({searching:s=>`Buscando «${s}»…`,noResults:"No hay productos que coincidan",retry:"Reintentar",collectionsLabel:"Colecciones",productsLabel:"Productos",collectionsCount:s=>s===1?"1 colección":`${e(s)} colecciones`,resultsCount:s=>s===1?"1 resultado":`${e(s)} resultados`,seeAllLabel:s=>s===1?"Ver el resultado":`Ver los ${e(s)} resultados`,previous:"Anterior",next:"Siguiente",pageOf:(s,r)=>`Página ${e(s)} / ${e(r)}`}),it:e=>({searching:s=>`Ricerca di “${s}”…`,noResults:"Nessun prodotto corrispondente",retry:"Riprova",collectionsLabel:"Collezioni",productsLabel:"Prodotti",collectionsCount:s=>s===1?"1 collezione":`${e(s)} collezioni`,resultsCount:s=>s===1?"1 risultato":`${e(s)} risultati`,seeAllLabel:s=>s===1?"Vedi il risultato":`Vedi tutti i ${e(s)} risultati`,previous:"Precedente",next:"Successivo",pageOf:(s,r)=>`Pagina ${e(s)} / ${e(r)}`})},x=e=>{var o;const s=((o=e==null?void 0:e.split("-")[0])==null?void 0:o.toLowerCase())??"en";return(I[s]??I.en)(a=>oe(a,e))},$=e=>e.status!==v.SearchStatus.LOADING&&e.response!==void 0&&e.response.nbPages>1,D=({controller:e,state:s,locale:r})=>{const o=s.response;if(o===void 0||!$(s))return null;const a=x(r);return t.jsxs("nav",{"aria-label":"Search results pages",className:"dialog-search-pagination",children:[t.jsx("button",{type:"button",disabled:o.page===0,onClick:()=>e.setPage(o.page-1),children:a.previous}),t.jsx("span",{children:a.pageOf(o.page+1,o.nbPages)}),t.jsx("button",{type:"button",disabled:o.page>=o.nbPages-1,onClick:()=>e.setPage(o.page+1),children:a.next})]})},M=e=>e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").replace(/ẞ/gu,"ß").toUpperCase().toLowerCase().replace(/ς/g,"σ"),re=(e,s)=>{const r={before:"",match:e,after:""},o=M(s.trim());if(o==="")return r;const a=[...e],c=[];let i="";a.forEach((f,u)=>{const g=M(f);for(let p=0;p<g.length;p+=1)c.push(u);i+=g});const n=i.indexOf(o);if(n===-1)return r;const l=c[n],h=c[n+o.length-1]+1;return{before:a.slice(0,l).join(""),match:a.slice(l,h).join(""),after:a.slice(h).join("")}},T=({title:e,query:s})=>{const{before:r,match:o,after:a}=re(e,s);return t.jsxs(t.Fragment,{children:[r!==""&&t.jsx("span",{className:"dialog-search-muted",children:r}),t.jsx("span",{className:"dialog-search-match",children:o}),a!==""&&t.jsx("span",{className:"dialog-search-muted",children:a})]})},ae=({variants_min_price:e,currency:s},r)=>{if(e===void 0)return"";try{return s===void 0?new Intl.NumberFormat(r).format(e):new Intl.NumberFormat(r,{style:"currency",currency:s}).format(e)}catch{return""}},ne=e=>e.product_image||e.image||void 0,ce=e=>{try{const{protocol:s}=new URL(e,window.location.href);return s==="http:"||s==="https:"?e:void 0}catch{return}},_=e=>e.url===void 0||e.url===""?void 0:ce(e.url),O=e=>e.title??e.handle??e.objectID,q=({controller:e,hit:s,index:r,locale:o,query:a=""})=>{const c=d.useRef(null);d.useEffect(()=>{c.current!==null&&e.observeResult(c.current,r)},[e,s,r]);const i=g=>{const p=g.metaKey||g.ctrlKey||g.shiftKey||g.altKey;e.selectResult(r,{navigate:!p})&&g.preventDefault()},n=g=>{g.button===1&&e.selectResult(r,{navigate:!1})},l=ae(s,o),h=_(s),f=ne(s),u=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"dialog-search-product-thumb","aria-hidden":!0,children:f!==void 0&&t.jsx("img",{src:f,alt:"",loading:"lazy"})}),t.jsx("span",{className:"dialog-search-product-title",children:t.jsx(T,{title:O(s),query:a})}),l!==""&&t.jsx("span",{className:"dialog-search-product-price",children:l})]});return t.jsx("li",{ref:c,className:"dialog-search-card",children:h===void 0?t.jsx("div",{className:"dialog-search-product",children:u}):t.jsx("a",{className:"dialog-search-product",href:h,onClick:i,onAuxClick:n,children:u})})},le=()=>t.jsx("svg",{width:16,height:16,viewBox:"0 0 256 256",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"})}),ie=()=>t.jsx("svg",{width:12,height:12,viewBox:"0 0 256 256",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"})}),H=e=>(e??[]).flatMap(s=>{const r=_(s);return r===void 0?[]:[{collection:s,href:r}]}),de=({collections:e,query:s,messages:r})=>{const o=H(e);return o.length===0?null:t.jsxs("aside",{className:"dialog-search-collections",children:[t.jsxs("div",{className:"dialog-search-section-head",children:[t.jsx("p",{className:"dialog-search-label",children:r.collectionsLabel}),t.jsx("span",{className:"dialog-search-count",children:r.collectionsCount(o.length)})]}),t.jsx("ul",{className:"dialog-search-collection-list",children:o.map(({collection:a,href:c})=>t.jsx("li",{children:t.jsxs("a",{className:"dialog-search-collection",href:c,children:[t.jsx("span",{className:"dialog-search-collection-thumb","aria-hidden":!0,children:a.imageUrl!==void 0&&a.imageUrl!==""&&t.jsx("img",{src:a.imageUrl,alt:"",loading:"lazy"})}),t.jsx("span",{className:"dialog-search-collection-title",children:t.jsx(T,{title:O(a),query:s})}),t.jsx("span",{className:"dialog-search-caret",children:t.jsx(ie,{})})]})},a.objectID))})]})},ue=({controller:e,response:s,locale:r,messages:o})=>t.jsxs("section",{className:"dialog-search-products",children:[t.jsx("div",{className:"dialog-search-section-head",children:t.jsxs("p",{className:"dialog-search-label",children:[o.productsLabel,s.nbHits>0&&t.jsx("span",{className:"dialog-search-label-count",children:` · ${o.resultsCount(s.nbHits)}`})]})}),t.jsx("ul",{className:"dialog-search-results",children:s.hits.length===0?t.jsx("li",{className:"dialog-search-empty",role:"status",children:o.noResults}):s.hits.map((a,c)=>t.jsx(q,{controller:e,hit:a,index:c,locale:r,query:s.query},a.objectID))})]}),y=8,S=16,he=200,ge=1440,pe=(e,s)=>e.bottom>0&&e.top<s,fe=(e,s)=>{const r=Math.min(ge,s-2*S),o=e.left+e.width/2-r/2;return{left:Math.min(Math.max(o,S),s-S-r),width:r}},be=(e,s,r)=>{const o=r-e.bottom-y-S,a=e.top-y-S,c=fe(e,s);return o<he&&a>o?{...c,bottom:r-e.top+y,maxHeight:Math.max(a,0)}:{...c,top:e.bottom+y,maxHeight:Math.max(o,0)}},ve=e=>{const s=e.trim().replace(/^#/,"");if(!/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(s))return;const r=s.length<=4?[...s].map(o=>o+o).join(""):s;return[0,2,4].map(o=>Number.parseInt(r.slice(o,o+2),16))},Ce=e=>{const s=/^rgba?\((\d+), (\d+), (\d+)(?:, [\d.]+)?\)$/.exec(e);if(s!==null)return[s[1],s[2],s[3]].map(Number)},Se=e=>{if(typeof document>"u")return;const s=document.createElement("span");if(s.style.color=e,s.style.color==="")return;document.body.appendChild(s);const r=Ce(getComputedStyle(s).color);return s.remove(),r},ye=e=>ve(e)??Se(e),me=e=>{const s=e/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4},B=e=>{const s=ye(e);if(s===void 0)return;const[r,o,a]=s.map(me);return .2126*r+.7152*o+.0722*a},we="#181825",Le="#ffffff",Ne="straight",w=.5,L={light:{panel:"#ffffff",side:"#fafbfc",text:"#111827","text-sec":"#6b7280",border:"#eceef2",hover:"#eef2f7",thumb:"#eef1f5"},dark:{panel:"#15171c",side:"#1b1e25",text:"#f3f4f6","text-sec":"#9ca3af",border:"#2b2f38",hover:"#242830",thumb:"#2b2f38"}},ke={rectangle:{"r-panel":"4px","r-item":"4px","r-thumb":"2px","r-btn":"4px"},"rectangle-rounded":{"r-panel":"16px","r-item":"10px","r-thumb":"8px","r-btn":"10px"}},m=e=>e===void 0||e.trim()===""?void 0:e.trim(),Ee=e=>{const s=e===void 0?void 0:B(e);return s===void 0?"light":s<w?"dark":"light"},Pe=(e,s)=>{const r=B(e);return r===void 0?L[s].text:(s==="light"?r<w:r>=w)?e:L[s].text},Ae=e=>{const s=Ee(m(e==null?void 0:e.backgroundColor)),r=(e==null?void 0:e.ctaBorderType)===Ne?"rectangle":"rectangle-rounded",o=m(e==null?void 0:e.primaryColor)??we,a=m(e==null?void 0:e.fontFamily),c={...L[s],...ke[r],primary:o,accent:Pe(o,s),"cta-text":m(e==null?void 0:e.ctaTextColor)??Le,...a===void 0?{}:{font:a}};return Object.fromEntries(Object.entries(c).map(([i,n])=>[`--dso-${i}`,n]))},Ie=e=>{const s=d.useRef(null),[r,o]=d.useState(void 0),[a,c]=d.useState({width:0,height:0});return d.useLayoutEffect(()=>{if(!e)return;const i=()=>{const n=s.current;if(n===null)return;const l=n.previousElementSibling??n,{top:h,bottom:f,left:u,width:g}=l.getBoundingClientRect();c(p=>p.width===window.innerWidth&&p.height===window.innerHeight?p:{width:window.innerWidth,height:window.innerHeight}),o(p=>p!==void 0&&p.top===h&&p.bottom===f&&p.left===u&&p.width===g?p:{top:h,bottom:f,left:u,width:g})};return i(),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[e]),{anchorRef:s,rect:r,viewport:a}},xe=(e,s)=>{const[r,o]=d.useState(!1),a=d.useRef(null),c=e.status!==v.SearchStatus.IDLE&&!r;return d.useEffect(()=>{o(!1)},[e.query]),d.useEffect(()=>{if(!c)return;const i=n=>{var g,p;const l=n.target;if(!(l instanceof Node))return;const h=(g=s.current)==null?void 0:g.previousElementSibling,f=((p=a.current)==null?void 0:p.contains(l))??!1,u=(h==null?void 0:h.contains(l))??!1;!f&&!u&&o(!0)};return document.addEventListener("pointerdown",i),()=>document.removeEventListener("pointerdown",i)},[c,s]),d.useEffect(()=>{var l;const i=(l=s.current)==null?void 0:l.previousElementSibling;if(i==null)return;const n=()=>o(!1);return i.addEventListener("focusin",n),()=>i.removeEventListener("focusin",n)},[s]),{isOpen:c,panelRef:a}},$e=e=>e instanceof v.DialogSearchError?`Search failed (${e.status}${e.code?` ${e.code}`:""}): ${e.message}`:"Search failed: network error. Check your connection and try again.",De=(e,s)=>{var g,p;const{controller:r,state:o,locale:a,seeAllHref:c}=e,{status:i,response:n}=o;if(i===v.SearchStatus.ERROR)return t.jsxs("div",{className:"dialog-search-error",children:[t.jsx("p",{role:"alert",className:"dialog-search-status dialog-search-status-error",children:$e(o.error)}),t.jsx("button",{type:"button",className:"dialog-search-retry",onClick:()=>r.retry(),children:s.retry})]});if(n===void 0)return t.jsx("p",{role:"status",className:"dialog-search-status",children:s.searching(o.query)});const l=((p=(g=o.sections)==null?void 0:g.collections)==null?void 0:p.hits)??[],h=H(l).length>0,f=c!==void 0&&n.nbHits>0,u=!f&&$(o);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`dialog-search-body${h?"":" dialog-search-body--no-collections"}`,children:[t.jsx(de,{collections:l,query:n.query,messages:s}),t.jsx(ue,{controller:r,response:n,locale:a,messages:s})]}),(f||u)&&t.jsx("div",{className:"dialog-search-footer",children:f?t.jsxs("a",{className:"dialog-search-cta",href:c(n.query),children:[s.seeAllLabel(n.nbHits),t.jsx(le,{})]}):t.jsx(D,{controller:r,state:o,locale:a})})]})},Me=e=>{const{state:s,locale:r,theme:o,layout:a="list"}=e,c=s.status!==v.SearchStatus.IDLE,{anchorRef:i,rect:n,viewport:l}=Ie(c),{isOpen:h,panelRef:f}=xe(s,i),u=x(r),g=d.useMemo(()=>Ae(o),[o]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:i}),h&&n!==void 0&&pe(n,l.height)&&F.createPortal(t.jsx("div",{ref:f,className:`dialog-search-panel dialog-search-panel--${a}`,style:{...be(n,l.width,l.height),...g},children:De(e,u)}),document.body)]})},Te={status:v.SearchStatus.IDLE,query:"",page:0},_e=e=>{const s=d.useRef(e);s.current=e;const r=d.useRef(void 0),o=d.useCallback(()=>{if(r.current===void 0){const{client:l,surface:h="search_page",...f}=s.current;r.current=v.createSearchController({search:(u,g)=>l.search(u,g),analytics:{surface:h,trackViewSearchResults:u=>l.trackViewSearchResults(u),trackSelectSearchResult:u=>l.trackSelectSearchResult(u)},...f})}return r.current},[]),a=d.useRef(void 0);a.current??(a.current={setQuery:l=>o().setQuery(l),submit:l=>o().submit(l),setPage:l=>o().setPage(l),retry:()=>o().retry(),observeResult:(l,h)=>o().observeResult(l,h),selectResult:(l,h)=>o().selectResult(l,h),subscribe:l=>o().subscribe(l),getState:()=>o().getState(),dispose:()=>{var l;(l=r.current)==null||l.dispose(),r.current=void 0}}),d.useEffect(()=>{v.registerDialogInstallation({method:"react",version:"2.9.0"});const l=o();return()=>{l.dispose(),r.current===l&&(r.current=void 0)}},[o]);const c=d.useCallback(l=>o().subscribe(l),[o]),i=d.useCallback(()=>o().getState(),[o]),n=d.useSyncExternalStore(c,i,()=>Te);return{controller:a.current,state:n,theme:e.client.theme}};b.DialogInput=P,b.DialogProductBlock=J,b.DialogSearchBar=te,b.DialogSearchPagination=D,b.DialogSearchProductCard=q,b.DialogSearchResults=Me,b.useDialogSearch=_e,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(b,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("react"),require("@askdialog/dialog-sdk"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@askdialog/dialog-sdk","react-dom"],t):(b=typeof globalThis<"u"?globalThis:b||self,t(b["dialog-react"]={},b["react/jsx-runtime"],b.React,b.dialogSdk,b.ReactDOM))})(this,(function(b,t,d,C,F){"use strict";const k={en:{placeholder:"Ask the AI a question",aiDisclosure:"You're chatting with an AI assistant. It can make mistakes, so please double-check important information",askSomethingElse:"Ask something else"},fr:{placeholder:"Posez une question à l'IA",aiDisclosure:"Vous discutez avec un assistant IA. Il peut se tromper, pensez à vérifier les informations importantes",askSomethingElse:"Posez une autre question"},es:{placeholder:"Haz una pregunta a la IA",aiDisclosure:"Estás chateando con un asistente de IA. Puede cometer errores, así que verifica la información importante",askSomethingElse:"Pregunta otra cosa"}},E=e=>{var r;const s=((r=e==null?void 0:e.split("-")[0])==null?void 0:r.toLowerCase())??"en";return k[s]??k.en},z=({client:e,questions:s,disabled:r,productId:o,productTitle:a,selectedVariantId:c})=>{const i=()=>{e.openAssistantWithSuggestions({questions:s??[],product:{id:o,title:a,selectedVariantId:c}})};return t.jsx("button",{type:"button",className:"dialog-ask-something-else",disabled:r,onClick:i,children:E(e.locale).askSomethingElse})},V=({title:e="Your expert",description:s="A question about this product?"})=>t.jsxs("div",{className:"dialog-block-header-container",children:[t.jsx("div",{className:"dialog-block-title",children:e}),t.jsx("div",{className:"dialog-block-description",children:s})]}),K=({color:e="#181825"})=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsxs("g",{clipPath:"url(#clip0_466_934)",children:[t.jsx("path",{d:"M5.41675 10.8333L6.07046 12.1408C6.2917 12.5832 6.40232 12.8045 6.55011 12.9962C6.68124 13.1663 6.83375 13.3188 7.00388 13.45C7.19559 13.5977 7.41684 13.7084 7.85932 13.9296L9.16675 14.5833L7.85932 15.237C7.41684 15.4583 7.19559 15.5689 7.00388 15.7167C6.83375 15.8478 6.68124 16.0003 6.55011 16.1704C6.40232 16.3622 6.2917 16.5834 6.07046 17.0259L5.41675 18.3333L4.76303 17.0259C4.54179 16.5834 4.43117 16.3622 4.28339 16.1704C4.15225 16.0003 3.99974 15.8478 3.82962 15.7167C3.6379 15.5689 3.41666 15.4583 2.97418 15.237L1.66675 14.5833L2.97418 13.9296C3.41666 13.7084 3.6379 13.5977 3.82962 13.45C3.99974 13.3188 4.15225 13.1663 4.28339 12.9962C4.43117 12.8045 4.54179 12.5832 4.76303 12.1408L5.41675 10.8333Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M12.5001 1.66666L13.4823 4.22034C13.7173 4.83136 13.8348 5.13688 14.0175 5.39386C14.1795 5.62162 14.3785 5.82061 14.6062 5.98256C14.8632 6.16529 15.1687 6.2828 15.7797 6.5178L18.3334 7.49999L15.7797 8.48217C15.1687 8.71718 14.8632 8.83469 14.6062 9.01742C14.3785 9.17937 14.1795 9.37836 14.0175 9.60612C13.8348 9.8631 13.7173 10.1686 13.4823 10.7796L12.5001 13.3333L11.5179 10.7796C11.2829 10.1686 11.1654 9.8631 10.9827 9.60612C10.8207 9.37836 10.6217 9.17937 10.3939 9.01742C10.137 8.83469 9.83145 8.71718 9.22043 8.48217L6.66675 7.49999L9.22043 6.5178C9.83145 6.28279 10.137 6.16529 10.3939 5.98256C10.6217 5.82061 10.8207 5.62162 10.9827 5.39386C11.1654 5.13688 11.2829 4.83136 11.5179 4.22034L12.5001 1.66666Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),t.jsx("defs",{children:t.jsx("clipPath",{id:"clip0_466_934",children:t.jsx("rect",{width:"20",height:"20",fill:"white"})})})]}),j=({client:e,questions:s,productId:r,productTitle:o,selectedVariantId:a})=>{const c=i=>{e.sendProductMessage({productId:r,productTitle:o,selectedVariantId:a,question:i,fromQuestionSuggestion:!0})};return t.jsx(t.Fragment,{children:s.map(i=>t.jsxs("button",{className:"dialog-block-suggestions-item",onClick:()=>c(i.question),children:[t.jsx(K,{color:e.theme.primaryColor}),t.jsx("span",{className:"dialog-block-suggestions-item-label",children:i.question})]},i.question))})},U=()=>t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"dialog-block-suggestions-skeleton-item"}),t.jsx("div",{className:"dialog-block-suggestions-skeleton-item"}),t.jsx("div",{className:"dialog-block-suggestions-skeleton-item"})]}),Q=({client:e,questions:s,isLoading:r,productId:o,productTitle:a,selectedVariantId:c})=>t.jsx("div",{className:"dialog-block-suggestions-container",children:r||!s?t.jsx(U,{}):t.jsx(j,{client:e,questions:s,productId:o,productTitle:a,selectedVariantId:c})}),W=({color:e="#ffffff"})=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),P=({client:e,productId:s,productTitle:r,selectedVariantId:o})=>{const a=d.useRef(null),[c,i]=d.useState(""),n=E(e.locale),l=()=>{var u;(u=a.current)==null||u.focus()},g=()=>{const u=c;u.trim()&&(e.sendProductMessage({productId:s,productTitle:r,selectedVariantId:o,question:u,fromQuestionSuggestion:!0}),i(""))},p=u=>{u.key==="Enter"&&g()};return t.jsxs("div",{className:"dialog-input-container",children:[t.jsxs("div",{className:"dialog-input-wrapper",onClick:l,children:[t.jsx("input",{id:"dialog-ask-anything-input-ai-input",ref:a,value:c,onChange:u=>i(u.target.value),className:"dialog-ask-anything-input-ai-input",placeholder:n.placeholder,"aria-describedby":"dialog-input-ai-disclosure",onKeyDown:p}),t.jsx("button",{id:"send-message-button-ai-input",className:"dialog-input-submit",disabled:!c.trim(),onClick:g,children:t.jsx(W,{color:e.theme.ctaTextColor})})]}),t.jsx("p",{id:"dialog-input-ai-disclosure",className:"dialog-input-ai-disclosure",children:n.aiDisclosure})]})},A=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),Z=e=>{if(!e)return;const s=document.body;Object.keys(e).forEach(r=>{const o=r,a=A(r);if(e[o]!==void 0){if(typeof e[o]=="object"){Object.keys(e[o]).forEach(c=>{var n;const i=c;if(i!==void 0){const l=A(c),g=e[o];s.style.setProperty(`--dialog-theme-${a}-${l}`,(n=g[i])==null?void 0:n.toString())}});return}if(o==="ctaBorderType"){const c=e[o]==="rounded"?"24px":"0";s.style.setProperty(`--dialog-theme-${a}`,c);return}s.style.setProperty(`--dialog-theme-${a}`,e[o].toString())}})},X=({theme:e,children:s})=>(d.useEffect(()=>{e&&Z(e)},[e]),t.jsx(t.Fragment,{children:s})),G=2,Y=5,J=({client:e,productId:s,productTitle:r,selectedVariantId:o,enableInput:a=!1})=>{var h;const[c,i]=d.useState(!0),[n,l]=d.useState(void 0);d.useEffect(()=>{C.registerDialogInstallation({method:"react",version:"2.10.1"}),C.addAuditCapability("pdp-block")},[]);const g=d.useMemo(()=>c?"":n==null?void 0:n.assistantName,[n,c]),p=d.useMemo(()=>c?"":n==null?void 0:n.description,[n,c]),u=d.useMemo(()=>c?"":n==null?void 0:n.inputPlaceholder,[n,c]),f=d.useMemo(()=>{var v;return C.resolveTextDirection((v=e.getLocalizationInformations())==null?void 0:v.languageCode)},[e]);return d.useEffect(()=>{let v=!0;return(async()=>{i(!0),l(void 0);try{const N=await e.getSuggestions(s,{limit:Y});v&&l(N)}catch(N){console.error("error",N)}finally{v&&i(!1)}})(),()=>{v=!1}},[e,s]),t.jsx(X,{theme:e.theme,children:t.jsxs("div",{id:"dialog-instant",className:"dialog-block-container",dir:f,children:[t.jsx(V,{title:g,description:p}),t.jsx(Q,{client:e,questions:(h=n==null?void 0:n.questions)==null?void 0:h.slice(0,G),isLoading:c,productId:s,productTitle:r,selectedVariantId:o}),a?t.jsx(P,{client:e,placeholder:u,productId:s,productTitle:r,selectedVariantId:o}):t.jsx(z,{client:e,questions:n==null?void 0:n.questions,disabled:c,productId:s,productTitle:r,selectedVariantId:o})]})})},R=()=>t.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M8 13V3M8 3L3 8M8 3L13 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),ee="M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z",se=({color:e="currentColor"})=>t.jsx("svg",{width:16,height:16,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:ee,fill:e})}),te=({controller:e,placeholder:s="Search products...",autoFocus:r=!1,submitAriaLabel:o="Search"})=>{const[a,c]=d.useState(""),i=n=>{n.preventDefault(),e.submit(a)};return t.jsxs("form",{className:"dialog-search-bar",role:"search",onSubmit:i,children:[t.jsxs("div",{className:"dialog-search-bar-field",children:[t.jsx("span",{className:"dialog-search-bar-icon",children:t.jsx(se,{})}),t.jsx("input",{type:"text",name:"dialog-search-query",className:"dialog-search-bar-input",value:a,"aria-label":s,placeholder:s,autoFocus:r,onChange:n=>{c(n.target.value),e.setQuery(n.target.value)}})]}),t.jsx("button",{type:"submit",className:"dialog-search-bar-submit","aria-label":o,children:t.jsx(R,{})})]})},oe=(e,s)=>{try{return new Intl.NumberFormat(s).format(e)}catch{return String(e)}},I={en:e=>({searching:s=>`Searching “${s}”…`,noResults:"No matching products",retry:"Retry",collectionsLabel:"Collections",productsLabel:"Products",collectionsCount:s=>s===1?"1 collection":`${e(s)} collections`,resultsCount:s=>s===1?"1 result":`${e(s)} results`,seeAllLabel:s=>s===1?"See the result":`See all ${e(s)} results`,previous:"Previous",next:"Next",pageOf:(s,r)=>`Page ${e(s)} / ${e(r)}`}),fr:e=>({searching:s=>`Recherche de « ${s} »…`,noResults:"Aucun produit correspondant",retry:"Réessayer",collectionsLabel:"Collections",productsLabel:"Produits",collectionsCount:s=>s===1?"1 collection":`${e(s)} collections`,resultsCount:s=>s===1?"1 résultat":`${e(s)} résultats`,seeAllLabel:s=>s===1?"Voir le résultat":`Voir les ${e(s)} résultats`,previous:"Précédent",next:"Suivant",pageOf:(s,r)=>`Page ${e(s)} / ${e(r)}`}),de:e=>({searching:s=>`Suche nach „${s}“…`,noResults:"Keine passenden Produkte",retry:"Erneut versuchen",collectionsLabel:"Kollektionen",productsLabel:"Produkte",collectionsCount:s=>s===1?"1 Kollektion":`${e(s)} Kollektionen`,resultsCount:s=>s===1?"1 Ergebnis":`${e(s)} Ergebnisse`,seeAllLabel:s=>s===1?"Das Ergebnis anzeigen":`Alle ${e(s)} Ergebnisse anzeigen`,previous:"Zurück",next:"Weiter",pageOf:(s,r)=>`Seite ${e(s)} / ${e(r)}`}),es:e=>({searching:s=>`Buscando «${s}»…`,noResults:"No hay productos que coincidan",retry:"Reintentar",collectionsLabel:"Colecciones",productsLabel:"Productos",collectionsCount:s=>s===1?"1 colección":`${e(s)} colecciones`,resultsCount:s=>s===1?"1 resultado":`${e(s)} resultados`,seeAllLabel:s=>s===1?"Ver el resultado":`Ver los ${e(s)} resultados`,previous:"Anterior",next:"Siguiente",pageOf:(s,r)=>`Página ${e(s)} / ${e(r)}`}),it:e=>({searching:s=>`Ricerca di “${s}”…`,noResults:"Nessun prodotto corrispondente",retry:"Riprova",collectionsLabel:"Collezioni",productsLabel:"Prodotti",collectionsCount:s=>s===1?"1 collezione":`${e(s)} collezioni`,resultsCount:s=>s===1?"1 risultato":`${e(s)} risultati`,seeAllLabel:s=>s===1?"Vedi il risultato":`Vedi tutti i ${e(s)} risultati`,previous:"Precedente",next:"Successivo",pageOf:(s,r)=>`Pagina ${e(s)} / ${e(r)}`})},x=e=>{var o;const s=((o=e==null?void 0:e.split("-")[0])==null?void 0:o.toLowerCase())??"en";return(I[s]??I.en)(a=>oe(a,e))},$=e=>e.status!==C.SearchStatus.LOADING&&e.response!==void 0&&e.response.nbPages>1,D=({controller:e,state:s,locale:r})=>{const o=s.response;if(o===void 0||!$(s))return null;const a=x(r);return t.jsxs("nav",{"aria-label":"Search results pages",className:"dialog-search-pagination",children:[t.jsx("button",{type:"button",disabled:o.page===0,onClick:()=>e.setPage(o.page-1),children:a.previous}),t.jsx("span",{children:a.pageOf(o.page+1,o.nbPages)}),t.jsx("button",{type:"button",disabled:o.page>=o.nbPages-1,onClick:()=>e.setPage(o.page+1),children:a.next})]})},M=e=>e.normalize("NFD").replace(new RegExp("\\p{M}","gu"),"").replace(/ẞ/gu,"ß").toUpperCase().toLowerCase().replace(/ς/g,"σ"),re=(e,s)=>{const r={before:"",match:e,after:""},o=M(s.trim());if(o==="")return r;const a=[...e],c=[];let i="";a.forEach((p,u)=>{const f=M(p);for(let h=0;h<f.length;h+=1)c.push(u);i+=f});const n=i.indexOf(o);if(n===-1)return r;const l=c[n],g=c[n+o.length-1]+1;return{before:a.slice(0,l).join(""),match:a.slice(l,g).join(""),after:a.slice(g).join("")}},T=({title:e,query:s})=>{const{before:r,match:o,after:a}=re(e,s);return t.jsxs(t.Fragment,{children:[r!==""&&t.jsx("span",{className:"dialog-search-muted",children:r}),t.jsx("span",{className:"dialog-search-match",children:o}),a!==""&&t.jsx("span",{className:"dialog-search-muted",children:a})]})},ae=e=>e.product_image||e.image||void 0,O=e=>{if(!(e===void 0||e===""))try{const{protocol:s}=new URL(e,window.location.href);return s==="http:"||s==="https:"?e:void 0}catch{return}},ne=e=>O(e.url),_=e=>e.title??e.handle??e.objectID,q=({controller:e,hit:s,index:r,locale:o,query:a=""})=>{const c=d.useRef(null);d.useEffect(()=>{c.current!==null&&e.observeResult(c.current,r)},[e,s,r]);const i=h=>{const v=h.metaKey||h.ctrlKey||h.shiftKey||h.altKey;e.selectResult(r,{navigate:!v})&&h.preventDefault()},n=h=>{h.button===1&&e.selectResult(r,{navigate:!1})},l=C.formatSearchPrice(s,o),g=C.formatSearchCompareAtPrice(s,o),p=O(e.productUrl(s)),u=ae(s),f=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"dialog-search-product-thumb","aria-hidden":!0,children:u!==void 0&&t.jsx("img",{src:u,alt:"",loading:"lazy"})}),t.jsx("span",{className:"dialog-search-product-title",children:t.jsx(T,{title:_(s),query:a})}),l!==""&&t.jsxs("span",{className:"dialog-search-product-price",children:[g!==""&&t.jsx("s",{className:"dialog-search-product-compare-at",children:g}),l]})]});return t.jsx("li",{ref:c,className:"dialog-search-card",children:p===void 0?t.jsx("div",{className:"dialog-search-product",children:f}):t.jsx("a",{className:"dialog-search-product",href:p,onClick:i,onAuxClick:n,children:f})})},ce=()=>t.jsx("svg",{width:16,height:16,viewBox:"0 0 256 256",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"})}),le=()=>t.jsx("svg",{width:12,height:12,viewBox:"0 0 256 256",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"})}),H=e=>(e??[]).flatMap(s=>{const r=ne(s);return r===void 0?[]:[{collection:s,href:r}]}),ie=({collections:e,query:s,messages:r})=>{const o=H(e);return o.length===0?null:t.jsxs("aside",{className:"dialog-search-collections",children:[t.jsxs("div",{className:"dialog-search-section-head",children:[t.jsx("p",{className:"dialog-search-label",children:r.collectionsLabel}),t.jsx("span",{className:"dialog-search-count",children:r.collectionsCount(o.length)})]}),t.jsx("ul",{className:"dialog-search-collection-list",children:o.map(({collection:a,href:c})=>t.jsx("li",{children:t.jsxs("a",{className:"dialog-search-collection",href:c,children:[t.jsx("span",{className:"dialog-search-collection-thumb","aria-hidden":!0,children:a.image?t.jsx("img",{src:a.image,alt:"",loading:"lazy"}):null}),t.jsx("span",{className:"dialog-search-collection-title",children:t.jsx(T,{title:_(a),query:s})}),t.jsx("span",{className:"dialog-search-caret",children:t.jsx(le,{})})]})},a.objectID))})]})},de=({controller:e,response:s,locale:r,messages:o})=>t.jsxs("section",{className:"dialog-search-products",children:[t.jsx("div",{className:"dialog-search-section-head",children:t.jsxs("p",{className:"dialog-search-label",children:[o.productsLabel,s.nbHits>0&&t.jsx("span",{className:"dialog-search-label-count",children:` · ${o.resultsCount(s.nbHits)}`})]})}),t.jsx("ul",{className:"dialog-search-results",children:s.hits.length===0?t.jsx("li",{className:"dialog-search-empty",role:"status",children:o.noResults}):s.hits.map((a,c)=>t.jsx(q,{controller:e,hit:a,index:c,locale:r,query:s.query},a.objectID))})]}),y=8,S=16,ue=200,he=1440,ge=(e,s)=>e.bottom>0&&e.top<s,pe=(e,s)=>{const r=Math.min(he,s-2*S),o=e.left+e.width/2-r/2;return{left:Math.min(Math.max(o,S),s-S-r),width:r}},fe=(e,s,r)=>{const o=r-e.bottom-y-S,a=e.top-y-S,c=pe(e,s);return o<ue&&a>o?{...c,bottom:r-e.top+y,maxHeight:Math.max(a,0)}:{...c,top:e.bottom+y,maxHeight:Math.max(o,0)}},be=e=>{const s=e.trim().replace(/^#/,"");if(!/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(s))return;const r=s.length<=4?[...s].map(o=>o+o).join(""):s;return[0,2,4].map(o=>Number.parseInt(r.slice(o,o+2),16))},Ce=e=>{const s=/^rgba?\((\d+), (\d+), (\d+)(?:, [\d.]+)?\)$/.exec(e);if(s!==null)return[s[1],s[2],s[3]].map(Number)},ve=e=>{if(typeof document>"u")return;const s=document.createElement("span");if(s.style.color=e,s.style.color==="")return;document.body.appendChild(s);const r=Ce(getComputedStyle(s).color);return s.remove(),r},Se=e=>be(e)??ve(e),ye=e=>{const s=e/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4},B=e=>{const s=Se(e);if(s===void 0)return;const[r,o,a]=s.map(ye);return .2126*r+.7152*o+.0722*a},me="#181825",we="#ffffff",Le="straight",w=.5,L={light:{panel:"#ffffff",side:"#fafbfc",text:"#111827","text-sec":"#6b7280",border:"#eceef2",hover:"#eef2f7",thumb:"#eef1f5"},dark:{panel:"#15171c",side:"#1b1e25",text:"#f3f4f6","text-sec":"#9ca3af",border:"#2b2f38",hover:"#242830",thumb:"#2b2f38"}},Ne={rectangle:{"r-panel":"4px","r-item":"4px","r-thumb":"2px","r-btn":"4px"},"rectangle-rounded":{"r-panel":"16px","r-item":"10px","r-thumb":"8px","r-btn":"10px"}},m=e=>e===void 0||e.trim()===""?void 0:e.trim(),ke=e=>{const s=e===void 0?void 0:B(e);return s===void 0?"light":s<w?"dark":"light"},Ee=(e,s)=>{const r=B(e);return r===void 0?L[s].text:(s==="light"?r<w:r>=w)?e:L[s].text},Pe=e=>{const s=ke(m(e==null?void 0:e.backgroundColor)),r=(e==null?void 0:e.ctaBorderType)===Le?"rectangle":"rectangle-rounded",o=m(e==null?void 0:e.primaryColor)??me,a=m(e==null?void 0:e.fontFamily),c={...L[s],...Ne[r],primary:o,accent:Ee(o,s),"cta-text":m(e==null?void 0:e.ctaTextColor)??we,...a===void 0?{}:{font:a}};return Object.fromEntries(Object.entries(c).map(([i,n])=>[`--dso-${i}`,n]))},Ae=e=>{const s=d.useRef(null),[r,o]=d.useState(void 0),[a,c]=d.useState({width:0,height:0});return d.useLayoutEffect(()=>{if(!e)return;const i=()=>{const n=s.current;if(n===null)return;const l=n.previousElementSibling??n,{top:g,bottom:p,left:u,width:f}=l.getBoundingClientRect();c(h=>h.width===window.innerWidth&&h.height===window.innerHeight?h:{width:window.innerWidth,height:window.innerHeight}),o(h=>h!==void 0&&h.top===g&&h.bottom===p&&h.left===u&&h.width===f?h:{top:g,bottom:p,left:u,width:f})};return i(),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[e]),{anchorRef:s,rect:r,viewport:a}},Ie=(e,s)=>{const[r,o]=d.useState(!1),a=d.useRef(null),c=e.status!==C.SearchStatus.IDLE&&!r;return d.useEffect(()=>{o(!1)},[e.query]),d.useEffect(()=>{if(!c)return;const i=n=>{var f,h;const l=n.target;if(!(l instanceof Node))return;const g=(f=s.current)==null?void 0:f.previousElementSibling,p=((h=a.current)==null?void 0:h.contains(l))??!1,u=(g==null?void 0:g.contains(l))??!1;!p&&!u&&o(!0)};return document.addEventListener("pointerdown",i),()=>document.removeEventListener("pointerdown",i)},[c,s]),d.useEffect(()=>{var l;const i=(l=s.current)==null?void 0:l.previousElementSibling;if(i==null)return;const n=()=>o(!1);return i.addEventListener("focusin",n),()=>i.removeEventListener("focusin",n)},[s]),{isOpen:c,panelRef:a}},xe=e=>e instanceof C.DialogSearchError?`Search failed (${e.status}${e.code?` ${e.code}`:""}): ${e.message}`:"Search failed: network error. Check your connection and try again.",$e=(e,s)=>{var f,h;const{controller:r,state:o,locale:a,seeAllHref:c}=e,{status:i,response:n}=o;if(i===C.SearchStatus.ERROR)return t.jsxs("div",{className:"dialog-search-error",children:[t.jsx("p",{role:"alert",className:"dialog-search-status dialog-search-status-error",children:xe(o.error)}),t.jsx("button",{type:"button",className:"dialog-search-retry",onClick:()=>r.retry(),children:s.retry})]});if(n===void 0)return t.jsx("p",{role:"status",className:"dialog-search-status",children:s.searching(o.query)});const l=((h=(f=o.sections)==null?void 0:f.collections)==null?void 0:h.hits)??[],g=H(l).length>0,p=c!==void 0&&n.nbHits>0,u=!p&&$(o);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`dialog-search-body${g?"":" dialog-search-body--no-collections"}`,children:[t.jsx(ie,{collections:l,query:n.query,messages:s}),t.jsx(de,{controller:r,response:n,locale:a,messages:s})]}),(p||u)&&t.jsx("div",{className:"dialog-search-footer",children:p?t.jsxs("a",{className:"dialog-search-cta",href:c(n.query),children:[s.seeAllLabel(n.nbHits),t.jsx(ce,{})]}):t.jsx(D,{controller:r,state:o,locale:a})})]})},De=e=>{const{state:s,locale:r,theme:o,layout:a="list"}=e,c=s.status!==C.SearchStatus.IDLE,{anchorRef:i,rect:n,viewport:l}=Ae(c),{isOpen:g,panelRef:p}=Ie(s,i),u=x(r),f=d.useMemo(()=>Pe(o),[o]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:i}),g&&n!==void 0&&ge(n,l.height)&&F.createPortal(t.jsx("div",{ref:p,className:`dialog-search-panel dialog-search-panel--${a}`,style:{...fe(n,l.width,l.height),...f},children:$e(e,u)}),document.body)]})},Me={status:C.SearchStatus.IDLE,query:"",page:0},Te=e=>{const s=d.useRef(e);s.current=e;const r=d.useRef(void 0),o=d.useCallback(()=>{if(r.current===void 0){const{client:l,surface:g="search_page",...p}=s.current;r.current=C.createSearchController({search:(u,f)=>l.search(u,f),analytics:{surface:g,trackViewSearchResults:u=>l.trackViewSearchResults(u),trackSelectSearchResult:u=>l.trackSelectSearchResult(u)},...p})}return r.current},[]),a=d.useRef(void 0);a.current??(a.current={setQuery:l=>o().setQuery(l),submit:l=>o().submit(l),setPage:l=>o().setPage(l),retry:()=>o().retry(),observeResult:(l,g)=>o().observeResult(l,g),selectResult:(l,g)=>o().selectResult(l,g),productUrl:l=>o().productUrl(l),subscribe:l=>o().subscribe(l),getState:()=>o().getState(),dispose:()=>{var l;(l=r.current)==null||l.dispose(),r.current=void 0}}),d.useEffect(()=>{C.registerDialogInstallation({method:"react",version:"2.10.1"});const l=o();return()=>{l.dispose(),r.current===l&&(r.current=void 0)}},[o]);const c=d.useCallback(l=>o().subscribe(l),[o]),i=d.useCallback(()=>o().getState(),[o]),n=d.useSyncExternalStore(c,i,()=>Me);return{controller:a.current,state:n,theme:e.client.theme}};b.DialogInput=P,b.DialogProductBlock=J,b.DialogSearchBar=te,b.DialogSearchPagination=D,b.DialogSearchProductCard=q,b.DialogSearchResults=De,b.useDialogSearch=Te,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askdialog/dialog-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/dialog-react.umd.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/react": "^19.2.7",
|
|
28
28
|
"@types/react-dom": "^19.2.3",
|
|
29
|
-
"@askdialog/dialog-sdk": "2.
|
|
29
|
+
"@askdialog/dialog-sdk": "2.18.0"
|
|
30
30
|
},
|
|
31
31
|
"author": "Dialog",
|
|
32
32
|
"publishConfig": {
|