@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.
- package/dist/InputDateComponent-CMJl1SsY.js +6188 -0
- package/dist/dictionaries/customers.d.ts +0 -1
- package/dist/dictionaries/orders.d.ts +0 -1
- package/dist/dictionaries/promotions.d.ts +0 -1
- package/dist/dictionaries/returns.d.ts +0 -1
- package/dist/dictionaries/shipments.d.ts +0 -1
- package/dist/dictionaries/stockTransfers.d.ts +0 -1
- package/dist/dictionaries/types.d.ts +0 -1
- package/dist/helpers/appsNavigation.d.ts +0 -1
- package/dist/helpers/attachments.d.ts +0 -1
- package/dist/helpers/currencies.d.ts +0 -1
- package/dist/helpers/date.d.ts +0 -1
- package/dist/helpers/resources.d.ts +0 -1
- package/dist/helpers/tracking.d.ts +0 -1
- package/dist/hooks/useClickAway.d.ts +0 -1
- package/dist/hooks/useEditMetadataOverlay.d.ts +0 -1
- package/dist/hooks/useEditTagsOverlay.d.ts +0 -1
- package/dist/hooks/useOverlay.d.ts +0 -1
- package/dist/{main-uMPiX52G.js → main-8vGdIM-n.js} +10840 -10718
- package/dist/main.d.ts +1 -2
- package/dist/main.js +102 -102
- package/dist/providers/CoreSdkProvider/CoreSdkProvider.d.ts +0 -1
- package/dist/providers/CoreSdkProvider/makeSdkClient.d.ts +0 -1
- package/dist/providers/CoreSdkProvider/useCoreApi.d.ts +0 -1
- package/dist/providers/ErrorBoundary.d.ts +0 -1
- package/dist/providers/GTMProvider.d.ts +0 -1
- package/dist/providers/TokenProvider/MockTokenProvider.d.ts +0 -1
- package/dist/providers/TokenProvider/TokenProvider.d.ts +0 -1
- package/dist/providers/TokenProvider/extras.d.ts +0 -1
- package/dist/providers/TokenProvider/getAccessTokenFromUrl.d.ts +0 -1
- package/dist/providers/TokenProvider/getInfoFromJwt.d.ts +0 -1
- package/dist/providers/TokenProvider/getOrganization.d.ts +0 -1
- package/dist/providers/TokenProvider/reducer.d.ts +0 -1
- package/dist/providers/TokenProvider/storage.d.ts +0 -1
- package/dist/providers/TokenProvider/types.d.ts +0 -1
- package/dist/providers/TokenProvider/validateToken.d.ts +0 -1
- package/dist/providers/createApp.d.ts +0 -1
- package/dist/style.css +1 -1
- package/dist/ui/atoms/A.d.ts +0 -1
- package/dist/ui/atoms/Avatar.d.ts +0 -1
- package/dist/ui/atoms/Badge/Badge.d.ts +0 -1
- package/dist/ui/atoms/Button.d.ts +0 -1
- package/dist/ui/atoms/ButtonFilter.d.ts +0 -1
- package/dist/ui/atoms/Card.d.ts +4 -2
- package/dist/ui/atoms/CodeBlock.d.ts +0 -1
- package/dist/ui/atoms/EmptyState.d.ts +0 -1
- package/dist/ui/atoms/Grid.d.ts +0 -1
- package/dist/ui/atoms/Hint.d.ts +0 -1
- package/dist/ui/atoms/Icon/Icon.d.ts +0 -1
- package/dist/ui/atoms/PageHeading/PageHeading.d.ts +0 -1
- package/dist/ui/atoms/PageHeading/PageHeadingToolbar.d.ts +0 -1
- package/dist/ui/atoms/RadialProgress.d.ts +0 -1
- package/dist/ui/atoms/ScrollToTop.d.ts +0 -1
- package/dist/ui/atoms/Section.d.ts +0 -1
- package/dist/ui/atoms/Skeleton.d.ts +0 -1
- package/dist/ui/atoms/SkeletonTemplate.d.ts +0 -1
- package/dist/ui/atoms/Spacer.d.ts +0 -1
- package/dist/ui/atoms/Stack.d.ts +0 -1
- package/dist/ui/atoms/StatusIcon.d.ts +0 -1
- package/dist/ui/atoms/Table/Table.d.ts +0 -1
- package/dist/ui/atoms/Table/Td.d.ts +0 -1
- package/dist/ui/atoms/Tabs.d.ts +0 -1
- package/dist/ui/atoms/Tag.d.ts +0 -1
- package/dist/ui/atoms/Text.d.ts +0 -1
- package/dist/ui/atoms/Tooltip.d.ts +0 -1
- package/dist/ui/composite/ActionButtons/ActionButtons.d.ts +0 -1
- package/dist/ui/composite/Dropdown/Dropdown.d.ts +0 -1
- package/dist/ui/composite/Dropdown/DropdownDivider.d.ts +0 -1
- package/dist/ui/composite/Dropdown/DropdownItem.d.ts +4 -3
- package/dist/ui/composite/Dropdown/DropdownMenu.d.ts +0 -1
- package/dist/ui/composite/HomePageLayout.d.ts +0 -1
- package/dist/ui/composite/List.d.ts +0 -1
- package/dist/ui/composite/ListDetails.d.ts +0 -1
- package/dist/ui/composite/ListDetailsItem.d.ts +0 -1
- package/dist/ui/composite/ListItem.d.ts +0 -1
- package/dist/ui/composite/PageError.d.ts +0 -1
- package/dist/ui/composite/PageLayout.d.ts +0 -1
- package/dist/ui/composite/Report.d.ts +0 -1
- package/dist/ui/composite/Routes/Routes.d.ts +0 -1
- package/dist/ui/composite/Routes/utils.d.ts +0 -1
- package/dist/ui/composite/SearchBar.d.ts +0 -1
- package/dist/ui/composite/TableData.d.ts +0 -1
- package/dist/ui/composite/Timeline.d.ts +0 -1
- package/dist/ui/composite/Toolbar.d.ts +0 -1
- package/dist/ui/forms/Form/HookedForm.d.ts +0 -1
- package/dist/ui/forms/Input/HookedInput.d.ts +0 -1
- package/dist/ui/forms/Input/Input.d.ts +0 -1
- package/dist/ui/forms/InputCheckbox/HookedInputCheckbox.d.ts +0 -1
- package/dist/ui/forms/InputCheckbox/InputCheckbox.d.ts +0 -1
- package/dist/ui/forms/InputCheckboxGroup/HookedInputCheckboxGroup.d.ts +0 -1
- package/dist/ui/forms/InputCheckboxGroup/InputCheckboxGroup.d.ts +0 -1
- package/dist/ui/forms/InputCheckboxGroup/InputCheckboxGroupItem.d.ts +0 -1
- package/dist/ui/forms/InputCheckboxGroup/reducer.d.ts +0 -1
- package/dist/ui/forms/InputCurrency/HookedInputCurrency.d.ts +0 -1
- package/dist/ui/forms/InputCurrency/InputCurrency.d.ts +0 -1
- package/dist/ui/forms/InputCurrency/utils.d.ts +0 -1
- package/dist/ui/forms/InputCurrencyRange.d.ts +0 -1
- package/dist/ui/forms/InputDate/HookedInputDate.d.ts +0 -1
- package/dist/ui/forms/InputDate/InputDate.d.ts +0 -1
- package/dist/ui/forms/InputDate/InputDateComponent.d.ts +0 -1
- package/dist/ui/forms/InputDateRange/HookedInputDateRange.d.ts +0 -1
- package/dist/ui/forms/InputDateRange/InputDateRange.d.ts +0 -1
- package/dist/ui/forms/InputFile.d.ts +0 -1
- package/dist/ui/forms/InputJson.d.ts +0 -1
- package/dist/ui/forms/InputRadioGroup/HookedInputRadioGroup.d.ts +0 -1
- package/dist/ui/forms/InputRadioGroup/InputRadioGroup.d.ts +0 -1
- package/dist/ui/forms/InputResourceGroup/FullList.d.ts +0 -1
- package/dist/ui/forms/InputResourceGroup/HookedInputResourceGroup.d.ts +0 -1
- package/dist/ui/forms/InputResourceGroup/InputResourceGroup.d.ts +0 -1
- package/dist/ui/forms/InputResourceGroup/utils.d.ts +0 -1
- package/dist/ui/forms/InputSelect/AsyncComponent.d.ts +0 -1
- package/dist/ui/forms/InputSelect/AsyncCreatableComponent.d.ts +0 -1
- package/dist/ui/forms/InputSelect/CreatableComponent.d.ts +0 -1
- package/dist/ui/forms/InputSelect/GenericAsyncComponent.d.ts +0 -1
- package/dist/ui/forms/InputSelect/HookedInputSelect.d.ts +0 -1
- package/dist/ui/forms/InputSelect/InputSelect.d.ts +0 -1
- package/dist/ui/forms/InputSelect/SelectComponent.d.ts +0 -1
- package/dist/ui/forms/InputSelect/overrides.d.ts +0 -1
- package/dist/ui/forms/InputSelect/styles.d.ts +0 -1
- package/dist/ui/forms/InputSelect/utils.d.ts +0 -1
- package/dist/ui/forms/InputSimpleSelect/HookedInputSimpleSelect.d.ts +0 -1
- package/dist/ui/forms/InputSimpleSelect/InputSimpleSelect.d.ts +0 -1
- package/dist/ui/forms/InputSpinner/HookedInputSpinner.d.ts +0 -1
- package/dist/ui/forms/InputSpinner/InputSpinner.d.ts +0 -1
- package/dist/ui/forms/InputSwitch/HookedInputSwitch.d.ts +0 -1
- package/dist/ui/forms/InputSwitch/InputSwitch.d.ts +0 -1
- package/dist/ui/forms/InputTextArea/HookedInputTextArea.d.ts +0 -1
- package/dist/ui/forms/InputTextArea/InputTextArea.d.ts +0 -1
- package/dist/ui/forms/InputToggleButton/HookedInputToggleButton.d.ts +0 -1
- package/dist/ui/forms/InputToggleButton/InputToggleButton.d.ts +0 -1
- package/dist/ui/forms/MarketWithCurrencySelector/HookedMarketWithCurrencySelector.d.ts +0 -1
- package/dist/ui/forms/ReactHookForm/setApiFormErrors.d.ts +0 -1
- package/dist/ui/forms/ReactHookForm/useValidationFeedback.d.ts +0 -1
- package/dist/ui/internals/FlexRow.d.ts +0 -1
- package/dist/ui/internals/InputWrapper.d.ts +0 -1
- package/dist/ui/resources/ResourceAddress/ResourceAddress.d.ts +0 -1
- package/dist/ui/resources/ResourceAddress/ResourceAddressForm.d.ts +0 -1
- package/dist/ui/resources/ResourceAddress/ResourceAddressFormFields.d.ts +0 -1
- package/dist/ui/resources/ResourceAddress/useResourceAddressOverlay.d.ts +0 -1
- package/dist/ui/resources/ResourceDetails/ResourceDetails.d.ts +2 -1
- package/dist/ui/resources/ResourceDetails/ResourceDetailsForm.d.ts +7 -0
- package/dist/ui/resources/ResourceDetails/useEditDetailsOverlay.d.ts +16 -0
- package/dist/ui/resources/ResourceLineItems/ResourceLineItems.d.ts +0 -1
- package/dist/ui/resources/ResourceLineItems/types.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/ResourceListItem.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/ResourceListItem.mocks.d.ts +41 -0
- package/dist/ui/resources/ResourceListItem/common.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/transformers/customers.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/transformers/orders.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/transformers/promotions.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/transformers/returns.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/transformers/shipments.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/transformers/skuListItem.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/transformers/stockTransfers.d.ts +0 -1
- package/dist/ui/resources/ResourceListItem/types.d.ts +0 -1
- package/dist/ui/resources/ResourceMetadata/ResourceMetadata.d.ts +0 -1
- package/dist/ui/resources/ResourceMetadata/ResourceMetadataForm.d.ts +0 -1
- package/dist/ui/resources/ResourceOrderTimeline.d.ts +0 -1
- package/dist/ui/resources/ResourceShipmentParcels.d.ts +0 -1
- package/dist/ui/resources/ResourceShipmentParcels.mocks.d.ts +0 -1
- package/dist/ui/resources/ResourceTags.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/FieldCurrencyRange.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/FieldOptions.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/FieldTextSearch.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/FieldTimeRange.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/FiltersForm.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/FiltersNav.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/FiltersSearchBar.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/adaptFormValuesToSdk.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/adaptFormValuesToUrlQuery.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/adaptSdkToMetrics.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/adaptSdkToUrlQuery.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/adaptUrlQueryToFormValues.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/adaptUrlQueryToSdk.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/adaptUrlQueryToUrlQuery.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/adapters.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/adapters.types.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/mockedInstructions.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/timeUtils.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/types.d.ts +0 -1
- package/dist/ui/resources/useResourceFilters/useResourceFilters.d.ts +5 -6
- package/dist/ui/resources/useResourceFilters/utils.d.ts +0 -1
- package/dist/ui/resources/{ResourceList → useResourceList}/VisibilityTrigger.d.ts +0 -1
- package/dist/ui/resources/{ResourceList → useResourceList}/adaptMetricsOrderToCore.d.ts +0 -1
- package/dist/ui/resources/useResourceList/index.d.ts +1 -0
- package/dist/ui/resources/{ResourceList → useResourceList}/infiniteFetcher.d.ts +1 -2
- package/dist/ui/resources/{ResourceList → useResourceList}/metricsApiClient.d.ts +1 -2
- package/dist/ui/resources/{ResourceList → useResourceList}/reducer.d.ts +0 -1
- package/dist/ui/resources/{ResourceList/ResourceList.d.ts → useResourceList/useResourceList.d.ts} +53 -48
- package/dist/utils/children.d.ts +0 -1
- package/dist/utils/extractHeaders.d.ts +0 -1
- package/dist/utils/text.d.ts +0 -1
- package/dist/vendor.css +1 -1
- package/package.json +22 -22
- package/dist/InputDateComponent-BHXJF53e.js +0 -5064
- package/dist/ui/resources/ResourceList/index.d.ts +0 -1
- /package/dist/ui/resources/{ResourceList → useResourceList}/VisibilityTrigger.test.d.ts +0 -0
- /package/dist/ui/resources/{ResourceList → useResourceList}/adaptMetricsOrderToCore.test.d.ts +0 -0
- /package/dist/ui/resources/{ResourceList/ResourceList.test.d.ts → useResourceList/useResourceList.test.d.ts} +0 -0
- /package/dist/ui/resources/{ResourceList → useResourceList}/utils.d.ts +0 -0
- /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
|
/**
|
|
@@ -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,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,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,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,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 */
|
|
@@ -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,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 {
|
|
2
|
-
import {
|
|
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<
|
|
62
|
-
query?: Omit<NonNullable<
|
|
63
|
-
metricsQuery?: Omit<NonNullable<
|
|
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
|
};
|
|
@@ -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> & {
|
package/dist/ui/resources/{ResourceList/ResourceList.d.ts → useResourceList/useResourceList.d.ts}
RENAMED
|
@@ -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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
|
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
|
|
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?:
|
|
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
|
-
})
|
|
51
|
+
});
|
|
52
|
+
export interface UseResourceListConfig<TResource extends ListableResourceType> {
|
|
74
53
|
/**
|
|
75
|
-
*
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|
96
|
-
|
|
97
|
-
|
|
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 {};
|
package/dist/utils/children.d.ts
CHANGED