Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
useSearchResults
was not updating the state when selected facets were provided on the initial state and no facets were in the response. userId
was not being passed on WidgetsProvider
. This was not allowing to register anonymous users.
Example usage:
All widget templates have been re factored in order to use the components provided by the @sitecore-search/cli package. widget templates are still created using the cli and when a new widget is created a folder labeled components is created in the same directory than the widget.
Before: 2 files were generated for a widget template (with the exception of tailwind, that only one file was generated).
and then on the file system:
Geo location payload was not property built for complex filters such and
and or
.
Using single filter with geo location:
This was working ✅
Using a composable filter with Geo location filters within:
This was fixed 🛠️
Changing the store context will update the widgets in order to show items related to a specific store. Example:
Store will also be sent together with the tracking information.
Issues on preview search:
To make the item close work some changes are going to be needed:
For styled-components
, on styled.ts
(or js
)
replace const PreviewSearchLink = styled.a
by const PreviewSearchLink = styled(PreviewSearch.ItemLink)
For tailwind, css and cssModules:
Replace the anchor tag that wraps the Product/Article card by
PreviewSearch.ItemLink
.
Properties should remain the same.
Now SDK provides a set of components that were used on the Widget Templates in order to facilitate reusability. In the same way than templates, Widget Components
can be created in different languages (Typescript
and Javascript
) and using different css implementations (tailwind
, styled-components
, css
, css modules
).
The list of components can be found here
In addition to the reusable components, a new command in the cli has been added to facilitate the copy/creation of those.
Having the @sitecore-search/cli
package installed, the addition of a new component can be done by executing the following command:
or just
and cli wizard will guide during the creation.
The following is the complete list of parameters:
Option | Alias | Type | description |
---|---|---|---|
name | n | string | The component name in our systems |
language | l | javascript or typescript | The component language |
styling | s | styled or css or cssModule or tailwind or plain | The component style |
overwrite | w | boolean | If it is present, will delete existing content that matches and will create the component again |
output | o | string | output directory for the component |
order-cloud-sdk
to peer dependenciesTo reduce build size, now order-cloud-sdk
is being loaded using dynamic imports. This gives the chance to the developer to avoid the inclusion of this libary in order to reduce bundle size.
In order to accomplish this, here are some examples based on different setups:
Using Vite and Rollup:
Using next.js
Using webpack
Similar to next.js
, ordercloud-javascript-sdk must be flagged as external.
In this example we want to gather all the widgets added on /search. /search content should be configured in CEC. Using usePageWidgets hook
A new type of filter related to Geo Location to search by a polygonal area. Examples:
requestMiddleware: async() => void
Example:
Added new parameter, trackConsent
to enable/disable tracking consent.
Added campaign properties for context:
utm_source: string
utm_medium: string
utm_campaign: string
utm_term: string
utm_content: string
Example:
Example:
PreviewSearch
templates.itemRedirectionHandler
: An optional custom redirection handler that will be called when the user clicks on an item.
itemRedirectionHandler?: (article: ArticleModel) => void;
Examples
submitRedirectionHandler
: An optional custom submit handler that will be called when the user submits the form by pressing the enter key.
submitRedirectionHandler?: (query: string) => void;
Examples
context.store.id
: string
context.store.group_id
: string
Example:
context.user.groups
: Array<string>
Example:
Example: before
now
useSearchResultsIncrementalResults
to get more results without loosing the current ones (this is useful for infinite scroll or load more experiences).Usage example:
Added a new primitive, SearchResultsLoadMore
. This is a Load More
button to be used together with useSearchResultsIncrementalResults
(by clicking it, will get the following page of results). Check this on the Primitives
section.
Added a new SearchResults
template using useSearchResultsIncrementalResults
and SearchResultsLoadMore
Range filters UI primitives, checkout docs.
Widget Config Parameter for query hooks
Example:
Now facets can be initialized by sending initial values as parameters. Facets can be set as ranges, text or value id, depending on the facet configuration.
Example:
PreviewSearch
primitives with better accessibility support and simpler structure.create-react-app
, next
and vite
(javasript
& typescript
)SearchResults
templatesremoveFilter
action (onFilterClick
will be deprecated).[BREAKING CHANGE] Improves Widget management
[BREAKING CHANGE] Moves to ESM
We're excited to announce a significant improvement in the library's architecture. Starting from this version, we have moved the entire library to ECMAScript Modules (ESM). This move brings several benefits, including better performance, improved tree-shaking capabilities, and enhanced compatibility with modern JavaScript tools and bundlers.
With the adoption of ESM, you'll be able to take advantage of a more streamlined and standardized module system, making it easier to integrate the library into various project setups. It also opens up opportunities for better code optimization and module isolation.
However, this change does come with a breaking impact on older environments and bundlers that do not fully support ESM. As a result, it's crucial to ensure that your project's build tools and runtime environment are compatible with ESM. Most modern bundlers like Webpack and Rollup have native support for ESM, so updating should be relatively straightforward.
We understand that upgrading to ESM may require some adjustments to your build configuration or dependencies. To help you through this process, we have provided detailed migration instructions in the updated documentation. Additionally, our support team is always available to assist you with any questions or issues you may encounter during the transition.
We believe that this move to ESM will bring long-term benefits to both the library's maintainability and your development experience. As always, we greatly appreciate your support and feedback as we continue to improve and evolve the library. Happy coding with the new ESM-powered version! 🚀
We're excited to introduce three new widgets: HTMLBlock, SEO, and Banner. Although pages support is still in development, you can already make use of these powerful new widgets in your app. Here's an example of how to use them:
context
to state
in all widget hooks for better clarity and consistencyTo provide even stronger typings when defining the widget, we have improved the type interface for all widget hooks. This allows you to type the initialized state (if any) and ensures proper type checking for the current state. We have also exposed some helpful type helpers to assist with the typing process. Here's an example of how you can use it:
With this enhancement, you can see that the state properties and un-initialized properties like keyphrase
are correctly typed
Previously, the SDK was tracking when the widget appears in the viewport transparently using an old React/React-DOM feature (findDOMNode). However, this feature is being deprecated in React and will eventually be removed. To adapt to this change, starting from this version, developers will need to manually reference the node that needs to be tracked. Don't worry, though, the SDK will still automatically trigger the event once the node is referenced. Here's how you can use the new widgetRef prop to track the widget:
Starting from this version, we have deprecated the useToken configuration property, and we encourage using it only when absolutely required. With this change, there's no need to include useToken in your configuration if API access doesn't specifically demand an access token.
Previously, useToken was intended for cases where API access required an access token. However, in most browser-based scenarios, this extra round-trip to the API was unnecessary and added overhead, resulting in a slightly slower experience.
Instead, we have introduced a more targeted approach with the useAccessToken property. This allows you to specify and handle access token usage more selectively and efficiently. Use useAccessToken only if your API access indeed necessitates an access token.
As always, our documentation has been updated to reflect these changes, and our support team is available to assist you should you have any questions or concerns. We hope that this enhancement empowers you to make informed decisions regarding authorization in your application.
We've enabled the noImplicitAny option by default in this version. This TypeScript compiler option enforces stricter type checking by requiring explicit type annotations for variables and function return types where TypeScript cannot infer the type.
Enabling noImplicitAny promotes safer code practices and helps catch potential type errors during compilation. While adopting this option may require adding more type annotations, it ultimately leads to a more robust and maintainable codebase.
Embrace the power of TypeScript's static type checking with noImplicitAny, and enjoy a more streamlined development process. If you need any assistance with this feature, refer to our documentation or reach out to our support resources.
or
-- These changes and additions to the library will greatly enhance your development experience and empower you to build even more dynamic and feature-rich applications. If you have any questions or feedback, please don't hesitate to reach out to us. Happy coding! 🎉