@commercelayer/app-elements 0.1.0 → 0.2.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/README.md +14 -48
- package/dist/{InputDateComponent-4461b3e6.js → InputDateComponent-926e5e6d.js} +133 -134
- package/dist/dictionaries/customers.d.ts +6 -0
- package/dist/dictionaries/orders.d.ts +4 -3
- package/dist/dictionaries/returns.d.ts +16 -0
- package/dist/dictionaries/types.d.ts +7 -0
- package/dist/helpers/appsNavigation.d.ts +5 -5
- package/dist/main-d208b3aa.js +29029 -0
- package/dist/main.d.ts +10 -8
- package/dist/main.js +141 -140
- package/dist/style.css +1 -1
- package/dist/ui/forms/InputCurrencyRange.d.ts +1 -1
- package/dist/ui/forms/InputSelect/{Async.d.ts → AsyncComponent.d.ts} +1 -4
- package/dist/ui/forms/InputSelect/HookedInputSelect.d.ts +1 -4
- package/dist/ui/forms/InputSelect/InputSelect.d.ts +61 -52
- package/dist/ui/forms/InputSelect/{Select.d.ts → SelectComponent.d.ts} +1 -4
- package/dist/ui/forms/InputSelect/index.d.ts +2 -1
- package/dist/ui/forms/InputSelect/overrides.d.ts +5 -1
- package/dist/ui/forms/InputSelect/utils.d.ts +48 -0
- package/dist/ui/internals/InputWrapper.d.ts +16 -5
- package/dist/ui/resources/{LineItems.d.ts → ResourceLineItems.d.ts} +1 -1
- package/dist/ui/resources/ResourceList/ResourceList.d.ts +5 -5
- package/dist/ui/resources/ResourceListItem/ResourceListItem.d.ts +26 -0
- package/dist/ui/resources/ResourceListItem/ResourceListItem.mocks.d.ts +399 -0
- package/dist/ui/resources/ResourceListItem/common.d.ts +14 -0
- package/dist/ui/resources/ResourceListItem/index.d.ts +1 -0
- package/dist/ui/resources/ResourceListItem/transformers/customers.d.ts +3 -0
- package/dist/ui/resources/ResourceListItem/transformers/index.d.ts +3 -0
- package/dist/ui/resources/ResourceListItem/transformers/orders.d.ts +3 -0
- package/dist/ui/resources/ResourceListItem/transformers/returns.d.ts +3 -0
- package/dist/ui/resources/ResourceListItem/types.d.ts +15 -0
- package/dist/ui/resources/{ListItemsMetadata.d.ts → ResourceListItemsMetadata.d.ts} +1 -2
- package/dist/ui/resources/{OrderSummary.d.ts → ResourceOrderSummary.d.ts} +1 -1
- package/dist/ui/resources/{OrderTimeline.d.ts → ResourceOrderTimeline.d.ts} +1 -1
- package/dist/ui/resources/{ShipmentParcels.d.ts → ResourceShipmentParcels.d.ts} +1 -1
- package/dist/ui/resources/ResourceTags.d.ts +1 -0
- package/dist/ui/resources/useResourceFilters/index.d.ts +1 -0
- package/dist/ui/resources/{Filters/useFilters.d.ts → useResourceFilters/useResourceFilters.d.ts} +5 -5
- package/package.json +2 -1
- package/dist/Async-566ec3f7.js +0 -99
- package/dist/Select-89937223.js +0 -38
- package/dist/main-795be39b.js +0 -24377
- package/dist/overrides-346bb0f6.js +0 -4225
- package/dist/ui/resources/Filters/index.d.ts +0 -5
- package/dist/ui/resources/ListItemOrder.d.ts +0 -8
- package/dist/unsupportedIterableToArray-a3020d44.js +0 -126
- /package/dist/ui/{resources/Filters → forms/InputSelect}/utils.test.d.ts +0 -0
- /package/dist/ui/resources/{LineItems.mocks.d.ts → ResourceLineItems.mocks.d.ts} +0 -0
- /package/dist/ui/resources/{Filters/adaptFormValuesToSdk.test.d.ts → ResourceLineItems.test.d.ts} +0 -0
- /package/dist/ui/resources/{Filters/adaptFormValuesToUrlQuery.test.d.ts → ResourceListItemsMetadata.test.d.ts} +0 -0
- /package/dist/ui/resources/{Filters/adaptUrlQueryToFormValues.test.d.ts → ResourceOrderSummary.test.d.ts} +0 -0
- /package/dist/ui/resources/{ShipmentParcels.mocks.d.ts → ResourceShipmentParcels.mocks.d.ts} +0 -0
- /package/dist/ui/resources/{Filters/adaptUrlQueryToSdk.test.d.ts → ResourceShipmentParcels.test.d.ts} +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/FieldCurrencyRange.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/FieldItem.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/FieldTimeRange.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/FiltersForm.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/FiltersNav.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/FiltersSearchBar.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/adaptFormValuesToSdk.d.ts +0 -0
- /package/dist/ui/resources/{Filters/adaptUrlQueryToUrlQuery.test.d.ts → useResourceFilters/adaptFormValuesToSdk.test.d.ts} +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/adaptFormValuesToUrlQuery.d.ts +0 -0
- /package/dist/ui/resources/{Filters/timeUtils.test.d.ts → useResourceFilters/adaptFormValuesToUrlQuery.test.d.ts} +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/adaptUrlQueryToFormValues.d.ts +0 -0
- /package/dist/ui/resources/{LineItems.test.d.ts → useResourceFilters/adaptUrlQueryToFormValues.test.d.ts} +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/adaptUrlQueryToSdk.d.ts +0 -0
- /package/dist/ui/resources/{ListItemOrder.test.d.ts → useResourceFilters/adaptUrlQueryToSdk.test.d.ts} +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/adaptUrlQueryToUrlQuery.d.ts +0 -0
- /package/dist/ui/resources/{ListItemsMetadata.test.d.ts → useResourceFilters/adaptUrlQueryToUrlQuery.test.d.ts} +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/adapters.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/adapters.types.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/mockedInstructions.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/timeUtils.d.ts +0 -0
- /package/dist/ui/resources/{OrderSummary.test.d.ts → useResourceFilters/timeUtils.test.d.ts} +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/types.d.ts +0 -0
- /package/dist/ui/resources/{Filters → useResourceFilters}/utils.d.ts +0 -0
- /package/dist/ui/resources/{ShipmentParcels.test.d.ts → useResourceFilters/utils.test.d.ts} +0 -0
|
@@ -21,7 +21,7 @@ export interface InputCurrencyRangeProps extends InputWrapperBaseProps {
|
|
|
21
21
|
defaultCurrency?: Uppercase<CurrencyCode>;
|
|
22
22
|
className?: string;
|
|
23
23
|
}
|
|
24
|
-
export declare function InputCurrencyRange({ fromCents, toCents, placeholders, onChange, label, hint, currencyList, defaultCurrency, className, feedback }: InputCurrencyRangeProps): JSX.Element;
|
|
24
|
+
export declare function InputCurrencyRange({ fromCents, toCents, placeholders, onChange, label, hint, currencyList, inline, defaultCurrency, className, feedback }: InputCurrencyRangeProps): JSX.Element;
|
|
25
25
|
export declare namespace InputCurrencyRange {
|
|
26
26
|
var displayName: string;
|
|
27
27
|
}
|
|
@@ -5,8 +5,5 @@ import { type InputSelectProps, type SelectValue } from './InputSelect';
|
|
|
5
5
|
interface AsyncSelectComponentProps extends Omit<SetRequired<InputSelectProps, 'loadAsyncValues'>, 'label' | 'hint'> {
|
|
6
6
|
styles: StylesConfig<SelectValue>;
|
|
7
7
|
}
|
|
8
|
-
export declare
|
|
9
|
-
export declare namespace AsyncSelectComponent {
|
|
10
|
-
var displayName: string;
|
|
11
|
-
}
|
|
8
|
+
export declare const AsyncSelectComponent: React.FC<AsyncSelectComponentProps>;
|
|
12
9
|
export {};
|
|
@@ -27,8 +27,5 @@ interface Props extends Omit<InputSelectProps, 'onSelect' | 'defaultValue'> {
|
|
|
27
27
|
* Value to be stored in the field can be controlled from the `pathToValue` prop.
|
|
28
28
|
* @see InputSelect
|
|
29
29
|
*/
|
|
30
|
-
export declare
|
|
31
|
-
export declare namespace HookedInputSelect {
|
|
32
|
-
var displayName: string;
|
|
33
|
-
}
|
|
30
|
+
export declare const HookedInputSelect: React.FC<Props>;
|
|
34
31
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InputWrapperBaseProps } from '../../internals/InputWrapper';
|
|
2
2
|
import { type FocusEventHandler } from 'react';
|
|
3
|
-
import { type MultiValue, type SingleValue } from 'react-select';
|
|
3
|
+
import { type MultiValue, type Options, type SingleValue } from 'react-select';
|
|
4
4
|
export type GroupedSelectValues = Array<{
|
|
5
5
|
label: string;
|
|
6
6
|
options: SelectValue[];
|
|
@@ -12,80 +12,89 @@ export interface SelectValue {
|
|
|
12
12
|
}
|
|
13
13
|
export type PossibleSelectValue = MultiValue<SelectValue> | SingleValue<SelectValue>;
|
|
14
14
|
export interface InputSelectProps extends InputWrapperBaseProps {
|
|
15
|
+
/**
|
|
16
|
+
* Initial values to populate the select options. It can be a flat array of values or a grouped array.
|
|
17
|
+
*/
|
|
15
18
|
initialValues: GroupedSelectValues | SelectValue[];
|
|
19
|
+
/**
|
|
20
|
+
* Selected value or values, in case of `isMulti`
|
|
21
|
+
*/
|
|
16
22
|
defaultValue?: SelectValue | SelectValue[];
|
|
23
|
+
/**
|
|
24
|
+
* Placeholder text to display when no value is selected
|
|
25
|
+
*/
|
|
17
26
|
placeholder?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Controls loading UI state
|
|
29
|
+
*/
|
|
18
30
|
isLoading?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Text to display when loading
|
|
33
|
+
*/
|
|
19
34
|
loadingText?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Add a clear button (x) to the select to empty all selected values
|
|
37
|
+
*/
|
|
20
38
|
isClearable?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Disable the select
|
|
41
|
+
*/
|
|
21
42
|
isDisabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* When `true` it's possible to type to narrow down the options
|
|
45
|
+
*/
|
|
22
46
|
isSearchable?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Allow to select multiple values
|
|
49
|
+
*/
|
|
23
50
|
isMulti?: boolean;
|
|
24
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Custom rule to disable an option
|
|
53
|
+
*/
|
|
54
|
+
isOptionDisabled?: (option: SelectValue, selectValue: Options<SelectValue>) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Callback triggered when a value is selected.
|
|
57
|
+
*/
|
|
25
58
|
onSelect: (value: PossibleSelectValue) => void;
|
|
59
|
+
/**
|
|
60
|
+
* onBlur event handler
|
|
61
|
+
*/
|
|
26
62
|
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
63
|
+
/**
|
|
64
|
+
* HTML name attribute for the input component
|
|
65
|
+
*/
|
|
27
66
|
name?: string;
|
|
67
|
+
/**
|
|
68
|
+
* When `true` the dropdown menu is always open
|
|
69
|
+
*/
|
|
28
70
|
menuIsOpen?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Message to display when no options are found
|
|
73
|
+
*/
|
|
29
74
|
noOptionsMessage?: string;
|
|
75
|
+
/**
|
|
76
|
+
* css class name
|
|
77
|
+
*/
|
|
30
78
|
className?: string;
|
|
31
79
|
/**
|
|
32
80
|
* Function to load async values on search
|
|
33
81
|
*/
|
|
34
82
|
loadAsyncValues?: (inputValue: string) => Promise<GroupedSelectValues | SelectValue[]>;
|
|
35
83
|
/**
|
|
36
|
-
* Debounce time in milliseconds for async search
|
|
37
|
-
*
|
|
84
|
+
* Debounce time in milliseconds for async search.
|
|
85
|
+
* It only works when `loadAsyncValues` is provided
|
|
38
86
|
*/
|
|
39
87
|
debounceMs?: number;
|
|
40
88
|
}
|
|
41
|
-
export declare function InputSelect({ label, hint, feedback, menuIsOpen, initialValues, defaultValue, isClearable, isLoading, loadingText, placeholder, isDisabled, isOptionDisabled, isSearchable, onSelect, isMulti, onBlur, name, className, loadAsyncValues, debounceMs, noOptionsMessage, ...rest }: InputSelectProps): JSX.Element;
|
|
42
|
-
export declare namespace InputSelect {
|
|
43
|
-
var displayName: string;
|
|
44
|
-
}
|
|
45
89
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @returns true if selected value is an array of selected values, from this point TypeScript will treat this as `SelectValue[]` type
|
|
55
|
-
*/
|
|
56
|
-
export declare function isMultiValueSelected(selectedValue: PossibleSelectValue): selectedValue is SelectValue[];
|
|
57
|
-
/**
|
|
58
|
-
* Type-guard to check if prop `initialValues` is a GroupedSelectValues or SelectValue
|
|
59
|
-
*/
|
|
60
|
-
export declare function isGroupedSelectValues(initialValues?: GroupedSelectValues | SelectValue[]): initialValues is GroupedSelectValues;
|
|
61
|
-
/**
|
|
62
|
-
* Helper function to extract only a specific property from the `SelectValue`
|
|
63
|
-
* @param selectedValue possible value returned from select component
|
|
64
|
-
* @param pathToValue optional path.to.property. Default is `value`
|
|
65
|
-
* @returns a string or an array of strings.
|
|
66
|
-
* Examples:
|
|
67
|
-
* ```
|
|
68
|
-
* flatSelectValues({value: 'ABCD', label: 'T-Shirt XL'})
|
|
69
|
-
* // returns 'ABCD'
|
|
90
|
+
* Advanced select component with support for async options loading and multi-select.
|
|
91
|
+
* It's a wrapper around `react-select` with a subset of props exposed.
|
|
92
|
+
*
|
|
93
|
+
* To enable async data fetching for loading options while typing, provide the `loadAsyncValues` prop.
|
|
94
|
+
* This function will be used to fetch new options while typing and the results will be displayed in the options menu.
|
|
95
|
+
*
|
|
96
|
+
* When `isSearchable` is `true`, it's possible to type to narrow down the options. The component will always be searchable when `loadAsyncValues` is provided.
|
|
97
|
+
* On both standard and async mode it can be set to select a single single value or multiple values.
|
|
70
98
|
*
|
|
71
|
-
* flatSelectValues([
|
|
72
|
-
* {value: 'ABCD', label: 'T-Shirt M'},
|
|
73
|
-
* {value: '1234', label: 'T-Shirt XL'},
|
|
74
|
-
* ], 'label')
|
|
75
|
-
* // returns ['T-Shirt M', 'T-Shirt XL']
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
export declare function flatSelectValues(selectedValue: PossibleSelectValue, pathToValue?: string): null | string | Array<string | number>;
|
|
79
|
-
/**
|
|
80
|
-
* To be used when storing the flatten value and there is the need
|
|
81
|
-
* to retrieve the `defaultValue` to pass as <InputSelect> prop
|
|
82
|
-
* @param currentValue the current value that is being stored in app state
|
|
83
|
-
* @param initialValues the array of SelectValue objects that should contain the `currentValue`
|
|
84
|
-
* @param pathToValue optional path.to.property. Default is `value`
|
|
85
|
-
* @returns the matched value or values, otherwise undefined.
|
|
86
99
|
*/
|
|
87
|
-
export declare
|
|
88
|
-
currentValue?: string | Array<string | number> | null;
|
|
89
|
-
initialValues?: GroupedSelectValues | SelectValue[];
|
|
90
|
-
pathToValue?: string;
|
|
91
|
-
}): SelectValue | SelectValue[] | undefined;
|
|
100
|
+
export declare const InputSelect: React.FC<InputSelectProps>;
|
|
@@ -4,8 +4,5 @@ import { type InputSelectProps, type SelectValue } from './InputSelect';
|
|
|
4
4
|
interface SelectComponentProps extends Omit<InputSelectProps, 'loadAsyncValues' | 'label' | 'hint'> {
|
|
5
5
|
styles: StylesConfig<SelectValue>;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
8
|
-
export declare namespace SelectComponent {
|
|
9
|
-
var displayName: string;
|
|
10
|
-
}
|
|
7
|
+
export declare const SelectComponent: React.FC<SelectComponentProps>;
|
|
11
8
|
export {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { HookedInputSelect } from './HookedInputSelect';
|
|
2
|
-
export { InputSelect,
|
|
2
|
+
export { InputSelect, type InputSelectProps, type SelectValue } from './InputSelect';
|
|
3
|
+
export { flatSelectValues, getDefaultValueFromFlatten, isGroupedSelectValues, isMultiValueSelected, isSingleValueSelected } from './utils';
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type ClearIndicatorProps, type DropdownIndicatorProps, type MultiValueRemoveProps } from 'react-select';
|
|
2
|
+
import { type ClearIndicatorProps, type DropdownIndicatorProps, type GroupBase, type MultiValueGenericProps, type MultiValueRemoveProps } from 'react-select';
|
|
3
3
|
import { type SelectValue } from '.';
|
|
4
4
|
declare function DropdownIndicator(props: DropdownIndicatorProps<SelectValue>): JSX.Element;
|
|
5
5
|
declare function ClearIndicator(props: ClearIndicatorProps<SelectValue>): JSX.Element;
|
|
6
|
+
declare function MultiValueContainer(props: MultiValueGenericProps<MultiValueGenericProps<SelectValue, boolean, GroupBase<SelectValue>>>): JSX.Element;
|
|
7
|
+
declare function MultiValueLabel(props: MultiValueGenericProps<MultiValueGenericProps<SelectValue, boolean, GroupBase<SelectValue>>>): string;
|
|
6
8
|
declare function MultiValueRemove(props: MultiValueRemoveProps<SelectValue>): JSX.Element;
|
|
7
9
|
declare const selectComponentOverrides: {
|
|
8
10
|
DropdownIndicator: typeof DropdownIndicator;
|
|
9
11
|
IndicatorSeparator: () => null;
|
|
10
12
|
ClearIndicator: typeof ClearIndicator;
|
|
13
|
+
MultiValueContainer: typeof MultiValueContainer;
|
|
14
|
+
MultiValueLabel: typeof MultiValueLabel;
|
|
11
15
|
MultiValueRemove: typeof MultiValueRemove;
|
|
12
16
|
};
|
|
13
17
|
export default selectComponentOverrides;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type GroupedSelectValues, type PossibleSelectValue, type SelectValue } from './InputSelect';
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to understand and refine type of a single selected value
|
|
4
|
+
* @param selectedValue possible value returned from select component
|
|
5
|
+
* @returns true if selected value is single, from this point TypeScript will treat this as `SelectValue` type
|
|
6
|
+
*/
|
|
7
|
+
export declare function isSingleValueSelected(selectedValue: PossibleSelectValue): selectedValue is SelectValue;
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to understand and refine type of a set of selected values
|
|
10
|
+
* @param selectedValue possible value returned from select component
|
|
11
|
+
* @returns true if selected value is an array of selected values, from this point TypeScript will treat this as `SelectValue[]` type
|
|
12
|
+
*/
|
|
13
|
+
export declare function isMultiValueSelected(selectedValue: PossibleSelectValue): selectedValue is SelectValue[];
|
|
14
|
+
/**
|
|
15
|
+
* Type-guard to check if prop `initialValues` is a GroupedSelectValues or SelectValue
|
|
16
|
+
*/
|
|
17
|
+
export declare function isGroupedSelectValues(initialValues?: GroupedSelectValues | SelectValue[]): initialValues is GroupedSelectValues;
|
|
18
|
+
/**
|
|
19
|
+
* Helper function to extract only a specific property from the `SelectValue`
|
|
20
|
+
* @param selectedValue possible value returned from select component
|
|
21
|
+
* @param pathToValue optional path.to.property. Default is `value`
|
|
22
|
+
* @returns a string or an array of strings.
|
|
23
|
+
* Examples:
|
|
24
|
+
* ```
|
|
25
|
+
* flatSelectValues({value: 'ABCD', label: 'T-Shirt XL'})
|
|
26
|
+
* // returns 'ABCD'
|
|
27
|
+
*
|
|
28
|
+
* flatSelectValues([
|
|
29
|
+
* {value: 'ABCD', label: 'T-Shirt M'},
|
|
30
|
+
* {value: '1234', label: 'T-Shirt XL'},
|
|
31
|
+
* ], 'label')
|
|
32
|
+
* // returns ['T-Shirt M', 'T-Shirt XL']
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function flatSelectValues(selectedValue: PossibleSelectValue, pathToValue?: string): null | string | Array<string | number>;
|
|
36
|
+
/**
|
|
37
|
+
* To be used when storing the flatten value and there is the need
|
|
38
|
+
* to retrieve the `defaultValue` to pass as <InputSelect> prop
|
|
39
|
+
* @param currentValue the current value that is being stored in app state
|
|
40
|
+
* @param initialValues the array of SelectValue objects that should contain the `currentValue`
|
|
41
|
+
* @param pathToValue optional path.to.property. Default is `value`
|
|
42
|
+
* @returns the matched value or values, otherwise undefined.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getDefaultValueFromFlatten({ currentValue, initialValues, pathToValue }: {
|
|
45
|
+
currentValue?: string | Array<string | number> | null;
|
|
46
|
+
initialValues?: GroupedSelectValues | SelectValue[];
|
|
47
|
+
pathToValue?: string;
|
|
48
|
+
}): SelectValue | SelectValue[] | undefined;
|
|
@@ -30,11 +30,22 @@ export interface InputWrapperProps extends InputWrapperBaseProps {
|
|
|
30
30
|
className?: string;
|
|
31
31
|
name?: string;
|
|
32
32
|
children: React.ReactNode;
|
|
33
|
+
fieldset?: boolean;
|
|
33
34
|
}
|
|
34
|
-
declare
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
export declare const InputWrapper: import('../atoms/SkeletonTemplate').SkeletonTemplateComponent<{
|
|
36
|
+
className?: string | undefined;
|
|
37
|
+
name?: string | undefined;
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
fieldset?: boolean | undefined;
|
|
40
|
+
label?: string | undefined;
|
|
41
|
+
hint?: {
|
|
42
|
+
icon?: HintProps['icon'];
|
|
43
|
+
text: HintProps['children'];
|
|
44
|
+
} | undefined;
|
|
45
|
+
feedback?: Omit<InputFeedbackProps, "className"> | undefined;
|
|
46
|
+
inline?: boolean | undefined;
|
|
47
|
+
delayMs?: number | undefined;
|
|
48
|
+
isLoading?: boolean | undefined;
|
|
49
|
+
}>;
|
|
39
50
|
export declare function getFeedbackStyle(feedback?: Omit<InputFeedbackProps, 'className'>): Record<string, boolean>;
|
|
40
51
|
export declare function getFeedbackCssInJs(variant?: InputFeedbackProps['variant']): Pick<CSSStyleDeclaration, 'borderColor' | 'borderWidth'>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LineItem, ParcelLineItem, StockLineItem } from '@commercelayer/sdk';
|
|
2
2
|
type Item = LineItem | ParcelLineItem | StockLineItem;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const ResourceLineItems: import('../atoms/SkeletonTemplate').SkeletonTemplateComponent<{
|
|
4
4
|
items: Item[];
|
|
5
5
|
size?: "small" | "normal" | undefined;
|
|
6
6
|
footer?: React.ReactNode;
|
|
@@ -5,7 +5,7 @@ import { type QueryParamsList } from '@commercelayer/sdk';
|
|
|
5
5
|
import { type ListableResourceType } from '@commercelayer/sdk/lib/cjs/api';
|
|
6
6
|
import { type FC } from 'react';
|
|
7
7
|
import { type Resource } from './infiniteFetcher';
|
|
8
|
-
export interface
|
|
8
|
+
export interface ResourceListItemTemplateProps<TResource extends ListableResourceType> extends SkeletonTemplateProps<{
|
|
9
9
|
/**
|
|
10
10
|
* The fetched resource
|
|
11
11
|
*/
|
|
@@ -17,13 +17,13 @@ export interface ResourceListItemProps<TResource extends ListableResourceType> e
|
|
|
17
17
|
remove?: () => void;
|
|
18
18
|
}> {
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
20
|
+
export interface ResourceListItemTemplate<TResource extends ListableResourceType> {
|
|
21
21
|
/**
|
|
22
22
|
* A react component to be used to render each item in the list.
|
|
23
23
|
* For best results, pass as `Item` a component already wrapped in a `SkeletonTemplate` (or `withSkeletonTemplate` HOC).
|
|
24
24
|
* In this way the loading state will be handled automatically.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
ItemTemplate: FC<ResourceListItemTemplateProps<TResource>>;
|
|
27
27
|
}
|
|
28
28
|
export type ResourceListProps<TResource extends ListableResourceType> = Pick<SectionProps, 'title' | 'actionButton'> & {
|
|
29
29
|
/**
|
|
@@ -38,7 +38,7 @@ export type ResourceListProps<TResource extends ListableResourceType> = Pick<Sec
|
|
|
38
38
|
* An element to be rendered when the list is empty.
|
|
39
39
|
*/
|
|
40
40
|
emptyState: JSX.Element;
|
|
41
|
-
} & (
|
|
41
|
+
} & (ResourceListItemTemplate<TResource> | {
|
|
42
42
|
/**
|
|
43
43
|
* Children as a function to render a custom element.
|
|
44
44
|
* @example
|
|
@@ -56,7 +56,7 @@ export type ResourceListProps<TResource extends ListableResourceType> = Pick<Sec
|
|
|
56
56
|
/**
|
|
57
57
|
* Renders a list of resources of a given type with infinite scrolling.
|
|
58
58
|
* It's possible to specify a query to filter the list and either
|
|
59
|
-
* a React component to be used as
|
|
59
|
+
* a React component (`ItemTemplate`) to be used as item template for the list or a function as `children` to render a custom element.
|
|
60
60
|
*/
|
|
61
61
|
export declare function ResourceList<TResource extends ListableResourceType>({ type, query, title, actionButton, emptyState, ...props }: ResourceListProps<TResource>): JSX.Element;
|
|
62
62
|
export declare namespace ResourceList {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ResourceListItemType } from './types';
|
|
3
|
+
export interface ResourceListItemProps {
|
|
4
|
+
/**
|
|
5
|
+
* Resource object used to generate list item content depending on its own type
|
|
6
|
+
*/
|
|
7
|
+
resource: ResourceListItemType;
|
|
8
|
+
/**
|
|
9
|
+
* HTML tag to render
|
|
10
|
+
*/
|
|
11
|
+
tag?: 'a' | 'div';
|
|
12
|
+
/**
|
|
13
|
+
* Optional onClick function
|
|
14
|
+
*/
|
|
15
|
+
onClick?: (e: React.MouseEvent<HTMLAnchorElement | HTMLDivElement, MouseEvent>) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* This component generates a list item based on the requested resource data and type.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ResourceListItem: import('../../atoms/SkeletonTemplate').SkeletonTemplateComponent<{
|
|
21
|
+
resource: ResourceListItemType;
|
|
22
|
+
tag?: "a" | "div" | undefined;
|
|
23
|
+
onClick?: ((e: React.MouseEvent<HTMLAnchorElement | HTMLDivElement, MouseEvent>) => void) | undefined;
|
|
24
|
+
delayMs?: number | undefined;
|
|
25
|
+
isLoading?: boolean | undefined;
|
|
26
|
+
}>;
|