@dropins/storefront-quick-order 0.1.2-alpha2 → 1.0.0-beta.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/api.js +1 -1
- package/chunks/QuickOrderDisabledOverlay.js +1 -1
- package/chunks/QuickOrderDisabledOverlay.js.map +1 -1
- package/chunks/debounce.js +4 -0
- package/chunks/debounce.js.map +1 -0
- package/chunks/getStoreConfig.js +10 -0
- package/chunks/getStoreConfig.js.map +1 -0
- package/components/QuickOrderVariantsActions/QuickOrderVariantsActions.d.ts +5 -0
- package/components/QuickOrderVariantsActions/index.d.ts +19 -0
- package/components/QuickOrderVariantsGrid/QuickOrderVariantsGrid.d.ts +5 -0
- package/components/QuickOrderVariantsGrid/index.d.ts +19 -0
- package/components/index.d.ts +2 -0
- package/containers/QuickOrderCsvUpload.js +2 -2
- package/containers/QuickOrderCsvUpload.js.map +1 -1
- package/containers/QuickOrderItems.js +1 -1
- package/containers/QuickOrderItems.js.map +1 -1
- package/containers/QuickOrderMultipleSku.js +1 -1
- package/containers/QuickOrderMultipleSku.js.map +1 -1
- package/containers/QuickOrderVariantsGrid/QuickOrderVariantsGrid.d.ts +5 -0
- package/containers/QuickOrderVariantsGrid/index.d.ts +19 -0
- package/containers/QuickOrderVariantsGrid.d.ts +3 -0
- package/containers/QuickOrderVariantsGrid.js +6 -0
- package/containers/QuickOrderVariantsGrid.js.map +1 -0
- package/containers/index.d.ts +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/useQuickOrderVariantsData.d.ts +4 -0
- package/i18n/en_US.json.d.ts +90 -70
- package/package.json +1 -1
- package/render.js +3 -2
- package/render.js.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/quickOrderVariantsGrid.types.d.ts +141 -0
- package/chunks/initialize.js +0 -10
- package/chunks/initialize.js.map +0 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { SlotProps } from '@dropins/tools/types/elsie/src/lib/slot';
|
|
2
|
+
import { VNode } from 'preact';
|
|
3
|
+
|
|
4
|
+
export interface ProductVariantAttribute {
|
|
5
|
+
name: string;
|
|
6
|
+
label: string;
|
|
7
|
+
value: string | number;
|
|
8
|
+
roles: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface ProductVariantImage {
|
|
11
|
+
url: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ProductVariantPrice {
|
|
14
|
+
final: {
|
|
15
|
+
amount: {
|
|
16
|
+
currency: string;
|
|
17
|
+
value: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface ProductVariant {
|
|
22
|
+
product: {
|
|
23
|
+
sku: string;
|
|
24
|
+
name: string;
|
|
25
|
+
inStock: boolean;
|
|
26
|
+
images: ProductVariantImage[];
|
|
27
|
+
attributes: ProductVariantAttribute[];
|
|
28
|
+
price: ProductVariantPrice;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface VariantRow {
|
|
32
|
+
id: string;
|
|
33
|
+
image: VNode | string;
|
|
34
|
+
sku: VNode | string;
|
|
35
|
+
availability: VNode | string;
|
|
36
|
+
price: VNode | string;
|
|
37
|
+
quantity: VNode | number;
|
|
38
|
+
subtotal: VNode | string;
|
|
39
|
+
[key: string]: VNode | string | number | undefined;
|
|
40
|
+
}
|
|
41
|
+
export interface VariantWithQuantity extends ProductVariant {
|
|
42
|
+
quantity: number;
|
|
43
|
+
}
|
|
44
|
+
export interface VariantTableData {
|
|
45
|
+
sku: string;
|
|
46
|
+
name: string;
|
|
47
|
+
inStock: boolean;
|
|
48
|
+
attributes: Record<string, {
|
|
49
|
+
label: string;
|
|
50
|
+
value: string | number;
|
|
51
|
+
}>;
|
|
52
|
+
price: number;
|
|
53
|
+
quantity: number;
|
|
54
|
+
subtotal: number;
|
|
55
|
+
image: string;
|
|
56
|
+
}
|
|
57
|
+
export type VariantActionsContext = {
|
|
58
|
+
onClear: () => void;
|
|
59
|
+
onSaveToCsv: () => void;
|
|
60
|
+
onCollectData: () => VariantTableData[];
|
|
61
|
+
isDisabled: boolean;
|
|
62
|
+
variantsCount: number;
|
|
63
|
+
};
|
|
64
|
+
export type VariantCellContext = {
|
|
65
|
+
variant: ProductVariant;
|
|
66
|
+
quantity: number;
|
|
67
|
+
onQuantityChange: (sku: string, quantity: number) => void;
|
|
68
|
+
};
|
|
69
|
+
export interface UseQuickOrderVariantsDataProps {
|
|
70
|
+
initialVariants?: ProductVariant[];
|
|
71
|
+
onVariantsLoaded?: (variants: VariantWithQuantity[]) => void;
|
|
72
|
+
onSelectedVariantsChange?: (data: VariantTableData[]) => void;
|
|
73
|
+
debounceMs?: number;
|
|
74
|
+
initialLoading?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface UseQuickOrderVariantsDataReturn {
|
|
77
|
+
variants: VariantWithQuantity[];
|
|
78
|
+
loading: boolean;
|
|
79
|
+
updateQuantity: (sku: string, quantity: number) => void;
|
|
80
|
+
clearAllQuantities: () => void;
|
|
81
|
+
exportToCsv: () => void;
|
|
82
|
+
collectTableData: () => VariantTableData[];
|
|
83
|
+
variantsWithQuantity: number;
|
|
84
|
+
}
|
|
85
|
+
export interface QuickOrderVariantsActionsProps {
|
|
86
|
+
t: Record<string, string>;
|
|
87
|
+
onClear: () => void;
|
|
88
|
+
onSaveToCsv: () => void;
|
|
89
|
+
onCollectData?: () => VariantTableData[];
|
|
90
|
+
isDisabled?: boolean;
|
|
91
|
+
variantsCount?: number;
|
|
92
|
+
className?: string;
|
|
93
|
+
slots?: {
|
|
94
|
+
Actions?: SlotProps<VariantActionsContext>;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export interface QuickOrderVariantsGridComponentProps {
|
|
98
|
+
t: Record<string, string>;
|
|
99
|
+
variants: VariantWithQuantity[];
|
|
100
|
+
loading?: boolean;
|
|
101
|
+
className?: string;
|
|
102
|
+
onQuantityChange: (sku: string, quantity: number) => void;
|
|
103
|
+
visibleVariantsLimit?: number;
|
|
104
|
+
columns?: Array<{
|
|
105
|
+
key: string;
|
|
106
|
+
label: string;
|
|
107
|
+
sortBy?: 'asc' | 'desc' | true;
|
|
108
|
+
}>;
|
|
109
|
+
slots?: {
|
|
110
|
+
ImageCell?: SlotProps<VariantCellContext>;
|
|
111
|
+
SKUCell?: SlotProps<VariantCellContext>;
|
|
112
|
+
AvailabilityCell?: SlotProps<VariantCellContext>;
|
|
113
|
+
PriceCell?: SlotProps<VariantCellContext>;
|
|
114
|
+
QuantityCell?: SlotProps<VariantCellContext>;
|
|
115
|
+
SubtotalCell?: SlotProps<VariantCellContext>;
|
|
116
|
+
} & Record<string, SlotProps<VariantCellContext> | undefined>;
|
|
117
|
+
}
|
|
118
|
+
export interface QuickOrderVariantsGridProps {
|
|
119
|
+
className?: string;
|
|
120
|
+
initialVariants?: ProductVariant[];
|
|
121
|
+
onVariantsLoaded?: (variants: VariantWithQuantity[]) => void;
|
|
122
|
+
onSelectedVariantsChange?: (data: VariantTableData[]) => void;
|
|
123
|
+
debounceMs?: number;
|
|
124
|
+
initialLoading?: boolean;
|
|
125
|
+
visibleVariantsLimit?: number;
|
|
126
|
+
columns?: Array<{
|
|
127
|
+
key: string;
|
|
128
|
+
label: string;
|
|
129
|
+
sortBy?: 'asc' | 'desc' | true;
|
|
130
|
+
}>;
|
|
131
|
+
slots?: {
|
|
132
|
+
Actions?: SlotProps<VariantActionsContext>;
|
|
133
|
+
ImageCell?: SlotProps<VariantCellContext>;
|
|
134
|
+
SKUCell?: SlotProps<VariantCellContext>;
|
|
135
|
+
AvailabilityCell?: SlotProps<VariantCellContext>;
|
|
136
|
+
PriceCell?: SlotProps<VariantCellContext>;
|
|
137
|
+
QuantityCell?: SlotProps<VariantCellContext>;
|
|
138
|
+
SubtotalCell?: SlotProps<VariantCellContext>;
|
|
139
|
+
} & Record<string, SlotProps<VariantActionsContext | VariantCellContext> | undefined>;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=quickOrderVariantsGrid.types.d.ts.map
|
package/chunks/initialize.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*! Copyright 2026 Adobe
|
|
2
|
-
All Rights Reserved. */
|
|
3
|
-
import{Initializer as c}from"@dropins/tools/lib.js";import{FetchGraphQL as a}from"@dropins/tools/fetch-graphql.js";import{events as n}from"@dropins/tools/event-bus.js";const{setEndpoint:m,setFetchGraphQlHeader:C,removeFetchGraphQlHeader:G,setFetchGraphQlHeaders:k,fetchGraphQl:s,getConfig:O}=new a().getMethods(),f=`
|
|
4
|
-
query GET_STORE_CONFIG {
|
|
5
|
-
storeConfig {
|
|
6
|
-
quickorder_active
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
`,h=r=>{throw r instanceof DOMException&&r.name==="AbortError"||n.emit("b2b-quick-order/error",{source:"auth",type:"network",error:r}),r},g=r=>{const t=r.map(e=>e.message).join(" ");throw Error(t)},d=async()=>await s(f,{method:"GET",cache:"force-cache"}).then(r=>{var t,e,o;return(t=r.errors)!=null&&t.length?g(r.errors):{storeConfig:{quickOrderActive:((o=(e=r==null?void 0:r.data)==null?void 0:e.storeConfig)==null?void 0:o.quickorder_active)??!1}}}).catch(h),i=new c({init:async r=>{const t={quickOrderActive:!1};try{const e=await d();t.quickOrderActive=e.storeConfig.quickOrderActive}catch(e){console.error("Failed to fetch store config:",e)}i.config.setConfig({...t,...r})},listeners:()=>[]}),p=i.config;export{d as a,C as b,p as c,k as d,s as f,O as g,i,G as r,m as s};
|
|
10
|
-
//# sourceMappingURL=initialize.js.map
|
package/chunks/initialize.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sources":["/@dropins/storefront-quick-order/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-quick-order/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-quick-order/src/lib/network-error.ts","/@dropins/storefront-quick-order/src/lib/fetch-error.ts","/@dropins/storefront-quick-order/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-quick-order/src/api/initialize/initialize.ts"],"sourcesContent":["import { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_STORE_CONFIG = /* GraphQL */ `\n query GET_STORE_CONFIG {\n storeConfig {\n quickorder_active\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { events } from '@adobe-commerce/event-bus';\n\n/**\n * A function which can be attached to fetchGraphQL to handle thrown errors in\n * a generic way.\n */\nexport const handleNetworkError = (error: Error) => {\n const isAbortError =\n error instanceof DOMException && error.name === 'AbortError';\n\n if (!isAbortError) {\n events.emit('b2b-quick-order/error', {\n source: 'auth',\n type: 'network',\n error,\n });\n }\n throw error;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n/** Actions */\nexport const handleFetchError = (errors: Array<{ message: string }>) => {\n const errorMessage = errors.map((e: any) => e.message).join(' ');\n\n throw Error(errorMessage);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_STORE_CONFIG } from './graphql/getStoreConfig.graphql';\nimport { handleNetworkError } from '@/b2b-quick-order/lib/network-error';\nimport { handleFetchError } from '@/b2b-quick-order/lib/fetch-error';\n\nexport const getStoreConfig = async (): Promise<{\n storeConfig: {\n quickOrderActive: boolean;\n };\n}> => {\n return await fetchGraphQl(GET_STORE_CONFIG, {\n method: 'GET',\n cache: 'force-cache',\n })\n .then((response) => {\n if (response.errors?.length) return handleFetchError(response.errors);\n\n return {\n storeConfig: {\n quickOrderActive:\n response?.data?.storeConfig?.quickorder_active ?? false,\n },\n };\n })\n .catch(handleNetworkError);\n};\n","import { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { getStoreConfig } from '../getStoreConfig/getStoreConfig';\n// import { events } from '@adobe-commerce/event-bus';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n quickOrderActive?: boolean;\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (config) => {\n const defaultConfig: Partial<ConfigProps> = {\n quickOrderActive: false,\n };\n\n try {\n const storeConfigResponse = await getStoreConfig();\n defaultConfig.quickOrderActive =\n storeConfigResponse.storeConfig.quickOrderActive;\n } catch (error) {\n console.error('Failed to fetch store config:', error);\n }\n\n initialize.config.setConfig({ ...defaultConfig, ...config });\n },\n\n listeners: () => [\n // events.on('authenticated', (authenticated) => {\n // console.log('authenticated', authenticated);\n // }),\n ],\n});\n\nexport const config = initialize.config;\n"],"names":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","GET_STORE_CONFIG","handleNetworkError","error","events","handleFetchError","errors","errorMessage","getStoreConfig","response","_a","_c","_b","initialize","Initializer","config","defaultConfig","storeConfigResponse"],"mappings":"wKAEO,KAAM,CACX,YAAAA,EACA,sBAAAC,EACA,yBAAAC,EACA,uBAAAC,EACA,aAAAC,EACA,UAAAC,CACF,EAAI,IAAIC,EAAA,EAAe,WAAA,ECQVC,EAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECMjCC,EAAsBC,GAAiB,CAIlD,MAFEA,aAAiB,cAAgBA,EAAM,OAAS,cAGhDC,EAAO,KAAK,wBAAyB,CACnC,OAAQ,OACR,KAAM,UACN,MAAAD,CAAA,CACD,EAEGA,CACR,ECjBaE,EAAoBC,GAAuC,CACtE,MAAMC,EAAeD,EAAO,IAAK,GAAW,EAAE,OAAO,EAAE,KAAK,GAAG,EAE/D,MAAM,MAAMC,CAAY,CAC1B,ECAaC,EAAiB,SAKrB,MAAMV,EAAaG,EAAkB,CAC1C,OAAQ,MACR,MAAO,aAAA,CACR,EACE,KAAMQ,GAAa,WAClB,OAAIC,EAAAD,EAAS,SAAT,MAAAC,EAAiB,OAAeL,EAAiBI,EAAS,MAAM,EAE7D,CACL,YAAa,CACX,mBACEE,GAAAC,EAAAH,GAAA,YAAAA,EAAU,OAAV,YAAAG,EAAgB,cAAhB,YAAAD,EAA6B,oBAAqB,EAAA,CACtD,CAEJ,CAAC,EACA,MAAMT,CAAkB,EC/BhBW,EAAa,IAAIC,EAAyB,CACrD,KAAM,MAAOC,GAAW,CACtB,MAAMC,EAAsC,CAC1C,iBAAkB,EAAA,EAGpB,GAAI,CACF,MAAMC,EAAsB,MAAMT,EAAA,EAClCQ,EAAc,iBACZC,EAAoB,YAAY,gBACpC,OAASd,EAAO,CACd,QAAQ,MAAM,gCAAiCA,CAAK,CACtD,CAEAU,EAAW,OAAO,UAAU,CAAE,GAAGG,EAAe,GAAGD,EAAQ,CAC7D,EAEA,UAAW,IAAM,CAAA,CAKnB,CAAC,EAEYA,EAASF,EAAW"}
|