@sonic-equipment/ui 0.0.19 → 0.0.21

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 (60) hide show
  1. package/dist/algolia/algolia-active-filters.d.ts +7 -0
  2. package/dist/algolia/algolia-categories.d.ts +1 -0
  3. package/dist/algolia/algolia-filter-panel.d.ts +4 -0
  4. package/dist/algolia/algolia-multi-select.d.ts +5 -0
  5. package/dist/algolia/algolia-pagination.d.ts +1 -0
  6. package/dist/algolia/algolia-product-list.d.ts +1 -0
  7. package/dist/algolia/algolia-provider.d.ts +13 -0
  8. package/dist/algolia/algolia-results-count.d.ts +1 -0
  9. package/dist/algolia/algolia-searchclient-mock.d.ts +4 -0
  10. package/dist/algolia/algolia-sort-by.d.ts +1 -0
  11. package/dist/algolia/algolia.stories.d.ts +17 -0
  12. package/dist/buttons/add-to-cart-button/add-to-cart-button.stories.d.ts +1 -0
  13. package/dist/buttons/add-to-cart-button/connected-add-to-cart-button.d.ts +5 -0
  14. package/dist/buttons/button/button.d.ts +5 -4
  15. package/dist/buttons/button/button.stories.d.ts +1 -0
  16. package/dist/buttons/icon-button/icon-button.d.ts +2 -1
  17. package/dist/buttons/link-button/link-button.d.ts +10 -0
  18. package/dist/buttons/link-button/link-button.stories.d.ts +19 -0
  19. package/dist/cards/product-card/connected-product-cart.d.ts +6 -0
  20. package/dist/cards/product-card/product-card.stories.d.ts +1 -0
  21. package/dist/collapsables/accordion/accordion-item.d.ts +2 -1
  22. package/dist/collapsables/accordion/accordion.d.ts +2 -1
  23. package/dist/collapsables/accordion/accordion.stories.d.ts +1 -1
  24. package/dist/collapsables/show-all/show-all.d.ts +9 -0
  25. package/dist/collapsables/show-all/show-all.stories.d.ts +17 -0
  26. package/dist/filters/active-filters/active-filters.d.ts +14 -0
  27. package/dist/filters/active-filters/active-filters.stories.d.ts +15 -0
  28. package/dist/filters/multi-select/multi-select.d.ts +19 -0
  29. package/dist/filters/multi-select/multi-select.stories.d.ts +20 -0
  30. package/dist/filters/pagination/pagination.d.ts +6 -0
  31. package/dist/filters/pagination/pagination.stories.d.ts +18 -0
  32. package/dist/forms/color-checkbox/color-checkbox.stories.d.ts +1 -0
  33. package/dist/forms/select/select.d.ts +5 -5
  34. package/dist/forms/select/select.stories.d.ts +10 -3
  35. package/dist/icons/chevrons/chevron-left-filled-icon.d.ts +2 -0
  36. package/dist/icons/chevrons/chevron-right-filled-icon.d.ts +2 -0
  37. package/dist/icons/close/close-filled-icon.d.ts +2 -0
  38. package/dist/icons/filter/filter-outlined-icon.d.ts +2 -0
  39. package/dist/index.d.ts +71 -32
  40. package/dist/index.js +402 -64
  41. package/dist/intl/translation-id.d.ts +1 -5
  42. package/dist/product-listing/product-listing.d.ts +12 -16
  43. package/dist/product-listing/product-listing.stories.d.ts +7 -2
  44. package/dist/shared/hooks/use-breakpoint.d.ts +5 -0
  45. package/dist/shared/hooks/use-debounce-callback.d.ts +1 -0
  46. package/dist/shared/hooks/use-disclosure.d.ts +9 -0
  47. package/dist/shared/hooks/use-scroll-lock.d.ts +1 -0
  48. package/dist/shared/providers/cart-provider.d.ts +33 -0
  49. package/dist/shared/providers/global-state-provider.d.ts +23 -0
  50. package/dist/shared/types/cart.d.ts +8 -0
  51. package/dist/shared/utils/event-emitter.d.ts +9 -0
  52. package/dist/sidebar/sidebar-context.d.ts +6 -0
  53. package/dist/sidebar/sidebar-provider.d.ts +6 -0
  54. package/dist/sidebar/sidebar.d.ts +5 -0
  55. package/dist/sidebar/sidebar.stories.d.ts +8 -0
  56. package/dist/sidebar/toggle-sidebar-button.d.ts +1 -0
  57. package/dist/sidebar/use-sidebar.d.ts +2 -0
  58. package/dist/styles.css +435 -12
  59. package/dist/typography/heading/heading.d.ts +1 -1
  60. package/package.json +37 -32
@@ -1,5 +1 @@
1
- export interface Translations {
2
- 'Excl. VAT': string;
3
- 'Incl. VAT': string;
4
- }
5
- export type TranslationId = keyof Translations;
1
+ export type TranslationId = 'Chosen filters' | 'Clear filters' | 'Excl. VAT' | 'Incl. VAT' | 'Show' | 'Show all' | 'Show filters' | 'Show less' | 'Sort' | 'articles' | 'article' | 'of';
@@ -1,4 +1,3 @@
1
- import { ComponentType } from 'react';
2
1
  export interface Filters {
3
2
  color: {
4
3
  options: {
@@ -8,28 +7,25 @@ export interface Filters {
8
7
  }[];
9
8
  };
10
9
  }
10
+ declare const sortOptions: {
11
+ readonly new: "New";
12
+ readonly popular: "Popular";
13
+ readonly price_asc: "Price: Low - High";
14
+ readonly price_desc: "Price: High - Low";
15
+ readonly recommended: "Recommended";
16
+ };
17
+ type SortKey = keyof typeof sortOptions;
11
18
  export type ActiveFilters = {
12
19
  colors: string[];
13
20
  };
14
- export type Sort = {
15
- by: string;
16
- direction: string;
17
- };
18
21
  export type ProductListingProps = {
19
22
  activeFilters: ActiveFilters;
20
23
  filters: Filters;
21
24
  isLoading?: boolean;
22
25
  onFilterChange: (filters: ActiveFilters) => void;
23
- onSortChange: (sort: Sort) => void;
24
- productCard: ComponentType<any>;
25
- products: {
26
- id: string;
27
- title: string;
28
- }[];
29
- sort: {
30
- by: string;
31
- direction: string;
32
- };
26
+ onSortChange: (sort: SortKey) => void;
27
+ sort: SortKey;
33
28
  total: number;
34
29
  };
35
- export declare function ProductListing({ activeFilters, filters, isLoading, onFilterChange, onSortChange, productCard: ProductCard, products, }: ProductListingProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function ProductListing({ isLoading }: ProductListingProps): import("react/jsx-runtime").JSX.Element;
31
+ export {};
@@ -1,16 +1,21 @@
1
+ import { ComponentProps } from 'react';
1
2
  import { StoryObj } from '@storybook/react';
2
3
  import { ProductListing } from './product-listing';
3
4
  declare const meta: {
4
5
  args: {
5
6
  onFilterChange: import("@vitest/spy").Mock<[filters: import("./product-listing").ActiveFilters], void>;
6
- onSortChange: import("@vitest/spy").Mock<[sort: import("./product-listing").Sort], void>;
7
+ onSortChange: import("@vitest/spy").Mock<[sort: "new" | "popular" | "price_asc" | "price_desc" | "recommended"], void>;
8
+ online: false;
7
9
  };
8
10
  component: typeof ProductListing;
9
11
  tags: string[];
10
12
  title: string;
11
13
  };
12
14
  export default meta;
13
- type Story = StoryObj<typeof ProductListing>;
15
+ type StoryProps = ComponentProps<typeof ProductListing> & {
16
+ online: boolean;
17
+ };
18
+ type Story = StoryObj<StoryProps>;
14
19
  export declare const Default: Story;
15
20
  export declare const Loading: Story;
16
21
  export declare const WithActiveFilters: Story;
@@ -0,0 +1,5 @@
1
+ export declare const useBreakpoint: () => {
2
+ isDesktop: boolean;
3
+ isMobile: boolean;
4
+ isTablet: boolean;
5
+ };
@@ -0,0 +1 @@
1
+ export declare function useDebouncedCallback<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
@@ -0,0 +1,9 @@
1
+ interface UseDisclosureReturnType {
2
+ close: () => void;
3
+ isClosed: boolean;
4
+ isOpen: boolean;
5
+ open: () => void;
6
+ toggle: () => void;
7
+ }
8
+ export declare const useDisclosure: () => UseDisclosureReturnType;
9
+ export {};
@@ -0,0 +1 @@
1
+ export declare const useScrollLock: (lock: boolean) => void;
@@ -0,0 +1,33 @@
1
+ import { Cart, CartLine } from 'shared/types/cart';
2
+ interface Props {
3
+ addToCart: (args: {
4
+ productId: string;
5
+ quantity: number;
6
+ }) => void;
7
+ currentCart: Cart;
8
+ isLoaded: boolean;
9
+ isLoading: boolean;
10
+ loadCurrentCart: VoidFunction;
11
+ removeCartLine: (args: {
12
+ cartLineId: string;
13
+ }) => void;
14
+ updateCartLine: (cartLine: CartLine) => void;
15
+ }
16
+ export declare function CartProvider(props: Props): null;
17
+ export declare function useCart(): Props;
18
+ export declare function useProductCartLine(productId: string): {
19
+ addToCart: (args: {
20
+ productId: string;
21
+ quantity: number;
22
+ }) => void;
23
+ cartLine: CartLine | undefined;
24
+ currentCart: Cart;
25
+ isLoaded: boolean;
26
+ isLoading: boolean;
27
+ loadCurrentCart: VoidFunction;
28
+ removeCartLine: (args: {
29
+ cartLineId: string;
30
+ }) => void;
31
+ updateCartLine: (cartLine: CartLine) => void;
32
+ };
33
+ export {};
@@ -0,0 +1,23 @@
1
+ import { MutableRefObject, ReactElement, ReactNode } from 'react';
2
+ import { EventEmitter } from 'shared/utils/event-emitter';
3
+ declare class State<T> extends EventEmitter<T | undefined> {
4
+ private _state;
5
+ constructor(state?: T);
6
+ get value(): T | undefined;
7
+ set value(newState: T | undefined);
8
+ }
9
+ declare class GlobalState {
10
+ private states;
11
+ constructor(states: MutableRefObject<Record<string | symbol, State<any>>>);
12
+ get<T>(key: string | symbol): State<T>;
13
+ get<T>(key: string | symbol, initialState: T | undefined): State<T>;
14
+ set<T>(key: string | symbol, state: State<T>): void;
15
+ }
16
+ export declare const GlobalStateProviderContext: React.Context<GlobalState>;
17
+ interface GlobalStateProviderProps {
18
+ children: ReactNode;
19
+ }
20
+ export declare function GlobalStateProvider({ children, }: GlobalStateProviderProps): ReactElement | null;
21
+ export declare function useGlobalState<T>(key: string | symbol): [T | undefined, (value: T) => void];
22
+ export declare function useGlobalState<T>(key: string | symbol, initialState: T): [T, (value: T) => void];
23
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface CartLine {
2
+ id: string;
3
+ productId: string;
4
+ qtyOrdered: number;
5
+ }
6
+ export interface Cart {
7
+ cartLines: CartLine[];
8
+ }
@@ -0,0 +1,9 @@
1
+ type EventCallback<T> = (data: T) => void;
2
+ export declare class EventEmitter<T> {
3
+ private listeners;
4
+ constructor();
5
+ addEventListener(event: string, listener: EventCallback<T>): void;
6
+ removeEventListener(event: string, listener: EventCallback<T>): void;
7
+ trigger(event: string, data: T): void;
8
+ }
9
+ export {};
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export interface SidebarContextType {
3
+ isOpen: boolean;
4
+ toggle: () => void;
5
+ }
6
+ export declare const SidebarContext: React.Context<SidebarContextType>;
@@ -0,0 +1,6 @@
1
+ import { ReactElement } from 'react';
2
+ interface SidebarProviderProps {
3
+ children: ReactElement;
4
+ }
5
+ export declare function SidebarProvider({ children }: SidebarProviderProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export interface SidebarProps {
3
+ children: React.ReactNode;
4
+ }
5
+ export declare function Sidebar({ children }: SidebarProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { SidebarProvider } from './sidebar-provider';
3
+ declare const meta: Meta<typeof SidebarProvider>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const SmallViewport: Story;
7
+ export declare const MediumViewport: Story;
8
+ export declare const LargeViewport: Story;
@@ -0,0 +1 @@
1
+ export declare const ToggleSidebarButton: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { SidebarContextType } from './sidebar-context';
2
+ export declare const useSidebar: () => SidebarContextType;