@sonic-equipment/ui 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/algolia/algolia-active-filters.d.ts +1 -1
- package/dist/icons/arrows/right-arrow-filled-icon.d.ts +0 -1
- package/dist/index.d.ts +175 -25
- package/dist/index.js +1709 -156
- package/dist/product-listing/product-listing.d.ts +0 -18
- package/dist/product-listing/product-listing.stories.d.ts +1 -2
- package/dist/shared/providers/cart-provider.d.ts +6 -6
- package/dist/shared/types/cart.d.ts +4 -4
- package/dist/styles.css +93 -93
- package/package.json +22 -22
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SelectedFilter } from 'filters/active-filters/active-filters';
|
|
2
2
|
import type { CurrentRefinementsConnectorParamsRefinement } from 'instantsearch.js/es/connectors/current-refinements/connectCurrentRefinements';
|
|
3
|
-
export interface
|
|
3
|
+
export interface AlgoliaSelectedFilterCategory {
|
|
4
4
|
filters: (SelectedFilter & CurrentRefinementsConnectorParamsRefinement)[];
|
|
5
5
|
label: string;
|
|
6
6
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,136 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ReactElement, MutableRefObject, ReactNode, HTMLAttributeAnchorTarget, FormEventHandler, KeyboardEvent, ComponentType } from 'react';
|
|
2
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { ReactNode, HTMLAttributeAnchorTarget, ReactElement, FormEventHandler, KeyboardEvent, ComponentType } from 'react';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
declare const useBreakpoint: () => {
|
|
6
|
+
isDesktop: boolean;
|
|
7
|
+
isMobile: boolean;
|
|
8
|
+
isTablet: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare function useDebouncedCallback<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
|
|
12
|
+
|
|
13
|
+
interface UseDisclosureReturnType {
|
|
14
|
+
close: () => void;
|
|
15
|
+
isClosed: boolean;
|
|
16
|
+
isOpen: boolean;
|
|
17
|
+
open: () => void;
|
|
18
|
+
toggle: () => void;
|
|
19
|
+
}
|
|
20
|
+
declare const useDisclosure: () => UseDisclosureReturnType;
|
|
21
|
+
|
|
22
|
+
declare const useScrollLock: (lock: boolean) => void;
|
|
23
|
+
|
|
24
|
+
interface CartLine$1 {
|
|
25
|
+
id: string
|
|
26
|
+
productId: string | null
|
|
27
|
+
qtyOrdered: number | null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Cart$1<T extends CartLine$1 = CartLine$1> {
|
|
31
|
+
cartLines?: T[] | null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface Props$1<TCartLine extends CartLine$1 = CartLine$1, TCart extends Cart$1<TCartLine> = Cart$1<TCartLine>> {
|
|
35
|
+
addToCart: (args: {
|
|
36
|
+
productId: string;
|
|
37
|
+
quantity: number;
|
|
38
|
+
}) => void;
|
|
39
|
+
currentCart: Readonly<TCart> | undefined;
|
|
40
|
+
isLoaded: boolean;
|
|
41
|
+
isLoading: boolean;
|
|
42
|
+
loadCurrentCart: VoidFunction;
|
|
43
|
+
removeCartLine: (args: {
|
|
44
|
+
cartLineId: string;
|
|
45
|
+
}) => void;
|
|
46
|
+
updateCartLine: (cartLine: TCartLine) => void;
|
|
47
|
+
}
|
|
48
|
+
declare function CartProvider<TCartLine extends CartLine$1 = CartLine$1, TCart extends Cart$1<TCartLine> = Cart$1<TCartLine>>(props: Props$1<TCartLine, TCart>): null;
|
|
49
|
+
declare function useCart(): Props$1<CartLine$1, Cart$1<CartLine$1>>;
|
|
50
|
+
declare function useProductCartLine(productId: string): {
|
|
51
|
+
addToCart: (args: {
|
|
52
|
+
productId: string;
|
|
53
|
+
quantity: number;
|
|
54
|
+
}) => void;
|
|
55
|
+
cartLine: CartLine$1 | undefined;
|
|
56
|
+
currentCart: Readonly<Cart$1<CartLine$1>> | undefined;
|
|
57
|
+
isLoaded: boolean;
|
|
58
|
+
isLoading: boolean;
|
|
59
|
+
loadCurrentCart: VoidFunction;
|
|
60
|
+
removeCartLine: (args: {
|
|
61
|
+
cartLineId: string;
|
|
62
|
+
}) => void;
|
|
63
|
+
updateCartLine: (cartLine: CartLine$1) => void;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type EventCallback<T> = (data: T) => void
|
|
67
|
+
|
|
68
|
+
declare class EventEmitter<T> {
|
|
69
|
+
private listeners: Map<string, EventCallback<T>[]>
|
|
70
|
+
|
|
71
|
+
constructor() {
|
|
72
|
+
this.listeners = new Map()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
addEventListener(event: string, listener: EventCallback<T>): void {
|
|
76
|
+
if (!this.listeners.has(event)) {
|
|
77
|
+
this.listeners.set(event, [])
|
|
78
|
+
}
|
|
79
|
+
this.listeners.get(event)!.push(listener)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
removeEventListener(event: string, listener: EventCallback<T>): void {
|
|
83
|
+
const listeners = this.listeners.get(event)
|
|
84
|
+
if (!listeners) return
|
|
85
|
+
|
|
86
|
+
const index = listeners.indexOf(listener)
|
|
87
|
+
if (index !== -1) {
|
|
88
|
+
listeners.splice(index, 1)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
trigger(event: string, data: T): void {
|
|
93
|
+
const listeners = this.listeners.get(event)
|
|
94
|
+
if (!listeners) return
|
|
95
|
+
|
|
96
|
+
listeners.forEach(listener => listener(data))
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare class State<T> extends EventEmitter<T | undefined> {
|
|
101
|
+
private _state;
|
|
102
|
+
constructor(state?: T);
|
|
103
|
+
get value(): T | undefined;
|
|
104
|
+
set value(newState: T | undefined);
|
|
105
|
+
}
|
|
106
|
+
declare class GlobalState {
|
|
107
|
+
private states;
|
|
108
|
+
constructor(states: MutableRefObject<Record<string | symbol, State<any>>>);
|
|
109
|
+
get<T>(key: string | symbol): State<T>;
|
|
110
|
+
get<T>(key: string | symbol, initialState: T | undefined): State<T>;
|
|
111
|
+
set<T>(key: string | symbol, state: State<T>): void;
|
|
112
|
+
}
|
|
113
|
+
declare const GlobalStateProviderContext: React.Context<GlobalState>;
|
|
114
|
+
interface GlobalStateProviderProps {
|
|
115
|
+
children: ReactNode;
|
|
116
|
+
}
|
|
117
|
+
declare function GlobalStateProvider({ children, }: GlobalStateProviderProps): ReactElement | null;
|
|
118
|
+
declare function useGlobalState<T>(key: string | symbol): [T | undefined, (value: T) => void];
|
|
119
|
+
declare function useGlobalState<T>(key: string | symbol, initialState: T): [T, (value: T) => void];
|
|
120
|
+
|
|
121
|
+
interface CartLine {
|
|
122
|
+
id: string;
|
|
123
|
+
productId: string | null;
|
|
124
|
+
qtyOrdered: number | null;
|
|
125
|
+
}
|
|
126
|
+
interface Cart<T extends CartLine = CartLine> {
|
|
127
|
+
cartLines?: T[] | null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface Product {
|
|
131
|
+
id: string;
|
|
132
|
+
title: string;
|
|
10
133
|
}
|
|
11
|
-
declare function AddToCartButton({ initialState, onChange, quantity, }: AddToCartButtonProps): react_jsx_runtime.JSX.Element;
|
|
12
134
|
|
|
13
135
|
interface ButtonProps {
|
|
14
136
|
_pseudo?: 'none' | 'focus' | 'hover' | 'active';
|
|
@@ -53,6 +175,19 @@ interface LinkButtonProps {
|
|
|
53
175
|
}
|
|
54
176
|
declare function LinkButton({ children, className, href, isDisabled, onPress, target, }: LinkButtonProps): react_jsx_runtime.JSX.Element;
|
|
55
177
|
|
|
178
|
+
type AddToCartState = 'initial' | 'spinner' | 'manual-input';
|
|
179
|
+
interface AddToCartButtonProps {
|
|
180
|
+
initialState?: AddToCartState;
|
|
181
|
+
onChange?: (quantity: number) => void;
|
|
182
|
+
quantity: number;
|
|
183
|
+
}
|
|
184
|
+
declare function AddToCartButton({ initialState, onChange, quantity, }: AddToCartButtonProps): react_jsx_runtime.JSX.Element;
|
|
185
|
+
|
|
186
|
+
interface Props {
|
|
187
|
+
productId: string;
|
|
188
|
+
}
|
|
189
|
+
declare const ConnectedAddToCartButton: ({ productId }: Props) => react_jsx_runtime.JSX.Element;
|
|
190
|
+
|
|
56
191
|
interface Source$1 {
|
|
57
192
|
url: string
|
|
58
193
|
width: number
|
|
@@ -316,25 +451,8 @@ interface Filters {
|
|
|
316
451
|
}[];
|
|
317
452
|
};
|
|
318
453
|
}
|
|
319
|
-
declare const sortOptions: {
|
|
320
|
-
readonly new: "New";
|
|
321
|
-
readonly popular: "Popular";
|
|
322
|
-
readonly price_asc: "Price: Low - High";
|
|
323
|
-
readonly price_desc: "Price: High - Low";
|
|
324
|
-
readonly recommended: "Recommended";
|
|
325
|
-
};
|
|
326
|
-
type SortKey = keyof typeof sortOptions;
|
|
327
|
-
type ActiveFilters = {
|
|
328
|
-
colors: string[];
|
|
329
|
-
};
|
|
330
454
|
type ProductListingProps = {
|
|
331
|
-
activeFilters: ActiveFilters;
|
|
332
|
-
filters: Filters;
|
|
333
455
|
isLoading?: boolean;
|
|
334
|
-
onFilterChange: (filters: ActiveFilters) => void;
|
|
335
|
-
onSortChange: (sort: SortKey) => void;
|
|
336
|
-
sort: SortKey;
|
|
337
|
-
total: number;
|
|
338
456
|
};
|
|
339
457
|
declare function ProductListing({ isLoading }: ProductListingProps): react_jsx_runtime.JSX.Element;
|
|
340
458
|
|
|
@@ -362,4 +480,36 @@ interface SidebarProps {
|
|
|
362
480
|
}
|
|
363
481
|
declare function Sidebar({ children }: SidebarProps): react_jsx_runtime.JSX.Element;
|
|
364
482
|
|
|
365
|
-
|
|
483
|
+
declare function AlgoliaCategories(): react_jsx_runtime.JSX.Element;
|
|
484
|
+
|
|
485
|
+
interface AlgoliaFilterPanelProps {
|
|
486
|
+
onShowProducts: VoidFunction;
|
|
487
|
+
}
|
|
488
|
+
declare function AlgoliaFilterPanel({ onShowProducts, }: AlgoliaFilterPanelProps): react_jsx_runtime.JSX.Element;
|
|
489
|
+
|
|
490
|
+
interface AlgoliaMultiSelectProps {
|
|
491
|
+
attribute: string;
|
|
492
|
+
}
|
|
493
|
+
declare function AlgoliaMultiSelect({ attribute }: AlgoliaMultiSelectProps): react_jsx_runtime.JSX.Element;
|
|
494
|
+
|
|
495
|
+
declare function AlgoliaPagination(): react_jsx_runtime.JSX.Element;
|
|
496
|
+
|
|
497
|
+
declare function AlgoliaProductList(): react_jsx_runtime.JSX.Element;
|
|
498
|
+
|
|
499
|
+
interface AlgoliaContextType {
|
|
500
|
+
online: boolean;
|
|
501
|
+
setOnline: (online: boolean) => void;
|
|
502
|
+
toggleOnline: VoidFunction;
|
|
503
|
+
}
|
|
504
|
+
interface AlgoliaProviderProps {
|
|
505
|
+
children: React.ReactNode;
|
|
506
|
+
online?: boolean;
|
|
507
|
+
}
|
|
508
|
+
declare function AlgoliaProvider({ children, online: _online, }: AlgoliaProviderProps): react_jsx_runtime.JSX.Element;
|
|
509
|
+
declare function useAlgolia(): AlgoliaContextType;
|
|
510
|
+
|
|
511
|
+
declare function AlgoliaResultsCount(): string | null;
|
|
512
|
+
|
|
513
|
+
declare function AlgoliaSortBy(): react_jsx_runtime.JSX.Element | null;
|
|
514
|
+
|
|
515
|
+
export { Accordion, AddToCartButton, AlgoliaCategories, AlgoliaFilterPanel, type AlgoliaFilterPanelProps, AlgoliaMultiSelect, AlgoliaPagination, AlgoliaProductList, AlgoliaProvider, AlgoliaResultsCount, AlgoliaSortBy, Button, type ButtonProps, type Cart, CartFilledIcon, type CartLine, CartOutlinedIcon, CartProvider, Checkbox, type CheckboxProps$1 as CheckboxProps, ColorCheckbox, type ColorCheckboxProps, ConnectedAddToCartButton, DehashedOutlinedIcon, FavoriteButton, type FavoriteButtonProps, FavoriteFilledIcon, FavoriteOutlinedIcon, type FilterOption, type Filters, FormattedMessage, type FormattedMessageFunction, type FormattedMessageProps, GlobalStateProvider, GlobalStateProviderContext, HashedOutlinedIcon, IconButton, type IconButtonProps, Image, type ImageProps, IntlProvider, LinkButton, type LinkButtonProps, MultiSelect, type MultiSelectProps, NumberField, type NumberFieldSize, type Product, ProductCard, type ProductCardProps, ProductListing, type ProductListingProps, ProductOverviewGrid, type ProductOverviewGridProps, ProductPrice, type ProductPriceProps, ProductSku, type ProductSkuProps, RightArrowFilledIcon, Select, type SelectProps, ShowAll, type ShowAllProps, Sidebar, type SidebarProps, TextField, createProductListingSearchParams, parseProductListingSearchParams, useAlgolia, useBreakpoint, useCart, useDebouncedCallback, useDisclosure, useFormattedMessage, useGlobalState, useProductCartLine, useScrollLock };
|