@sentecacommerce-theme/lib 0.12.102 → 0.13.3
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/cjs/basket/api/mutations/index.js +14 -0
- package/dist/cjs/basket/api/mutations/useChangeGiftVariant.js +116 -0
- package/dist/cjs/basket/hooks/index.js +12 -0
- package/dist/cjs/basket/hooks/useChangeGiftVariant.js +16 -0
- package/dist/cjs/hooks/useLineItem/LineItemContext.js +86 -0
- package/dist/cjs/hooks/useLineItem/index.js +34 -12
- package/dist/cjs/hooks/useProduct/index.js +17 -276
- package/dist/cjs/hooks/useProduct/utils/index.js +44 -18
- package/dist/cjs/hooks/useProductVariants/index.js +334 -0
- package/dist/cjs/hooks/useProductVariants/types.js +3 -0
- package/dist/cjs/index.js +16 -4
- package/dist/cjs/listing/api/queries/useListingQuery.js +1 -0
- package/dist/cjs/listing/hooks/useListingBreadcrumbs.js +20 -8
- package/dist/cjs/listing/hooks/useListingCategories.js +2 -2
- package/dist/cjs/listing/hooks/useListingMeta.js +12 -10
- package/dist/cjs/listing/utils/buildCategoryQuery.js +22 -1
- package/dist/cjs/seo/components/TranslationsMeta/index.js +1 -0
- package/dist/cjs/utils/localStorage.js +7 -2
- package/dist/esm/basket/api/mutations/index.js +1 -0
- package/dist/esm/basket/api/mutations/useChangeGiftVariant.js +106 -0
- package/dist/esm/basket/hooks/index.js +1 -0
- package/dist/esm/basket/hooks/useChangeGiftVariant.js +3 -0
- package/dist/esm/hooks/useLineItem/LineItemContext.js +75 -0
- package/dist/esm/hooks/useLineItem/index.js +16 -12
- package/dist/esm/hooks/useProduct/index.js +18 -277
- package/dist/esm/hooks/useProduct/utils/index.js +44 -18
- package/dist/esm/hooks/useProductVariants/index.js +293 -0
- package/dist/esm/hooks/useProductVariants/types.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/listing/api/queries/useListingQuery.js +1 -0
- package/dist/esm/listing/hooks/useListingBreadcrumbs.js +15 -3
- package/dist/esm/listing/hooks/useListingCategories.js +2 -2
- package/dist/esm/listing/hooks/useListingMeta.js +12 -12
- package/dist/esm/listing/utils/buildCategoryQuery.js +22 -1
- package/dist/esm/seo/components/TranslationsMeta/index.js +1 -0
- package/dist/esm/utils/localStorage.js +7 -2
- package/dist/types/basket/api/mutations/index.d.ts +1 -0
- package/dist/types/basket/api/mutations/useChangeGiftVariant.d.ts +2 -0
- package/dist/types/basket/hooks/index.d.ts +1 -0
- package/dist/types/basket/hooks/useChangeGiftVariant.d.ts +2 -0
- package/dist/types/hooks/basket-hooks/useBasketLineItem/index.d.ts +1 -2
- package/dist/types/hooks/useLineItem/LineItemContext.d.ts +22 -0
- package/dist/types/hooks/useLineItem/index.d.ts +2 -2
- package/dist/types/hooks/useProduct/index.d.ts +2 -76
- package/dist/types/hooks/useProduct/utils/index.d.ts +6 -4
- package/dist/types/hooks/useProductVariants/index.d.ts +34 -0
- package/dist/types/hooks/useProductVariants/types.d.ts +79 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/listing/hooks/useListingMeta.d.ts +4 -0
- package/dist/types/listing/types.d.ts +1 -0
- package/package.json +5 -5
@@ -2,7 +2,7 @@ import { LineItemDTO, LineItemDTOLineItemModeEnum, LineItemDTOStatusEnum, MoneyD
|
|
2
2
|
import { BaseProductType } from '../../useLineItem';
|
3
3
|
import { SelectedOptionType } from '../../useProduct/utils';
|
4
4
|
import { AssetsMap } from '../../../utils/assetsToMap';
|
5
|
-
interface BasketLineItemProps extends BaseProductType {
|
5
|
+
export interface BasketLineItemProps extends BaseProductType {
|
6
6
|
productId: string;
|
7
7
|
lineItemId: string;
|
8
8
|
quantityInBasket: number;
|
@@ -36,4 +36,3 @@ export declare const useBasketLineItem: (props: {
|
|
36
36
|
item: LineItemDTO;
|
37
37
|
expiry?: number;
|
38
38
|
}) => BasketLineItemProps;
|
39
|
-
export {};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { VariantMap, VariantType } from '../useProductVariants';
|
2
|
+
import { SearchResultDTO } from '@sentecacommerce/sdk';
|
3
|
+
import { LineItemType } from '../../';
|
4
|
+
declare type LineItemStateContextType = {
|
5
|
+
variants?: VariantMap;
|
6
|
+
selectedVariant: (LineItemType & VariantType) | null;
|
7
|
+
};
|
8
|
+
declare type CountFunctionsContextType = {
|
9
|
+
selectVariantById: (id: string) => void;
|
10
|
+
selectVariantByAttribute: (key: string) => void;
|
11
|
+
selectVariantByCombination: (key: string, value: string) => void;
|
12
|
+
getVariantById: (id: string) => VariantType;
|
13
|
+
getVariantByAttribute: (key: string) => VariantType;
|
14
|
+
getVariantByCombination: (key: string, value: string) => VariantType;
|
15
|
+
};
|
16
|
+
export declare function LineItemStateProvider({ product, children, }: {
|
17
|
+
product: SearchResultDTO;
|
18
|
+
children: any;
|
19
|
+
}): JSX.Element;
|
20
|
+
export declare function useLineItemState(): LineItemStateContextType;
|
21
|
+
export declare function useLineItemFunctions(): CountFunctionsContextType;
|
22
|
+
export {};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { SearchResultDTO, ImageDTO, MoneyDTO, ReviewRatingStatisticsDTO, OfferDTO } from '@sentecacommerce/sdk';
|
2
|
+
export { useLineItemFunctions, useLineItemState, LineItemStateProvider, } from './LineItemContext';
|
2
3
|
export interface BaseProductType {
|
3
4
|
name: string;
|
4
5
|
slug: string;
|
@@ -26,7 +27,7 @@ export interface AttributesType {
|
|
26
27
|
count: number;
|
27
28
|
elements: AttributeType[];
|
28
29
|
}
|
29
|
-
interface LineItemType extends BaseProductType {
|
30
|
+
export interface LineItemType extends BaseProductType {
|
30
31
|
name: string;
|
31
32
|
brand?: {
|
32
33
|
name: string;
|
@@ -47,4 +48,3 @@ interface LineItemType extends BaseProductType {
|
|
47
48
|
getCustomFieldByKey: (key: string) => any;
|
48
49
|
}
|
49
50
|
export declare const useLineItem: (props: SearchResultDTO) => LineItemType;
|
50
|
-
export {};
|
@@ -1,23 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import type { ProductDTO,
|
3
|
-
import { SelectedOptionType } from './utils';
|
2
|
+
import type { ProductDTO, ReviewRatingStatisticsDTO } from '@sentecacommerce/sdk';
|
4
3
|
import { getProductBySlugConfig } from '../../api/productsApi';
|
5
4
|
import { AssetsMap } from '../../utils/assetsToMap';
|
6
|
-
|
7
|
-
definitionKey: string;
|
8
|
-
label: string;
|
9
|
-
elements?: SubOptionType[];
|
10
|
-
}
|
11
|
-
export interface SubOptionType {
|
12
|
-
optionKey: string;
|
13
|
-
label: string;
|
14
|
-
imageIndex?: number;
|
15
|
-
}
|
16
|
-
export interface ContentType {
|
17
|
-
key: string;
|
18
|
-
name?: string;
|
19
|
-
content?: string;
|
20
|
-
}
|
5
|
+
import { VariantMap, VariantType, ContentType, AttributeRulesMap } from '../useProductVariants';
|
21
6
|
export interface MetaInfoCategoryType {
|
22
7
|
name: string;
|
23
8
|
id: string;
|
@@ -55,65 +40,6 @@ interface SeoInformationType {
|
|
55
40
|
description?: string;
|
56
41
|
keywords?: string;
|
57
42
|
}
|
58
|
-
interface AttributeRulesType extends AttributeRuleDTO {
|
59
|
-
label: string;
|
60
|
-
values: {
|
61
|
-
[id: string]: {
|
62
|
-
label: string;
|
63
|
-
extra: any;
|
64
|
-
combinations: {
|
65
|
-
[id: string]: string;
|
66
|
-
};
|
67
|
-
};
|
68
|
-
};
|
69
|
-
}
|
70
|
-
export interface VariantType extends Omit<ProductVariantDTO, 'attributes' | 'availableOptions' | 'selectedOptions' | 'labels'> {
|
71
|
-
attributes: ProductAttributeDraftDTO[];
|
72
|
-
options?: OptionsType[];
|
73
|
-
selectedOptions: SelectedOptionDTO[];
|
74
|
-
mappedSelectedOptions?: SelectedOptionType[];
|
75
|
-
isAvailable: boolean;
|
76
|
-
quantity?: number;
|
77
|
-
inventory: {
|
78
|
-
hasAvailableQuantity?: boolean;
|
79
|
-
availableQuantity?: number;
|
80
|
-
};
|
81
|
-
labels?: string[];
|
82
|
-
getAttribute: (rule: string) => {
|
83
|
-
id: string;
|
84
|
-
label: string;
|
85
|
-
name: string;
|
86
|
-
extra: any;
|
87
|
-
combinations: {
|
88
|
-
[id: string]: string;
|
89
|
-
};
|
90
|
-
};
|
91
|
-
getAttributeByKey: (key: string) => undefined | any;
|
92
|
-
getAvailabilityByStore: () => InventoryAvailabilityType[] | undefined;
|
93
|
-
}
|
94
|
-
interface VariantMap {
|
95
|
-
[productId: string]: VariantType;
|
96
|
-
}
|
97
|
-
export interface BooleanKVP {
|
98
|
-
[sku: string]: boolean | undefined;
|
99
|
-
}
|
100
|
-
export interface AttributeRulesMap {
|
101
|
-
[name: string]: AttributeRulesType;
|
102
|
-
}
|
103
|
-
export interface CombinationsMap {
|
104
|
-
[id: string]: {
|
105
|
-
value: string;
|
106
|
-
params: {
|
107
|
-
[id: string]: string;
|
108
|
-
};
|
109
|
-
};
|
110
|
-
}
|
111
|
-
export interface InventoryAvailabilityType {
|
112
|
-
storeName: string;
|
113
|
-
availableQuantity: number;
|
114
|
-
acceptsBackorders: boolean;
|
115
|
-
restockableInDays: number;
|
116
|
-
}
|
117
43
|
declare type ProductProviderProps = {
|
118
44
|
children: React.ReactNode;
|
119
45
|
product?: ProductDTO;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { ProductAttributeDTO, CustomField, ProductDTO, ProductVariantDTO, InventoryAvailability, OptionDefinitionDTO, SelectedOptionDTO, IdReferenceDTO, ProductVariantLabelDTO } from '@sentecacommerce/sdk';
|
2
|
-
import {
|
1
|
+
import { ProductAttributeDTO, CustomField, ProductDTO, ProductVariantDTO, InventoryAvailability, OptionDefinitionDTO, SelectedOptionDTO, IdReferenceDTO, ProductVariantLabelDTO, AttributeRuleDTO } from '@sentecacommerce/sdk';
|
2
|
+
import { InventoryAvailabilityType, OptionsType, AttributeRulesMap, BooleanKVP, CombinationsMap } from '../../useProductVariants';
|
3
|
+
import { MetaInformationType } from '../index';
|
3
4
|
export declare const createCustomFieldsMap: (customFields?: CustomField[] | undefined) => BooleanKVP | undefined;
|
4
5
|
export declare const createCombinationsMap: (mappedAttributeRulesKeys: string[], attributesArray: {
|
5
6
|
variantId: string;
|
@@ -12,7 +13,7 @@ export declare const createProductContent: (data: any) => {
|
|
12
13
|
content: string;
|
13
14
|
};
|
14
15
|
export declare const createCollapseKeyImagesMap: (product?: ProductDTO | undefined) => {} | undefined;
|
15
|
-
export declare const createAttributeRulesMap: (product?: ProductDTO | undefined) => any;
|
16
|
+
export declare const createAttributeRulesMap: (product?: ProductDTO | undefined, isLineItem?: boolean) => any;
|
16
17
|
export declare const createMappedOptions: (options?: OptionDefinitionDTO[] | undefined) => OptionsType[];
|
17
18
|
export declare type SelectedOptionType = {
|
18
19
|
label?: string;
|
@@ -24,7 +25,7 @@ export declare type SelectedOptionType = {
|
|
24
25
|
};
|
25
26
|
export declare const createSelectedOption2: (options?: OptionsType[] | undefined, selectedOption?: SelectedOptionDTO | undefined) => SelectedOptionType;
|
26
27
|
export declare const createSelectedOption: (options?: OptionDefinitionDTO[] | undefined, selectedOption?: SelectedOptionDTO | undefined) => SelectedOptionType;
|
27
|
-
export declare const createMappedAttributes: (currentVariant: ProductVariantDTO) =>
|
28
|
+
export declare const createMappedAttributes: (currentVariant: ProductVariantDTO, isLineItem?: boolean) => any;
|
28
29
|
export declare const processAvailabilityPerStore: (availabilities?: InventoryAvailability[] | undefined) => InventoryAvailabilityType[] | undefined;
|
29
30
|
export declare const getProductVideos: (assets: MetaInformationType['assets']) => {
|
30
31
|
type: string;
|
@@ -40,3 +41,4 @@ export declare const formatCategories: (categories?: IdReferenceDTO[] | undefine
|
|
40
41
|
link: string;
|
41
42
|
}[];
|
42
43
|
export declare const createLabelsMap: (data?: ProductVariantLabelDTO[] | undefined) => string[] | undefined;
|
44
|
+
export declare function remapLineItemAttributes(attributes: ProductAttributeDTO[]): ProductAttributeDTO[] | AttributeRuleDTO[];
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { VariantType, BooleanKVP, VariantMap, AttributeRulesMap, CombinationsMap } from './types';
|
3
|
+
export * from './types';
|
4
|
+
export declare const useProductVariants: ({ product, defaultVariantId, isLineItem, }: {
|
5
|
+
product: any;
|
6
|
+
defaultVariantId: any;
|
7
|
+
isLineItem?: boolean | undefined;
|
8
|
+
}) => {
|
9
|
+
combinations: CombinationsMap;
|
10
|
+
attributeRules: AttributeRulesMap;
|
11
|
+
variants: VariantMap;
|
12
|
+
selectedVariant: VariantType | null;
|
13
|
+
setSelectedVariant: React.Dispatch<React.SetStateAction<VariantType | null>>;
|
14
|
+
customFields: BooleanKVP;
|
15
|
+
getVariantByAttribute: (key: string) => VariantType;
|
16
|
+
getVariantById: (id: string) => VariantType;
|
17
|
+
getCombinationsAndAttributeRules: () => {
|
18
|
+
combinations: CombinationsMap;
|
19
|
+
attributeRules: AttributeRulesMap;
|
20
|
+
};
|
21
|
+
getCombinationsForAttributeRule: (key: string, id: string) => {
|
22
|
+
label: string;
|
23
|
+
extra: any;
|
24
|
+
combinations: {
|
25
|
+
[id: string]: string;
|
26
|
+
};
|
27
|
+
};
|
28
|
+
getVariantByCombination: (key: string, value: string) => VariantType;
|
29
|
+
getCustomFieldValue: (field: string) => boolean | undefined;
|
30
|
+
selectVariantByAttribute: (key: string) => void;
|
31
|
+
selectVariantByCombination: (key: string, value: string) => void;
|
32
|
+
selectVariantOptions: (definitionKey: string, optionKey: string) => void;
|
33
|
+
selectVariantById: (id: string) => void;
|
34
|
+
};
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import type { ProductVariantDTO, ProductAttributeDraftDTO, SelectedOptionDTO, AttributeRuleDTO, LangValue } from '@sentecacommerce/sdk';
|
2
|
+
import { SelectedOptionType } from '../useProduct/utils';
|
3
|
+
export interface VariantType extends Omit<ProductVariantDTO, 'attributes' | 'availableOptions' | 'selectedOptions' | 'labels'> {
|
4
|
+
name?: LangValue[];
|
5
|
+
slug?: LangValue[];
|
6
|
+
attributes: ProductAttributeDraftDTO[];
|
7
|
+
options?: OptionsType[];
|
8
|
+
selectedOptions: SelectedOptionDTO[];
|
9
|
+
mappedSelectedOptions?: SelectedOptionType[];
|
10
|
+
isAvailable: boolean;
|
11
|
+
quantity?: number;
|
12
|
+
inventory: {
|
13
|
+
hasAvailableQuantity?: boolean;
|
14
|
+
availableQuantity?: number;
|
15
|
+
};
|
16
|
+
labels?: string[];
|
17
|
+
getAttribute: (rule: string) => {
|
18
|
+
id: string;
|
19
|
+
label: string;
|
20
|
+
name: string;
|
21
|
+
extra: any;
|
22
|
+
combinations: {
|
23
|
+
[id: string]: string;
|
24
|
+
};
|
25
|
+
};
|
26
|
+
getAttributeByKey: (key: string) => undefined | any;
|
27
|
+
getAvailabilityByStore: () => InventoryAvailabilityType[] | undefined;
|
28
|
+
variantAttributes?: any[];
|
29
|
+
}
|
30
|
+
export interface OptionsType {
|
31
|
+
definitionKey: string;
|
32
|
+
label: string;
|
33
|
+
elements?: SubOptionType[];
|
34
|
+
}
|
35
|
+
export interface SubOptionType {
|
36
|
+
optionKey: string;
|
37
|
+
label: string;
|
38
|
+
imageIndex?: number;
|
39
|
+
}
|
40
|
+
export interface ContentType {
|
41
|
+
key: string;
|
42
|
+
name?: string;
|
43
|
+
content?: string;
|
44
|
+
}
|
45
|
+
export interface AttributeRulesType extends AttributeRuleDTO {
|
46
|
+
label: string;
|
47
|
+
values: {
|
48
|
+
[id: string]: {
|
49
|
+
label: string;
|
50
|
+
extra: any;
|
51
|
+
combinations: {
|
52
|
+
[id: string]: string;
|
53
|
+
};
|
54
|
+
};
|
55
|
+
};
|
56
|
+
}
|
57
|
+
export interface VariantMap {
|
58
|
+
[productId: string]: VariantType;
|
59
|
+
}
|
60
|
+
export interface BooleanKVP {
|
61
|
+
[sku: string]: boolean | undefined;
|
62
|
+
}
|
63
|
+
export interface AttributeRulesMap {
|
64
|
+
[name: string]: AttributeRulesType;
|
65
|
+
}
|
66
|
+
export interface CombinationsMap {
|
67
|
+
[id: string]: {
|
68
|
+
value: string;
|
69
|
+
params: {
|
70
|
+
[id: string]: string;
|
71
|
+
};
|
72
|
+
};
|
73
|
+
}
|
74
|
+
export interface InventoryAvailabilityType {
|
75
|
+
storeName: string;
|
76
|
+
availableQuantity: number;
|
77
|
+
acceptsBackorders: boolean;
|
78
|
+
restockableInDays: number;
|
79
|
+
}
|
package/dist/types/index.d.ts
CHANGED
@@ -85,6 +85,7 @@ export * from './hooks/useRouterRedirect';
|
|
85
85
|
export * from './hooks/useProgressBar';
|
86
86
|
export * from './hooks/useCatalogDiscounts';
|
87
87
|
export * from './hooks/useLocalRating';
|
88
|
+
export * from './hooks/useProductVariants/types';
|
88
89
|
export * from './utils';
|
89
90
|
export * from './types';
|
90
91
|
export * from './seo';
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import { AssetType } from '../../utils/assetsToMap';
|
2
|
+
import { NextRouter } from 'next/router';
|
3
|
+
import { Node } from './useListingCategories';
|
2
4
|
export declare type UseListingMetaResult = {
|
3
5
|
displayName: string;
|
4
6
|
description: string;
|
@@ -10,3 +12,5 @@ export declare type UseListingMetaResult = {
|
|
10
12
|
getCustomFieldByKey: (key: string) => any | undefined;
|
11
13
|
};
|
12
14
|
export declare const useListingMeta: () => UseListingMetaResult;
|
15
|
+
export declare function getFilterByType(filterType: string, router?: NextRouter): string;
|
16
|
+
export declare function getCategoryName(router?: NextRouter, categories?: Node[] | null): string | undefined;
|
@@ -71,6 +71,7 @@ export interface DefaultListingPageProps {
|
|
71
71
|
categoryTreeConfig?: Aggregate;
|
72
72
|
sortOptions?: ListField<ListingPageSortOption>;
|
73
73
|
attributeSortType?: AggregateSortEnum;
|
74
|
+
includeVariants?: boolean;
|
74
75
|
meta: ListingPageMeta;
|
75
76
|
}
|
76
77
|
export interface ListingPageMeta {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentecacommerce-theme/lib",
|
3
3
|
"sideEffects": false,
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.13.3",
|
5
5
|
"main": "dist/cjs/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
7
7
|
"types": "dist/types/index.d.ts",
|
@@ -31,14 +31,14 @@
|
|
31
31
|
"watch:cjs": "swc src --out-dir dist/cjs -w",
|
32
32
|
"watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
|
33
33
|
},
|
34
|
-
"gitHead": "
|
34
|
+
"gitHead": "3f7ef1f62b26764823980283fd8c545c0e9aae0e",
|
35
35
|
"peerDependencies": {
|
36
36
|
"react-query": "^2.26.2"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@sentecacommerce-theme/base": "^0.
|
40
|
-
"@sentecacommerce-theme/cms": "^0.
|
41
|
-
"@sentecacommerce/sdk": "2.0.
|
39
|
+
"@sentecacommerce-theme/base": "^0.13.3",
|
40
|
+
"@sentecacommerce-theme/cms": "^0.13.3",
|
41
|
+
"@sentecacommerce/sdk": "2.0.175",
|
42
42
|
"body-scroll-lock": "^3.1.5",
|
43
43
|
"copy-to-clipboard": "^3.3.1",
|
44
44
|
"embla-carousel": "^4.5.1",
|