@dropins/storefront-quick-order 0.0.1-alpha1

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 (82) hide show
  1. package/LICENSE.md +188 -0
  2. package/api/fetch-graphql/fetch-graphql.d.ts +8 -0
  3. package/api/fetch-graphql/index.d.ts +2 -0
  4. package/api/index.d.ts +3 -0
  5. package/api/initialize/index.d.ts +2 -0
  6. package/api/initialize/initialize.d.ts +10 -0
  7. package/api.d.ts +1 -0
  8. package/api.js +4 -0
  9. package/api.js.map +1 -0
  10. package/chunks/CsvFileInput.js +4 -0
  11. package/chunks/CsvFileInput.js.map +1 -0
  12. package/chunks/Search.js +4 -0
  13. package/chunks/Search.js.map +1 -0
  14. package/components/CsvFileInput/CsvFileInput.d.ts +5 -0
  15. package/components/CsvFileInput/index.d.ts +19 -0
  16. package/components/QuickOrderItemsList/QuickOrderItemsList.d.ts +5 -0
  17. package/components/QuickOrderItemsList/index.d.ts +19 -0
  18. package/components/QuickOrderListItem/QuickOrderListItem.d.ts +5 -0
  19. package/components/QuickOrderListItem/index.d.ts +19 -0
  20. package/components/Search/Search.d.ts +4 -0
  21. package/components/Search/index.d.ts +19 -0
  22. package/components/SkuListInput/SkuListInput.d.ts +5 -0
  23. package/components/SkuListInput/index.d.ts +19 -0
  24. package/components/index.d.ts +22 -0
  25. package/configs/index.d.ts +19 -0
  26. package/configs/order-item.config.d.ts +4 -0
  27. package/configs/search-filter.config.d.ts +5 -0
  28. package/containers/QuickOrderCsvUpload/QuickOrderCsvUpload.d.ts +5 -0
  29. package/containers/QuickOrderCsvUpload/index.d.ts +19 -0
  30. package/containers/QuickOrderCsvUpload.d.ts +3 -0
  31. package/containers/QuickOrderCsvUpload.js +7 -0
  32. package/containers/QuickOrderCsvUpload.js.map +1 -0
  33. package/containers/QuickOrderItems/QuickOrderItems.d.ts +5 -0
  34. package/containers/QuickOrderItems/index.d.ts +19 -0
  35. package/containers/QuickOrderItems.d.ts +3 -0
  36. package/containers/QuickOrderItems.js +4 -0
  37. package/containers/QuickOrderItems.js.map +1 -0
  38. package/containers/QuickOrderMultipleSku/QuickOrderMultipleSku.d.ts +5 -0
  39. package/containers/QuickOrderMultipleSku/index.d.ts +19 -0
  40. package/containers/QuickOrderMultipleSku.d.ts +3 -0
  41. package/containers/QuickOrderMultipleSku.js +4 -0
  42. package/containers/QuickOrderMultipleSku.js.map +1 -0
  43. package/containers/index.d.ts +20 -0
  44. package/data/models/index.d.ts +2 -0
  45. package/data/transforms/index.d.ts +2 -0
  46. package/hooks/index.d.ts +21 -0
  47. package/hooks/useItemSearch.d.ts +11 -0
  48. package/hooks/useQuickOrderCsvUpload.d.ts +4 -0
  49. package/hooks/useQuickOrderItems.d.ts +4 -0
  50. package/hooks/useQuickOrderMultipleSku.d.ts +4 -0
  51. package/i18n/en_US.json.d.ts +66 -0
  52. package/lib/addOrMergeItems.d.ts +13 -0
  53. package/lib/buildCartItem.d.ts +32 -0
  54. package/lib/buildCartItemsFromForms.d.ts +8 -0
  55. package/lib/cleanCsvValue.d.ts +24 -0
  56. package/lib/findDuplicateItem.d.ts +19 -0
  57. package/lib/generateItemId.d.ts +22 -0
  58. package/lib/getItemScope.d.ts +8 -0
  59. package/lib/index.d.ts +35 -0
  60. package/lib/mapProductsToOrderItems.d.ts +11 -0
  61. package/lib/mergeDuplicateItems.d.ts +8 -0
  62. package/lib/processFormOptions.d.ts +29 -0
  63. package/lib/productOptionsStorage.d.ts +41 -0
  64. package/lib/removeReplacedItems.d.ts +7 -0
  65. package/lib/replaceOrAddItems.d.ts +18 -0
  66. package/lib/searchBlurHandler.d.ts +38 -0
  67. package/lib/searchKeyboardNavigation.d.ts +42 -0
  68. package/lib/updateItemInList.d.ts +13 -0
  69. package/lib/validateCsvContent.d.ts +20 -0
  70. package/lib/validateOrderItems.d.ts +18 -0
  71. package/package.json +1 -0
  72. package/render/Provider.d.ts +8 -0
  73. package/render/index.d.ts +2 -0
  74. package/render/render.d.ts +4 -0
  75. package/render.d.ts +1 -0
  76. package/render.js +6 -0
  77. package/render.js.map +1 -0
  78. package/types/index.d.ts +21 -0
  79. package/types/quickOrderCsvUpload.types.d.ts +32 -0
  80. package/types/quickOrderItems.types.d.ts +205 -0
  81. package/types/quickOrderMultipleSku.types.d.ts +34 -0
  82. package/types/search.types.d.ts +41 -0
@@ -0,0 +1,22 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2024 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ /**
18
+ * Generate unique ID for an item
19
+ * Format: {sku}-{timestamp}-{random}
20
+ */
21
+ export declare const generateItemId: (sku: string) => string;
22
+ //# sourceMappingURL=generateItemId.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { OrderItem } from '../types';
2
+
3
+ /**
4
+ * Get unique scope identifier for an item
5
+ * Uses unique id if available, otherwise falls back to variantSku or sku
6
+ */
7
+ export declare const getItemScope: (item: OrderItem) => string;
8
+ //# sourceMappingURL=getItemScope.d.ts.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2024 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './processFormOptions';
18
+ export * from './buildCartItem';
19
+ export * from './mapProductsToOrderItems';
20
+ export * from './cleanCsvValue';
21
+ export * from './validateCsvContent';
22
+ export * from './validateOrderItems';
23
+ export * from './getItemScope';
24
+ export * from './generateItemId';
25
+ export * from './findDuplicateItem';
26
+ export * from './removeReplacedItems';
27
+ export * from './mergeDuplicateItems';
28
+ export * from './addOrMergeItems';
29
+ export * from './replaceOrAddItems';
30
+ export * from './updateItemInList';
31
+ export * from './buildCartItemsFromForms';
32
+ export * from './productOptionsStorage';
33
+ export * from './searchBlurHandler';
34
+ export * from './searchKeyboardNavigation';
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { OrderItem, OrderItemInput } from '../types';
2
+
3
+ /**
4
+ * Maps fetched products to OrderItems
5
+ * Creates error items for products not found in the response
6
+ * @param requestedItems - Items that were requested
7
+ * @param products - Products returned from API
8
+ * @returns Array of OrderItems with proper quantity set
9
+ */
10
+ export declare const mapProductsToOrderItems: (requestedItems: OrderItemInput[], products: OrderItem[]) => OrderItem[];
11
+ //# sourceMappingURL=mapProductsToOrderItems.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { OrderItem } from '../types';
2
+
3
+ /**
4
+ * Merge duplicate items by removing the item at removeIndex and
5
+ * adding its quantity to the item at mergeIntoIndex
6
+ */
7
+ export declare const mergeDuplicateItems: (items: OrderItem[], removeIndex: number, mergeIntoIndex: number, quantityToAdd?: number) => OrderItem[];
8
+ //# sourceMappingURL=mergeDuplicateItems.d.ts.map
@@ -0,0 +1,29 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2024 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export interface ProcessedFormOptions {
18
+ optionUIDs: string[];
19
+ enteredOptions: {
20
+ uid: string;
21
+ value: string;
22
+ }[];
23
+ }
24
+ /**
25
+ * Processes form data to extract product options
26
+ * Separates base64-encoded configurable options (optionUIDs) from custom entered options
27
+ */
28
+ export declare const processFormOptions: (formData: FormData) => ProcessedFormOptions;
29
+ //# sourceMappingURL=processFormOptions.d.ts.map
@@ -0,0 +1,41 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2024 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ /**
18
+ * Extract optionsUIDs from various data formats
19
+ */
20
+ export declare const extractOptionsUIDs: (valuesData: any) => string[];
21
+ /**
22
+ * Get options from localStorage
23
+ */
24
+ export declare const getOptionsFromStorage: (storageKey: string) => Record<string, string[]>;
25
+ /**
26
+ * Save options to localStorage
27
+ */
28
+ export declare const saveOptionsToStorage: (storageKey: string, itemId: string, optionsUIDs: string[]) => void;
29
+ /**
30
+ * Enrich cart items with selected options from storage
31
+ */
32
+ export declare const enrichCartItemsWithOptions: <T extends {
33
+ sku: string;
34
+ }>(cartItems: T[], items: Array<{
35
+ id?: string;
36
+ sku: string;
37
+ variantSku?: string;
38
+ }>, storageData: Record<string, string[]>) => (T & {
39
+ optionsUIDs?: string[] | undefined;
40
+ })[];
41
+ //# sourceMappingURL=productOptionsStorage.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { OrderItem, OrderItemInput } from '../types';
2
+
3
+ /**
4
+ * Remove items that should be replaced based on replaceItemSku property
5
+ */
6
+ export declare const removeReplacedItems: (items: OrderItem[], inputItems: OrderItemInput[]) => OrderItem[];
7
+ //# sourceMappingURL=removeReplacedItems.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { OrderItem, OrderItemInput } from '../types';
2
+
3
+ export interface ReplaceOrAddItemsResult {
4
+ updatedItems: OrderItem[];
5
+ addedItems: OrderItem[];
6
+ replacedItems: OrderItem[];
7
+ mergedItems: OrderItem[];
8
+ }
9
+ /**
10
+ * Replace, merge, or add items into existing list
11
+ * Handles three scenarios:
12
+ * 1. Replace: When inputItem has replaceItemSku, replace item at same position
13
+ * - If new item already exists in list, collapse by removing replaced item and merging quantity
14
+ * 2. Merge: When item exists, increase quantity
15
+ * 3. Add: When item doesn't exist, add to end
16
+ */
17
+ export declare const replaceOrAddItems: (existingItems: OrderItem[], newItems: OrderItem[], inputItems: OrderItemInput[]) => ReplaceOrAddItemsResult;
18
+ //# sourceMappingURL=replaceOrAddItems.d.ts.map
@@ -0,0 +1,38 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2024 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export interface BlurHandlerOptions {
18
+ containerRef: HTMLElement | null;
19
+ itemSelected: boolean;
20
+ initialValue: string;
21
+ currentValue: string;
22
+ onValueRestore: (value: string) => void;
23
+ onClose: () => void;
24
+ }
25
+ /**
26
+ * Handles blur logic for search component
27
+ * Checks if focus moved outside component and restores initial value if needed
28
+ */
29
+ export declare const handleSearchBlur: (options: BlurHandlerOptions) => void;
30
+ /**
31
+ * Creates a blur handler with timeout
32
+ */
33
+ export declare const createBlurHandler: (options: BlurHandlerOptions, delay?: number) => number;
34
+ /**
35
+ * Clears blur timeout if exists
36
+ */
37
+ export declare const clearBlurTimeout: (timeoutRef: number | null) => void;
38
+ //# sourceMappingURL=searchBlurHandler.d.ts.map
@@ -0,0 +1,42 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2024 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export interface KeyboardNavigationResult {
18
+ nextIndex: number;
19
+ shouldFocusElement?: HTMLElement | null;
20
+ shouldPreventDefault: boolean;
21
+ }
22
+ /**
23
+ * Calculates next active index when ArrowDown is pressed
24
+ */
25
+ export declare const handleArrowDown: (currentIndex: number, itemsLength: number, itemRefs: (HTMLElement | null)[]) => KeyboardNavigationResult;
26
+ /**
27
+ * Calculates next active index when ArrowUp is pressed
28
+ */
29
+ export declare const handleArrowUp: (currentIndex: number, inputRef: HTMLElement | null, itemRefs: (HTMLElement | null)[]) => KeyboardNavigationResult;
30
+ /**
31
+ * Handles Enter key press on active item
32
+ */
33
+ export declare const handleEnterKey: <T>(activeIndex: number, items: T[], onItemSelect: (item: T) => void) => boolean;
34
+ /**
35
+ * Handles Escape key press
36
+ */
37
+ export declare const handleEscapeKey: (initialValue: string, inputRef: HTMLElement | null, onValueRestore: (value: string) => void, onClose: () => void) => void;
38
+ /**
39
+ * Focuses an element if it exists and has focus method
40
+ */
41
+ export declare const focusElement: (element: HTMLElement | null) => void;
42
+ //# sourceMappingURL=searchKeyboardNavigation.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { OrderItem } from '../types';
2
+
3
+ export interface UpdateItemResult {
4
+ updatedItems: OrderItem[];
5
+ wasMerged: boolean;
6
+ mergedIntoIndex?: number;
7
+ }
8
+ /**
9
+ * Update a specific item in the list and check for duplicates
10
+ * If duplicate is found, merge the items
11
+ */
12
+ export declare const updateItemInList: (items: OrderItem[], itemId: string, updatedItem: OrderItem, currentQuantity?: number) => UpdateItemResult;
13
+ //# sourceMappingURL=updateItemInList.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { CSVValidationResult } from '../types';
2
+
3
+ export interface ValidationMessages {
4
+ emptyFile: string;
5
+ missingColumns: string;
6
+ extraColumns: string;
7
+ maxRowsExceeded: string;
8
+ skuRequired: string;
9
+ invalidQuantity: string;
10
+ noValidData: string;
11
+ }
12
+ /**
13
+ * Validates CSV content and extracts SKU/quantity data
14
+ * Handles BOM, different line endings, quoted values, and empty lines
15
+ * @param content - Raw CSV file content
16
+ * @param messages - Localized error messages
17
+ * @returns Validation result with data or error
18
+ */
19
+ export declare const validateCsvContent: (content: string, messages: ValidationMessages) => CSVValidationResult;
20
+ //# sourceMappingURL=validateCsvContent.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { OrderItem } from '../types';
2
+
3
+ /**
4
+ * Validates order items to determine if all items are ready for cart addition
5
+ * @param items - Array of order items to validate
6
+ * @returns true if all items are valid, false otherwise
7
+ */
8
+ export declare const validateOrderItems: (items: OrderItem[]) => boolean;
9
+ /**
10
+ * Get items that are out of stock
11
+ * @param items - Array of order items to check
12
+ * @returns Array of out of stock items with their names
13
+ */
14
+ export declare const getOutOfStockItems: (items: OrderItem[]) => Array<{
15
+ sku: string;
16
+ name: string;
17
+ }>;
18
+ //# sourceMappingURL=validateOrderItems.d.ts.map
package/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name": "@dropins/storefront-quick-order", "version": "0.0.1-alpha1", "@dropins/tools": "~1.6.0", "license": "SEE LICENSE IN LICENSE.md"}
@@ -0,0 +1,8 @@
1
+ import { FunctionComponent } from 'preact';
2
+
3
+ interface CartProviderProps {
4
+ children?: any;
5
+ }
6
+ export declare const Provider: FunctionComponent<CartProviderProps>;
7
+ export {};
8
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './render';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { Render } from '@dropins/tools/types/elsie/src/lib';
2
+
3
+ export declare const render: Render;
4
+ //# sourceMappingURL=render.d.ts.map
package/render.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './render/index'
package/render.js ADDED
@@ -0,0 +1,6 @@
1
+ /*! Copyright 2026 Adobe
2
+ All Rights Reserved. */
3
+ (function(i,t){try{if(typeof document<"u"){const r=document.createElement("style"),a=t.styleId;for(const e in t.attributes)r.setAttribute(e,t.attributes[e]);r.setAttribute("data-dropin",a),r.appendChild(document.createTextNode(i));const o=document.querySelector('style[data-dropin="sdk"]');if(o)o.after(r);else{const e=document.querySelector('link[rel="stylesheet"], style');e?e.before(r):document.head.append(r)}}}catch(r){console.error("dropin-styles (injectCodeFunction)",r)}})(`.b2b-quick-order-quick-order-multiple-sku{display:flex;flex-direction:column;gap:var(--grid-1-gutters)}.b2b-quick-order-sku-list-input__title{color:var(--color-neutral-800);font:var(--type-headline-2-font);letter-spacing:var(--type-headline-2-letter-spacing);margin-bottom:var(--spacing-small)}.b2b-quick-order-sku-list-input__textarea{margin-bottom:var(--spacing-xsmall)}.b2b-quick-order-sku-list-input__message{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);margin-bottom:var(--spacing-xsmall);text-align:left}.b2b-quick-order-form-quick-order-items-list{width:100%}.b2b-quick-order-form-quick-order-items-list__title{color:var(--color-neutral-800);font:var(--type-headline-2-font);letter-spacing:var(--type-headline-2-letter-spacing);margin-bottom:var(--spacing-small)}.b2b-quick-order-form-quick-order-items-list__empty{color:var(--color-neutral-600);font:var(--type-body-1-font);letter-spacing:var(--type-body-1-letter-spacing);text-align:center;padding:var(--spacing-large)}.b2b-quick-order-form-quick-order-items-list__actions{display:flex;justify-content:flex-start;margin-top:var(--spacing-medium)}.b2b-quick-order-form-quick-order-items-list__warning{background-color:var(--color-warning-200, #fef3cd);border:1px solid var(--color-warning-500, #ff9800);border-radius:var(--shape-border-radius-2);padding:var(--spacing-medium);margin-bottom:var(--spacing-medium)}.b2b-quick-order-form-quick-order-items-list__warning-title{color:var(--color-warning-800, #e65100);font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing);margin-bottom:var(--spacing-xsmall)}.b2b-quick-order-form-quick-order-items-list__warning-description{color:var(--color-warning-700, #f57c00);font:var(--type-body-2-font);letter-spacing:var(--type-body-2-letter-spacing)}.b2b-quick-order-form-quick-order-items-list .dropin-divider--secondary{border-width:var(--shape-border-width-3);margin-top:0}@media screen and (max-width: 1285px){.b2b-quick-order-form-quick-order-items-list .dropin-divider--secondary{display:none}}.b2b-quick-order-form-quick-order-items__item-form{min-height:170px}.b2b-quick-order-form-quick-order-items__item-form .dropin-accordion-section__content-container{margin-bottom:0}.b2b-quick-order-form-quick-order-items__item-form:last-child{margin-bottom:var(--spacing-medium)}.b2b-quick-order-list-item__accordion .dropin-accordion-section__title{color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.b2b-quick-order-items__error{color:var(--color-alert-800);font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing)}.b2b-quick-order-form-quick-order-items__item-search{margin-bottom:var(--spacing-big)}.b2b-quick-order-items__configurable-error{color:var(--color-alert-500);font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing)}.b2b-quick-order-search{position:relative;width:100%}.b2b-quick-order-search__input{width:100%}.b2b-quick-order-search__results{position:absolute;top:100%;left:0;right:0;background-color:var(--color-neutral-50);border:var(--shape-border-width-1) solid var(--color-neutral-300);border-radius:var(--spacing-xxsmall);margin-top:var(--spacing-xxsmall);max-height:300px;overflow-y:auto;z-index:10;box-shadow:0 2px 8px #0000001a}.b2b-quick-order-search__result-item{padding:var(--spacing-xsmall) var(--spacing-small);cursor:pointer;transition:background-color .2s}.b2b-quick-order-search__result-item:hover,.b2b-quick-order-search__result-item--active{background-color:var(--color-neutral-100)}.b2b-quick-order-search__result-item:focus{outline:2px solid var(--color-brand-500);outline-offset:-2px}.b2b-quick-order-search__result-item:not(:last-child){border-bottom:var(--shape-border-width-1) solid var(--color-neutral-200)}.b2b-quick-order-search__empty-state{position:absolute;top:100%;left:0;right:0;z-index:10;text-align:center;background-color:var(--color-neutral-50);border:var(--shape-border-width-1) solid var(--color-neutral-300);border-radius:var(--shape-border-radius-1);margin-top:var(--spacing-xxsmall);padding:var(--spacing-small);color:var(--color-neutral-600);box-shadow:0 2px 8px #0000001a}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}
4
+ .b2b-quick-order-csv-file-input{display:flex;flex-direction:column;gap:var(--grid-1-gutters)}.b2b-quick-order-csv-file-input__title{color:var(--color-neutral-800);font:var(--type-headline-2-font);letter-spacing:var(--type-headline-2-letter-spacing)}.b2b-quick-order-csv-file-input__helper{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);text-align:left}.b2b-quick-order-csv-file-input__download-link{color:var(--color-informational-800);text-decoration:underline;background:none;border:none;padding:0;cursor:pointer;font-size:inherit}.b2b-quick-order-csv-file-input__download-link:hover{color:var(--color-informational-500)}.b2b-quick-order-csv-file-input__input{margin-top:var(--spacing-xsmall);width:max-content}.b2b-quick-order-csv-file-input__input--loading{cursor:not-allowed;opacity:.3}.b2b-quick-order-csv-file-input__file-name{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.b2b-quick-order-csv-file-input__error{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);padding-top:var(--spacing-xsmall);text-align:left;color:var(--color-alert-800)}`,{styleId:"b2b-quick-order"});
5
+ import{jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{Render as n}from"@dropins/tools/lib.js";import{useState as s,useEffect as l}from"@dropins/tools/preact-hooks.js";import{UIProvider as d}from"@dropins/tools/components.js";import{events as u}from"@dropins/tools/event-bus.js";const c={Search:{placeholder:"Search by SKU...",ariaLabel:"Search for products by SKU",emptyState:"No results found",resultsAvailable:"results available",resultAvailable:"result available",srInstructions:"Use arrow keys or Tab to navigate, Enter or Space to select, Escape to close."},SkuListInput:{title:"Add Products by SKU",helperText:"Use commas or paragraphs to separate SKUs.",textArea:{label:"Enter Multiple SKUs",placeholder:"Enter SKUs here..."},button:"Add to List"},CsvFileInput:{title:"Add from File",helperText:'File must be in .csv format and include "SKU" and "QTY" columns ',downloadSample:"Download sample",inputLabel:"Choose File",selectedFile:"Selected file",uploadCSVErrors:{invalidFile:"Invalid CSV file",emptyFile:"File is empty",missingColumns:'Must contain "SKU" and "QTY" columns',extraColumns:'Must contain only "SKU" and "QTY" columns',maxRowsExceeded:"File exceeds maximum of {maxRows} rows",skuRequired:"Row {rowNumber}: SKU is required",invalidQuantity:"Row {rowNumber}: QTY must be a positive integer",noValidData:"File contains no valid data rows",onlyCSV:"Only CSV files are allowed",failedToRead:"Failed to read file",failedToParse:"Failed to parse CSV file"}},QuickOrderItem:{title:"Enter SKU or search by Product Name",quantity:"Quantity: ",price:"Price: ",sku:"SKU",remove:"Remove",removeItem:"Remove item",showOptions:"Show additional options",hideOptions:"Hide additional options",additionalOptions:"Additional options",noAdditionalOptions:"No additional options available",emptyList:"No products in the list",loading:"Loading...",productNotFound:"Product not found",productNotFoundDescription:"The product with SKU {sku} could not be found",configurableProductError:"Configuration required",configurableProductErrorDescription:"Configurable products aren’t supported here. Use the correct component for products with options. ",configurableOptionsWarning:"Product configuration required",configurableOptionsWarningDescription:"Please select all required product options before adding to cart",productOptions:"Product Options",outOfStock:"Out of Stock",addAllToCart:"Add to Cart"}},p={QuickOrder:c},m={default:p},f=({children:t})=>{const[r,i]=s("en_US");return l(()=>{const e=u.on("locale",a=>{i(a)},{eager:!0});return()=>{e==null||e.off()}},[]),o(d,{lang:r,langDefinitions:m,children:t})},U=new n(o(f,{}));export{U as render};
6
+ //# sourceMappingURL=render.js.map
package/render.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sources":["/@dropins/storefront-quick-order/src/render/Provider.tsx","/@dropins/storefront-quick-order/src/render/render.tsx"],"sourcesContent":["import { FunctionComponent } from 'preact';\nimport { useState, useEffect } from 'preact/hooks';\nimport { UIProvider } from '@adobe-commerce/elsie/components';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\n\nimport en_US from '../i18n/en_US.json';\n\n// Langs\nconst langDefinitions = {\n default: en_US,\n};\n\ninterface CartProviderProps {\n children?: any;\n}\n\nexport const Provider: FunctionComponent<CartProviderProps> = ({\n children,\n}) => {\n const [lang, setLang] = useState<Lang>('en_US');\n\n // Events\n useEffect(() => {\n const localeEvent = events.on(\n 'locale',\n (locale: string) => {\n setLang(locale as Lang);\n },\n { eager: true }\n );\n return () => {\n localeEvent?.off();\n };\n }, []);\n\n return (\n <UIProvider lang={lang} langDefinitions={langDefinitions}>\n {children}\n </UIProvider>\n );\n};\n","import { Render } from '@adobe-commerce/elsie/lib';\nimport { Provider } from './Provider';\n\nexport const render = new Render(<Provider />);\n"],"names":["langDefinitions","en_US","Provider","children","lang","setLang","useState","useEffect","localeEvent","events","locale","jsx","UIProvider","render","Render"],"mappings":"u4EASMA,EAAkB,CACtB,QAASC,CACX,EAMaC,EAAiD,CAAC,CAC7D,SAAAC,CACF,IAAM,CACJ,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAe,OAAO,EAG9C,OAAAC,EAAU,IAAM,CACd,MAAMC,EAAcC,EAAO,GACzB,SACCC,GAAmB,CAClBL,EAAQK,CAAc,CACxB,EACA,CAAE,MAAO,EAAA,CAAK,EAEhB,MAAO,IAAM,CACXF,GAAA,MAAAA,EAAa,KACf,CACF,EAAG,CAAA,CAAE,EAGHG,EAACC,EAAA,CAAW,KAAAR,EAAY,gBAAAJ,EACrB,SAAAG,CAAA,CACH,CAEJ,ECtCaU,EAAS,IAAIC,EAAOH,EAACT,IAAS,CAAE"}
@@ -0,0 +1,21 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2024 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export * from './quickOrderMultipleSku.types';
18
+ export * from './quickOrderCsvUpload.types';
19
+ export * from './quickOrderItems.types';
20
+ export * from './search.types';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { SubmitSkuValue } from './quickOrderMultipleSku.types';
2
+
3
+ export interface QuickOrderCsvUploadProps {
4
+ className?: string;
5
+ routeSampleCSV?: string;
6
+ onFileUpload?: (values: SubmitSkuValue) => void;
7
+ }
8
+ export interface CsvFileInputProps {
9
+ t: Record<string, string>;
10
+ onFileUpload: (file: File) => void;
11
+ error: string | null;
12
+ fileName: string | null;
13
+ onDownloadSample: () => void;
14
+ showSampleDownload: boolean;
15
+ }
16
+ export interface UseQuickOrderCsvUploadProps {
17
+ routeSampleCSV?: string;
18
+ onFileUpload?: (values: SubmitSkuValue) => void;
19
+ }
20
+ export interface UseQuickOrderCsvUploadReturn {
21
+ handleFileUpload: (file: File) => void;
22
+ error: string | null;
23
+ fileName: string | null;
24
+ handleDownloadSample: () => void;
25
+ showSampleDownload: boolean;
26
+ }
27
+ export interface CSVValidationResult {
28
+ isValid: boolean;
29
+ error?: string;
30
+ data?: SubmitSkuValue;
31
+ }
32
+ //# sourceMappingURL=quickOrderCsvUpload.types.d.ts.map
@@ -0,0 +1,205 @@
1
+ import { SlotProps } from '@dropins/tools/types/elsie/src/lib/slot';
2
+ import { SearchItem } from './search.types';
3
+
4
+ export type AddAllToCartContext = {
5
+ handleAddToCart: (() => void) | undefined;
6
+ loading?: boolean;
7
+ isDisabledButton?: boolean;
8
+ };
9
+ export type QuickOrderItemSearchContext = {
10
+ item: OrderItem;
11
+ scope: string;
12
+ handleSearchChange: (e: Event) => void;
13
+ searchResults: OrderItem[];
14
+ searchValue: string;
15
+ shouldShowResults: boolean;
16
+ handleItemClick: (item: OrderItem) => void;
17
+ };
18
+ export type QuickOrderSearchAutocompleteItemContext<T extends SearchItem = SearchItem> = {
19
+ item: T;
20
+ index: number;
21
+ createItemClickHandler: (item: T) => () => void;
22
+ createResultItemKeyDownHandler: (index: number, item: T) => (e: KeyboardEvent) => void;
23
+ };
24
+ export type ProductPriceContext = {
25
+ item: OrderItem;
26
+ scope: string;
27
+ };
28
+ export type ProductOptionsContext = {
29
+ item: OrderItem;
30
+ scope: string;
31
+ };
32
+ export interface ProductImage {
33
+ url: string;
34
+ label: string;
35
+ roles: string[];
36
+ }
37
+ export interface ProductPrice {
38
+ regular?: {
39
+ amount?: number;
40
+ currency?: string;
41
+ variant?: string;
42
+ };
43
+ final: {
44
+ amount?: number;
45
+ minimumAmount?: number;
46
+ maximumAmount?: number;
47
+ currency: string;
48
+ variant?: string;
49
+ };
50
+ tiers: Array<unknown>;
51
+ visible: boolean;
52
+ }
53
+ export interface ProductAttribute {
54
+ id: string;
55
+ label: string;
56
+ value: string;
57
+ }
58
+ export interface ProductOptionItem {
59
+ id: string;
60
+ inStock: boolean;
61
+ label: string;
62
+ selected: boolean;
63
+ value: string;
64
+ }
65
+ export interface ProductOption {
66
+ id: string;
67
+ type: string;
68
+ typename: string;
69
+ label: string;
70
+ required: boolean;
71
+ multiple: boolean;
72
+ items: ProductOptionItem[];
73
+ }
74
+ export interface ProductData {
75
+ name: string;
76
+ sku: string;
77
+ isBundle: boolean;
78
+ addToCartAllowed: boolean;
79
+ inStock: boolean;
80
+ shortDescription: string;
81
+ metaDescription: string;
82
+ metaKeyword: string;
83
+ metaTitle: string;
84
+ description: string;
85
+ images: ProductImage[];
86
+ prices: ProductPrice;
87
+ attributes: ProductAttribute[];
88
+ options: ProductOption[];
89
+ optionUIDs?: string[];
90
+ url: string;
91
+ urlKey: string;
92
+ externalId: string;
93
+ productType: string;
94
+ }
95
+ export interface OrderItemInput {
96
+ sku: string;
97
+ variantSku?: string;
98
+ quantity?: number;
99
+ replaceItemSku?: string;
100
+ }
101
+ export interface OrderItem extends ProductData {
102
+ id?: string;
103
+ variantSku?: string;
104
+ sku: string;
105
+ quantity: number;
106
+ }
107
+ export interface QuickOrderItemsProps {
108
+ className?: string;
109
+ getProductsData?: (items: OrderItemInput[]) => Promise<OrderItem[]>;
110
+ productsSearch?: (params: {
111
+ phrase: string;
112
+ filter: Array<{
113
+ attribute: string;
114
+ in: string[];
115
+ }>;
116
+ }) => Promise<{
117
+ items: OrderItem[];
118
+ }>;
119
+ onAddAllToCart?: (items: any[]) => void | Promise<void>;
120
+ searchFilter?: Array<{
121
+ attribute: string;
122
+ in: string[];
123
+ }>;
124
+ slots?: {
125
+ AddAllToCartButton?: SlotProps<AddAllToCartContext>;
126
+ ProductPrice?: SlotProps<ProductPriceContext>;
127
+ ProductOptions?: SlotProps<ProductOptionsContext>;
128
+ QuickOrderItemSearch?: SlotProps<QuickOrderItemSearchContext>;
129
+ QuickOrderSearchAutocompleteItem?: SlotProps<QuickOrderSearchAutocompleteItemContext<SearchItem>>;
130
+ };
131
+ }
132
+ export interface QuickOrderItemProps {
133
+ item: OrderItem;
134
+ index: number;
135
+ t: Record<string, string>;
136
+ onRemove: (sku: string) => void;
137
+ slots?: QuickOrderItemsProps['slots'];
138
+ scope: string;
139
+ }
140
+ export interface QuickOrderListItemProps {
141
+ item: OrderItem;
142
+ t: Record<string, string>;
143
+ onRemove: (sku: string) => void;
144
+ onUpdateQuantity?: (sku: string, quantity: number) => void;
145
+ isUpdating?: boolean;
146
+ loading?: boolean;
147
+ productsSearch?: (params: {
148
+ phrase: string;
149
+ filter: Array<{
150
+ attribute: string;
151
+ in: string[];
152
+ }>;
153
+ }) => Promise<{
154
+ items: OrderItem[];
155
+ }>;
156
+ searchFilter?: Array<{
157
+ attribute: string;
158
+ in: string[];
159
+ }>;
160
+ slots?: {
161
+ AddAllToCartButton?: SlotProps<AddAllToCartContext>;
162
+ ProductPrice?: SlotProps<ProductPriceContext>;
163
+ ProductOptions?: SlotProps<ProductOptionsContext>;
164
+ QuickOrderItemSearch?: SlotProps<QuickOrderItemSearchContext>;
165
+ };
166
+ }
167
+ export interface QuickOrderItemsListProps {
168
+ t: Record<string, string>;
169
+ items: OrderItem[];
170
+ onRemove: (sku: string) => void;
171
+ onUpdateQuantity?: (sku: string, quantity: number) => void;
172
+ handleAddToCart?: () => void;
173
+ isItemUpdating?: (sku: string) => boolean;
174
+ setDisabledCartButton?: (disabled: boolean) => void;
175
+ productsSearch?: (params: {
176
+ phrase: string;
177
+ filter: Array<{
178
+ attribute: string;
179
+ in: string[];
180
+ }>;
181
+ }) => Promise<{
182
+ items: OrderItem[];
183
+ }>;
184
+ searchFilter?: Array<{
185
+ attribute: string;
186
+ in: string[];
187
+ }>;
188
+ slots?: QuickOrderItemsProps['slots'];
189
+ loading?: boolean;
190
+ isDisabledButton?: boolean;
191
+ }
192
+ export interface UseQuickOrderItemsProps extends Omit<QuickOrderItemsProps, 'className'> {
193
+ getProductsData?: (items: OrderItemInput[]) => Promise<OrderItem[]>;
194
+ }
195
+ export interface UseQuickOrderItemsReturn {
196
+ items: OrderItem[];
197
+ loading: boolean;
198
+ removeItem: (sku: string) => void;
199
+ updateItemQuantity: (sku: string, quantity: number) => void;
200
+ handleAddToCart: () => void;
201
+ isItemUpdating: (sku: string) => boolean;
202
+ isDisabledButton: boolean;
203
+ setDisabledCartButton: (disabled: boolean) => void;
204
+ }
205
+ //# sourceMappingURL=quickOrderItems.types.d.ts.map