@wix/headless-restaurants-olo 0.0.0

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 (55) hide show
  1. package/cjs/dist/react/ClickableItem.d.ts +9 -0
  2. package/cjs/dist/react/ClickableItem.js +14 -0
  3. package/cjs/dist/react/ItemDetails.d.ts +279 -0
  4. package/cjs/dist/react/ItemDetails.js +137 -0
  5. package/cjs/dist/react/OLO.d.ts +179 -0
  6. package/cjs/dist/react/OLO.js +134 -0
  7. package/cjs/dist/react/core/ClickableItem.d.ts +13 -0
  8. package/cjs/dist/react/core/ClickableItem.js +21 -0
  9. package/cjs/dist/react/core/ItemDetails.d.ts +68 -0
  10. package/cjs/dist/react/core/ItemDetails.js +127 -0
  11. package/cjs/dist/react/core/OLO.d.ts +92 -0
  12. package/cjs/dist/react/core/OLO.js +122 -0
  13. package/cjs/dist/react/core/index.d.ts +3 -0
  14. package/cjs/dist/react/core/index.js +3 -0
  15. package/cjs/dist/react/index.d.ts +3 -0
  16. package/cjs/dist/react/index.js +3 -0
  17. package/cjs/dist/services/common-types.d.ts +19 -0
  18. package/cjs/dist/services/common-types.js +8 -0
  19. package/cjs/dist/services/index.d.ts +3 -0
  20. package/cjs/dist/services/index.js +3 -0
  21. package/cjs/dist/services/item-details-service.d.ts +169 -0
  22. package/cjs/dist/services/item-details-service.js +248 -0
  23. package/cjs/dist/services/olo-settings-service.d.ts +37 -0
  24. package/cjs/dist/services/olo-settings-service.js +45 -0
  25. package/cjs/dist/services/utils.d.ts +20 -0
  26. package/cjs/dist/services/utils.js +34 -0
  27. package/dist/react/ClickableItem.d.ts +9 -0
  28. package/dist/react/ClickableItem.js +14 -0
  29. package/dist/react/ItemDetails.d.ts +279 -0
  30. package/dist/react/ItemDetails.js +137 -0
  31. package/dist/react/OLO.d.ts +179 -0
  32. package/dist/react/OLO.js +134 -0
  33. package/dist/react/core/ClickableItem.d.ts +13 -0
  34. package/dist/react/core/ClickableItem.js +21 -0
  35. package/dist/react/core/ItemDetails.d.ts +68 -0
  36. package/dist/react/core/ItemDetails.js +127 -0
  37. package/dist/react/core/OLO.d.ts +92 -0
  38. package/dist/react/core/OLO.js +122 -0
  39. package/dist/react/core/index.d.ts +3 -0
  40. package/dist/react/core/index.js +3 -0
  41. package/dist/react/index.d.ts +3 -0
  42. package/dist/react/index.js +3 -0
  43. package/dist/services/common-types.d.ts +19 -0
  44. package/dist/services/common-types.js +8 -0
  45. package/dist/services/index.d.ts +3 -0
  46. package/dist/services/index.js +3 -0
  47. package/dist/services/item-details-service.d.ts +169 -0
  48. package/dist/services/item-details-service.js +248 -0
  49. package/dist/services/olo-settings-service.d.ts +37 -0
  50. package/dist/services/olo-settings-service.js +45 -0
  51. package/dist/services/utils.d.ts +20 -0
  52. package/dist/services/utils.js +34 -0
  53. package/package.json +81 -0
  54. package/react/package.json +4 -0
  55. package/services/package.json +4 -0
@@ -0,0 +1,134 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { CoreOLO } from './core/index.js';
4
+ /**
5
+ * Root headless component for OLO service management
6
+ * Wraps CoreOLO.Root and provides service state to children
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * <OLO.Root itemId="item-123">
11
+ * {({ isLoading, hasServices, error, retry }) => (
12
+ * isLoading ? (
13
+ * <LoadingSpinner />
14
+ * ) : error ? (
15
+ * <ErrorMessage error={error} onRetry={retry} />
16
+ * ) : hasServices ? (
17
+ * <ItemDetailsComponents />
18
+ * ) : null
19
+ * )}
20
+ * </OLO.Root>
21
+ * ```
22
+ */
23
+ export const Root = ({ itemId, oloSettingsServiceConfig, children, }) => {
24
+ const [retryKey] = React.useState(0);
25
+ // const retry = React.useCallback(() => {
26
+ // setRetryKey(prev => prev + 1);
27
+ // }, []);
28
+ return (_jsx(CoreOLO.Root, { itemId: itemId, oloSettingsServiceConfig: oloSettingsServiceConfig, children: children }, retryKey));
29
+ };
30
+ /**
31
+ * Convenience provider that handles loading and error states automatically
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * <OLO.Provider
36
+ * itemId="item-123"
37
+ * loading={<Spinner />}
38
+ * error={({ error, retry }) => <ErrorBanner message={error} onRetry={retry} />}
39
+ * >
40
+ * <ItemDetailsComponents />
41
+ * </OLO.Provider>
42
+ * ```
43
+ */
44
+ export const Provider = ({ itemId, configs,
45
+ // loading = (
46
+ // <div className="flex items-center justify-center p-8">
47
+ // <div className="text-secondary-foreground">Loading services...</div>
48
+ // </div>
49
+ // ),
50
+ // error: errorComponent = ({ error, retry }) => (
51
+ // <div className="flex flex-col items-center justify-center p-8 space-y-4">
52
+ // <div className="text-destructive">Error: {error}</div>
53
+ // <button
54
+ // onClick={retry}
55
+ // className="px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90"
56
+ // >
57
+ // Retry
58
+ // </button>
59
+ // </div>
60
+ // ),
61
+ children, }) => {
62
+ return (_jsx(Root, { itemId: itemId, itemServiceConfig: configs?.itemServiceConfig, children: children }));
63
+ };
64
+ /**
65
+ * Specialized headless component for item details
66
+ * Includes item-specific error handling (like 404 not found)
67
+ *
68
+ * @example
69
+ * ```tsx
70
+ * <OLO.ItemDetails
71
+ * itemId="item-123"
72
+ * notFound={<NotFoundPage />}
73
+ * >
74
+ * <ItemDetailsUI />
75
+ * </OLO.ItemDetails>
76
+ * ```
77
+ */
78
+ export const ItemDetails = ({ itemId, configs, loading, error, notFound = (_jsx("div", { className: "flex items-center justify-center p-8", children: _jsx("div", { className: "text-secondary-foreground", children: "Item not found" }) })), children, }) => {
79
+ return (_jsx(Provider, { itemId: itemId, configs: configs, loading: loading, error: ({ error: errorMessage, retry }) => {
80
+ // Handle item not found specifically
81
+ if (errorMessage === 'Item not found') {
82
+ return _jsx(_Fragment, { children: notFound });
83
+ }
84
+ // Use custom error component if provided
85
+ if (error) {
86
+ return _jsx(_Fragment, { children: error({ error: errorMessage, retry }) });
87
+ }
88
+ // Default error handling
89
+ return (_jsxs("div", { className: "flex flex-col items-center justify-center p-8 space-y-4", children: [_jsxs("div", { className: "text-destructive", children: ["Error: ", errorMessage] }), _jsx("button", { onClick: retry, className: "px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90", children: "Retry" })] }));
90
+ }, children: children }));
91
+ };
92
+ /**
93
+ * Headless component for cart-only functionality
94
+ * Doesn't load item services, only cart services
95
+ *
96
+ * @example
97
+ * ```tsx
98
+ * <OLO.Cart>
99
+ * <CartComponents />
100
+ * </OLO.Cart>
101
+ * ```
102
+ */
103
+ export const Cart = ({ loading, error, children }) => {
104
+ return (_jsx(Provider, { loading: loading, error: error, children: children }));
105
+ };
106
+ /**
107
+ * Headless component for checking service status
108
+ * Useful for debugging or conditional rendering
109
+ *
110
+ * @example
111
+ * ```tsx
112
+ * <OLO.ServicesStatus itemId="item-123">
113
+ * {({ hasItemService, hasCartService, error }) => (
114
+ * <div>
115
+ * Item Service: {hasItemService ? '✅' : '❌'}
116
+ * Cart Service: {hasCartService ? '✅' : '❌'}
117
+ * {error && <div>Error: {error}</div>}
118
+ * </div>
119
+ * )}
120
+ * </OLO.ServicesStatus>
121
+ * ```
122
+ */
123
+ export const ServicesStatus = ({ itemId, children, }) => {
124
+ return (_jsx(Root, { itemId: itemId, children: children }));
125
+ };
126
+ export const Menus = ({
127
+ // menuServiceConfig,
128
+ children, }) => {
129
+ // const [retryKey, setRetryKey] = React.useState(0);
130
+ // const [menus, setMenus] = React.useState<any[]>([]);
131
+ // const [isLoading, setIsLoading] = React.useState(true);
132
+ // const [error, setError] = React.useState<string | undefined>(undefined);
133
+ return _jsx(_Fragment, { children: children });
134
+ };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ /**
3
+ * CoreMenuItem
4
+ *
5
+ * A core menu item component that displays the item image, name, description, and price
6
+ * using the project's design system for colors and fonts.
7
+ */
8
+ export declare function CoreClickableItem({ children, }: {
9
+ children: (props: {
10
+ item: any;
11
+ itemSelected: () => void;
12
+ }) => React.ReactNode;
13
+ }): React.ReactNode;
@@ -0,0 +1,21 @@
1
+ import { useItemContext, useMenuContext, useSectionContext, } from '@wix/headless-restaurants-menus/react';
2
+ import { useService } from '@wix/services-manager-react';
3
+ import { OLOSettingsServiceDefinition } from '@wix/headless-restaurants-olo/services';
4
+ // import { OLOSettingsServiceDefinition } from "../../services/OLOSettingsService";
5
+ /**
6
+ * CoreMenuItem
7
+ *
8
+ * A core menu item component that displays the item image, name, description, and price
9
+ * using the project's design system for colors and fonts.
10
+ */
11
+ export function CoreClickableItem({ children, }) {
12
+ const { item } = useItemContext();
13
+ const { section } = useSectionContext();
14
+ const { menu } = useMenuContext();
15
+ const service = useService(OLOSettingsServiceDefinition);
16
+ const itemSelected = () => {
17
+ const selectedItem = { ...item, sectionId: section._id, menuId: menu._id };
18
+ service.selectedItem?.set(selectedItem);
19
+ };
20
+ return children({ item, itemSelected });
21
+ }
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import { type LineItem } from '@wix/ecom/services';
3
+ import { ItemServiceConfig } from '../../services/item-details-service.js';
4
+ import { EnhancedModifier, EnhancedModifierGroup, EnhancedVariant } from '@wix/headless-restaurants-menus/services';
5
+ import { AvailabilityStatus, AvailabilityStatusMap } from '../../services/common-types.js';
6
+ interface ItemDetailsRootProps {
7
+ children: (props: {
8
+ item: unknown;
9
+ }) => React.ReactNode;
10
+ itemDetailsServiceConfig?: ItemServiceConfig;
11
+ }
12
+ export declare const Root: React.FC<ItemDetailsRootProps>;
13
+ interface ItemDetailsSpecialRequestProps {
14
+ children: (props: {
15
+ value: string;
16
+ onChange: (value: string) => void;
17
+ }) => React.ReactNode;
18
+ }
19
+ export declare const SpecialRequest: React.FC<ItemDetailsSpecialRequestProps>;
20
+ interface ItemDetailsLineItemProps {
21
+ children: (props: {
22
+ lineItem: LineItem;
23
+ }) => React.ReactNode;
24
+ }
25
+ export declare const LineItemComponent: React.FC<ItemDetailsLineItemProps>;
26
+ interface ItemDetailsQuantityProps {
27
+ children: (props: {
28
+ quantity: number;
29
+ increment: () => void;
30
+ decrement: () => void;
31
+ setQuantity: (quantity: number) => void;
32
+ canIncrement: boolean;
33
+ canDecrement: boolean;
34
+ onValueChange: (value: number) => void;
35
+ }) => React.ReactNode;
36
+ }
37
+ export declare const QuantityComponent: React.FC<ItemDetailsQuantityProps>;
38
+ interface ItemDetailsVariantsProps {
39
+ children: (props: {
40
+ variants: EnhancedVariant[];
41
+ hasVariants: boolean;
42
+ selectedVariantId?: string;
43
+ onVariantChange?: (variantId: string) => void;
44
+ selectedVariant?: EnhancedVariant;
45
+ }) => React.ReactNode;
46
+ }
47
+ export declare const VariantsComponent: React.FC<ItemDetailsVariantsProps>;
48
+ interface ItemDetailsModifiersProps {
49
+ children: (props: {
50
+ selectedModifierIds: string[];
51
+ onToggle: (modifierId: string) => void;
52
+ modifierGroup: EnhancedModifierGroup;
53
+ modifiers: EnhancedModifier[];
54
+ }) => React.ReactNode;
55
+ singleSelect?: boolean;
56
+ }
57
+ export declare const ModifiersComponent: React.FC<ItemDetailsModifiersProps>;
58
+ interface ItemDetailsAvailabilityProps {
59
+ availabilityStatusMap: AvailabilityStatusMap;
60
+ children: (props: {
61
+ availabilityStatus: AvailabilityStatus;
62
+ availabilityAction?: () => void;
63
+ availabilityStatusText?: string;
64
+ availabilityStatusButtonText?: string;
65
+ }) => React.ReactNode;
66
+ }
67
+ export declare const AvailabilityComponent: React.FC<ItemDetailsAvailabilityProps>;
68
+ export {};
@@ -0,0 +1,127 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { useService, WixServices } from '@wix/services-manager-react';
4
+ import { createServicesMap } from '@wix/services-manager';
5
+ import { ItemService, ItemServiceDefinition, loadItemServiceConfig, } from '../../services/item-details-service.js';
6
+ import { OLOSettingsServiceDefinition } from '../../services/olo-settings-service.js';
7
+ import { useItemContext, useModifierGroupContext, } from '@wix/headless-restaurants-menus/react';
8
+ import { AvailabilityStatus, } from '../../services/common-types.js';
9
+ import { convertModifierToFormModifier } from '../../services/utils.js';
10
+ export const Root = ({ children, itemDetailsServiceConfig, }) => {
11
+ const service = useService(OLOSettingsServiceDefinition);
12
+ const selectedItem = service.selectedItem?.get();
13
+ let config = itemDetailsServiceConfig;
14
+ if (!config) {
15
+ config = loadItemServiceConfig({
16
+ item: selectedItem,
17
+ operationId: service.operation?.get()?._id ?? '',
18
+ });
19
+ }
20
+ if (config.item) {
21
+ service.selectedItem?.set(config.item);
22
+ }
23
+ return (_jsx(WixServices, { servicesMap: createServicesMap().addService(ItemServiceDefinition, ItemService, config), children: children({ item: itemDetailsServiceConfig?.item ?? selectedItem }) }));
24
+ };
25
+ export const SpecialRequest = ({ children, }) => {
26
+ const [value, setValue] = useState('');
27
+ const service = useService(ItemServiceDefinition);
28
+ const onChange = (newValue) => {
29
+ setValue(newValue);
30
+ service.updateSpecialRequest(newValue);
31
+ };
32
+ return children({
33
+ value,
34
+ onChange,
35
+ // placeholder: 'Any special requests or dietary restrictions?',
36
+ // maxLength: 200
37
+ });
38
+ };
39
+ export const LineItemComponent = ({ children, }) => {
40
+ const service = useService(ItemServiceDefinition);
41
+ const lineItem = service.lineItem?.get?.() ?? {};
42
+ return children({ lineItem });
43
+ };
44
+ export const QuantityComponent = ({ children, }) => {
45
+ const service = useService(ItemServiceDefinition);
46
+ const quantity = service.quantity?.get?.() ?? 1;
47
+ const increment = () => service.quantity?.set?.(quantity + 1);
48
+ const decrement = () => service.quantity?.set?.(quantity - 1);
49
+ const setQuantity = (quantity) => {
50
+ service.updateQuantity?.(quantity);
51
+ };
52
+ const canIncrement = true;
53
+ const canDecrement = quantity > 1;
54
+ const onValueChange = (value) => {
55
+ service.updateQuantity?.(value);
56
+ };
57
+ return children({
58
+ quantity,
59
+ increment,
60
+ decrement,
61
+ setQuantity,
62
+ canIncrement,
63
+ canDecrement,
64
+ onValueChange,
65
+ });
66
+ };
67
+ export const VariantsComponent = ({ children, }) => {
68
+ const service = useService(ItemServiceDefinition);
69
+ const { item } = useItemContext();
70
+ const selectedVariant = service.selectedVariant?.get?.();
71
+ // Get variants from item context
72
+ const variants = item?.priceVariants || [];
73
+ const hasVariants = variants.length > 0;
74
+ const selectedVariantId = selectedVariant?._id ?? undefined;
75
+ const onVariantChange = (variantId) => {
76
+ const variant = variants.find((v) => v._id === variantId);
77
+ if (variant) {
78
+ service.updateSelectedVariant?.(variant);
79
+ }
80
+ };
81
+ return children({
82
+ variants,
83
+ hasVariants,
84
+ selectedVariantId,
85
+ onVariantChange,
86
+ selectedVariant,
87
+ });
88
+ };
89
+ export const ModifiersComponent = ({ children, singleSelect, }) => {
90
+ const service = useService(ItemServiceDefinition);
91
+ const { modifierGroup } = useModifierGroupContext();
92
+ // Get selected modifier IDs for this group
93
+ const groupId = modifierGroup._id;
94
+ const groupSelectedModifierIds = service.getSelectedModifiers?.(groupId ?? '');
95
+ const onToggle = (modifierId) => {
96
+ if (groupId) {
97
+ service.toggleModifier?.(groupId, modifierId, singleSelect);
98
+ }
99
+ };
100
+ return children({
101
+ selectedModifierIds: groupSelectedModifierIds,
102
+ onToggle,
103
+ modifierGroup,
104
+ modifiers: modifierGroup.modifiers.map(convertModifierToFormModifier),
105
+ });
106
+ };
107
+ export const AvailabilityComponent = ({ children, availabilityStatusMap, }) => {
108
+ const oloSettingsService = useService(OLOSettingsServiceDefinition);
109
+ const availabilityDispatchAction = oloSettingsService.availabilityDispatchAction?.get?.();
110
+ const itemService = useService(ItemServiceDefinition);
111
+ const availabilityStatus = itemService.availabilityStatus?.get?.() ?? AvailabilityStatus.AVAILABLE;
112
+ const availabilityStatusWithAction = availabilityStatus === AvailabilityStatus.NEXT_AVAILABILITY_PICKUP ||
113
+ availabilityStatus === AvailabilityStatus.NEXT_AVAILABILITY_DELIVERY;
114
+ const availabilityStatusObject = availabilityStatusMap[availabilityStatus];
115
+ const availabilityStatusButtonText = availabilityStatusWithAction
116
+ ? availabilityStatusObject
117
+ ?.buttonText
118
+ : undefined;
119
+ return children({
120
+ availabilityStatus,
121
+ availabilityAction: availabilityStatusWithAction
122
+ ? availabilityDispatchAction
123
+ : undefined,
124
+ availabilityStatusText: availabilityStatusObject?.text,
125
+ availabilityStatusButtonText,
126
+ });
127
+ };
@@ -0,0 +1,92 @@
1
+ import React from 'react';
2
+ import { OLOSettingsServiceConfig } from '../../services/olo-settings-service.js';
3
+ import { ItemServiceConfig } from '../../services/item-details-service.js';
4
+ interface CoreOLORootProps {
5
+ /** The ID of the item to load */
6
+ itemId?: string;
7
+ /** Pre-loaded item service config (optional) */
8
+ itemServiceConfig?: ItemServiceConfig;
9
+ /** Pre-loaded cart service config (optional) */
10
+ cartServiceConfig?: any;
11
+ /** Pre-loaded OLO settings service config (optional) */
12
+ oloSettingsServiceConfig?: OLOSettingsServiceConfig;
13
+ /** Children render prop that receives the services manager state */
14
+ children: React.ReactNode;
15
+ }
16
+ /**
17
+ * Core OLO Root component that sets up service management
18
+ * Provides ItemService and CurrentCartService to child components
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * <CoreOLO.Root itemId="item-123">
23
+ * {({ servicesManager, isLoading, hasServices }) => (
24
+ * hasServices ? (
25
+ * <ServicesManagerProvider servicesManager={servicesManager}>
26
+ * <ItemDetailsComponents />
27
+ * </ServicesManagerProvider>
28
+ * ) : (
29
+ * <LoadingSpinner />
30
+ * )
31
+ * )}
32
+ * </CoreOLO.Root>
33
+ * ```
34
+ */
35
+ export declare const Root: React.FC<CoreOLORootProps>;
36
+ interface CoreOLOProviderProps {
37
+ /** The ID of the item to load */
38
+ itemId?: string;
39
+ /** Pre-loaded item service config (optional) */
40
+ itemServiceConfig?: ItemServiceConfig;
41
+ /** Pre-loaded cart service config (optional) */
42
+ cartServiceConfig?: any;
43
+ /** Pre-loaded OLO settings service config (optional) */
44
+ oloSettingsServiceConfig?: OLOSettingsServiceConfig;
45
+ /** Loading component to show while services are initializing */
46
+ loading?: React.ReactNode;
47
+ /** Error component to show if service initialization fails */
48
+ error?: (error: string) => React.ReactNode;
49
+ /** Children that will receive the services context */
50
+ children: React.ReactNode;
51
+ }
52
+ /**
53
+ * Convenience wrapper that combines Root with ServicesManagerProvider
54
+ * Automatically provides services context to children
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * <CoreOLO.Provider itemId="item-123">
59
+ * <ItemDetailsComponents />
60
+ * </CoreOLO.Provider>
61
+ * ```
62
+ */
63
+ export declare const Provider: React.FC<CoreOLOProviderProps>;
64
+ interface CoreOLOItemDetailsProps {
65
+ /** The ID of the item to load */
66
+ itemId: string;
67
+ /** Pre-loaded configurations (optional) */
68
+ configs?: {
69
+ itemServiceConfig?: ItemServiceConfig;
70
+ cartServiceConfig?: any;
71
+ };
72
+ /** Loading component */
73
+ loading?: React.ReactNode;
74
+ /** Error component */
75
+ error?: (error: string) => React.ReactNode;
76
+ /** Children that will have access to item services */
77
+ children: React.ReactNode;
78
+ }
79
+ /**
80
+ * Specialized wrapper for item details that ensures ItemService is available
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * <CoreOLO.ItemDetails itemId="item-123">
85
+ * <ItemDetailsPrimitive.Root>
86
+ * {({ item }) => <div>{item.name}</div>}
87
+ * </ItemDetailsPrimitive.Root>
88
+ * </CoreOLO.ItemDetails>
89
+ * ```
90
+ */
91
+ export declare const ItemDetails: React.FC<CoreOLOItemDetailsProps>;
92
+ export {};
@@ -0,0 +1,122 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect } from 'react';
3
+ import { createServicesMap } from '@wix/services-manager';
4
+ import { WixServices } from '@wix/services-manager-react';
5
+ // import { ItemService, ItemServiceDefinition, loadItemServiceConfig } from '@/components/restaurants-olo/services/itemDetailsService';
6
+ import { OLOSettingsService, OLOSettingsServiceDefinition, } from '@wix/headless-restaurants-olo/services';
7
+ /**
8
+ * Core OLO Root component that sets up service management
9
+ * Provides ItemService and CurrentCartService to child components
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * <CoreOLO.Root itemId="item-123">
14
+ * {({ servicesManager, isLoading, hasServices }) => (
15
+ * hasServices ? (
16
+ * <ServicesManagerProvider servicesManager={servicesManager}>
17
+ * <ItemDetailsComponents />
18
+ * </ServicesManagerProvider>
19
+ * ) : (
20
+ * <LoadingSpinner />
21
+ * )
22
+ * )}
23
+ * </CoreOLO.Root>
24
+ * ```
25
+ */
26
+ export const Root = ({ itemId, itemServiceConfig, cartServiceConfig, oloSettingsServiceConfig, children, }) => {
27
+ // const [servicesManager, setServicesManager] = useState<ServicesManager | null>(null);
28
+ // const [isLoading, setIsLoading] = useState(true);
29
+ // const [error, setError] = useState<string | undefined>();
30
+ useEffect(() => {
31
+ // const initializeServices = async () => {
32
+ // setIsLoading(true);
33
+ // setError(undefined);
34
+ // try {
35
+ // // Load configurations if not provided
36
+ // const loadedConfigs = await Promise.all([
37
+ // cartServiceConfig || loadCurrentCartServiceConfig(),
38
+ // itemServiceConfig || (loadItemServiceConfig(itemId))
39
+ // ]);
40
+ // const [currentCartServiceConfig, itemServiceConfigResult] = loadedConfigs;
41
+ // // Handle item service config result (discriminated union)
42
+ // if (itemServiceConfigResult && 'type' in itemServiceConfigResult) {
43
+ // if (itemServiceConfigResult.type === 'notFound') {
44
+ // setError('Item not found');
45
+ // return;
46
+ // }
47
+ // // Use the config from the success result
48
+ // const finalItemServiceConfig = itemServiceConfigResult.config;
49
+ // // Create services manager with both services
50
+ // const manager = createServicesManager(
51
+ // createServicesMap()
52
+ // .addService(CurrentCartServiceDefinition, CurrentCartService, currentCartServiceConfig)
53
+ // // .addService(ItemServiceDefinition, ItemService, finalItemServiceConfig)
54
+ // );
55
+ // setServicesManager(manager);
56
+ // } else if (itemServiceConfigResult) {
57
+ // // Direct config provided
58
+ // const manager = createServicesManager(
59
+ // createServicesMap()
60
+ // .addService(CurrentCartServiceDefinition, CurrentCartService, currentCartServiceConfig)
61
+ // // .addService(ItemServiceDefinition, ItemService, itemServiceConfigResult)
62
+ // );
63
+ // setServicesManager(manager);
64
+ // } else {
65
+ // // Only cart service, no item service
66
+ // const manager = createServicesManager(
67
+ // createServicesMap()
68
+ // .addService(CurrentCartServiceDefinition, CurrentCartService, currentCartServiceConfig)
69
+ // );
70
+ // setServicesManager(manager);
71
+ // }
72
+ // } catch (err) {
73
+ // console.error('Failed to initialize services:', err);
74
+ // setError('Failed to initialize services');
75
+ // } finally {
76
+ // setIsLoading(false);
77
+ // }
78
+ // };
79
+ // initializeServices();
80
+ }, [itemId, itemServiceConfig, cartServiceConfig]);
81
+ // const hasServices = Boolean(servicesManager);
82
+ // return children({
83
+ // servicesManager,
84
+ // isLoading,
85
+ // error,
86
+ // hasServices
87
+ // });
88
+ console.log('oloSettingsServiceConfig', oloSettingsServiceConfig);
89
+ return (_jsx(WixServices, { servicesMap: createServicesMap().addService(OLOSettingsServiceDefinition, OLOSettingsService, oloSettingsServiceConfig), children: children }));
90
+ };
91
+ /**
92
+ * Convenience wrapper that combines Root with ServicesManagerProvider
93
+ * Automatically provides services context to children
94
+ *
95
+ * @example
96
+ * ```tsx
97
+ * <CoreOLO.Provider itemId="item-123">
98
+ * <ItemDetailsComponents />
99
+ * </CoreOLO.Provider>
100
+ * ```
101
+ */
102
+ export const Provider = ({ itemId, itemServiceConfig, cartServiceConfig, oloSettingsServiceConfig,
103
+ // loading = <div>Loading services...</div>,
104
+ // error: errorComponent = (error: string) => <div>Error: {error}</div>,
105
+ children, }) => {
106
+ return (_jsx(Root, { itemId: itemId, itemServiceConfig: itemServiceConfig, cartServiceConfig: cartServiceConfig, oloSettingsServiceConfig: oloSettingsServiceConfig, children: children }));
107
+ };
108
+ /**
109
+ * Specialized wrapper for item details that ensures ItemService is available
110
+ *
111
+ * @example
112
+ * ```tsx
113
+ * <CoreOLO.ItemDetails itemId="item-123">
114
+ * <ItemDetailsPrimitive.Root>
115
+ * {({ item }) => <div>{item.name}</div>}
116
+ * </ItemDetailsPrimitive.Root>
117
+ * </CoreOLO.ItemDetails>
118
+ * ```
119
+ */
120
+ export const ItemDetails = ({ itemId, configs, loading, error, children, }) => {
121
+ return (_jsx(Provider, { itemId: itemId, itemServiceConfig: configs?.itemServiceConfig, cartServiceConfig: configs?.cartServiceConfig, loading: loading, error: error, children: children }));
122
+ };
@@ -0,0 +1,3 @@
1
+ export * as CoreItemDetails from './ItemDetails.js';
2
+ export { CoreClickableItem } from './ClickableItem.js';
3
+ export * as CoreOLO from './OLO.js';
@@ -0,0 +1,3 @@
1
+ export * as CoreItemDetails from './ItemDetails.js';
2
+ export { CoreClickableItem } from './ClickableItem.js';
3
+ export * as CoreOLO from './OLO.js';
@@ -0,0 +1,3 @@
1
+ export * as ItemDetails from './ItemDetails.js';
2
+ export * as ClickableItem from './ClickableItem.js';
3
+ export * as OLO from './OLO.js';
@@ -0,0 +1,3 @@
1
+ export * as ItemDetails from './ItemDetails.js';
2
+ export * as ClickableItem from './ClickableItem.js';
3
+ export * as OLO from './OLO.js';
@@ -0,0 +1,19 @@
1
+ import * as currentCart from '@wix/auto_sdk_ecom_current-cart';
2
+ export type LineItem = currentCart.LineItem;
3
+ export type DescriptionLine = currentCart.DescriptionLine;
4
+ export declare enum AvailabilityStatus {
5
+ AVAILABLE = 0,
6
+ NOT_AVAILABLE = 1,
7
+ OUT_OF_STOCK = 2,
8
+ NEXT_AVAILABILITY_PICKUP = 3,
9
+ NEXT_AVAILABILITY_DELIVERY = 4
10
+ }
11
+ export type NextAvailability = AvailabilityStatus.NEXT_AVAILABILITY_PICKUP | AvailabilityStatus.NEXT_AVAILABILITY_DELIVERY;
12
+ export type AvailabilityStatusWithActionObject = {
13
+ text?: string;
14
+ buttonText?: string;
15
+ };
16
+ export type AvailabilityStatusObject = {
17
+ text?: string;
18
+ };
19
+ export type AvailabilityStatusMap = Partial<Record<Exclude<AvailabilityStatus, NextAvailability>, AvailabilityStatusObject>> & Record<NextAvailability, AvailabilityStatusWithActionObject>;
@@ -0,0 +1,8 @@
1
+ export var AvailabilityStatus;
2
+ (function (AvailabilityStatus) {
3
+ AvailabilityStatus[AvailabilityStatus["AVAILABLE"] = 0] = "AVAILABLE";
4
+ AvailabilityStatus[AvailabilityStatus["NOT_AVAILABLE"] = 1] = "NOT_AVAILABLE";
5
+ AvailabilityStatus[AvailabilityStatus["OUT_OF_STOCK"] = 2] = "OUT_OF_STOCK";
6
+ AvailabilityStatus[AvailabilityStatus["NEXT_AVAILABILITY_PICKUP"] = 3] = "NEXT_AVAILABILITY_PICKUP";
7
+ AvailabilityStatus[AvailabilityStatus["NEXT_AVAILABILITY_DELIVERY"] = 4] = "NEXT_AVAILABILITY_DELIVERY";
8
+ })(AvailabilityStatus || (AvailabilityStatus = {}));
@@ -0,0 +1,3 @@
1
+ export { ItemService, ItemServiceDefinition, loadItemServiceConfig, ItemServiceConfig, } from './item-details-service.js';
2
+ export { OLOSettingsService, OLOSettingsServiceDefinition, loadOLOSettingsServiceConfig, type OLOSettingsServiceConfig, type OLOSettingsServiceAPI, } from './olo-settings-service.js';
3
+ export { AvailabilityStatus, AvailabilityStatusMap } from './common-types.js';
@@ -0,0 +1,3 @@
1
+ export { ItemService, ItemServiceDefinition, loadItemServiceConfig, } from './item-details-service.js';
2
+ export { OLOSettingsService, OLOSettingsServiceDefinition, loadOLOSettingsServiceConfig, } from './olo-settings-service.js';
3
+ export { AvailabilityStatus } from './common-types.js';