@commercelayer/app-elements 2.8.3 → 2.10.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 (201) hide show
  1. package/dist/InputDateComponent-CMJl1SsY.js +6188 -0
  2. package/dist/dictionaries/customers.d.ts +0 -1
  3. package/dist/dictionaries/orders.d.ts +0 -1
  4. package/dist/dictionaries/promotions.d.ts +0 -1
  5. package/dist/dictionaries/returns.d.ts +0 -1
  6. package/dist/dictionaries/shipments.d.ts +0 -1
  7. package/dist/dictionaries/stockTransfers.d.ts +0 -1
  8. package/dist/dictionaries/types.d.ts +0 -1
  9. package/dist/helpers/appsNavigation.d.ts +0 -1
  10. package/dist/helpers/attachments.d.ts +0 -1
  11. package/dist/helpers/currencies.d.ts +0 -1
  12. package/dist/helpers/date.d.ts +0 -1
  13. package/dist/helpers/resources.d.ts +0 -1
  14. package/dist/helpers/tracking.d.ts +0 -1
  15. package/dist/hooks/useClickAway.d.ts +0 -1
  16. package/dist/hooks/useEditMetadataOverlay.d.ts +0 -1
  17. package/dist/hooks/useEditTagsOverlay.d.ts +0 -1
  18. package/dist/hooks/useOverlay.d.ts +0 -1
  19. package/dist/{main-uMPiX52G.js → main-8vGdIM-n.js} +10840 -10718
  20. package/dist/main.d.ts +1 -2
  21. package/dist/main.js +102 -102
  22. package/dist/providers/CoreSdkProvider/CoreSdkProvider.d.ts +0 -1
  23. package/dist/providers/CoreSdkProvider/makeSdkClient.d.ts +0 -1
  24. package/dist/providers/CoreSdkProvider/useCoreApi.d.ts +0 -1
  25. package/dist/providers/ErrorBoundary.d.ts +0 -1
  26. package/dist/providers/GTMProvider.d.ts +0 -1
  27. package/dist/providers/TokenProvider/MockTokenProvider.d.ts +0 -1
  28. package/dist/providers/TokenProvider/TokenProvider.d.ts +0 -1
  29. package/dist/providers/TokenProvider/extras.d.ts +0 -1
  30. package/dist/providers/TokenProvider/getAccessTokenFromUrl.d.ts +0 -1
  31. package/dist/providers/TokenProvider/getInfoFromJwt.d.ts +0 -1
  32. package/dist/providers/TokenProvider/getOrganization.d.ts +0 -1
  33. package/dist/providers/TokenProvider/reducer.d.ts +0 -1
  34. package/dist/providers/TokenProvider/storage.d.ts +0 -1
  35. package/dist/providers/TokenProvider/types.d.ts +0 -1
  36. package/dist/providers/TokenProvider/validateToken.d.ts +0 -1
  37. package/dist/providers/createApp.d.ts +0 -1
  38. package/dist/style.css +1 -1
  39. package/dist/ui/atoms/A.d.ts +0 -1
  40. package/dist/ui/atoms/Avatar.d.ts +0 -1
  41. package/dist/ui/atoms/Badge/Badge.d.ts +0 -1
  42. package/dist/ui/atoms/Button.d.ts +0 -1
  43. package/dist/ui/atoms/ButtonFilter.d.ts +0 -1
  44. package/dist/ui/atoms/Card.d.ts +4 -2
  45. package/dist/ui/atoms/CodeBlock.d.ts +0 -1
  46. package/dist/ui/atoms/EmptyState.d.ts +0 -1
  47. package/dist/ui/atoms/Grid.d.ts +0 -1
  48. package/dist/ui/atoms/Hint.d.ts +0 -1
  49. package/dist/ui/atoms/Icon/Icon.d.ts +0 -1
  50. package/dist/ui/atoms/PageHeading/PageHeading.d.ts +0 -1
  51. package/dist/ui/atoms/PageHeading/PageHeadingToolbar.d.ts +0 -1
  52. package/dist/ui/atoms/RadialProgress.d.ts +0 -1
  53. package/dist/ui/atoms/ScrollToTop.d.ts +0 -1
  54. package/dist/ui/atoms/Section.d.ts +0 -1
  55. package/dist/ui/atoms/Skeleton.d.ts +0 -1
  56. package/dist/ui/atoms/SkeletonTemplate.d.ts +0 -1
  57. package/dist/ui/atoms/Spacer.d.ts +0 -1
  58. package/dist/ui/atoms/Stack.d.ts +0 -1
  59. package/dist/ui/atoms/StatusIcon.d.ts +0 -1
  60. package/dist/ui/atoms/Table/Table.d.ts +0 -1
  61. package/dist/ui/atoms/Table/Td.d.ts +0 -1
  62. package/dist/ui/atoms/Tabs.d.ts +0 -1
  63. package/dist/ui/atoms/Tag.d.ts +0 -1
  64. package/dist/ui/atoms/Text.d.ts +0 -1
  65. package/dist/ui/atoms/Tooltip.d.ts +0 -1
  66. package/dist/ui/composite/ActionButtons/ActionButtons.d.ts +0 -1
  67. package/dist/ui/composite/Dropdown/Dropdown.d.ts +0 -1
  68. package/dist/ui/composite/Dropdown/DropdownDivider.d.ts +0 -1
  69. package/dist/ui/composite/Dropdown/DropdownItem.d.ts +4 -3
  70. package/dist/ui/composite/Dropdown/DropdownMenu.d.ts +0 -1
  71. package/dist/ui/composite/HomePageLayout.d.ts +0 -1
  72. package/dist/ui/composite/List.d.ts +0 -1
  73. package/dist/ui/composite/ListDetails.d.ts +0 -1
  74. package/dist/ui/composite/ListDetailsItem.d.ts +0 -1
  75. package/dist/ui/composite/ListItem.d.ts +0 -1
  76. package/dist/ui/composite/PageError.d.ts +0 -1
  77. package/dist/ui/composite/PageLayout.d.ts +0 -1
  78. package/dist/ui/composite/Report.d.ts +0 -1
  79. package/dist/ui/composite/Routes/Routes.d.ts +0 -1
  80. package/dist/ui/composite/Routes/utils.d.ts +0 -1
  81. package/dist/ui/composite/SearchBar.d.ts +0 -1
  82. package/dist/ui/composite/TableData.d.ts +0 -1
  83. package/dist/ui/composite/Timeline.d.ts +0 -1
  84. package/dist/ui/composite/Toolbar.d.ts +0 -1
  85. package/dist/ui/forms/Form/HookedForm.d.ts +0 -1
  86. package/dist/ui/forms/Input/HookedInput.d.ts +0 -1
  87. package/dist/ui/forms/Input/Input.d.ts +0 -1
  88. package/dist/ui/forms/InputCheckbox/HookedInputCheckbox.d.ts +0 -1
  89. package/dist/ui/forms/InputCheckbox/InputCheckbox.d.ts +0 -1
  90. package/dist/ui/forms/InputCheckboxGroup/HookedInputCheckboxGroup.d.ts +0 -1
  91. package/dist/ui/forms/InputCheckboxGroup/InputCheckboxGroup.d.ts +0 -1
  92. package/dist/ui/forms/InputCheckboxGroup/InputCheckboxGroupItem.d.ts +0 -1
  93. package/dist/ui/forms/InputCheckboxGroup/reducer.d.ts +0 -1
  94. package/dist/ui/forms/InputCurrency/HookedInputCurrency.d.ts +0 -1
  95. package/dist/ui/forms/InputCurrency/InputCurrency.d.ts +0 -1
  96. package/dist/ui/forms/InputCurrency/utils.d.ts +0 -1
  97. package/dist/ui/forms/InputCurrencyRange.d.ts +0 -1
  98. package/dist/ui/forms/InputDate/HookedInputDate.d.ts +0 -1
  99. package/dist/ui/forms/InputDate/InputDate.d.ts +0 -1
  100. package/dist/ui/forms/InputDate/InputDateComponent.d.ts +0 -1
  101. package/dist/ui/forms/InputDateRange/HookedInputDateRange.d.ts +0 -1
  102. package/dist/ui/forms/InputDateRange/InputDateRange.d.ts +0 -1
  103. package/dist/ui/forms/InputFile.d.ts +0 -1
  104. package/dist/ui/forms/InputJson.d.ts +0 -1
  105. package/dist/ui/forms/InputRadioGroup/HookedInputRadioGroup.d.ts +0 -1
  106. package/dist/ui/forms/InputRadioGroup/InputRadioGroup.d.ts +0 -1
  107. package/dist/ui/forms/InputResourceGroup/FullList.d.ts +0 -1
  108. package/dist/ui/forms/InputResourceGroup/HookedInputResourceGroup.d.ts +0 -1
  109. package/dist/ui/forms/InputResourceGroup/InputResourceGroup.d.ts +0 -1
  110. package/dist/ui/forms/InputResourceGroup/utils.d.ts +0 -1
  111. package/dist/ui/forms/InputSelect/AsyncComponent.d.ts +0 -1
  112. package/dist/ui/forms/InputSelect/AsyncCreatableComponent.d.ts +0 -1
  113. package/dist/ui/forms/InputSelect/CreatableComponent.d.ts +0 -1
  114. package/dist/ui/forms/InputSelect/GenericAsyncComponent.d.ts +0 -1
  115. package/dist/ui/forms/InputSelect/HookedInputSelect.d.ts +0 -1
  116. package/dist/ui/forms/InputSelect/InputSelect.d.ts +0 -1
  117. package/dist/ui/forms/InputSelect/SelectComponent.d.ts +0 -1
  118. package/dist/ui/forms/InputSelect/overrides.d.ts +0 -1
  119. package/dist/ui/forms/InputSelect/styles.d.ts +0 -1
  120. package/dist/ui/forms/InputSelect/utils.d.ts +0 -1
  121. package/dist/ui/forms/InputSimpleSelect/HookedInputSimpleSelect.d.ts +0 -1
  122. package/dist/ui/forms/InputSimpleSelect/InputSimpleSelect.d.ts +0 -1
  123. package/dist/ui/forms/InputSpinner/HookedInputSpinner.d.ts +0 -1
  124. package/dist/ui/forms/InputSpinner/InputSpinner.d.ts +0 -1
  125. package/dist/ui/forms/InputSwitch/HookedInputSwitch.d.ts +0 -1
  126. package/dist/ui/forms/InputSwitch/InputSwitch.d.ts +0 -1
  127. package/dist/ui/forms/InputTextArea/HookedInputTextArea.d.ts +0 -1
  128. package/dist/ui/forms/InputTextArea/InputTextArea.d.ts +0 -1
  129. package/dist/ui/forms/InputToggleButton/HookedInputToggleButton.d.ts +0 -1
  130. package/dist/ui/forms/InputToggleButton/InputToggleButton.d.ts +0 -1
  131. package/dist/ui/forms/MarketWithCurrencySelector/HookedMarketWithCurrencySelector.d.ts +0 -1
  132. package/dist/ui/forms/ReactHookForm/setApiFormErrors.d.ts +0 -1
  133. package/dist/ui/forms/ReactHookForm/useValidationFeedback.d.ts +0 -1
  134. package/dist/ui/internals/FlexRow.d.ts +0 -1
  135. package/dist/ui/internals/InputWrapper.d.ts +0 -1
  136. package/dist/ui/resources/ResourceAddress/ResourceAddress.d.ts +0 -1
  137. package/dist/ui/resources/ResourceAddress/ResourceAddressForm.d.ts +0 -1
  138. package/dist/ui/resources/ResourceAddress/ResourceAddressFormFields.d.ts +0 -1
  139. package/dist/ui/resources/ResourceAddress/useResourceAddressOverlay.d.ts +0 -1
  140. package/dist/ui/resources/ResourceDetails/ResourceDetails.d.ts +2 -1
  141. package/dist/ui/resources/ResourceDetails/ResourceDetailsForm.d.ts +7 -0
  142. package/dist/ui/resources/ResourceDetails/useEditDetailsOverlay.d.ts +16 -0
  143. package/dist/ui/resources/ResourceLineItems/ResourceLineItems.d.ts +0 -1
  144. package/dist/ui/resources/ResourceLineItems/types.d.ts +0 -1
  145. package/dist/ui/resources/ResourceListItem/ResourceListItem.d.ts +0 -1
  146. package/dist/ui/resources/ResourceListItem/ResourceListItem.mocks.d.ts +41 -0
  147. package/dist/ui/resources/ResourceListItem/common.d.ts +0 -1
  148. package/dist/ui/resources/ResourceListItem/transformers/customers.d.ts +0 -1
  149. package/dist/ui/resources/ResourceListItem/transformers/orders.d.ts +0 -1
  150. package/dist/ui/resources/ResourceListItem/transformers/promotions.d.ts +0 -1
  151. package/dist/ui/resources/ResourceListItem/transformers/returns.d.ts +0 -1
  152. package/dist/ui/resources/ResourceListItem/transformers/shipments.d.ts +0 -1
  153. package/dist/ui/resources/ResourceListItem/transformers/skuListItem.d.ts +0 -1
  154. package/dist/ui/resources/ResourceListItem/transformers/stockTransfers.d.ts +0 -1
  155. package/dist/ui/resources/ResourceListItem/types.d.ts +0 -1
  156. package/dist/ui/resources/ResourceMetadata/ResourceMetadata.d.ts +0 -1
  157. package/dist/ui/resources/ResourceMetadata/ResourceMetadataForm.d.ts +0 -1
  158. package/dist/ui/resources/ResourceOrderTimeline.d.ts +0 -1
  159. package/dist/ui/resources/ResourceShipmentParcels.d.ts +0 -1
  160. package/dist/ui/resources/ResourceShipmentParcels.mocks.d.ts +0 -1
  161. package/dist/ui/resources/ResourceTags.d.ts +0 -1
  162. package/dist/ui/resources/useResourceFilters/FieldCurrencyRange.d.ts +0 -1
  163. package/dist/ui/resources/useResourceFilters/FieldOptions.d.ts +0 -1
  164. package/dist/ui/resources/useResourceFilters/FieldTextSearch.d.ts +0 -1
  165. package/dist/ui/resources/useResourceFilters/FieldTimeRange.d.ts +0 -1
  166. package/dist/ui/resources/useResourceFilters/FiltersForm.d.ts +0 -1
  167. package/dist/ui/resources/useResourceFilters/FiltersNav.d.ts +0 -1
  168. package/dist/ui/resources/useResourceFilters/FiltersSearchBar.d.ts +0 -1
  169. package/dist/ui/resources/useResourceFilters/adaptFormValuesToSdk.d.ts +0 -1
  170. package/dist/ui/resources/useResourceFilters/adaptFormValuesToUrlQuery.d.ts +0 -1
  171. package/dist/ui/resources/useResourceFilters/adaptSdkToMetrics.d.ts +0 -1
  172. package/dist/ui/resources/useResourceFilters/adaptSdkToUrlQuery.d.ts +0 -1
  173. package/dist/ui/resources/useResourceFilters/adaptUrlQueryToFormValues.d.ts +0 -1
  174. package/dist/ui/resources/useResourceFilters/adaptUrlQueryToSdk.d.ts +0 -1
  175. package/dist/ui/resources/useResourceFilters/adaptUrlQueryToUrlQuery.d.ts +0 -1
  176. package/dist/ui/resources/useResourceFilters/adapters.d.ts +0 -1
  177. package/dist/ui/resources/useResourceFilters/adapters.types.d.ts +0 -1
  178. package/dist/ui/resources/useResourceFilters/mockedInstructions.d.ts +0 -1
  179. package/dist/ui/resources/useResourceFilters/timeUtils.d.ts +0 -1
  180. package/dist/ui/resources/useResourceFilters/types.d.ts +0 -1
  181. package/dist/ui/resources/useResourceFilters/useResourceFilters.d.ts +5 -6
  182. package/dist/ui/resources/useResourceFilters/utils.d.ts +0 -1
  183. package/dist/ui/resources/{ResourceList → useResourceList}/VisibilityTrigger.d.ts +0 -1
  184. package/dist/ui/resources/{ResourceList → useResourceList}/adaptMetricsOrderToCore.d.ts +0 -1
  185. package/dist/ui/resources/useResourceList/index.d.ts +1 -0
  186. package/dist/ui/resources/{ResourceList → useResourceList}/infiniteFetcher.d.ts +1 -2
  187. package/dist/ui/resources/{ResourceList → useResourceList}/metricsApiClient.d.ts +1 -2
  188. package/dist/ui/resources/{ResourceList → useResourceList}/reducer.d.ts +0 -1
  189. package/dist/ui/resources/{ResourceList/ResourceList.d.ts → useResourceList/useResourceList.d.ts} +53 -48
  190. package/dist/utils/children.d.ts +0 -1
  191. package/dist/utils/extractHeaders.d.ts +0 -1
  192. package/dist/utils/text.d.ts +0 -1
  193. package/dist/vendor.css +1 -1
  194. package/package.json +22 -22
  195. package/dist/InputDateComponent-BHXJF53e.js +0 -5064
  196. package/dist/ui/resources/ResourceList/index.d.ts +0 -1
  197. /package/dist/ui/resources/{ResourceList → useResourceList}/VisibilityTrigger.test.d.ts +0 -0
  198. /package/dist/ui/resources/{ResourceList → useResourceList}/adaptMetricsOrderToCore.test.d.ts +0 -0
  199. /package/dist/ui/resources/{ResourceList/ResourceList.test.d.ts → useResourceList/useResourceList.test.d.ts} +0 -0
  200. /package/dist/ui/resources/{ResourceList → useResourceList}/utils.d.ts +0 -0
  201. /package/dist/ui/resources/{ResourceList → useResourceList}/utils.test.d.ts +0 -0
@@ -0,0 +1,16 @@
1
+ import { FC } from 'react';
2
+ import { ResourceDetailsProps } from './ResourceDetails';
3
+ export interface EditDetailsOverlayProps {
4
+ /**
5
+ * Optional title shown as first line in edit overlay heading
6
+ */
7
+ title?: string;
8
+ resource: ResourceDetailsProps['resource'];
9
+ onUpdated: ResourceDetailsProps['onUpdated'];
10
+ }
11
+ interface DetailsOverlayHook {
12
+ show: () => void;
13
+ Overlay: FC<EditDetailsOverlayProps>;
14
+ }
15
+ export declare function useEditDetailsOverlay(): DetailsOverlayHook;
16
+ export {};
@@ -1,7 +1,6 @@
1
1
  import { LineItem, ParcelLineItem, ReturnLineItem } from '@commercelayer/sdk';
2
2
  import { ComponentProps } from 'react';
3
3
  import { StockLineItemWithStockTransfer } from './types';
4
-
5
4
  type Item = LineItem | ParcelLineItem | StockLineItemWithStockTransfer | ReturnLineItem;
6
5
  export type ResourceLineItemsProps = ComponentProps<typeof ResourceLineItems>;
7
6
  /**
@@ -1,5 +1,4 @@
1
1
  import { StockLineItem, StockTransfer } from '@commercelayer/sdk';
2
-
3
2
  export type StockLineItemWithStockTransfer = StockLineItem & {
4
3
  stockTransfer?: StockTransfer;
5
4
  };
@@ -1,6 +1,5 @@
1
1
  import { ListItemProps } from '../../composite/ListItem';
2
2
  import { ResourceListItemType } from './types';
3
-
4
3
  export interface ResourceListItemProps {
5
4
  /**
6
5
  * Resource object used to generate list item content depending on its own type
@@ -363,6 +363,47 @@ export declare const presetResourceListItem: {
363
363
  };
364
364
  };
365
365
  };
366
+ returnRefunded: {
367
+ type: "returns";
368
+ id: string;
369
+ number: string;
370
+ updated_at: string;
371
+ created_at: string;
372
+ status: "refunded";
373
+ order: {
374
+ readonly type: "orders";
375
+ readonly id: "";
376
+ readonly updated_at: "2023-06-10T06:38:44.964Z";
377
+ readonly placed_at: "2023-06-09T11:00:00.000Z";
378
+ readonly created_at: "";
379
+ readonly formatted_total_amount: "$650.00";
380
+ readonly fulfillment_status: "unfulfilled";
381
+ readonly number: "123456";
382
+ readonly payment_status: "authorized";
383
+ readonly status: "placed";
384
+ readonly market: {
385
+ readonly type: "markets";
386
+ readonly id: "";
387
+ readonly name: "Europe";
388
+ readonly created_at: "";
389
+ readonly updated_at: "";
390
+ readonly shared_secret: "";
391
+ };
392
+ readonly billing_address: {
393
+ readonly first_name: "Bruce";
394
+ readonly last_name: "Wayne";
395
+ readonly type: "addresses";
396
+ readonly id: "";
397
+ readonly updated_at: "";
398
+ readonly created_at: "";
399
+ readonly line_1: "";
400
+ readonly state_code: "";
401
+ readonly phone: "";
402
+ readonly city: "";
403
+ readonly country_code: "";
404
+ };
405
+ };
406
+ };
366
407
  customerProspect: {
367
408
  type: "customers";
368
409
  id: string;
@@ -1,5 +1,4 @@
1
1
  import { DisplayStatus } from '../../../dictionaries/types';
2
-
3
2
  export declare const ListItemDescription: import('../../atoms/SkeletonTemplate').SkeletonTemplateComponent<{
4
3
  displayStatus: DisplayStatus;
5
4
  date: string;
@@ -1,4 +1,3 @@
1
1
  import { Customer } from '@commercelayer/sdk';
2
2
  import { ResourceToProps } from '../types';
3
-
4
3
  export declare const customerToProps: ResourceToProps<Customer>;
@@ -1,4 +1,3 @@
1
1
  import { Order } from '@commercelayer/sdk';
2
2
  import { ResourceToProps } from '../types';
3
-
4
3
  export declare const orderToProps: ResourceToProps<Order>;
@@ -1,4 +1,3 @@
1
1
  import { Promotion } from '@commercelayer/sdk';
2
2
  import { ResourceToProps } from '../types';
3
-
4
3
  export declare const promotionToProps: ResourceToProps<Omit<Promotion, 'type'>>;
@@ -1,4 +1,3 @@
1
1
  import { Return } from '@commercelayer/sdk';
2
2
  import { ResourceToProps } from '../types';
3
-
4
3
  export declare const returnToProps: ResourceToProps<Return>;
@@ -1,4 +1,3 @@
1
1
  import { Shipment } from '@commercelayer/sdk';
2
2
  import { ResourceToProps } from '../types';
3
-
4
3
  export declare const shipmentToProps: ResourceToProps<Shipment>;
@@ -1,4 +1,3 @@
1
1
  import { SkuListItem } from '@commercelayer/sdk';
2
2
  import { ResourceToProps } from '../types';
3
-
4
3
  export declare const skuListItemToProps: ResourceToProps<SkuListItem>;
@@ -1,4 +1,3 @@
1
1
  import { StockTransfer } from '@commercelayer/sdk';
2
2
  import { ResourceToProps } from '../types';
3
-
4
3
  export declare const stockTransferToProps: ResourceToProps<StockTransfer>;
@@ -1,7 +1,6 @@
1
1
  import { TokenProviderAuthUser } from '../../../providers/TokenProvider/types';
2
2
  import { ListItemProps } from '../../composite/ListItem';
3
3
  import { BuyXPayYPromotion, Customer, ExternalPromotion, FixedAmountPromotion, FixedPricePromotion, FreeGiftPromotion, FreeShippingPromotion, Order, PercentageDiscountPromotion, Return, Shipment, SkuListItem, StockTransfer } from '@commercelayer/sdk';
4
-
5
4
  export type ResourceListItemType = Order | Return | Customer | StockTransfer | SkuListItem | Shipment | BuyXPayYPromotion | ExternalPromotion | FixedAmountPromotion | FixedPricePromotion | FreeGiftPromotion | FreeShippingPromotion | PercentageDiscountPromotion;
6
5
  export interface ResourceListItemComponentProps {
7
6
  name: React.ReactNode;
@@ -1,6 +1,5 @@
1
1
  import { EditMetadataOverlayProps } from '../../../hooks/useEditMetadataOverlay';
2
2
  import { ListableResourceType } from '@commercelayer/sdk';
3
-
4
3
  interface MetadataOverlay extends Omit<EditMetadataOverlayProps, 'resourceId' | 'resourceType'> {
5
4
  }
6
5
  export interface ResourceMetadataProps {
@@ -1,5 +1,4 @@
1
1
  import { ResourceMetadataProps } from './ResourceMetadata';
2
-
3
2
  export declare const ResourceMetadataForm: import('../../atoms/SkeletonTemplate').SkeletonTemplateComponent<{
4
3
  resourceId: ResourceMetadataProps["resourceId"];
5
4
  resourceType: ResourceMetadataProps["resourceType"];
@@ -1,6 +1,5 @@
1
1
  import { referenceOrigins } from '../../helpers/attachments';
2
2
  import { Attachment } from '@commercelayer/sdk';
3
-
4
3
  export interface ResourceOrderTimelineProps {
5
4
  orderId?: string;
6
5
  refresh?: boolean;
@@ -1,5 +1,4 @@
1
1
  import { Shipment as ShipmentResource } from '@commercelayer/sdk';
2
-
3
2
  export interface ResourceShipmentParcelsProps {
4
3
  shipment: ShipmentResource;
5
4
  onRemoveParcel?: (parcelId: string) => void;
@@ -1,5 +1,4 @@
1
1
  import { ResourceShipmentParcels } from './ResourceShipmentParcels';
2
-
3
2
  type Shipment = Parameters<typeof ResourceShipmentParcels>[0]['shipment'];
4
3
  type Parcel = NonNullable<Shipment['parcels']>[number];
5
4
  export declare const parcelWithoutTracking1: import('@commercelayer/sdk').Parcel;
@@ -1,6 +1,5 @@
1
1
  import { EditTagsOverlayProps } from '../../hooks/useEditTagsOverlay';
2
2
  import { ListableResourceType } from '@commercelayer/sdk';
3
-
4
3
  type TaggableResource = Extract<ListableResourceType, 'addresses' | 'bundles' | 'coupons' | 'customers' | 'gift_cards' | 'line_items' | 'line_item_options' | 'order_subscriptions' | 'orders' | 'buy_x_pay_y_promotions' | 'external_promotions' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'flex_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'percentage_discount_promotions' | 'returns' | 'shipments' | 'sku_options' | 'skus'>;
5
4
  interface TagsOverlay extends Omit<EditTagsOverlayProps, 'resourceId' | 'resourceType'> {
6
5
  }
@@ -1,5 +1,4 @@
1
1
  import { FilterItemCurrencyRange } from './types';
2
-
3
2
  interface FieldCurrencyRangeProps {
4
3
  item: FilterItemCurrencyRange;
5
4
  }
@@ -1,5 +1,4 @@
1
1
  import { FilterItemOptions } from './types';
2
-
3
2
  interface FieldProps {
4
3
  item: FilterItemOptions;
5
4
  }
@@ -1,5 +1,4 @@
1
1
  import { FilterItemTextSearch } from './types';
2
-
3
2
  interface FieldProps {
4
3
  item: FilterItemTextSearch;
5
4
  }
@@ -1,5 +1,4 @@
1
1
  import { FilterItemTime } from './types';
2
-
3
2
  interface FieldTimeRangeProps {
4
3
  item: FilterItemTime;
5
4
  }
@@ -1,5 +1,4 @@
1
1
  import { FiltersInstructions } from './types';
2
-
3
2
  export interface FiltersFormProps {
4
3
  /**
5
4
  * Array of instruction items to build the filters behaviors
@@ -1,5 +1,4 @@
1
1
  import { FiltersInstructions } from './types';
2
-
3
2
  export interface FiltersNavProps {
4
3
  /**
5
4
  * Array of instruction items to build the filters behaviors
@@ -1,6 +1,5 @@
1
1
  import { SearchBarProps } from '../../composite/SearchBar';
2
2
  import { FiltersInstructions } from './types';
3
-
4
3
  export interface FilterSearchBarProps extends Pick<SearchBarProps, 'placeholder' | 'debounceMs'> {
5
4
  /**
6
5
  * Array of instruction items to build the filters behaviors
@@ -1,6 +1,5 @@
1
1
  import { QueryFilter } from '@commercelayer/sdk';
2
2
  import { CurrencyRangeFieldValue, FiltersInstructions, UiFilterName, UiFilterValue } from './types';
3
-
4
3
  export interface AdaptFormValuesToSdkParams<FilterFormValues> {
5
4
  formValues: FilterFormValues;
6
5
  timezone?: string;
@@ -1,5 +1,4 @@
1
1
  import { FiltersInstructions, FormFullValues } from './types';
2
-
3
2
  export interface AdaptFormValuesToUrlQueryParams<FilterFormValues extends FormFullValues> {
4
3
  formValues: FilterFormValues;
5
4
  instructions: FiltersInstructions;
@@ -1,6 +1,5 @@
1
1
  import { FiltersInstructions } from './types';
2
2
  import { ListableResourceType, QueryFilter } from '@commercelayer/sdk';
3
-
4
3
  export type CoreResourceEnabledInMetrics = 'orders' | 'returns';
5
4
  type MetricsResource = 'order' | 'return';
6
5
  /** Record of core api filter operators with relative metrics operator */
@@ -1,6 +1,5 @@
1
1
  import { FiltersInstructions } from './types';
2
2
  import { QueryFilter } from '@commercelayer/sdk';
3
-
4
3
  export interface AdaptSdkToUrlQueryParams {
5
4
  sdkFilters: QueryFilter;
6
5
  instructions: FiltersInstructions;
@@ -1,5 +1,4 @@
1
1
  import { FiltersInstructions, FormFullValues, UiFilterName, UiFilterValue } from './types';
2
-
3
2
  export interface AdaptUrlQueryToFormValuesParams {
4
3
  queryString: string;
5
4
  instructions: FiltersInstructions;
@@ -1,6 +1,5 @@
1
1
  import { QueryFilter } from '@commercelayer/sdk';
2
2
  import { FiltersInstructions } from './types';
3
-
4
3
  export interface AdaptUrlQueryToSdkParams {
5
4
  queryString: string;
6
5
  instructions: FiltersInstructions;
@@ -1,5 +1,4 @@
1
1
  import { FiltersInstructions } from './types';
2
-
3
2
  export interface AdaptUrlQueryToUrlQueryParams {
4
3
  queryString: string;
5
4
  instructions: FiltersInstructions;
@@ -1,3 +1,2 @@
1
1
  import { MakeFiltersAdapters } from './adapters.types';
2
-
3
2
  export declare const makeFilterAdapters: MakeFiltersAdapters;
@@ -7,7 +7,6 @@ import { AdaptUrlQueryToFormValuesParams } from './adaptUrlQueryToFormValues';
7
7
  import { AdaptUrlQueryToSdkParams } from './adaptUrlQueryToSdk';
8
8
  import { AdaptUrlQueryToUrlQueryParams } from './adaptUrlQueryToUrlQuery';
9
9
  import { FiltersInstructions, FormFullValues, PageInfoFormValues, TimeRangeFormValues, UiFilterName, UiFilterValue } from './types';
10
-
11
10
  interface MakeFilterAdaptersParams {
12
11
  instructions: FiltersInstructions;
13
12
  predicateWhitelist: string[];
@@ -1,3 +1,2 @@
1
1
  import { FiltersInstructions } from './types';
2
-
3
2
  export declare const instructions: FiltersInstructions;
@@ -1,6 +1,5 @@
1
1
  import { z } from 'zod';
2
2
  import { TimeRangeFormValues, TimeRangePreset } from './types';
3
-
4
3
  interface MakerSdkFilterTimeParams {
5
4
  timePreset?: TimeRangePreset;
6
5
  timeFrom?: Date | null;
@@ -1,6 +1,5 @@
1
1
  import { InputCurrencyRangeProps } from '../../forms/InputCurrencyRange';
2
2
  import { InputResourceGroupProps } from '../../forms/InputResourceGroup';
3
-
4
3
  export declare const filterableTimeRangePreset: readonly ["today", "last7days", "last30days", "custom"];
5
4
  export type UiFilterName = string;
6
5
  export type UiFilterValue = string | string[] | boolean | Date | undefined;
@@ -1,11 +1,10 @@
1
- import { ResourceListProps } from '../ResourceList';
2
- import { ResourceListItemTemplate } from '../ResourceList/ResourceList';
1
+ import { UseResourceListConfig } from '../useResourceList';
2
+ import { ResourceListProps } from '../useResourceList/useResourceList';
3
3
  import { ListableResourceType, QueryFilter } from '@commercelayer/sdk';
4
4
  import { FiltersFormProps } from './FiltersForm';
5
5
  import { FiltersNavProps } from './FiltersNav';
6
6
  import { makeFilterAdapters } from './adapters';
7
7
  import { FiltersInstructions } from './types';
8
-
9
8
  interface UseResourceFiltersConfig {
10
9
  /**
11
10
  * Array of instruction items to build the filters behaviors
@@ -58,9 +57,9 @@ interface UseResourceFiltersHook {
58
57
  /**
59
58
  * Filtered ResourceList component based on current active filters
60
59
  */
61
- FilteredList: <TResource extends ListableResourceType>(props: Omit<ResourceListProps<TResource>, 'query' | 'metricsQuery'> & ResourceListItemTemplate<TResource> & {
62
- query?: Omit<NonNullable<ResourceListProps<TResource>['query']>, 'filters'>;
63
- metricsQuery?: Omit<NonNullable<ResourceListProps<TResource>['metricsQuery']>, 'filter'> & {
60
+ FilteredList: <TResource extends ListableResourceType>(props: Omit<UseResourceListConfig<TResource>, 'query' | 'metricsQuery'> & ResourceListProps<TResource> & {
61
+ query?: Omit<NonNullable<UseResourceListConfig<TResource>['query']>, 'filters'>;
62
+ metricsQuery?: Omit<NonNullable<UseResourceListConfig<TResource>['metricsQuery']>, 'filter'> & {
64
63
  /** Filters need to be configured within the `useResourceFilters` options. */
65
64
  filters?: never;
66
65
  };
@@ -1,5 +1,4 @@
1
1
  import { FilterItemOptions, FiltersInstructions } from './types';
2
-
3
2
  /**
4
3
  * Show the filter label with the counter for selected options
5
4
  * or just the total of available options when nothing is selected
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  interface VisibilityTriggerProps extends React.HTMLAttributes<HTMLDivElement> {
4
3
  rootMargin?: string;
5
4
  callback: (entry: IntersectionObserverEntry) => void;
@@ -1,5 +1,4 @@
1
1
  import { Order } from '@commercelayer/sdk';
2
-
3
2
  export interface MetricsResourceOrder {
4
3
  id: string;
5
4
  type: 'orders';
@@ -0,0 +1 @@
1
+ export { useResourceList, type ResourceListItemTemplateProps, type ResourceListProps, type UseResourceListConfig } from './useResourceList';
@@ -1,6 +1,5 @@
1
- import { MetricsApiClient } from './metricsApiClient';
2
1
  import { CommerceLayerClient, ListableResourceType, QueryParamsList, ResourceFields } from '@commercelayer/sdk';
3
-
2
+ import { MetricsApiClient } from './metricsApiClient';
4
3
  type ListResource<TResource extends ListableResourceType> = Awaited<ReturnType<CommerceLayerClient[TResource]['list']>>;
5
4
  export type Resource<TResource extends ListableResourceType> = ListResource<TResource>[number];
6
5
  export interface FetcherResponse<TResource> {
@@ -1,8 +1,7 @@
1
- import { Resource } from './infiniteFetcher';
2
1
  import { MetricsFilters } from '../useResourceFilters/adaptSdkToMetrics';
3
2
  import { ListableResourceType, ListMeta, ListResponse } from '@commercelayer/sdk';
4
3
  import { Writable } from 'type-fest';
5
-
4
+ import { Resource } from './infiniteFetcher';
6
5
  export type MetricsResources = 'orders' | 'returns';
7
6
  type ListResponseWithoutMeta<ResourceType extends MetricsResources> = Omit<ListResponse<Resource<ResourceType>>, 'meta'>;
8
7
  type ListMetaWithCursor = Writable<ListMeta> & {
@@ -1,6 +1,5 @@
1
1
  import { ListableResourceType } from '@commercelayer/sdk';
2
2
  import { FetcherResponse, Resource } from './infiniteFetcher';
3
-
4
3
  interface ResourceListInternalState<TResource extends ListableResourceType> {
5
4
  isLoading: boolean;
6
5
  error?: {
@@ -1,10 +1,9 @@
1
1
  import { SectionProps } from '../../atoms/Section';
2
2
  import { SkeletonTemplateProps } from '../../atoms/SkeletonTemplate';
3
3
  import { ThProps } from '../../atoms/Table/Th';
4
- import { FetcherResponse, Resource } from './infiniteFetcher';
5
- import { ListableResourceType, QueryParamsList, ResourceFields } from '@commercelayer/sdk';
6
- import { default as React, FC } from 'react';
7
-
4
+ import { ListMeta, ListableResourceType, QueryParamsList, ResourceFields } from '@commercelayer/sdk';
5
+ import { default as React, FC, ReactNode } from 'react';
6
+ import { Resource } from './infiniteFetcher';
8
7
  export interface ResourceListItemTemplateProps<TResource extends ListableResourceType> extends SkeletonTemplateProps<{
9
8
  /**
10
9
  * The fetched resource
@@ -20,42 +19,20 @@ export interface ResourceListItemTemplateProps<TResource extends ListableResourc
20
19
  type TableVariantHeading = Omit<ThProps, 'children'> & {
21
20
  label: React.ReactNode;
22
21
  };
23
- export interface ResourceListItemTemplate<TResource extends ListableResourceType> {
22
+ export type ResourceListProps<TResource extends ListableResourceType> = Pick<SectionProps, 'actionButton'> & {
24
23
  /**
25
24
  * A react component to be used to render each item in the list.
26
25
  * For best results, pass as `Item` a component already wrapped in a `SkeletonTemplate` (or `withSkeletonTemplate` HOC).
27
26
  * In this way the loading state will be handled automatically.
28
27
  */
29
28
  ItemTemplate: FC<ResourceListItemTemplateProps<TResource>>;
30
- }
31
- export type ResourceListProps<TResource extends ListableResourceType> = Pick<SectionProps, 'actionButton'> & {
32
- /**
33
- * The resource type to be fetched in the list
34
- */
35
- type: TResource;
36
- /**
37
- * SDK query object to be used to fetch the list, excluding the pageNumber that is handled internally for infinite scrolling.
38
- */
39
- query?: Omit<QueryParamsList<ResourceFields[TResource]>, 'pageNumber'>;
40
- /**
41
- * When set the component will fetch data from the Metrics API, and automatically use the returned cursor for infinite scrolling.
42
- */
43
- metricsQuery?: {
44
- search: {
45
- limit?: number;
46
- sort?: 'asc' | 'desc';
47
- sort_by?: string;
48
- fields?: string[];
49
- };
50
- filter: Record<string, unknown>;
51
- };
52
29
  /**
53
30
  * An element to be rendered when the list is empty.
54
31
  * When not provided, a default message will be shown.
55
32
  * When a string is provided, it will be rendered as inline text below title and actionButton.
56
- * When a JSX element is provided, it will be rendered as a custom element and no title or actionButton will be shown.
33
+ * When other ReactNode is provided, it will be rendered as a custom element and no title or actionButton will be shown.
57
34
  */
58
- emptyState?: JSX.Element;
35
+ emptyState?: ReactNode;
59
36
  /**
60
37
  * Title.
61
38
  */
@@ -68,32 +45,60 @@ export type ResourceListProps<TResource extends ListableResourceType> = Pick<Sec
68
45
  /** Boxed variant wraps the list in a Card */
69
46
  variant?: 'boxed';
70
47
  } | {
48
+ /** Table variant wraps the list in a Table and enables the `headings` prop */
71
49
  variant: 'table';
72
50
  headings: TableVariantHeading[];
73
- }) & (ResourceListItemTemplate<TResource> | {
51
+ });
52
+ export interface UseResourceListConfig<TResource extends ListableResourceType> {
74
53
  /**
75
- * Children as a function to render a custom element.
76
- * @example
77
- * ```
78
- * <ResourceList type='customers'>
79
- * {({ isLoading, data }) => <ol>{data?.list.map(customer => <li>{customer.email}</li>)}</ol>
80
- * </ResourceList>
81
- * ```
54
+ * The resource type to be fetched in the list
82
55
  */
83
- children: (childrenProps: {
84
- isLoading: boolean;
85
- data?: FetcherResponse<Resource<TResource>>;
86
- isFirstLoading: boolean;
87
- removeItem: (resourceId: string) => void;
88
- }) => React.ReactNode;
89
- });
56
+ type: TResource;
57
+ /**
58
+ * SDK query object to be used to fetch the list, excluding the pageNumber that is handled internally for infinite scrolling.
59
+ */
60
+ query?: Omit<QueryParamsList<ResourceFields[TResource]>, 'pageNumber'>;
61
+ /**
62
+ * When set the component will fetch data from the Metrics API, and automatically use the returned cursor for infinite scrolling.
63
+ */
64
+ metricsQuery?: {
65
+ search: {
66
+ limit?: number;
67
+ sort?: 'asc' | 'desc';
68
+ sort_by?: string;
69
+ fields?: string[];
70
+ };
71
+ filter: Record<string, unknown>;
72
+ };
73
+ }
90
74
  /**
91
75
  * Renders a list of resources of a given type with infinite scrolling.
92
76
  * It's possible to specify a query to filter the list and either
93
77
  * a React component (`ItemTemplate`) to be used as item template for the list or a function as `children` to render a custom element.
94
78
  */
95
- export declare function ResourceList<TResource extends ListableResourceType>({ type, query, title, titleSize, variant, actionButton, metricsQuery, emptyState: emptyStateProp, ...props }: ResourceListProps<TResource>): JSX.Element;
96
- export declare namespace ResourceList {
97
- var displayName: string;
98
- }
79
+ export declare function useResourceList<TResource extends ListableResourceType>({ type, query, metricsQuery }: UseResourceListConfig<TResource>): {
80
+ /** The component that renders the list with infinite scrolling functionality */
81
+ ResourceList: FC<ResourceListProps<TResource>>;
82
+ /** The raw array of fetched resources, which grows each time a new page is fetched */
83
+ list?: Array<Resource<TResource>>;
84
+ /** Metadata related to pagination, as returned by the SDK */
85
+ meta?: ListMeta;
86
+ /** Indicates whether the list is currently loading the next page */
87
+ isLoading: boolean;
88
+ /** Indicates whether the list is loading for the first time (initial page load) */
89
+ isFirstLoading: boolean;
90
+ /** The error message (already parsed) returned from the API when a fetch request fails */
91
+ error?: string;
92
+ /** Removes an item from the list, typically can be triggered after a delete action from the UI */
93
+ removeItem: (resourceId: string) => void;
94
+ /**
95
+ * Manually triggers data fetching for the next page without requiring the user to reach the infinite scroll trigger.
96
+ * It does not trigger when last page has been reached.
97
+ */
98
+ fetchMore: () => Promise<void>;
99
+ /** Refreshes the list by clearing all previously fetched data and resetting the initial loading state before refetching the first page. */
100
+ refresh: () => void;
101
+ /** Indicates whether there are more pages available for fetching */
102
+ hasMorePages?: boolean;
103
+ };
99
104
  export {};
@@ -1,5 +1,4 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
-
3
2
  export declare function isFunctionComponent(reactNode: ReactNode): reactNode is ReactElement<any, React.FunctionComponent<any>>;
4
3
  /**
5
4
  * Checks if a ReactNode matches a specific component display name.
@@ -1,5 +1,4 @@
1
1
  import { JsonObject } from 'type-fest';
2
-
3
2
  /**
4
3
  * Extract all keys from an array of objects of different shapes,
5
4
  * @param data - array of objects of different shapes
@@ -1,5 +1,4 @@
1
1
  import { JsonPrimitive } from 'type-fest';
2
-
3
2
  /**
4
3
  * Given a `text` and a list of `values` it returns always the same value given the same `text`.
5
4
  * For example this is used when you need to map a full name with a color.