@dutchiesdk/ecommerce-extensions-sdk 0.7.0 → 0.8.1
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/components/remote-boundary.cjs +95 -0
- package/dist/components/remote-boundary.d.ts +27 -0
- package/dist/context/ecommerce-data-bridge.cjs +65 -0
- package/dist/context/ecommerce-data-bridge.d.ts +31 -0
- package/dist/esm/components/remote-boundary.d.ts +27 -0
- package/dist/esm/components/remote-boundary.js +45 -0
- package/dist/esm/context/ecommerce-data-bridge.d.ts +31 -0
- package/dist/esm/context/ecommerce-data-bridge.js +22 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/types/actions.d.ts +118 -0
- package/dist/esm/types/actions.js +0 -0
- package/dist/esm/types/data.d.ts +152 -0
- package/dist/esm/types/data.js +0 -0
- package/dist/esm/types/ecommerce-extension.d.ts +16 -0
- package/dist/esm/types/ecommerce-extension.js +0 -0
- package/dist/esm/types/interface.d.ts +10 -0
- package/dist/esm/types/interface.js +0 -0
- package/dist/index.cjs +105 -0
- package/dist/index.d.ts +6 -0
- package/dist/types/actions.cjs +18 -0
- package/dist/types/actions.d.ts +118 -0
- package/dist/types/data.cjs +18 -0
- package/dist/types/data.d.ts +152 -0
- package/dist/types/ecommerce-extension.cjs +18 -0
- package/dist/types/ecommerce-extension.d.ts +16 -0
- package/dist/types/interface.cjs +18 -0
- package/dist/types/interface.d.ts +10 -0
- package/package.json +4 -3
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
createLazyRemoteBoundaryComponent: ()=>createLazyRemoteBoundaryComponent,
|
|
37
|
+
default: ()=>remote_boundary,
|
|
38
|
+
withRemoteBoundary: ()=>withRemoteBoundary
|
|
39
|
+
});
|
|
40
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
41
|
+
const external_react_namespaceObject = require("react");
|
|
42
|
+
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
43
|
+
const ecommerce_data_bridge_cjs_namespaceObject = require("../context/ecommerce-data-bridge.cjs");
|
|
44
|
+
const withRemoteBoundary = (WrappedComponent)=>{
|
|
45
|
+
function WithRemoteBoundaryComponent(props) {
|
|
46
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RemoteBoundary, {
|
|
47
|
+
...props,
|
|
48
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(WrappedComponent, {})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
WithRemoteBoundaryComponent.DataBridgeVersion = ecommerce_data_bridge_cjs_namespaceObject.DataBridgeVersion;
|
|
52
|
+
return WithRemoteBoundaryComponent;
|
|
53
|
+
};
|
|
54
|
+
const RemoteBoundary = ({ children, data })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ecommerce_data_bridge_cjs_namespaceObject.DataBridgeContext.Provider, {
|
|
55
|
+
value: data,
|
|
56
|
+
children: children
|
|
57
|
+
});
|
|
58
|
+
RemoteBoundary.DataBridgeVersion = ecommerce_data_bridge_cjs_namespaceObject.DataBridgeVersion;
|
|
59
|
+
const remote_boundary = RemoteBoundary;
|
|
60
|
+
function createLazyRemoteBoundaryComponent(importFn, options = {}) {
|
|
61
|
+
const { fallback, onError } = options;
|
|
62
|
+
const LazyComponent = /*#__PURE__*/ external_react_default().lazy(async ()=>{
|
|
63
|
+
try {
|
|
64
|
+
const module = await importFn();
|
|
65
|
+
const WrappedComponent = withRemoteBoundary(module.default);
|
|
66
|
+
return {
|
|
67
|
+
default: WrappedComponent
|
|
68
|
+
};
|
|
69
|
+
} catch (error) {
|
|
70
|
+
onError?.(error);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
function LazyRemoteBoundaryWrapper(props) {
|
|
75
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Suspense, {
|
|
76
|
+
fallback: fallback || null,
|
|
77
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LazyComponent, {
|
|
78
|
+
...props
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
LazyRemoteBoundaryWrapper.DataBridgeVersion = ecommerce_data_bridge_cjs_namespaceObject.DataBridgeVersion;
|
|
83
|
+
return LazyRemoteBoundaryWrapper;
|
|
84
|
+
}
|
|
85
|
+
exports.createLazyRemoteBoundaryComponent = __webpack_exports__.createLazyRemoteBoundaryComponent;
|
|
86
|
+
exports["default"] = __webpack_exports__["default"];
|
|
87
|
+
exports.withRemoteBoundary = __webpack_exports__.withRemoteBoundary;
|
|
88
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
89
|
+
"createLazyRemoteBoundaryComponent",
|
|
90
|
+
"default",
|
|
91
|
+
"withRemoteBoundary"
|
|
92
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
93
|
+
Object.defineProperty(exports, '__esModule', {
|
|
94
|
+
value: true
|
|
95
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RemoteBoundaryComponent, RemoteModuleRegistry } from '../types/ecommerce-extension';
|
|
3
|
+
import type { CommerceComponentsDataInterface } from '../types/interface';
|
|
4
|
+
export type { RemoteBoundaryComponent, RemoteModuleRegistry };
|
|
5
|
+
interface RemoteBoundaryProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
data: CommerceComponentsDataInterface;
|
|
8
|
+
}
|
|
9
|
+
export declare const withRemoteBoundary: (WrappedComponent: React.ComponentType) => {
|
|
10
|
+
(props: RemoteBoundaryProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
DataBridgeVersion: string;
|
|
12
|
+
};
|
|
13
|
+
declare const RemoteBoundary: {
|
|
14
|
+
({ children, data }: RemoteBoundaryProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
DataBridgeVersion: string;
|
|
16
|
+
};
|
|
17
|
+
export default RemoteBoundary;
|
|
18
|
+
interface LazyRemoteBoundaryOptions {
|
|
19
|
+
fallback?: React.ReactNode;
|
|
20
|
+
onError?: (error: Error) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function createLazyRemoteBoundaryComponent<P extends RemoteBoundaryProps = RemoteBoundaryProps>(importFn: () => Promise<{
|
|
23
|
+
default: React.ComponentType;
|
|
24
|
+
}>, options?: LazyRemoteBoundaryOptions): {
|
|
25
|
+
(props: P): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
DataBridgeVersion: string;
|
|
27
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
DataBridgeContext: ()=>DataBridgeContext,
|
|
28
|
+
DataBridgeVersion: ()=>DataBridgeVersion,
|
|
29
|
+
useAsyncLoader: ()=>useAsyncLoader,
|
|
30
|
+
useDataBridge: ()=>useDataBridge
|
|
31
|
+
});
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const external_package_json_namespaceObject = require("../../package.json");
|
|
34
|
+
const DataBridgeVersion = external_package_json_namespaceObject.version;
|
|
35
|
+
const DataBridgeContext = (0, external_react_namespaceObject.createContext)(void 0);
|
|
36
|
+
const useDataBridge = ()=>{
|
|
37
|
+
const context = (0, external_react_namespaceObject.useContext)(DataBridgeContext);
|
|
38
|
+
if (void 0 === context) throw new Error('useDataBridge must be used within a DataBridgeProvider');
|
|
39
|
+
return context;
|
|
40
|
+
};
|
|
41
|
+
const useAsyncLoader = (fn)=>{
|
|
42
|
+
const [data, setData] = (0, external_react_namespaceObject.useState)(null);
|
|
43
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
44
|
+
fn().then(setData);
|
|
45
|
+
}, [
|
|
46
|
+
fn
|
|
47
|
+
]);
|
|
48
|
+
return {
|
|
49
|
+
data,
|
|
50
|
+
isLoading: null === data
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.DataBridgeContext = __webpack_exports__.DataBridgeContext;
|
|
54
|
+
exports.DataBridgeVersion = __webpack_exports__.DataBridgeVersion;
|
|
55
|
+
exports.useAsyncLoader = __webpack_exports__.useAsyncLoader;
|
|
56
|
+
exports.useDataBridge = __webpack_exports__.useDataBridge;
|
|
57
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
58
|
+
"DataBridgeContext",
|
|
59
|
+
"DataBridgeVersion",
|
|
60
|
+
"useAsyncLoader",
|
|
61
|
+
"useDataBridge"
|
|
62
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
63
|
+
Object.defineProperty(exports, '__esModule', {
|
|
64
|
+
value: true
|
|
65
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CommerceComponentsDataInterface } from '../types/interface';
|
|
2
|
+
/**
|
|
3
|
+
* The version of the expected provided data. This value reflects the SDK version.
|
|
4
|
+
*
|
|
5
|
+
* If the implementation has a lower major version of the expected interface, the
|
|
6
|
+
* component will not render.
|
|
7
|
+
*
|
|
8
|
+
* For example, if `MyComponent.DataBridgeVersion == '1.1.0';` and `DataBridgeVersion`
|
|
9
|
+
* in the front end is providing data compatible with `>=2.0.0`, `MyComponent` will not be loaded.
|
|
10
|
+
*
|
|
11
|
+
* It is recommended to use this value directly in the component:
|
|
12
|
+
* `MyComponent.DataBridgeVersion = DataBridgeVersion`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DataBridgeVersion: string;
|
|
15
|
+
export declare const DataBridgeContext: import("react").Context<CommerceComponentsDataInterface | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* A hook to access the data bridge context.
|
|
18
|
+
*
|
|
19
|
+
* @returns The data bridge context.
|
|
20
|
+
*/
|
|
21
|
+
export declare const useDataBridge: () => CommerceComponentsDataInterface;
|
|
22
|
+
/**
|
|
23
|
+
* A hook to load data asynchronously.
|
|
24
|
+
*
|
|
25
|
+
* @param fn - The function to load the data.
|
|
26
|
+
* @returns The data and a boolean indicating if the data is loading.
|
|
27
|
+
*/
|
|
28
|
+
export declare const useAsyncLoader: <S>(fn: () => Promise<S>) => {
|
|
29
|
+
data: S | null;
|
|
30
|
+
isLoading: boolean;
|
|
31
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RemoteBoundaryComponent, RemoteModuleRegistry } from '../types/ecommerce-extension';
|
|
3
|
+
import type { CommerceComponentsDataInterface } from '../types/interface';
|
|
4
|
+
export type { RemoteBoundaryComponent, RemoteModuleRegistry };
|
|
5
|
+
interface RemoteBoundaryProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
data: CommerceComponentsDataInterface;
|
|
8
|
+
}
|
|
9
|
+
export declare const withRemoteBoundary: (WrappedComponent: React.ComponentType) => {
|
|
10
|
+
(props: RemoteBoundaryProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
DataBridgeVersion: string;
|
|
12
|
+
};
|
|
13
|
+
declare const RemoteBoundary: {
|
|
14
|
+
({ children, data }: RemoteBoundaryProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
DataBridgeVersion: string;
|
|
16
|
+
};
|
|
17
|
+
export default RemoteBoundary;
|
|
18
|
+
interface LazyRemoteBoundaryOptions {
|
|
19
|
+
fallback?: React.ReactNode;
|
|
20
|
+
onError?: (error: Error) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function createLazyRemoteBoundaryComponent<P extends RemoteBoundaryProps = RemoteBoundaryProps>(importFn: () => Promise<{
|
|
23
|
+
default: React.ComponentType;
|
|
24
|
+
}>, options?: LazyRemoteBoundaryOptions): {
|
|
25
|
+
(props: P): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
DataBridgeVersion: string;
|
|
27
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import external_react_default, { Suspense } from "react";
|
|
3
|
+
import { DataBridgeContext, DataBridgeVersion } from "../context/ecommerce-data-bridge.js";
|
|
4
|
+
const withRemoteBoundary = (WrappedComponent)=>{
|
|
5
|
+
function WithRemoteBoundaryComponent(props) {
|
|
6
|
+
return /*#__PURE__*/ jsx(RemoteBoundary, {
|
|
7
|
+
...props,
|
|
8
|
+
children: /*#__PURE__*/ jsx(WrappedComponent, {})
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
WithRemoteBoundaryComponent.DataBridgeVersion = DataBridgeVersion;
|
|
12
|
+
return WithRemoteBoundaryComponent;
|
|
13
|
+
};
|
|
14
|
+
const RemoteBoundary = ({ children, data })=>/*#__PURE__*/ jsx(DataBridgeContext.Provider, {
|
|
15
|
+
value: data,
|
|
16
|
+
children: children
|
|
17
|
+
});
|
|
18
|
+
RemoteBoundary.DataBridgeVersion = DataBridgeVersion;
|
|
19
|
+
const remote_boundary = RemoteBoundary;
|
|
20
|
+
function createLazyRemoteBoundaryComponent(importFn, options = {}) {
|
|
21
|
+
const { fallback, onError } = options;
|
|
22
|
+
const LazyComponent = /*#__PURE__*/ external_react_default.lazy(async ()=>{
|
|
23
|
+
try {
|
|
24
|
+
const module = await importFn();
|
|
25
|
+
const WrappedComponent = withRemoteBoundary(module.default);
|
|
26
|
+
return {
|
|
27
|
+
default: WrappedComponent
|
|
28
|
+
};
|
|
29
|
+
} catch (error) {
|
|
30
|
+
onError?.(error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
function LazyRemoteBoundaryWrapper(props) {
|
|
35
|
+
return /*#__PURE__*/ jsx(Suspense, {
|
|
36
|
+
fallback: fallback || null,
|
|
37
|
+
children: /*#__PURE__*/ jsx(LazyComponent, {
|
|
38
|
+
...props
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
LazyRemoteBoundaryWrapper.DataBridgeVersion = DataBridgeVersion;
|
|
43
|
+
return LazyRemoteBoundaryWrapper;
|
|
44
|
+
}
|
|
45
|
+
export { createLazyRemoteBoundaryComponent, remote_boundary as default, withRemoteBoundary };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CommerceComponentsDataInterface } from '../types/interface';
|
|
2
|
+
/**
|
|
3
|
+
* The version of the expected provided data. This value reflects the SDK version.
|
|
4
|
+
*
|
|
5
|
+
* If the implementation has a lower major version of the expected interface, the
|
|
6
|
+
* component will not render.
|
|
7
|
+
*
|
|
8
|
+
* For example, if `MyComponent.DataBridgeVersion == '1.1.0';` and `DataBridgeVersion`
|
|
9
|
+
* in the front end is providing data compatible with `>=2.0.0`, `MyComponent` will not be loaded.
|
|
10
|
+
*
|
|
11
|
+
* It is recommended to use this value directly in the component:
|
|
12
|
+
* `MyComponent.DataBridgeVersion = DataBridgeVersion`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DataBridgeVersion: string;
|
|
15
|
+
export declare const DataBridgeContext: import("react").Context<CommerceComponentsDataInterface | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* A hook to access the data bridge context.
|
|
18
|
+
*
|
|
19
|
+
* @returns The data bridge context.
|
|
20
|
+
*/
|
|
21
|
+
export declare const useDataBridge: () => CommerceComponentsDataInterface;
|
|
22
|
+
/**
|
|
23
|
+
* A hook to load data asynchronously.
|
|
24
|
+
*
|
|
25
|
+
* @param fn - The function to load the data.
|
|
26
|
+
* @returns The data and a boolean indicating if the data is loading.
|
|
27
|
+
*/
|
|
28
|
+
export declare const useAsyncLoader: <S>(fn: () => Promise<S>) => {
|
|
29
|
+
data: S | null;
|
|
30
|
+
isLoading: boolean;
|
|
31
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
2
|
+
import { version } from "../../package.json";
|
|
3
|
+
const DataBridgeVersion = version;
|
|
4
|
+
const DataBridgeContext = createContext(void 0);
|
|
5
|
+
const useDataBridge = ()=>{
|
|
6
|
+
const context = useContext(DataBridgeContext);
|
|
7
|
+
if (void 0 === context) throw new Error('useDataBridge must be used within a DataBridgeProvider');
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
const useAsyncLoader = (fn)=>{
|
|
11
|
+
const [data, setData] = useState(null);
|
|
12
|
+
useEffect(()=>{
|
|
13
|
+
fn().then(setData);
|
|
14
|
+
}, [
|
|
15
|
+
fn
|
|
16
|
+
]);
|
|
17
|
+
return {
|
|
18
|
+
data,
|
|
19
|
+
isLoading: null === data
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export { DataBridgeContext, DataBridgeVersion, useAsyncLoader, useDataBridge };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
type AuthenticationActions = {
|
|
2
|
+
/**
|
|
3
|
+
* Navigate to login
|
|
4
|
+
*/
|
|
5
|
+
goToLogin: () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Navigate to registration
|
|
8
|
+
*/
|
|
9
|
+
goToRegister: () => void;
|
|
10
|
+
};
|
|
11
|
+
type CartActions = {
|
|
12
|
+
/**
|
|
13
|
+
* Add product to cart
|
|
14
|
+
* @param productId - The product ID
|
|
15
|
+
* @param quantity - The quantity
|
|
16
|
+
*/
|
|
17
|
+
addToCart: (productId: string, quantity: number) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Clear cart
|
|
20
|
+
*/
|
|
21
|
+
clearCart: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Hide cart sidebar/modal
|
|
24
|
+
*/
|
|
25
|
+
hideCart: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Navigate to checkout
|
|
28
|
+
*/
|
|
29
|
+
goToCheckout: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Remove product from cart
|
|
32
|
+
* @param productId - The product ID
|
|
33
|
+
*/
|
|
34
|
+
removeFromCart: (productId: string) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Show cart sidebar/modal
|
|
37
|
+
*/
|
|
38
|
+
showCart: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Update product quantity in cart
|
|
41
|
+
* @param productId - The product ID
|
|
42
|
+
* @param quantity - The quantity
|
|
43
|
+
*/
|
|
44
|
+
updateCartItem: (productId: string, quantity: number) => void;
|
|
45
|
+
};
|
|
46
|
+
type ComponentActions = {
|
|
47
|
+
/**
|
|
48
|
+
* Navigate to search
|
|
49
|
+
* @param query - The search query
|
|
50
|
+
*/
|
|
51
|
+
goToSearch: (query?: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Navigate to store browser
|
|
54
|
+
*/
|
|
55
|
+
goToStoreBrowser: () => void;
|
|
56
|
+
/**
|
|
57
|
+
* Navigate to store locator
|
|
58
|
+
*/
|
|
59
|
+
goToStoreLocator: () => void;
|
|
60
|
+
};
|
|
61
|
+
type DetailPageActions = {
|
|
62
|
+
/**
|
|
63
|
+
* Navigate to category page
|
|
64
|
+
* @param categoryId - The category ID
|
|
65
|
+
* @param categoryCname - The category CNAME
|
|
66
|
+
*/
|
|
67
|
+
goToCategory: (categoryId?: string, categoryCname?: string) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Navigate to brand page
|
|
70
|
+
*/
|
|
71
|
+
goToBrand: (brandId?: string, brandCname?: string) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Navigate to product details
|
|
74
|
+
* @param productId - The product ID
|
|
75
|
+
* @param productCname - The product CNAME
|
|
76
|
+
*/
|
|
77
|
+
goToProductDetails: (productId?: string, productCname?: string) => void;
|
|
78
|
+
};
|
|
79
|
+
type ListPageActions = {
|
|
80
|
+
/**
|
|
81
|
+
* Navigate to brand list
|
|
82
|
+
* @param brandId - The brand ID
|
|
83
|
+
* @param brandCname - The brand CNAME
|
|
84
|
+
*/
|
|
85
|
+
goToBrandList: (brandId?: string, brandCname?: string) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Navigate to collection list
|
|
88
|
+
*/
|
|
89
|
+
goToCollectionList: (collectionId?: string, collectionCname?: string) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Navigate to product list
|
|
92
|
+
* @param categoryId - The category ID
|
|
93
|
+
* @param categoryCname - The category CNAME
|
|
94
|
+
* @param brandId - The brand ID
|
|
95
|
+
* @param brandCname - The brand CNAME
|
|
96
|
+
* @param collectionId - The collection ID
|
|
97
|
+
* @param collectionCname - The collection CNAME
|
|
98
|
+
*/
|
|
99
|
+
goToProductList: (categoryId?: string, categoryCname?: string, brandId?: string, brandCname?: string, collectionId?: string, collectionCname?: string) => void;
|
|
100
|
+
};
|
|
101
|
+
type NavigationActions = {
|
|
102
|
+
/**
|
|
103
|
+
* Navigate to store info
|
|
104
|
+
*/
|
|
105
|
+
goToInfoPage: () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Navigate to specific store
|
|
108
|
+
* @param storeId - The store ID
|
|
109
|
+
* @param storeCname - The store CNAME
|
|
110
|
+
*/
|
|
111
|
+
goToStore: (storeId?: string, storeCname?: string) => void;
|
|
112
|
+
/**
|
|
113
|
+
* Navigate to store front
|
|
114
|
+
*/
|
|
115
|
+
goToStoreFront: () => void;
|
|
116
|
+
};
|
|
117
|
+
export type Actions = AuthenticationActions & CartActions & ComponentActions & DetailPageActions & ListPageActions & NavigationActions;
|
|
118
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export type Brand = {
|
|
2
|
+
cname: string;
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export type CartItem = {
|
|
7
|
+
name: string;
|
|
8
|
+
price: number;
|
|
9
|
+
productId: string;
|
|
10
|
+
quantity: number;
|
|
11
|
+
};
|
|
12
|
+
export type Cart = {
|
|
13
|
+
discount: number;
|
|
14
|
+
items: CartItem[];
|
|
15
|
+
subtotal: number;
|
|
16
|
+
tax: number;
|
|
17
|
+
total: number;
|
|
18
|
+
};
|
|
19
|
+
export type Category = {
|
|
20
|
+
cname: string;
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
export type Collection = {
|
|
25
|
+
cname: string;
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
export type MenuContext = 'store-front' | 'kiosk';
|
|
30
|
+
export type DayHours = {
|
|
31
|
+
active?: boolean;
|
|
32
|
+
end?: string;
|
|
33
|
+
start?: string;
|
|
34
|
+
};
|
|
35
|
+
export type Dispensary = {
|
|
36
|
+
address: DispensaryAddress;
|
|
37
|
+
chain: string;
|
|
38
|
+
cname: string;
|
|
39
|
+
email: string;
|
|
40
|
+
hours: DispensaryHoursSettings;
|
|
41
|
+
id: string;
|
|
42
|
+
images: {
|
|
43
|
+
logo: string;
|
|
44
|
+
};
|
|
45
|
+
links: {
|
|
46
|
+
website: string;
|
|
47
|
+
storeFrontRoot: string;
|
|
48
|
+
};
|
|
49
|
+
name: string;
|
|
50
|
+
orderTypes: DispensaryOrderTypes;
|
|
51
|
+
orderTypesConfig: OrderTypesConfig;
|
|
52
|
+
phone: string;
|
|
53
|
+
status: string;
|
|
54
|
+
};
|
|
55
|
+
export type DispensaryAddress = {
|
|
56
|
+
city: string;
|
|
57
|
+
stateAbbreviation: string;
|
|
58
|
+
state: string;
|
|
59
|
+
street1: string;
|
|
60
|
+
street2: string;
|
|
61
|
+
zip: string;
|
|
62
|
+
};
|
|
63
|
+
export type DispensaryHoursSettings = {
|
|
64
|
+
curbsidePickup?: HoursSettingsForOrderType;
|
|
65
|
+
delivery?: HoursSettingsForOrderType;
|
|
66
|
+
driveThruPickup?: HoursSettingsForOrderType;
|
|
67
|
+
inStorePickup?: HoursSettingsForOrderType;
|
|
68
|
+
};
|
|
69
|
+
export type DispensaryOrderTypes = {
|
|
70
|
+
curbsidePickup: boolean;
|
|
71
|
+
delivery: boolean;
|
|
72
|
+
driveThruPickup: boolean;
|
|
73
|
+
inStorePickup: boolean;
|
|
74
|
+
kiosk: boolean;
|
|
75
|
+
pickup: boolean;
|
|
76
|
+
};
|
|
77
|
+
export type HoursSettingsForOrderType = {
|
|
78
|
+
effectiveHours?: {
|
|
79
|
+
Monday?: DayHours;
|
|
80
|
+
Tuesday?: DayHours;
|
|
81
|
+
Wednesday?: DayHours;
|
|
82
|
+
Thursday?: DayHours;
|
|
83
|
+
Friday?: DayHours;
|
|
84
|
+
Saturday?: DayHours;
|
|
85
|
+
Sunday?: DayHours;
|
|
86
|
+
};
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
};
|
|
89
|
+
export type OrderTypeConfig = {
|
|
90
|
+
enableAfterHoursOrdering?: boolean;
|
|
91
|
+
enableASAPOrdering?: boolean;
|
|
92
|
+
enableScheduledOrdering?: boolean;
|
|
93
|
+
};
|
|
94
|
+
export type OrderTypesConfig = {
|
|
95
|
+
curbsidePickup?: OrderTypeConfig;
|
|
96
|
+
delivery?: OrderTypeConfig;
|
|
97
|
+
driveThruPickup?: OrderTypeConfig;
|
|
98
|
+
inStorePickup?: OrderTypeConfig;
|
|
99
|
+
offerAnyPickupService?: boolean;
|
|
100
|
+
offerDeliveryService?: boolean;
|
|
101
|
+
};
|
|
102
|
+
export type Product = {
|
|
103
|
+
cname: string;
|
|
104
|
+
description: string;
|
|
105
|
+
id: string;
|
|
106
|
+
image: string;
|
|
107
|
+
name: string;
|
|
108
|
+
price: number;
|
|
109
|
+
};
|
|
110
|
+
export type Special = {
|
|
111
|
+
cname: string;
|
|
112
|
+
description: string;
|
|
113
|
+
id: string;
|
|
114
|
+
image: string;
|
|
115
|
+
name: string;
|
|
116
|
+
};
|
|
117
|
+
export type User = {
|
|
118
|
+
birthday: string;
|
|
119
|
+
email: string;
|
|
120
|
+
firstName: string;
|
|
121
|
+
lastName: string;
|
|
122
|
+
};
|
|
123
|
+
export type DataLoaders = {
|
|
124
|
+
/**
|
|
125
|
+
* Available brands
|
|
126
|
+
*/
|
|
127
|
+
brands: () => Promise<Brand[] | []>;
|
|
128
|
+
/**
|
|
129
|
+
* Product categories
|
|
130
|
+
*/
|
|
131
|
+
categories: () => Promise<Category[] | []>;
|
|
132
|
+
/**
|
|
133
|
+
* Product collections
|
|
134
|
+
*/
|
|
135
|
+
collections: () => Promise<Collection[] | []>;
|
|
136
|
+
/**
|
|
137
|
+
* All dispensary locations
|
|
138
|
+
*/
|
|
139
|
+
getAllLocations: () => Promise<Dispensary[] | []>;
|
|
140
|
+
/**
|
|
141
|
+
* Current context locations
|
|
142
|
+
*/
|
|
143
|
+
locations: () => Promise<Dispensary[] | []>;
|
|
144
|
+
/**
|
|
145
|
+
* Product catalog
|
|
146
|
+
*/
|
|
147
|
+
products: () => Promise<Product[] | []>;
|
|
148
|
+
/**
|
|
149
|
+
* Available specials
|
|
150
|
+
*/
|
|
151
|
+
specials: () => Promise<Special[] | []>;
|
|
152
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export type RemoteBoundaryComponent<P = {}> = React.FC<P> & {
|
|
3
|
+
DataBridgeVersion: string;
|
|
4
|
+
};
|
|
5
|
+
export type RoutablePageRegistryEntry = {
|
|
6
|
+
component: RemoteBoundaryComponent;
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
9
|
+
export type RemoteModuleRegistry = {
|
|
10
|
+
RouteablePages?: RoutablePageRegistryEntry[];
|
|
11
|
+
StoreFrontHeader?: RemoteBoundaryComponent;
|
|
12
|
+
StoreFrontNavigation?: RemoteBoundaryComponent;
|
|
13
|
+
StoreFrontFooter?: RemoteBoundaryComponent;
|
|
14
|
+
StoreFrontHero?: RemoteBoundaryComponent;
|
|
15
|
+
ProductDetailsPrimary?: RemoteBoundaryComponent;
|
|
16
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Actions } from './actions';
|
|
2
|
+
import type { Cart, DataLoaders, Dispensary, MenuContext, User } from './data';
|
|
3
|
+
export type CommerceComponentsDataInterface = {
|
|
4
|
+
actions: Actions;
|
|
5
|
+
cart?: Cart;
|
|
6
|
+
dataLoaders: DataLoaders;
|
|
7
|
+
location?: Dispensary;
|
|
8
|
+
menuContext: MenuContext;
|
|
9
|
+
user?: User;
|
|
10
|
+
};
|
|
File without changes
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./components/remote-boundary": function(module) {
|
|
4
|
+
module.exports = require("./components/remote-boundary.cjs");
|
|
5
|
+
},
|
|
6
|
+
"./context/ecommerce-data-bridge": function(module) {
|
|
7
|
+
module.exports = require("./context/ecommerce-data-bridge.cjs");
|
|
8
|
+
},
|
|
9
|
+
"./types/actions": function(module) {
|
|
10
|
+
module.exports = require("./types/actions.cjs");
|
|
11
|
+
},
|
|
12
|
+
"./types/data": function(module) {
|
|
13
|
+
module.exports = require("./types/data.cjs");
|
|
14
|
+
},
|
|
15
|
+
"./types/ecommerce-extension": function(module) {
|
|
16
|
+
module.exports = require("./types/ecommerce-extension.cjs");
|
|
17
|
+
},
|
|
18
|
+
"./types/interface": function(module) {
|
|
19
|
+
module.exports = require("./types/interface.cjs");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var __webpack_module_cache__ = {};
|
|
23
|
+
function __webpack_require__(moduleId) {
|
|
24
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
25
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
26
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
27
|
+
exports: {}
|
|
28
|
+
};
|
|
29
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
30
|
+
return module.exports;
|
|
31
|
+
}
|
|
32
|
+
(()=>{
|
|
33
|
+
__webpack_require__.n = (module)=>{
|
|
34
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
35
|
+
__webpack_require__.d(getter, {
|
|
36
|
+
a: getter
|
|
37
|
+
});
|
|
38
|
+
return getter;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
(()=>{
|
|
42
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
43
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: definition[key]
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
(()=>{
|
|
50
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
51
|
+
})();
|
|
52
|
+
(()=>{
|
|
53
|
+
__webpack_require__.r = (exports1)=>{
|
|
54
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
55
|
+
value: 'Module'
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
58
|
+
value: true
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
})();
|
|
62
|
+
var __webpack_exports__ = {};
|
|
63
|
+
(()=>{
|
|
64
|
+
__webpack_require__.r(__webpack_exports__);
|
|
65
|
+
var _components_remote_boundary__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./components/remote-boundary");
|
|
66
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
67
|
+
for(var __WEBPACK_IMPORT_KEY__ in _components_remote_boundary__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
68
|
+
return _components_remote_boundary__WEBPACK_IMPORTED_MODULE_0__[key];
|
|
69
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
70
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
71
|
+
var _context_ecommerce_data_bridge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./context/ecommerce-data-bridge");
|
|
72
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
73
|
+
for(var __WEBPACK_IMPORT_KEY__ in _context_ecommerce_data_bridge__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
74
|
+
return _context_ecommerce_data_bridge__WEBPACK_IMPORTED_MODULE_1__[key];
|
|
75
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
76
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
77
|
+
var _types_actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./types/actions");
|
|
78
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
79
|
+
for(var __WEBPACK_IMPORT_KEY__ in _types_actions__WEBPACK_IMPORTED_MODULE_2__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
80
|
+
return _types_actions__WEBPACK_IMPORTED_MODULE_2__[key];
|
|
81
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
82
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
83
|
+
var _types_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./types/data");
|
|
84
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
85
|
+
for(var __WEBPACK_IMPORT_KEY__ in _types_data__WEBPACK_IMPORTED_MODULE_3__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
86
|
+
return _types_data__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
87
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
88
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
89
|
+
var _types_ecommerce_extension__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./types/ecommerce-extension");
|
|
90
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
91
|
+
for(var __WEBPACK_IMPORT_KEY__ in _types_ecommerce_extension__WEBPACK_IMPORTED_MODULE_4__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
92
|
+
return _types_ecommerce_extension__WEBPACK_IMPORTED_MODULE_4__[key];
|
|
93
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
94
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
95
|
+
var _types_interface__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./types/interface");
|
|
96
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
97
|
+
for(var __WEBPACK_IMPORT_KEY__ in _types_interface__WEBPACK_IMPORTED_MODULE_5__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
98
|
+
return _types_interface__WEBPACK_IMPORTED_MODULE_5__[key];
|
|
99
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
100
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
101
|
+
})();
|
|
102
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
103
|
+
Object.defineProperty(exports, '__esModule', {
|
|
104
|
+
value: true
|
|
105
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
type AuthenticationActions = {
|
|
2
|
+
/**
|
|
3
|
+
* Navigate to login
|
|
4
|
+
*/
|
|
5
|
+
goToLogin: () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Navigate to registration
|
|
8
|
+
*/
|
|
9
|
+
goToRegister: () => void;
|
|
10
|
+
};
|
|
11
|
+
type CartActions = {
|
|
12
|
+
/**
|
|
13
|
+
* Add product to cart
|
|
14
|
+
* @param productId - The product ID
|
|
15
|
+
* @param quantity - The quantity
|
|
16
|
+
*/
|
|
17
|
+
addToCart: (productId: string, quantity: number) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Clear cart
|
|
20
|
+
*/
|
|
21
|
+
clearCart: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Hide cart sidebar/modal
|
|
24
|
+
*/
|
|
25
|
+
hideCart: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Navigate to checkout
|
|
28
|
+
*/
|
|
29
|
+
goToCheckout: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Remove product from cart
|
|
32
|
+
* @param productId - The product ID
|
|
33
|
+
*/
|
|
34
|
+
removeFromCart: (productId: string) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Show cart sidebar/modal
|
|
37
|
+
*/
|
|
38
|
+
showCart: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Update product quantity in cart
|
|
41
|
+
* @param productId - The product ID
|
|
42
|
+
* @param quantity - The quantity
|
|
43
|
+
*/
|
|
44
|
+
updateCartItem: (productId: string, quantity: number) => void;
|
|
45
|
+
};
|
|
46
|
+
type ComponentActions = {
|
|
47
|
+
/**
|
|
48
|
+
* Navigate to search
|
|
49
|
+
* @param query - The search query
|
|
50
|
+
*/
|
|
51
|
+
goToSearch: (query?: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Navigate to store browser
|
|
54
|
+
*/
|
|
55
|
+
goToStoreBrowser: () => void;
|
|
56
|
+
/**
|
|
57
|
+
* Navigate to store locator
|
|
58
|
+
*/
|
|
59
|
+
goToStoreLocator: () => void;
|
|
60
|
+
};
|
|
61
|
+
type DetailPageActions = {
|
|
62
|
+
/**
|
|
63
|
+
* Navigate to category page
|
|
64
|
+
* @param categoryId - The category ID
|
|
65
|
+
* @param categoryCname - The category CNAME
|
|
66
|
+
*/
|
|
67
|
+
goToCategory: (categoryId?: string, categoryCname?: string) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Navigate to brand page
|
|
70
|
+
*/
|
|
71
|
+
goToBrand: (brandId?: string, brandCname?: string) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Navigate to product details
|
|
74
|
+
* @param productId - The product ID
|
|
75
|
+
* @param productCname - The product CNAME
|
|
76
|
+
*/
|
|
77
|
+
goToProductDetails: (productId?: string, productCname?: string) => void;
|
|
78
|
+
};
|
|
79
|
+
type ListPageActions = {
|
|
80
|
+
/**
|
|
81
|
+
* Navigate to brand list
|
|
82
|
+
* @param brandId - The brand ID
|
|
83
|
+
* @param brandCname - The brand CNAME
|
|
84
|
+
*/
|
|
85
|
+
goToBrandList: (brandId?: string, brandCname?: string) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Navigate to collection list
|
|
88
|
+
*/
|
|
89
|
+
goToCollectionList: (collectionId?: string, collectionCname?: string) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Navigate to product list
|
|
92
|
+
* @param categoryId - The category ID
|
|
93
|
+
* @param categoryCname - The category CNAME
|
|
94
|
+
* @param brandId - The brand ID
|
|
95
|
+
* @param brandCname - The brand CNAME
|
|
96
|
+
* @param collectionId - The collection ID
|
|
97
|
+
* @param collectionCname - The collection CNAME
|
|
98
|
+
*/
|
|
99
|
+
goToProductList: (categoryId?: string, categoryCname?: string, brandId?: string, brandCname?: string, collectionId?: string, collectionCname?: string) => void;
|
|
100
|
+
};
|
|
101
|
+
type NavigationActions = {
|
|
102
|
+
/**
|
|
103
|
+
* Navigate to store info
|
|
104
|
+
*/
|
|
105
|
+
goToInfoPage: () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Navigate to specific store
|
|
108
|
+
* @param storeId - The store ID
|
|
109
|
+
* @param storeCname - The store CNAME
|
|
110
|
+
*/
|
|
111
|
+
goToStore: (storeId?: string, storeCname?: string) => void;
|
|
112
|
+
/**
|
|
113
|
+
* Navigate to store front
|
|
114
|
+
*/
|
|
115
|
+
goToStoreFront: () => void;
|
|
116
|
+
};
|
|
117
|
+
export type Actions = AuthenticationActions & CartActions & ComponentActions & DetailPageActions & ListPageActions & NavigationActions;
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export type Brand = {
|
|
2
|
+
cname: string;
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export type CartItem = {
|
|
7
|
+
name: string;
|
|
8
|
+
price: number;
|
|
9
|
+
productId: string;
|
|
10
|
+
quantity: number;
|
|
11
|
+
};
|
|
12
|
+
export type Cart = {
|
|
13
|
+
discount: number;
|
|
14
|
+
items: CartItem[];
|
|
15
|
+
subtotal: number;
|
|
16
|
+
tax: number;
|
|
17
|
+
total: number;
|
|
18
|
+
};
|
|
19
|
+
export type Category = {
|
|
20
|
+
cname: string;
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
export type Collection = {
|
|
25
|
+
cname: string;
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
export type MenuContext = 'store-front' | 'kiosk';
|
|
30
|
+
export type DayHours = {
|
|
31
|
+
active?: boolean;
|
|
32
|
+
end?: string;
|
|
33
|
+
start?: string;
|
|
34
|
+
};
|
|
35
|
+
export type Dispensary = {
|
|
36
|
+
address: DispensaryAddress;
|
|
37
|
+
chain: string;
|
|
38
|
+
cname: string;
|
|
39
|
+
email: string;
|
|
40
|
+
hours: DispensaryHoursSettings;
|
|
41
|
+
id: string;
|
|
42
|
+
images: {
|
|
43
|
+
logo: string;
|
|
44
|
+
};
|
|
45
|
+
links: {
|
|
46
|
+
website: string;
|
|
47
|
+
storeFrontRoot: string;
|
|
48
|
+
};
|
|
49
|
+
name: string;
|
|
50
|
+
orderTypes: DispensaryOrderTypes;
|
|
51
|
+
orderTypesConfig: OrderTypesConfig;
|
|
52
|
+
phone: string;
|
|
53
|
+
status: string;
|
|
54
|
+
};
|
|
55
|
+
export type DispensaryAddress = {
|
|
56
|
+
city: string;
|
|
57
|
+
stateAbbreviation: string;
|
|
58
|
+
state: string;
|
|
59
|
+
street1: string;
|
|
60
|
+
street2: string;
|
|
61
|
+
zip: string;
|
|
62
|
+
};
|
|
63
|
+
export type DispensaryHoursSettings = {
|
|
64
|
+
curbsidePickup?: HoursSettingsForOrderType;
|
|
65
|
+
delivery?: HoursSettingsForOrderType;
|
|
66
|
+
driveThruPickup?: HoursSettingsForOrderType;
|
|
67
|
+
inStorePickup?: HoursSettingsForOrderType;
|
|
68
|
+
};
|
|
69
|
+
export type DispensaryOrderTypes = {
|
|
70
|
+
curbsidePickup: boolean;
|
|
71
|
+
delivery: boolean;
|
|
72
|
+
driveThruPickup: boolean;
|
|
73
|
+
inStorePickup: boolean;
|
|
74
|
+
kiosk: boolean;
|
|
75
|
+
pickup: boolean;
|
|
76
|
+
};
|
|
77
|
+
export type HoursSettingsForOrderType = {
|
|
78
|
+
effectiveHours?: {
|
|
79
|
+
Monday?: DayHours;
|
|
80
|
+
Tuesday?: DayHours;
|
|
81
|
+
Wednesday?: DayHours;
|
|
82
|
+
Thursday?: DayHours;
|
|
83
|
+
Friday?: DayHours;
|
|
84
|
+
Saturday?: DayHours;
|
|
85
|
+
Sunday?: DayHours;
|
|
86
|
+
};
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
};
|
|
89
|
+
export type OrderTypeConfig = {
|
|
90
|
+
enableAfterHoursOrdering?: boolean;
|
|
91
|
+
enableASAPOrdering?: boolean;
|
|
92
|
+
enableScheduledOrdering?: boolean;
|
|
93
|
+
};
|
|
94
|
+
export type OrderTypesConfig = {
|
|
95
|
+
curbsidePickup?: OrderTypeConfig;
|
|
96
|
+
delivery?: OrderTypeConfig;
|
|
97
|
+
driveThruPickup?: OrderTypeConfig;
|
|
98
|
+
inStorePickup?: OrderTypeConfig;
|
|
99
|
+
offerAnyPickupService?: boolean;
|
|
100
|
+
offerDeliveryService?: boolean;
|
|
101
|
+
};
|
|
102
|
+
export type Product = {
|
|
103
|
+
cname: string;
|
|
104
|
+
description: string;
|
|
105
|
+
id: string;
|
|
106
|
+
image: string;
|
|
107
|
+
name: string;
|
|
108
|
+
price: number;
|
|
109
|
+
};
|
|
110
|
+
export type Special = {
|
|
111
|
+
cname: string;
|
|
112
|
+
description: string;
|
|
113
|
+
id: string;
|
|
114
|
+
image: string;
|
|
115
|
+
name: string;
|
|
116
|
+
};
|
|
117
|
+
export type User = {
|
|
118
|
+
birthday: string;
|
|
119
|
+
email: string;
|
|
120
|
+
firstName: string;
|
|
121
|
+
lastName: string;
|
|
122
|
+
};
|
|
123
|
+
export type DataLoaders = {
|
|
124
|
+
/**
|
|
125
|
+
* Available brands
|
|
126
|
+
*/
|
|
127
|
+
brands: () => Promise<Brand[] | []>;
|
|
128
|
+
/**
|
|
129
|
+
* Product categories
|
|
130
|
+
*/
|
|
131
|
+
categories: () => Promise<Category[] | []>;
|
|
132
|
+
/**
|
|
133
|
+
* Product collections
|
|
134
|
+
*/
|
|
135
|
+
collections: () => Promise<Collection[] | []>;
|
|
136
|
+
/**
|
|
137
|
+
* All dispensary locations
|
|
138
|
+
*/
|
|
139
|
+
getAllLocations: () => Promise<Dispensary[] | []>;
|
|
140
|
+
/**
|
|
141
|
+
* Current context locations
|
|
142
|
+
*/
|
|
143
|
+
locations: () => Promise<Dispensary[] | []>;
|
|
144
|
+
/**
|
|
145
|
+
* Product catalog
|
|
146
|
+
*/
|
|
147
|
+
products: () => Promise<Product[] | []>;
|
|
148
|
+
/**
|
|
149
|
+
* Available specials
|
|
150
|
+
*/
|
|
151
|
+
specials: () => Promise<Special[] | []>;
|
|
152
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export type RemoteBoundaryComponent<P = {}> = React.FC<P> & {
|
|
3
|
+
DataBridgeVersion: string;
|
|
4
|
+
};
|
|
5
|
+
export type RoutablePageRegistryEntry = {
|
|
6
|
+
component: RemoteBoundaryComponent;
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
9
|
+
export type RemoteModuleRegistry = {
|
|
10
|
+
RouteablePages?: RoutablePageRegistryEntry[];
|
|
11
|
+
StoreFrontHeader?: RemoteBoundaryComponent;
|
|
12
|
+
StoreFrontNavigation?: RemoteBoundaryComponent;
|
|
13
|
+
StoreFrontFooter?: RemoteBoundaryComponent;
|
|
14
|
+
StoreFrontHero?: RemoteBoundaryComponent;
|
|
15
|
+
ProductDetailsPrimary?: RemoteBoundaryComponent;
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Actions } from './actions';
|
|
2
|
+
import type { Cart, DataLoaders, Dispensary, MenuContext, User } from './data';
|
|
3
|
+
export type CommerceComponentsDataInterface = {
|
|
4
|
+
actions: Actions;
|
|
5
|
+
cart?: Cart;
|
|
6
|
+
dataLoaders: DataLoaders;
|
|
7
|
+
location?: Dispensary;
|
|
8
|
+
menuContext: MenuContext;
|
|
9
|
+
user?: User;
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.8.1",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"module": "./dist/esm/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test": "vitest run"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@biomejs/biome": "^
|
|
33
|
+
"@biomejs/biome": "^2.0.6",
|
|
34
34
|
"@rsbuild/plugin-react": "^1.3.2",
|
|
35
35
|
"@rslib/core": "^0.9.2",
|
|
36
36
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "^17.0.0 || ^18.0.0",
|
|
49
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
49
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
50
|
+
"react-shadow": "^20.5.0"
|
|
50
51
|
},
|
|
51
52
|
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
|
52
53
|
}
|