@wix/headless-restaurants-olo 0.0.14 → 0.0.16

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 (85) hide show
  1. package/cjs/dist/mappers/operation-mapper.d.ts +3 -0
  2. package/cjs/dist/mappers/operation-mapper.js +95 -0
  3. package/cjs/dist/react/ItemDetails.d.ts +4 -162
  4. package/cjs/dist/react/ItemDetails.js +6 -78
  5. package/cjs/dist/react/ModifierGroup.d.ts +57 -0
  6. package/cjs/dist/react/ModifierGroup.js +61 -0
  7. package/cjs/dist/react/OLO.d.ts +3 -2
  8. package/cjs/dist/react/OLOMenus.d.ts +20 -0
  9. package/cjs/dist/react/OLOMenus.js +22 -0
  10. package/cjs/dist/react/Settings.d.ts +160 -0
  11. package/cjs/dist/react/Settings.js +94 -0
  12. package/cjs/dist/react/core/ItemDetails.d.ts +1 -11
  13. package/cjs/dist/react/core/ItemDetails.js +4 -21
  14. package/cjs/dist/react/core/ModifierGroup.d.ts +42 -0
  15. package/cjs/dist/react/core/ModifierGroup.js +67 -0
  16. package/cjs/dist/react/core/OLO.js +16 -2
  17. package/cjs/dist/react/core/OLOMenus.d.ts +7 -0
  18. package/cjs/dist/react/core/OLOMenus.js +12 -0
  19. package/cjs/dist/react/core/Settings.d.ts +157 -0
  20. package/cjs/dist/react/core/Settings.js +192 -0
  21. package/cjs/dist/react/core/index.d.ts +1 -0
  22. package/cjs/dist/react/core/index.js +1 -0
  23. package/cjs/dist/react/index.d.ts +3 -0
  24. package/cjs/dist/react/index.js +3 -0
  25. package/cjs/dist/services/common-types.d.ts +18 -0
  26. package/cjs/dist/services/common-types.js +10 -0
  27. package/cjs/dist/services/fulfillments-service.d.ts +13 -0
  28. package/cjs/dist/services/fulfillments-service.js +64 -0
  29. package/cjs/dist/services/index.d.ts +1 -0
  30. package/cjs/dist/services/index.js +1 -0
  31. package/cjs/dist/services/item-details-service.d.ts +2 -0
  32. package/cjs/dist/services/item-details-service.js +8 -1
  33. package/cjs/dist/services/olo-settings-service.d.ts +14 -8
  34. package/cjs/dist/services/olo-settings-service.js +24 -5
  35. package/cjs/dist/services/utils.d.ts +17 -0
  36. package/cjs/dist/services/utils.js +104 -0
  37. package/cjs/dist/types/fulfillments-types.d.ts +33 -0
  38. package/cjs/dist/types/fulfillments-types.js +7 -0
  39. package/cjs/dist/types/operation.d.ts +57 -0
  40. package/cjs/dist/types/operation.js +1 -0
  41. package/cjs/dist/utils/fulfillments-utils.d.ts +23 -0
  42. package/cjs/dist/utils/fulfillments-utils.js +144 -0
  43. package/dist/mappers/operation-mapper.d.ts +3 -0
  44. package/dist/mappers/operation-mapper.js +95 -0
  45. package/dist/react/ItemDetails.d.ts +4 -162
  46. package/dist/react/ItemDetails.js +6 -78
  47. package/dist/react/ModifierGroup.d.ts +57 -0
  48. package/dist/react/ModifierGroup.js +61 -0
  49. package/dist/react/OLO.d.ts +3 -2
  50. package/dist/react/OLOMenus.d.ts +20 -0
  51. package/dist/react/OLOMenus.js +22 -0
  52. package/dist/react/Settings.d.ts +160 -0
  53. package/dist/react/Settings.js +94 -0
  54. package/dist/react/core/ItemDetails.d.ts +1 -11
  55. package/dist/react/core/ItemDetails.js +4 -21
  56. package/dist/react/core/ModifierGroup.d.ts +42 -0
  57. package/dist/react/core/ModifierGroup.js +67 -0
  58. package/dist/react/core/OLO.js +16 -2
  59. package/dist/react/core/OLOMenus.d.ts +7 -0
  60. package/dist/react/core/OLOMenus.js +12 -0
  61. package/dist/react/core/Settings.d.ts +157 -0
  62. package/dist/react/core/Settings.js +192 -0
  63. package/dist/react/core/index.d.ts +1 -0
  64. package/dist/react/core/index.js +1 -0
  65. package/dist/react/index.d.ts +3 -0
  66. package/dist/react/index.js +3 -0
  67. package/dist/services/common-types.d.ts +18 -0
  68. package/dist/services/common-types.js +10 -0
  69. package/dist/services/fulfillments-service.d.ts +13 -0
  70. package/dist/services/fulfillments-service.js +64 -0
  71. package/dist/services/index.d.ts +1 -0
  72. package/dist/services/index.js +1 -0
  73. package/dist/services/item-details-service.d.ts +2 -0
  74. package/dist/services/item-details-service.js +8 -1
  75. package/dist/services/olo-settings-service.d.ts +14 -8
  76. package/dist/services/olo-settings-service.js +24 -5
  77. package/dist/services/utils.d.ts +17 -0
  78. package/dist/services/utils.js +104 -0
  79. package/dist/types/fulfillments-types.d.ts +33 -0
  80. package/dist/types/fulfillments-types.js +7 -0
  81. package/dist/types/operation.d.ts +57 -0
  82. package/dist/types/operation.js +1 -0
  83. package/dist/utils/fulfillments-utils.d.ts +23 -0
  84. package/dist/utils/fulfillments-utils.js +144 -0
  85. package/package.json +5 -6
@@ -0,0 +1,3 @@
1
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
+ import { Operation } from '../types/operation.js';
3
+ export declare const OperationMapper: (operation: operationsSDK.Operation) => Operation;
@@ -0,0 +1,95 @@
1
+ import * as operationsSDK from '@wix/auto_sdk_restaurants_operations';
2
+ import { DispatchType } from '../types/fulfillments-types.js';
3
+ const TIME_UNIT_MULTIPLIER = {
4
+ MINUTES: 1,
5
+ UNKNOWN_TIME_UNIT: 0,
6
+ DAYS: 24 * 60,
7
+ HOURS: 60,
8
+ };
9
+ const getAsapOptionsFromOperation = (operation) => {
10
+ if (!operation.orderScheduling?.asapOptions) {
11
+ return;
12
+ }
13
+ const { timeRangeOptions, maxTimeOptions } = operation.orderScheduling.asapOptions.preparationTime || {};
14
+ if (maxTimeOptions &&
15
+ maxTimeOptions.duration !== null &&
16
+ maxTimeOptions.duration !== undefined &&
17
+ maxTimeOptions.timeUnit) {
18
+ return {
19
+ maxInMinutes: maxTimeOptions.duration * TIME_UNIT_MULTIPLIER[maxTimeOptions.timeUnit],
20
+ };
21
+ }
22
+ if (timeRangeOptions &&
23
+ timeRangeOptions.timeUnit &&
24
+ timeRangeOptions.maxDuration !== undefined &&
25
+ timeRangeOptions.maxDuration !== null &&
26
+ timeRangeOptions.minDuration !== undefined &&
27
+ timeRangeOptions.minDuration !== null) {
28
+ return {
29
+ rangeInMinutes: {
30
+ min: timeRangeOptions.minDuration *
31
+ TIME_UNIT_MULTIPLIER[timeRangeOptions.timeUnit],
32
+ max: timeRangeOptions.maxDuration *
33
+ TIME_UNIT_MULTIPLIER[timeRangeOptions.timeUnit],
34
+ },
35
+ };
36
+ }
37
+ };
38
+ function getPreOrderOptions(operation) {
39
+ if (!operation.orderScheduling?.preorderOptions) {
40
+ return;
41
+ }
42
+ const timeBoundedOptions = operation.orderScheduling?.preorderOptions?.method?.timeBoundedOptions;
43
+ if (!timeBoundedOptions) {
44
+ return;
45
+ }
46
+ const { maxTimeInAdvance, minTimeInAdvance } = timeBoundedOptions;
47
+ const max = TIME_UNIT_MULTIPLIER[maxTimeInAdvance?.timeUnit] *
48
+ maxTimeInAdvance?.duration;
49
+ const min = TIME_UNIT_MULTIPLIER[minTimeInAdvance?.timeUnit] *
50
+ minTimeInAdvance?.duration;
51
+ const timeWindowsOptions = operation.orderScheduling?.preorderOptions?.fulfillmentTimesDisplay
52
+ ?.timeWindowsOptions;
53
+ const timeWindowDuration = TIME_UNIT_MULTIPLIER[timeWindowsOptions.timeUnit] *
54
+ timeWindowsOptions.duration;
55
+ return {
56
+ timeInAdvance: { min, max },
57
+ timeWindowDuration,
58
+ };
59
+ }
60
+ function getOperationType(operation) {
61
+ switch (operation.orderScheduling?.type) {
62
+ case operationsSDK.SchedulingType.PREORDER:
63
+ return 'PRE_ORDER';
64
+ case operationsSDK.SchedulingType.ASAP:
65
+ default:
66
+ return 'ASAP';
67
+ }
68
+ }
69
+ export const OperationMapper = (operation) => {
70
+ const { asapFutureHandlingType, businessDaysAheadHandlingOptions } = operation.orderScheduling?.asapOptions || {};
71
+ const { daysCount } = businessDaysAheadHandlingOptions || {};
72
+ const allowAsapFutureHandling = asapFutureHandlingType ===
73
+ operationsSDK.AsapFutureHandlingType.BUSINESS_DAYS_AHEAD_HANDLING &&
74
+ Number(daysCount) >= 0;
75
+ return {
76
+ id: operation._id || '',
77
+ name: operation.name || '',
78
+ // @ts-expect-error - operation is not typed
79
+ enabled: !!operation.enabled,
80
+ fulfillmentIds: operation.fulfillmentIds || [],
81
+ asapOptions: getAsapOptionsFromOperation(operation),
82
+ preOrderOptions: getPreOrderOptions(operation),
83
+ operationType: getOperationType(operation),
84
+ allowAsapFutureHandling,
85
+ businessDaysAheadHandlingOptions: daysCount ?? undefined,
86
+ defaultDispatchType: operation.defaultFulfillmentType ===
87
+ operationsSDK.FulfillmentType.DELIVERY
88
+ ? DispatchType.DELIVERY
89
+ : DispatchType.PICKUP,
90
+ operationGroupId: operation.operationGroupId || '',
91
+ locationId: operation.businessLocationId || '',
92
+ // @ts-expect-error - operation is not typed
93
+ locationDetails: operation.businessLocationDetails,
94
+ };
95
+ };
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Commerce } from '@wix/ecom/components';
3
- import { type LineItem } from '@wix/ecom/services';
4
3
  import { type AsChildChildren } from '@wix/headless-utils/react';
5
4
  import { ItemServiceConfig } from '../services/item-details-service.js';
6
- import { EnhancedModifier, EnhancedModifierGroup, EnhancedVariant } from '@wix/headless-restaurants-menus/services';
5
+ import { EnhancedVariant } from '@wix/headless-restaurants-menus/services';
7
6
  import { AvailabilityStatus, AvailabilityStatusMap } from '../services/common-types.js';
8
7
  /**
9
8
  * Root component for menu item display and interaction.
@@ -26,136 +25,6 @@ export interface RootProps {
26
25
  itemDetailsServiceConfig?: ItemServiceConfig;
27
26
  }
28
27
  export declare const Root: ({ children, itemDetailsServiceConfig }: RootProps) => import("react/jsx-runtime").JSX.Element;
29
- /**
30
- * Displays the item name with customizable rendering.
31
- *
32
- * @component
33
- * @example
34
- * ```tsx
35
- * <ItemDetails.Name />
36
- * <ItemDetails.Name asChild>
37
- * <h2 className="font-heading text-lg" />
38
- * </ItemDetails.Name>
39
- * ```
40
- */
41
- export interface ItemDetailsNameProps {
42
- asChild?: boolean;
43
- /** Custom render function when using asChild */
44
- children?: AsChildChildren<{
45
- name: string;
46
- }>;
47
- /** CSS classes to apply to the default element */
48
- className?: string;
49
- }
50
- export declare const Name: React.ForwardRefExoticComponent<ItemDetailsNameProps & React.RefAttributes<HTMLElement>>;
51
- /**
52
- * Displays the item price with customizable rendering.
53
- *
54
- * @component
55
- * @example
56
- * ```tsx
57
- * <ItemDetails.Price />
58
- * <ItemDetails.Price asChild>
59
- * <span className="font-semibold text-lg" />
60
- * </ItemDetails.Price>
61
- * ```
62
- */
63
- export interface ItemDetailsPriceProps {
64
- asChild?: boolean;
65
- /** CSS classes to apply to the default element */
66
- className?: string;
67
- }
68
- export declare const Price: React.ForwardRefExoticComponent<ItemDetailsPriceProps & React.RefAttributes<HTMLElement>>;
69
- /**
70
- * Displays the item description with customizable rendering.
71
- *
72
- * @component
73
- * @example
74
- * ```tsx
75
- * <ItemDetails.Description />
76
- * <ItemDetails.Description asChild>
77
- * <p className="text-sm" />
78
- * </ItemDetails.Description>
79
- * ```
80
- */
81
- export interface ItemDetailsDescriptionProps {
82
- asChild?: boolean;
83
- /** CSS classes to apply to the default element */
84
- className?: string;
85
- }
86
- export declare const Description: React.ForwardRefExoticComponent<ItemDetailsDescriptionProps & React.RefAttributes<HTMLElement>>;
87
- /**
88
- * Wrapper component for CoreItemDetails.ModifierComponent.
89
- * Renders a single modifier with checkbox functionality.
90
- *
91
- * @component
92
- * @example
93
- * ```tsx
94
- * <ItemDetails.Modifier>
95
- * {({ modifier, isSelected, onToggle }) => (
96
- * <div style={{ display: "flex", alignItems: "center" }}>
97
- * <CheckboxPrimitive.Root
98
- * className="CheckboxRoot"
99
- * checked={isSelected}
100
- * onCheckedChange={onToggle}
101
- * id={modifier._id}
102
- * >
103
- * <CheckboxPrimitive.Indicator className="CheckboxIndicator">
104
- * <CheckIcon />
105
- * </CheckboxPrimitive.Indicator>
106
- * </CheckboxPrimitive.Root>
107
- * <label className="Label" htmlFor={modifier._id}>
108
- * {modifier.name}
109
- * </label>
110
- * </div>
111
- * )}
112
- * </ItemDetails.Modifier>
113
- * ```
114
- */
115
- export interface ItemDetailsModifiersSingleSelectProps {
116
- children?: AsChildChildren<{
117
- selectedModifierIds: string[];
118
- onToggle: (modifierId: string) => void;
119
- modifierGroup: EnhancedModifierGroup;
120
- modifiers: EnhancedModifier[];
121
- }>;
122
- className?: string;
123
- asChild?: boolean;
124
- modifierNameClassName?: string;
125
- modifierPriceClassName?: string;
126
- }
127
- export interface ModifierCheckboxProps {
128
- selectedModifierIds: string[];
129
- onToggle: (modifierId: string) => void;
130
- className?: string;
131
- asChild?: boolean;
132
- modifierNameClassName?: string;
133
- modifierPriceClassName?: string;
134
- children?: AsChildChildren<{
135
- selectedModifierIds: string[];
136
- onToggle: (modifierId: string) => void;
137
- }>;
138
- }
139
- export declare const ModifierCheckbox: React.ForwardRefExoticComponent<ModifierCheckboxProps & React.RefAttributes<HTMLElement>>;
140
- export interface ModifierRadioProps {
141
- modifierNameClassName?: string;
142
- modifierPriceClassName?: string;
143
- }
144
- export declare const ModifierRadio: React.ForwardRefExoticComponent<ModifierRadioProps & React.RefAttributes<HTMLElement>>;
145
- export declare const ModifiersSingleSelect: React.ForwardRefExoticComponent<ItemDetailsModifiersSingleSelectProps & React.RefAttributes<HTMLElement>>;
146
- export interface ItemDetailsModifiersMultiSelectProps {
147
- children?: AsChildChildren<{
148
- selectedModifierIds: string[];
149
- onToggle: (modifierId: string) => void;
150
- modifierGroup: EnhancedModifierGroup;
151
- modifiers: EnhancedModifier[];
152
- }>;
153
- className?: string;
154
- asChild?: boolean;
155
- modifierNameClassName?: string;
156
- modifierPriceClassName?: string;
157
- }
158
- export declare const ModifiersMultiSelect: React.ForwardRefExoticComponent<ItemDetailsModifiersMultiSelectProps & React.RefAttributes<HTMLElement>>;
159
28
  /**
160
29
  * Wrapper component for CoreItemDetails.VariantsComponent.
161
30
  * Renders the variants for the item using Radix UI RadioGroup.
@@ -170,7 +39,9 @@ export declare const ModifiersMultiSelect: React.ForwardRefExoticComponent<ItemD
170
39
  */
171
40
  export interface ItemDetailsVariantsProps {
172
41
  children?: AsChildChildren<{
42
+ variant: EnhancedVariant;
173
43
  variants: EnhancedVariant[];
44
+ hasVariants: boolean;
174
45
  selectedVariantId?: string;
175
46
  onVariantChange?: (variantId: string) => void;
176
47
  }>;
@@ -178,37 +49,9 @@ export interface ItemDetailsVariantsProps {
178
49
  asChild?: boolean;
179
50
  variantNameClassName?: string;
180
51
  variantPriceClassName?: string;
52
+ emptyState?: React.ReactNode;
181
53
  }
182
54
  export declare const Variants: React.ForwardRefExoticComponent<ItemDetailsVariantsProps & React.RefAttributes<HTMLElement>>;
183
- export interface AddToCartActionProps {
184
- /** Whether to render as a child component */
185
- asChild?: boolean;
186
- /** Text label for the button */
187
- label: string;
188
- /** Custom render function when using asChild */
189
- lineItems: LineItem[];
190
- /** CSS classes to apply to the button */
191
- className?: string;
192
- /** Content to display when loading */
193
- loadingState?: string | React.ReactNode;
194
- children?: React.ReactNode;
195
- }
196
- /**
197
- * Add to Cart button for the menu item.
198
- * Triggers the action to add the selected item (and its modifiers/variants) to the cart.
199
- *
200
- * @component
201
- * @example
202
- * ```tsx
203
- * <ItemDetails>
204
- * <AddToCart
205
- * label="Add to Cart"
206
- * lineItems={[{ catalogReference: { ... }, quantity: 1 }]}
207
- * />
208
- * </ItemDetails>
209
- * ```
210
- */
211
- export declare const AddToCart: React.ForwardRefExoticComponent<AddToCartActionProps & React.RefAttributes<HTMLButtonElement>>;
212
55
  /**
213
56
  * Multi-line text input component for special requests or instructions.
214
57
  * Provides a textarea for customers to add custom notes or modifications.
@@ -256,7 +99,6 @@ export interface AddToCartButtonProps extends Omit<React.ComponentPropsWithoutRe
256
99
  children?: React.ReactNode;
257
100
  className?: string;
258
101
  label?: string;
259
- onClick?: () => void;
260
102
  }
261
103
  export interface ItemDetailsQuantityProps {
262
104
  children: React.ReactNode;
@@ -4,8 +4,7 @@ import { Commerce } from '@wix/ecom/components';
4
4
  import { AsChildSlot } from '@wix/headless-utils/react';
5
5
  import { Quantity as QuantityComponent } from '@wix/headless-components/react';
6
6
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
7
- import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
8
- import { Item, Modifier, ModifierGroup, useModifierContext, } from '@wix/headless-restaurants-menus/react';
7
+ import { Item } from '@wix/headless-restaurants-menus/react';
9
8
  import * as CoreItemDetails from './core/ItemDetails.js';
10
9
  import { AvailabilityStatus, } from '../services/common-types.js';
11
10
  var TestIds;
@@ -18,69 +17,19 @@ var TestIds;
18
17
  TestIds["itemSpecialRequest"] = "item-special-request";
19
18
  TestIds["itemLabels"] = "item-labels";
20
19
  TestIds["itemVariants"] = "item-variants";
21
- TestIds["itemModifier"] = "item-modifier";
22
20
  TestIds["itemAvailability"] = "item-availability";
23
21
  })(TestIds || (TestIds = {}));
24
- const CheckIcon = () => (_jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z", fill: "currentColor" }) }));
25
22
  export const Root = ({ children, itemDetailsServiceConfig }) => {
26
23
  return (_jsx(CoreItemDetails.Root, { itemDetailsServiceConfig: itemDetailsServiceConfig, children: ({ item }) => _jsx(Item.Root, { item: item, children: children }) }));
27
24
  };
28
- export const Name = React.forwardRef(({ asChild, children, className, ...rest }, ref) => {
29
- return (_jsx(Item.Name, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.itemName, ...rest, children: children }));
30
- });
31
- Name.displayName = 'ItemDetails.Name';
32
- export const Price = React.forwardRef(({ asChild, className, ...rest }, ref) => {
33
- return (_jsx(Item.Price, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.itemPrice, ...rest }));
34
- });
35
- Price.displayName = 'ItemDetails.Price';
36
- export const Description = React.forwardRef(({ asChild, className, ...rest }, ref) => {
37
- return (_jsx(Item.Description, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.itemDescription, ...rest }));
38
- });
39
- Description.displayName = 'ItemDetails.Description';
40
- export const ModifierCheckbox = React.forwardRef(({ selectedModifierIds, onToggle, className, asChild, modifierNameClassName, modifierPriceClassName, children, ...rest }) => {
41
- const { modifier } = useModifierContext();
42
- const isSelected = selectedModifierIds.includes(modifier._id || '');
43
- return (_jsx(AsChildSlot, { asChild: asChild, testId: TestIds.itemModifier, className: className, customElement: children, customElementProps: {
44
- selectedModifierIds,
45
- onToggle,
46
- }, ...rest, children: _jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx(CheckboxPrimitive.Root, { className: "CheckboxRoot", checked: isSelected, onCheckedChange: () => onToggle(modifier._id || ''), id: modifier._id || undefined, children: _jsx(CheckboxPrimitive.Indicator, { className: "CheckboxIndicator", children: _jsx(CheckIcon, {}) }) }), _jsxs("label", { className: "Label", htmlFor: modifier._id || undefined, children: [_jsx(Modifier.Name, { className: modifierNameClassName }), _jsx(Modifier.Price, { className: modifierPriceClassName })] })] }) }));
47
- });
48
- ModifierCheckbox.displayName = 'ItemDetails.ModifierCheckbox';
49
- export const ModifierRadio = React.forwardRef(({ modifierNameClassName, modifierPriceClassName }) => {
50
- const { modifier } = useModifierContext();
51
- return (_jsx(RadioGroupPrimitive.Item, { className: "RadioGroupItem", value: modifier._id || '', id: modifier._id || undefined, children: _jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx(RadioGroupPrimitive.Indicator, { className: "RadioGroupIndicator" }), _jsxs("label", { className: "Label", htmlFor: modifier._id || undefined, children: [_jsx(Modifier.Name, { className: modifierNameClassName }), _jsx(Modifier.Price, { className: modifierPriceClassName })] })] }) }));
52
- });
53
- ModifierRadio.displayName = 'ItemDetails.ModifierRadio';
54
- export const ModifiersSingleSelect = React.forwardRef(({ children, className, asChild, modifierNameClassName, modifierPriceClassName, ...rest }) => {
55
- return (_jsx(CoreItemDetails.ModifiersComponent, { singleSelect: true, children: ({ selectedModifierIds, onToggle, modifierGroup, modifiers }) => {
56
- const selectedModifierId = selectedModifierIds.length > 0 ? selectedModifierIds[0] : '';
57
- return (_jsx(AsChildSlot, { asChild: asChild, testId: TestIds.itemModifier, className: className, customElement: children, customElementProps: {
58
- selectedModifierIds,
59
- onToggle,
60
- modifierGroup,
61
- modifiers,
62
- }, ...rest, children: _jsx(RadioGroupPrimitive.Root, { value: selectedModifierId, onValueChange: onToggle, children: _jsx(ModifierGroup.ModifiersRepeater, { children: _jsx(ModifierRadio, { modifierNameClassName: modifierNameClassName, modifierPriceClassName: modifierPriceClassName }) }) }) }));
63
- } }));
64
- });
65
- ModifiersSingleSelect.displayName = 'ItemDetails.ModifiersSingleSelect';
66
- export const ModifiersMultiSelect = React.forwardRef(({ children, className, asChild, modifierNameClassName, modifierPriceClassName, ...rest }) => {
67
- return (_jsx(CoreItemDetails.ModifiersComponent, { singleSelect: false, children: ({ selectedModifierIds, onToggle, modifierGroup, modifiers }) => {
68
- return (_jsx(AsChildSlot, { asChild: asChild, testId: TestIds.itemModifier, className: className, customElement: children, customElementProps: {
69
- selectedModifierIds,
70
- onToggle,
71
- modifierGroup,
72
- modifiers,
73
- }, ...rest, children: _jsx(ModifierGroup.ModifiersRepeater, { children: _jsx(ModifierCheckbox, { selectedModifierIds: selectedModifierIds, onToggle: onToggle, modifierNameClassName: modifierNameClassName, modifierPriceClassName: modifierPriceClassName }) }) }));
74
- } }));
75
- });
76
- ModifiersMultiSelect.displayName = 'ItemDetails.ModifiersMultiSelect';
77
- export const Variants = React.forwardRef(({ children, className, asChild, variantNameClassName, variantPriceClassName, }, ref) => {
25
+ export const Variants = React.forwardRef(({ children, className, asChild, variantNameClassName, variantPriceClassName, emptyState, }, ref) => {
78
26
  return (_jsx(CoreItemDetails.VariantsComponent, { children: ({ variants, hasVariants, selectedVariantId, onVariantChange }) => {
79
27
  if (!hasVariants) {
80
- return null;
28
+ return emptyState || null;
81
29
  }
82
30
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, testId: TestIds.itemVariants, className: className, customElement: children, customElementProps: {
83
31
  variants,
32
+ hasVariants,
84
33
  selectedVariantId,
85
34
  onVariantChange,
86
35
  }, children: _jsx(RadioGroupPrimitive.Root, { value: selectedVariantId, onValueChange: onVariantChange, children: variants.map((variant) => (_jsx(RadioGroupPrimitive.Item, { value: variant._id ?? '', children: _jsxs("div", { children: [_jsx("div", { className: variantNameClassName, children: variant.name }), _jsx("div", { className: variantPriceClassName, children: variant.priceInfo?.formattedPrice ||
@@ -89,29 +38,8 @@ export const Variants = React.forwardRef(({ children, className, asChild, varian
89
38
  } }));
90
39
  });
91
40
  Variants.displayName = 'ItemDetails.Variants';
92
- /**
93
- * Add to Cart button for the menu item.
94
- * Triggers the action to add the selected item (and its modifiers/variants) to the cart.
95
- *
96
- * @component
97
- * @example
98
- * ```tsx
99
- * <ItemDetails>
100
- * <AddToCart
101
- * label="Add to Cart"
102
- * lineItems={[{ catalogReference: { ... }, quantity: 1 }]}
103
- * />
104
- * </ItemDetails>
105
- * ```
106
- */
107
- export const AddToCart = React.forwardRef(({ lineItems, className, label, ...props }, ref) => {
108
- return (_jsx(Commerce.Actions.AddToCart, { ref: ref, asChild: false, label: label, className: className, lineItems: lineItems, children: props.children }));
109
- });
110
- AddToCart.displayName = 'AddToCart';
111
- export const AddToCartButton = ({ asChild = false, children, className, onClick, label = 'Add to cart', ...props }) => {
112
- return (_jsx(CoreItemDetails.LineItemComponent, { children: ({ lineItem }) => (_jsx(AsChildSlot, { asChild: asChild, className: className, customElement: children, customElementProps: {
113
- onClick,
114
- }, children: _jsx(Commerce.Actions.AddToCart, { asChild: false, label: label, className: className, lineItems: [lineItem], ...props, children: children }) })) }));
41
+ export const AddToCartButton = ({ asChild, children, className, label = 'Add to cart', ...props }) => {
42
+ return (_jsx(CoreItemDetails.LineItemComponent, { children: ({ lineItem }) => (_jsx(Commerce.Actions.AddToCart, { asChild: asChild, label: label, className: className, lineItems: [lineItem], ...props, children: children })) }));
115
43
  };
116
44
  export const Quantity = ({ children }) => {
117
45
  return (_jsx(CoreItemDetails.QuantityComponent, { children: ({ quantity, onValueChange, }) => (_jsx(QuantityComponent.Root, { onValueChange: onValueChange, initialValue: quantity, children: children })) }));
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { type AsChildChildren } from '@wix/headless-utils/react';
3
+ import { EnhancedModifier, EnhancedModifierGroup } from '@wix/headless-restaurants-menus/services';
4
+ import { RuleTypeMap } from '../services/common-types.js';
5
+ export interface ItemDetailsModifierGroupProps {
6
+ children: React.ReactNode;
7
+ }
8
+ export interface ModifiersProps {
9
+ className?: string;
10
+ asChild?: boolean;
11
+ modifierNameClassName?: string;
12
+ modifierPriceClassName?: string;
13
+ children?: AsChildChildren<{
14
+ selectedModifierIds: string[];
15
+ onToggle: (modifierId: string) => void;
16
+ modifierGroup: EnhancedModifierGroup;
17
+ modifiers: EnhancedModifier[];
18
+ isSingleSelect: boolean;
19
+ }>;
20
+ }
21
+ export interface ModifierCheckboxProps {
22
+ selectedModifierIds: string[];
23
+ onToggle: (modifierId: string) => void;
24
+ className?: string;
25
+ modifierNameClassName?: string;
26
+ modifierPriceClassName?: string;
27
+ }
28
+ export interface ModifierRadioProps {
29
+ modifierNameClassName?: string;
30
+ modifierPriceClassName?: string;
31
+ }
32
+ export declare const Root: React.ForwardRefExoticComponent<ItemDetailsModifierGroupProps & React.RefAttributes<HTMLElement>>;
33
+ export declare const Modifiers: React.ForwardRefExoticComponent<ModifiersProps & React.RefAttributes<HTMLElement>>;
34
+ export interface DescriptionProps {
35
+ ruleTypeMap: RuleTypeMap;
36
+ className?: string;
37
+ asChild?: boolean;
38
+ children?: AsChildChildren<{
39
+ description: string;
40
+ }>;
41
+ }
42
+ export declare const Description: React.ForwardRefExoticComponent<DescriptionProps & React.RefAttributes<HTMLElement>>;
43
+ export interface ErrorProps {
44
+ ruleTypeMap: RuleTypeMap;
45
+ className?: string;
46
+ asChild?: boolean;
47
+ children?: AsChildChildren<{
48
+ error: string;
49
+ }>;
50
+ }
51
+ export declare const Error: React.ForwardRefExoticComponent<ErrorProps & React.RefAttributes<HTMLElement>>;
52
+ export declare const ModifierGroup: {
53
+ readonly Root: React.ForwardRefExoticComponent<ItemDetailsModifierGroupProps & React.RefAttributes<HTMLElement>>;
54
+ readonly Modifiers: React.ForwardRefExoticComponent<ModifiersProps & React.RefAttributes<HTMLElement>>;
55
+ readonly Description: React.ForwardRefExoticComponent<DescriptionProps & React.RefAttributes<HTMLElement>>;
56
+ readonly Error: React.ForwardRefExoticComponent<ErrorProps & React.RefAttributes<HTMLElement>>;
57
+ };
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { AsChildSlot } from '@wix/headless-utils/react';
4
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
5
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
6
+ import { Modifier, ModifierGroup as ModifierGroupComponents, useModifierContext, } from '@wix/headless-restaurants-menus/react';
7
+ import { ModifierGroupComponent, ModifiersComponent, Description as DescriptionComponent, GroupError, } from './core/ModifierGroup.js';
8
+ var TestIds;
9
+ (function (TestIds) {
10
+ TestIds["modifiers"] = "modifiers";
11
+ TestIds["modifierGroupDescription"] = "modifier-group-description";
12
+ TestIds["modifierGroupError"] = "modifier-group-error";
13
+ })(TestIds || (TestIds = {}));
14
+ const CheckIcon = () => (_jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z", fill: "currentColor" }) }));
15
+ export const Root = React.forwardRef(({ children }) => {
16
+ return _jsx(ModifierGroupComponent, { children: children });
17
+ });
18
+ Root.displayName = 'ItemDetailsModifierGroup.Root';
19
+ export const Modifiers = React.forwardRef(({ className, asChild, modifierNameClassName, modifierPriceClassName, children, }, ref) => {
20
+ return (_jsx(ModifiersComponent, { children: ({ selectedModifierIds, onToggle, modifierGroup, modifiers, isSingleSelect, singleSelectedModifierId, }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, testId: TestIds.modifiers, className: className, customElement: children, customElementProps: {
21
+ selectedModifierIds,
22
+ onToggle,
23
+ modifierGroup,
24
+ modifiers,
25
+ isSingleSelect,
26
+ }, children: isSingleSelect ? (_jsx(RadioGroupPrimitive.Root, { value: singleSelectedModifierId, onValueChange: onToggle, children: _jsx(ModifierGroupComponents.ModifiersRepeater, { children: _jsx(ModifierRadio, { modifierNameClassName: modifierNameClassName, modifierPriceClassName: modifierPriceClassName }) }) })) : (_jsx(ModifierGroupComponents.ModifiersRepeater, { children: _jsx(ModifierCheckbox, { selectedModifierIds: selectedModifierIds, onToggle: onToggle, modifierNameClassName: modifierNameClassName, modifierPriceClassName: modifierPriceClassName }) })) })) }));
27
+ });
28
+ Modifiers.displayName = 'ItemDetailsModifierGroup.Modifiers';
29
+ const ModifierCheckbox = ({ selectedModifierIds, onToggle, className, modifierNameClassName, modifierPriceClassName, }) => {
30
+ const { modifier } = useModifierContext();
31
+ const isSelected = selectedModifierIds.includes(modifier._id || '');
32
+ return (_jsxs("div", { className: className, style: { display: 'flex', alignItems: 'center' }, children: [_jsx(CheckboxPrimitive.Root, { className: "CheckboxRoot", checked: isSelected, onCheckedChange: () => onToggle(modifier._id || ''), id: modifier._id || undefined, disabled: !modifier.inStock, children: _jsx(CheckboxPrimitive.Indicator, { className: "CheckboxIndicator", children: _jsx(CheckIcon, {}) }) }), _jsxs("label", { className: "Label", htmlFor: modifier._id || undefined, children: [_jsx(Modifier.Name, { className: modifierNameClassName }), _jsx(Modifier.Price, { className: modifierPriceClassName })] })] }));
33
+ };
34
+ const ModifierRadio = ({ modifierNameClassName, modifierPriceClassName, }) => {
35
+ const { modifier } = useModifierContext();
36
+ return (_jsx(RadioGroupPrimitive.Item, { className: "RadioGroupItem", value: modifier._id || '', id: modifier._id || undefined, disabled: !modifier.inStock, children: _jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx(RadioGroupPrimitive.Indicator, { className: "RadioGroupIndicator" }), _jsxs("label", { className: "Label", htmlFor: modifier._id || undefined, children: [_jsx(Modifier.Name, { className: modifierNameClassName }), _jsx(Modifier.Price, { className: modifierPriceClassName })] })] }) }));
37
+ };
38
+ export const Description = React.forwardRef(({ ruleTypeMap, className, asChild, children }, ref) => {
39
+ return (_jsx(DescriptionComponent, { ruleTypeMap: ruleTypeMap, children: ({ description }) => {
40
+ if (!description) {
41
+ return null;
42
+ }
43
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, testId: TestIds.modifierGroupDescription, className: className, customElement: children, customElementProps: { description }, children: _jsx("p", { className: className, children: description }) }));
44
+ } }));
45
+ });
46
+ Description.displayName = 'ItemDetailsModifierGroup.Description';
47
+ export const Error = React.forwardRef(({ ruleTypeMap, className, asChild, children }, ref) => {
48
+ return (_jsx(GroupError, { ruleTypeMap: ruleTypeMap, children: ({ error }) => {
49
+ if (!error) {
50
+ return null;
51
+ }
52
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, testId: TestIds.modifierGroupError, className: className, customElement: children, customElementProps: { error }, children: _jsx("p", { className: className, children: error }) }));
53
+ } }));
54
+ });
55
+ Error.displayName = 'ItemDetailsModifierGroup.Error';
56
+ export const ModifierGroup = {
57
+ Root,
58
+ Modifiers,
59
+ Description,
60
+ Error,
61
+ };
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { ItemServiceConfig } from '../services/item-details-service.js';
3
+ import { OLOSettingsServiceConfig } from '../services/olo-settings-service.js';
3
4
  interface OLORootProps {
4
5
  /** The ID of the item to load */
5
6
  itemId?: string;
6
7
  /** Pre-loaded item service config (optional) */
7
- itemServiceConfig?: any;
8
+ itemServiceConfig?: ItemServiceConfig;
8
9
  /** Pre-loaded OLO settings service config (optional) */
9
- oloSettingsServiceConfig?: any;
10
+ oloSettingsServiceConfig?: OLOSettingsServiceConfig;
10
11
  /** Children render prop that receives the service state */
11
12
  children: React.ReactNode;
12
13
  }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { type MenusServiceConfig } from '@wix/headless-restaurants-menus/services';
3
+ declare enum TestIds {
4
+ menusRoot = "menus-root"
5
+ }
6
+ /**
7
+ * Menus.Root
8
+ * Container for the menus context and data loading.
9
+ * Does not render if there are no menus.
10
+ */
11
+ export interface MenusRootProps {
12
+ children: React.ReactNode;
13
+ config: MenusServiceConfig;
14
+ }
15
+ export declare const Root: React.ForwardRefExoticComponent<MenusRootProps & React.RefAttributes<HTMLElement>>;
16
+ export declare const OLOMenus: {
17
+ Root: React.ForwardRefExoticComponent<MenusRootProps & React.RefAttributes<HTMLElement>>;
18
+ TestIds: typeof TestIds;
19
+ };
20
+ export {};
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { Menus } from '@wix/headless-restaurants-menus/react';
4
+ import * as CoreOLOMenus from './core/OLOMenus.js';
5
+ // =======================
6
+ // TestIds Enum
7
+ // =======================
8
+ var TestIds;
9
+ (function (TestIds) {
10
+ // Container Level
11
+ TestIds["menusRoot"] = "menus-root";
12
+ })(TestIds || (TestIds = {}));
13
+ export const Root = React.forwardRef((props) => {
14
+ const { children, config } = props;
15
+ return (_jsx(CoreOLOMenus.Root, { "data-testid": TestIds.menusRoot, config: config, children: (updatedConfig) => (_jsx(Menus.Root, { "data-testid": TestIds.menusRoot, config: updatedConfig, children: children })) }));
16
+ });
17
+ Root.displayName = 'Menus.Root';
18
+ // Compose Menus namespace
19
+ export const OLOMenus = {
20
+ Root,
21
+ TestIds,
22
+ };