@sonic-equipment/ui 0.0.22 → 0.0.24

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.
Files changed (73) hide show
  1. package/dist/algolia/algolia-filter-section.d.ts +18 -0
  2. package/dist/algolia/algolia-multi-select-filter-section.d.ts +5 -0
  3. package/dist/algolia/algolia-provider.d.ts +10 -3
  4. package/dist/algolia/algolia-query-string-routing.d.ts +3 -0
  5. package/dist/algolia/algolia-searchclient-offline.d.ts +3 -0
  6. package/dist/badges/tag/tag.d.ts +2 -1
  7. package/dist/badges/tag/tag.stories.d.ts +0 -1
  8. package/dist/breadcrumbs/breadcrumb.d.ts +9 -0
  9. package/dist/breadcrumbs/breadcrumb.stories.d.ts +19 -0
  10. package/dist/breadcrumbs/connected-breadcrumb.d.ts +1 -0
  11. package/dist/buttons/add-to-cart-button/add-to-cart-button.stories.d.ts +0 -1
  12. package/dist/buttons/button/button.stories.d.ts +0 -1
  13. package/dist/buttons/favorite/connected-favorite-button.d.ts +3 -0
  14. package/dist/buttons/favorite/favorite-button.stories.d.ts +0 -1
  15. package/dist/buttons/icon-button/icon-button.stories.d.ts +0 -1
  16. package/dist/buttons/link-button/link-button.stories.d.ts +0 -1
  17. package/dist/cards/category-card/category-card.d.ts +8 -0
  18. package/dist/cards/category-card/category-card.stories.d.ts +15 -0
  19. package/dist/cards/product-card/product-card.d.ts +4 -2
  20. package/dist/cards/product-card/product-card.stories.d.ts +2 -3
  21. package/dist/carousel/carousel-navigation-button.d.ts +6 -0
  22. package/dist/carousel/carousel.d.ts +13 -0
  23. package/dist/carousel/category-carousel/category-carousel.d.ts +5 -0
  24. package/dist/carousel/category-carousel/category-carousel.stories.d.ts +15 -0
  25. package/dist/collapsables/accordion/accordion-item.d.ts +3 -3
  26. package/dist/collapsables/accordion/accordion.stories.d.ts +0 -1
  27. package/dist/collapsables/show-all/show-all.stories.d.ts +0 -1
  28. package/dist/display/product-price/product-price.stories.d.ts +0 -1
  29. package/dist/display/product-sku/product-sku.stories.d.ts +0 -1
  30. package/dist/filters/multi-select/multi-select.d.ts +1 -3
  31. package/dist/filters/multi-select/multi-select.stories.d.ts +0 -1
  32. package/dist/filters/pagination/pagination.stories.d.ts +0 -1
  33. package/dist/forms/checkbox/checkbox.stories.d.ts +0 -1
  34. package/dist/forms/color-checkbox/color-checkbox.stories.d.ts +0 -1
  35. package/dist/forms/field-error/field-error.stories.d.ts +0 -1
  36. package/dist/forms/input/input.stories.d.ts +0 -1
  37. package/dist/forms/label/label.stories.d.ts +0 -1
  38. package/dist/forms/number-field/number-field.stories.d.ts +0 -1
  39. package/dist/forms/select/select.stories.d.ts +0 -1
  40. package/dist/forms/text-field/text-field.stories.d.ts +0 -1
  41. package/dist/forms/textarea/textarea.stories.d.ts +0 -1
  42. package/dist/icons/arrows/left-arrow-filled-icon.d.ts +2 -0
  43. package/dist/icons/home/home-filled-icon.d.ts +2 -0
  44. package/dist/index.d.ts +125 -47
  45. package/dist/index.js +5600 -1704
  46. package/dist/intl/formatted-message.d.ts +2 -0
  47. package/dist/intl/formatted-message.stories.d.ts +1 -1
  48. package/dist/intl/translation-id.d.ts +1 -1
  49. package/dist/intl/types.d.ts +1 -1
  50. package/dist/intl/use-format-message.d.ts +5 -1
  51. package/dist/media/image/image.stories.d.ts +0 -1
  52. package/dist/pages/page/page.d.ts +7 -0
  53. package/dist/pages/page/page.stories.d.ts +19 -0
  54. package/dist/pages/page-layout/page-layout.d.ts +5 -0
  55. package/dist/pages/page-layout/page-layout.stories.d.ts +22 -0
  56. package/dist/pages/product-listing-page/product-listing-page.d.ts +14 -0
  57. package/dist/{product-listing/product-listing.stories.d.ts → pages/product-listing-page/product-listing-page.stories.d.ts} +7 -4
  58. package/dist/shared/hooks/use-breakpoint.d.ts +12 -4
  59. package/dist/shared/hooks/use-disclosure.d.ts +1 -1
  60. package/dist/shared/providers/breadcrumb-provider.d.ts +11 -0
  61. package/dist/shared/providers/favorite-provider.d.ts +10 -0
  62. package/dist/sidebar/sidebar-context.d.ts +1 -0
  63. package/dist/styles.css +639 -60
  64. package/dist/typography/heading/heading.stories.d.ts +1 -2
  65. package/package.json +15 -4
  66. package/dist/algolia/algolia-multi-select.d.ts +0 -5
  67. package/dist/algolia/algolia-product-list.d.ts +0 -1
  68. package/dist/algolia/algolia-searchclient-mock.d.ts +0 -4
  69. package/dist/algolia/algolia.stories.d.ts +0 -17
  70. package/dist/product-listing/filters/colors/color-filter.d.ts +0 -11
  71. package/dist/product-listing/filters/filter/filter.d.ts +0 -7
  72. package/dist/product-listing/product-listing.d.ts +0 -13
  73. package/dist/product-listing/search-params.d.ts +0 -18
package/dist/index.d.ts CHANGED
@@ -1,12 +1,23 @@
1
1
  /// <reference types="react" />
2
2
  import { ReactElement, MutableRefObject, ReactNode, HTMLAttributeAnchorTarget, FormEventHandler, KeyboardEvent, ComponentType } from 'react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
-
5
- declare const useBreakpoint: () => {
6
- isDesktop: boolean;
7
- isMobile: boolean;
8
- isTablet: boolean;
4
+ import { PressEvent } from 'react-aria-components';
5
+ import { SearchClient } from 'algoliasearch/lite';
6
+ import { RouterProps } from 'instantsearch.js/es/middlewares/createRouterMiddleware';
7
+ import { UiState } from 'instantsearch.js/es/types';
8
+
9
+ declare const breakpoints: {
10
+ readonly sm: 0;
11
+ readonly md: 576;
12
+ readonly lg: 768;
13
+ readonly xl: 1024;
14
+ readonly xxl: 1440;
9
15
  };
16
+ type Breakpoint$2 = keyof typeof breakpoints;
17
+ interface UseBreakpointReturnType extends Record<Breakpoint$2, boolean> {
18
+ current: Breakpoint$2;
19
+ }
20
+ declare const useBreakpoint: () => UseBreakpointReturnType;
10
21
 
11
22
  declare function useDebouncedCallback<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
12
23
 
@@ -17,10 +28,21 @@ interface UseDisclosureReturnType {
17
28
  open: () => void;
18
29
  toggle: () => void;
19
30
  }
20
- declare const useDisclosure: () => UseDisclosureReturnType;
31
+ declare const useDisclosure: (initialState?: boolean) => UseDisclosureReturnType;
21
32
 
22
33
  declare const useScrollLock: (lock: boolean) => void;
23
34
 
35
+ interface Link$1 {
36
+ href: string;
37
+ label: string;
38
+ }
39
+ interface Props$3 {
40
+ links: Link$1[];
41
+ updateLinks: (links: Link$1[]) => void;
42
+ }
43
+ declare function BreadcrumbProvider(props: Props$3): null;
44
+ declare function useBreadcrumb(): Props$3;
45
+
24
46
  interface CartLine$1 {
25
47
  id: string
26
48
  productId: string | null
@@ -31,7 +53,7 @@ interface Cart$1<T extends CartLine$1 = CartLine$1> {
31
53
  cartLines?: T[] | null
32
54
  }
33
55
 
34
- interface Props$1<TCartLine extends CartLine$1 = CartLine$1, TCart extends Cart$1<TCartLine> = Cart$1<TCartLine>> {
56
+ interface Props$2<TCartLine extends CartLine$1 = CartLine$1, TCart extends Cart$1<TCartLine> = Cart$1<TCartLine>> {
35
57
  addToCart: (args: {
36
58
  productId: string;
37
59
  quantity: number;
@@ -45,8 +67,8 @@ interface Props$1<TCartLine extends CartLine$1 = CartLine$1, TCart extends Cart$
45
67
  }) => void;
46
68
  updateCartLine: (cartLine: TCartLine) => void;
47
69
  }
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>>;
70
+ declare function CartProvider<TCartLine extends CartLine$1 = CartLine$1, TCart extends Cart$1<TCartLine> = Cart$1<TCartLine>>(props: Props$2<TCartLine, TCart>): null;
71
+ declare function useCart(): Props$2<CartLine$1, Cart$1<CartLine$1>>;
50
72
  declare function useProductCartLine(productId: string): {
51
73
  addToCart: (args: {
52
74
  productId: string;
@@ -63,6 +85,16 @@ declare function useProductCartLine(productId: string): {
63
85
  updateCartLine: (cartLine: CartLine$1) => void;
64
86
  };
65
87
 
88
+ interface Props$1 {
89
+ isFavorite: (productId: string) => boolean;
90
+ toggleFavorite: (productId: string) => void;
91
+ }
92
+ declare function FavoriteProvider(props: Props$1): null;
93
+ declare function useFavorite(productId: string): {
94
+ isFavorite: boolean;
95
+ toggle: () => void;
96
+ };
97
+
66
98
  type EventCallback<T> = (data: T) => void
67
99
 
68
100
  declare class EventEmitter<T> {
@@ -132,6 +164,17 @@ interface Product {
132
164
  title: string;
133
165
  }
134
166
 
167
+ interface Link {
168
+ href: string;
169
+ label: string;
170
+ }
171
+ interface BreadcrumbProps {
172
+ links: Link[];
173
+ }
174
+ declare function Breadcrumb({ links }: BreadcrumbProps): react_jsx_runtime.JSX.Element | null;
175
+
176
+ declare function ConnectedBreadcrumb(): react_jsx_runtime.JSX.Element;
177
+
135
178
  interface ButtonProps {
136
179
  _pseudo?: 'none' | 'focus' | 'hover' | 'active';
137
180
  children?: ReactNode | string;
@@ -220,24 +263,37 @@ interface ProductPrice$1 {
220
263
  interface ProductCardProps {
221
264
  addToCartButton: ReactElement;
222
265
  favoriteButton?: ReactElement;
266
+ href: string;
223
267
  image: ImageProps$1;
224
- onClick: React.MouseEventHandler<HTMLDivElement>;
268
+ onClick?: (e: PressEvent) => void;
225
269
  price: ProductPrice$1;
226
270
  sku: string;
227
271
  tag?: 'new' | 'sale';
228
272
  title: string;
229
273
  }
230
- declare function ProductCard({ addToCartButton: AddToCartButton, favoriteButton: FavoriteButton, image: { alt, fit, src, title: imageTitle }, onClick, price, sku, tag, title, }: ProductCardProps): react_jsx_runtime.JSX.Element;
274
+ declare function ProductCard({ addToCartButton: AddToCartButton, favoriteButton: FavoriteButton, href, image: { alt, fit, src, title: imageTitle }, onClick, price, sku, tag, title, }: ProductCardProps): react_jsx_runtime.JSX.Element;
275
+
276
+ interface CategoryCardProps {
277
+ href: string
278
+ image: ImageProps$1
279
+ isSelected?: boolean
280
+ title: string
281
+ }
282
+
283
+ interface CategoryCarouselProps {
284
+ categories: CategoryCardProps[];
285
+ }
286
+ declare function CategoryCarousel({ categories }: CategoryCarouselProps): react_jsx_runtime.JSX.Element;
231
287
 
232
288
  interface AccordionItemProps {
233
289
  _pseudo?: 'none' | 'focus' | 'hover' | 'active';
234
290
  children: ReactNode;
235
291
  className?: string;
236
292
  id: string;
293
+ initialIsOpen?: boolean;
237
294
  isDisabled?: boolean;
238
- isOpen?: boolean;
239
295
  size?: 'md' | 'lg';
240
- title: string;
296
+ title: ReactNode;
241
297
  }
242
298
 
243
299
  interface AccordionProps {
@@ -279,16 +335,14 @@ interface FilterOption {
279
335
  }
280
336
  interface MultiSelectProps<T extends FilterOption> {
281
337
  amountShown?: number;
282
- isOpen: boolean;
283
338
  onChange: (value: T) => void;
284
- onToggleOpen: (isOpen: boolean) => void;
285
339
  options: T[];
286
340
  render: ({ onChange, option, }: {
287
341
  onChange: (key: string) => void;
288
342
  option: T;
289
343
  }) => ReactNode;
290
344
  }
291
- declare function MultiSelect<T extends FilterOption>({ amountShown, isOpen, onChange, onToggleOpen, options, render, }: MultiSelectProps<T>): react_jsx_runtime.JSX.Element;
345
+ declare function MultiSelect<T extends FilterOption>({ amountShown, onChange, options, render, }: MultiSelectProps<T>): react_jsx_runtime.JSX.Element | null;
292
346
 
293
347
  interface CheckboxProps$1 {
294
348
  _pseudo?: 'none' | 'focus' | 'hover' | 'active';
@@ -397,15 +451,17 @@ declare function FavoriteOutlinedIcon(props: React.SVGProps<SVGSVGElement>): rea
397
451
 
398
452
  declare function HashedOutlinedIcon(props: React.SVGProps<SVGSVGElement>): react_jsx_runtime.JSX.Element;
399
453
 
400
- type TranslationId = 'Chosen filters' | 'Clear filters' | 'Excl. VAT' | 'Incl. VAT' | 'Show' | 'Show all' | 'Show filters' | 'Show less' | 'Sort' | 'articles' | 'article' | 'of';
454
+ type TranslationId = 'Chosen filters' | 'Clear filters' | 'Excl. VAT' | 'Hide filters' | 'Incl. VAT' | 'Show' | 'Show all' | 'Show filters' | 'Show less' | 'Sort' | 'articles' | 'article' | 'of';
401
455
 
402
456
  interface FormattedMessageProps {
457
+ fallbackValue?: string;
403
458
  id: TranslationId;
459
+ optional?: boolean;
404
460
  replacementValues?: Record<string, string>;
405
461
  }
406
462
  declare const FormattedMessage: ComponentType<FormattedMessageProps>;
407
463
 
408
- type FormatMessageFunction = (id: string, ...replacementValues: readonly string[]) => string;
464
+ type FormatMessageFunction = (id: string, ...replacementValues: readonly string[]) => string | undefined;
409
465
 
410
466
  interface IntlProviderProps {
411
467
  children: React.ReactNode;
@@ -413,7 +469,11 @@ interface IntlProviderProps {
413
469
  }
414
470
  declare function IntlProvider({ children, formatMessage }: IntlProviderProps): react_jsx_runtime.JSX.Element;
415
471
 
416
- type FormattedMessageFunction = (key: TranslationId, replacementValues?: Record<string, string>) => string;
472
+ type FormattedMessageFunction = (id: TranslationId, options?: {
473
+ fallbackValue?: string;
474
+ optional?: boolean;
475
+ replacementValues?: Record<string, string>;
476
+ }) => string;
417
477
  declare const useFormattedMessage: () => FormattedMessageFunction;
418
478
 
419
479
  interface ProductOverviewGridProps {
@@ -442,6 +502,18 @@ interface ImageProps {
442
502
  }
443
503
  declare function Image({ alt, className, fallbackSrc, fit, height, loading, sizes: sizesProp, src, srcSet: srcSetProp, title, width, }: ImageProps): react_jsx_runtime.JSX.Element;
444
504
 
505
+ declare function PageLayout({ children, className, }: {
506
+ children: ReactNode;
507
+ className?: string;
508
+ }): react_jsx_runtime.JSX.Element;
509
+
510
+ interface PageProps {
511
+ children: ReactNode;
512
+ className?: string;
513
+ title?: string;
514
+ }
515
+ declare function Page({ children, className, title }: PageProps): react_jsx_runtime.JSX.Element;
516
+
445
517
  interface Filters {
446
518
  color: {
447
519
  options: {
@@ -451,35 +523,22 @@ interface Filters {
451
523
  }[];
452
524
  };
453
525
  }
454
- type ProductListingProps = {
526
+ type ProductListingPageProps = {
527
+ category: string;
455
528
  isLoading?: boolean;
456
529
  };
457
- declare function ProductListing({ isLoading }: ProductListingProps): react_jsx_runtime.JSX.Element;
458
-
459
- declare function createProductListingSearchParams(state: {
460
- filters: {
461
- colors: string[];
462
- };
463
- sort: {
464
- by: string;
465
- direction: string;
466
- };
467
- }): URLSearchParams;
468
- declare function parseProductListingSearchParams(params: URLSearchParams): {
469
- filters: {
470
- colors: string[];
471
- };
472
- sort: {
473
- by: string;
474
- direction: string;
475
- };
476
- };
530
+ declare function ProductListingPage({ category, isLoading, }: ProductListingPageProps): react_jsx_runtime.JSX.Element;
477
531
 
478
532
  interface SidebarProps {
479
533
  children: React.ReactNode;
480
534
  }
481
535
  declare function Sidebar({ children }: SidebarProps): react_jsx_runtime.JSX.Element;
482
536
 
537
+ interface SidebarProviderProps {
538
+ children: ReactElement;
539
+ }
540
+ declare function SidebarProvider({ children }: SidebarProviderProps): react_jsx_runtime.JSX.Element;
541
+
483
542
  declare function AlgoliaCategories(): react_jsx_runtime.JSX.Element;
484
543
 
485
544
  interface AlgoliaFilterPanelProps {
@@ -487,29 +546,48 @@ interface AlgoliaFilterPanelProps {
487
546
  }
488
547
  declare function AlgoliaFilterPanel({ onShowProducts, }: AlgoliaFilterPanelProps): react_jsx_runtime.JSX.Element;
489
548
 
490
- interface AlgoliaMultiSelectProps {
549
+ interface RefinementListItem {
550
+ count: number;
551
+ highlighted?: string;
552
+ isRefined: boolean;
553
+ label: string;
554
+ value: string;
555
+ }
556
+ interface AlgoliaFilterSectionProps {
557
+ attribute: string;
558
+ children({ items, refine, }: {
559
+ items: RefinementListItem[];
560
+ refine(value: string): void;
561
+ }): React.ReactNode;
562
+ initialIsOpen?: boolean;
563
+ }
564
+ declare function AlgoliaFilterSection({ attribute, children, initialIsOpen, }: AlgoliaFilterSectionProps): react_jsx_runtime.JSX.Element | null;
565
+
566
+ interface AlgoliaMultiSelectFilterSectionProps {
491
567
  attribute: string;
492
568
  }
493
- declare function AlgoliaMultiSelect({ attribute }: AlgoliaMultiSelectProps): react_jsx_runtime.JSX.Element;
569
+ declare function AlgoliaMultiSelectFilterSection({ attribute, }: AlgoliaMultiSelectFilterSectionProps): react_jsx_runtime.JSX.Element;
494
570
 
495
571
  declare function AlgoliaPagination(): react_jsx_runtime.JSX.Element;
496
572
 
497
- declare function AlgoliaProductList(): react_jsx_runtime.JSX.Element;
498
-
499
573
  interface AlgoliaContextType {
500
574
  online: boolean;
501
575
  setOnline: (online: boolean) => void;
502
576
  toggleOnline: VoidFunction;
503
577
  }
504
578
  interface AlgoliaProviderProps {
505
- children: React.ReactNode;
579
+ category: string;
580
+ children: ReactNode;
581
+ offlineSearchClient?: SearchClient;
506
582
  online?: boolean;
583
+ routing?: boolean | RouterProps<UiState, UiState> | undefined;
584
+ searchClient: SearchClient;
507
585
  }
508
- declare function AlgoliaProvider({ children, online: _online, }: AlgoliaProviderProps): react_jsx_runtime.JSX.Element;
586
+ declare function AlgoliaProvider({ category, children, offlineSearchClient, online: _online, routing, searchClient, }: AlgoliaProviderProps): react_jsx_runtime.JSX.Element;
509
587
  declare function useAlgolia(): AlgoliaContextType;
510
588
 
511
589
  declare function AlgoliaResultsCount(): string | null;
512
590
 
513
591
  declare function AlgoliaSortBy(): react_jsx_runtime.JSX.Element | null;
514
592
 
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 };
593
+ export { Accordion, AddToCartButton, AlgoliaCategories, AlgoliaFilterPanel, type AlgoliaFilterPanelProps, AlgoliaFilterSection, AlgoliaMultiSelectFilterSection, AlgoliaPagination, AlgoliaProvider, AlgoliaResultsCount, AlgoliaSortBy, Breadcrumb, type BreadcrumbProps, BreadcrumbProvider, Button, type ButtonProps, type Cart, CartFilledIcon, type CartLine, CartOutlinedIcon, CartProvider, CategoryCarousel, type CategoryCarouselProps, Checkbox, type CheckboxProps$1 as CheckboxProps, ColorCheckbox, type ColorCheckboxProps, ConnectedAddToCartButton, ConnectedBreadcrumb, DehashedOutlinedIcon, FavoriteButton, type FavoriteButtonProps, FavoriteFilledIcon, FavoriteOutlinedIcon, FavoriteProvider, type FilterOption, type Filters, FormattedMessage, type FormattedMessageFunction, type FormattedMessageProps, GlobalStateProvider, GlobalStateProviderContext, HashedOutlinedIcon, IconButton, type IconButtonProps, Image, type ImageProps, IntlProvider, type Link$1 as Link, LinkButton, type LinkButtonProps, MultiSelect, type MultiSelectProps, NumberField, type NumberFieldSize, Page, PageLayout, type PageProps, type Product, ProductCard, type ProductCardProps, ProductListingPage, type ProductListingPageProps, ProductOverviewGrid, type ProductOverviewGridProps, ProductPrice, type ProductPriceProps, ProductSku, type ProductSkuProps, type RefinementListItem, RightArrowFilledIcon, Select, type SelectProps, ShowAll, type ShowAllProps, Sidebar, type SidebarProps, SidebarProvider, TextField, useAlgolia, useBreadcrumb, useBreakpoint, useCart, useDebouncedCallback, useDisclosure, useFavorite, useFormattedMessage, useGlobalState, useProductCartLine, useScrollLock };