@commercelayer/app-elements 2.8.2 → 2.9.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-DllMLsS1.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 +2 -3
- package/dist/hooks/useEditTagsOverlay.d.ts +0 -1
- package/dist/hooks/useOverlay.d.ts +0 -1
- package/dist/{main-D23WtsYD.js → main-D1_o3ggn.js} +10737 -11001
- 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 +0 -1
- 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/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 +1 -15
- package/dist/ui/resources/ResourceMetadata/ResourceMetadataForm.d.ts +0 -2
- package/dist/ui/resources/ResourceMetadata/index.d.ts +1 -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} +50 -45
- 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-D2ChTbp8.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
|
@@ -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,19 +1,10 @@
|
|
|
1
1
|
import { EditMetadataOverlayProps } from '../../../hooks/useEditMetadataOverlay';
|
|
2
2
|
import { ListableResourceType } from '@commercelayer/sdk';
|
|
3
|
-
|
|
4
|
-
interface MetadataOverlay extends Omit<EditMetadataOverlayProps, 'resourceId' | 'resourceType' | 'mode'> {
|
|
3
|
+
interface MetadataOverlay extends Omit<EditMetadataOverlayProps, 'resourceId' | 'resourceType'> {
|
|
5
4
|
}
|
|
6
|
-
export type ResourceMetadataMode = 'simple' | 'advanced';
|
|
7
5
|
export interface ResourceMetadataProps {
|
|
8
6
|
resourceType: ListableResourceType;
|
|
9
7
|
resourceId: string;
|
|
10
|
-
/**
|
|
11
|
-
* Metadata management mode:
|
|
12
|
-
* - If set to `simple` the edit page will permit to edit just the values of the existing items.
|
|
13
|
-
* - If set to `advanced` the edit page will permit to fully create, edit and remove the items.
|
|
14
|
-
* @default advanced
|
|
15
|
-
*/
|
|
16
|
-
mode?: ResourceMetadataMode;
|
|
17
8
|
/**
|
|
18
9
|
* Edit overlay configuration
|
|
19
10
|
*/
|
|
@@ -29,11 +20,6 @@ export declare const isUpdatableType: (value: any) => value is UpdatableType;
|
|
|
29
20
|
export declare const ResourceMetadata: import('../../atoms/SkeletonTemplate').SkeletonTemplateComponent<{
|
|
30
21
|
resourceType: ListableResourceType;
|
|
31
22
|
resourceId: string;
|
|
32
|
-
mode?: ResourceMetadataMode
|
|
33
|
-
/**
|
|
34
|
-
* Edit overlay configuration
|
|
35
|
-
*/
|
|
36
|
-
| undefined;
|
|
37
23
|
overlay?: MetadataOverlay | undefined;
|
|
38
24
|
delayMs?: number | undefined;
|
|
39
25
|
isLoading?: boolean | undefined;
|
|
@@ -1,9 +1,7 @@
|
|
|
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"];
|
|
6
|
-
mode: ResourceMetadataProps["mode"];
|
|
7
5
|
onSubmitted: () => void;
|
|
8
6
|
delayMs?: number | undefined;
|
|
9
7
|
isLoading?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ResourceMetadata, type
|
|
1
|
+
export { ResourceMetadata, type ResourceMetadataProps } from './ResourceMetadata';
|
|
@@ -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 { ListableResourceType, QueryParamsList, ResourceFields } from '@commercelayer/sdk';
|
|
4
|
+
import { ListMeta, ListableResourceType, QueryParamsList, ResourceFields } from '@commercelayer/sdk';
|
|
6
5
|
import { default as React, FC } from 'react';
|
|
7
|
-
|
|
6
|
+
import { Resource } from './infiniteFetcher';
|
|
8
7
|
export interface ResourceListItemTemplateProps<TResource extends ListableResourceType> extends SkeletonTemplateProps<{
|
|
9
8
|
/**
|
|
10
9
|
* The fetched resource
|
|
@@ -20,35 +19,13 @@ 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.
|
|
@@ -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