@commercelayer/app-elements 0.0.80 → 0.1.1

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 (128) hide show
  1. package/README.md +14 -48
  2. package/dist/{Async-a8cbdb5b.js → Async-566ec3f7.js} +3 -3
  3. package/dist/{InputDateComponent-a8c34dc1.js → InputDateComponent-4461b3e6.js} +3 -3
  4. package/dist/{Select-e581ae99.js → Select-89937223.js} +3 -3
  5. package/dist/helpers/appsNavigation.d.ts +1 -1
  6. package/dist/{main-dd440dc6.js → main-795be39b.js} +7119 -7022
  7. package/dist/main.d.ts +22 -38
  8. package/dist/main.js +97 -97
  9. package/dist/mocks/setup.d.ts +3 -0
  10. package/dist/{overrides-0673bab0.js → overrides-346bb0f6.js} +621 -618
  11. package/dist/providers/TokenProvider/TokenProvider.d.ts +15 -11
  12. package/dist/providers/TokenProvider/getInfoFromJwt.d.ts +3 -2
  13. package/dist/providers/TokenProvider/url.d.ts +3 -2
  14. package/dist/providers/TokenProvider/validateToken.d.ts +6 -1
  15. package/dist/style.css +1 -1
  16. package/dist/ui/atoms/Section.d.ts +31 -0
  17. package/dist/ui/atoms/Table/Table.d.ts +21 -0
  18. package/dist/ui/atoms/Table/Td.d.ts +8 -0
  19. package/dist/ui/atoms/{tables → Table}/index.d.ts +3 -2
  20. package/dist/ui/{lists → composite}/ListDetails.d.ts +1 -1
  21. package/dist/ui/composite/TableData.d.ts +23 -0
  22. package/dist/ui/forms/Form/index.d.ts +1 -0
  23. package/dist/ui/{hook-form → forms/Input}/HookedInput.d.ts +4 -4
  24. package/dist/ui/forms/{Input.d.ts → Input/Input.d.ts} +2 -3
  25. package/dist/ui/forms/Input/index.d.ts +2 -0
  26. package/dist/ui/{hook-form → forms/InputCheckbox}/HookedInputCheckbox.d.ts +4 -4
  27. package/dist/ui/forms/{InputCheckbox.d.ts → InputCheckbox/InputCheckbox.d.ts} +2 -2
  28. package/dist/ui/forms/InputCheckbox/index.d.ts +2 -0
  29. package/dist/ui/forms/InputCheckboxGroup.d.ts +2 -3
  30. package/dist/ui/{hook-form → forms/InputCurrency}/HookedInputCurrency.d.ts +4 -4
  31. package/dist/ui/forms/InputCurrency/InputCurrency.d.ts +48 -0
  32. package/dist/ui/forms/InputCurrency/index.d.ts +3 -58
  33. package/dist/ui/forms/InputCurrency/utils.d.ts +10 -0
  34. package/dist/ui/forms/InputCurrencyRange.d.ts +8 -5
  35. package/dist/ui/{hook-form → forms/InputDate}/HookedInputDate.d.ts +4 -4
  36. package/dist/ui/forms/InputDate/InputDate.d.ts +4 -0
  37. package/dist/ui/forms/InputDate/InputDateComponent.d.ts +1 -2
  38. package/dist/ui/forms/InputDate/index.d.ts +2 -5
  39. package/dist/ui/{hook-form → forms/InputDateRange}/HookedInputDateRange.d.ts +4 -4
  40. package/dist/ui/forms/{InputDateRange.d.ts → InputDateRange/InputDateRange.d.ts} +3 -4
  41. package/dist/ui/forms/InputDateRange/index.d.ts +2 -0
  42. package/dist/ui/forms/InputFeedback.d.ts +2 -3
  43. package/dist/ui/forms/InputFile.d.ts +6 -2
  44. package/dist/ui/forms/InputJson.d.ts +2 -3
  45. package/dist/ui/{hook-form → forms/InputMetadata}/HookedInputMetadata.d.ts +3 -3
  46. package/dist/ui/forms/InputMetadata/index.d.ts +1 -0
  47. package/dist/ui/forms/InputRadioGroup.d.ts +9 -4
  48. package/dist/ui/forms/InputReadonly.d.ts +3 -3
  49. package/dist/ui/{resources/RelationshipSelector → forms/InputResourceGroup}/Checkbox.d.ts +1 -1
  50. package/dist/ui/forms/InputResourceGroup/HookedInputResourceGroup.d.ts +15 -0
  51. package/dist/ui/forms/InputResourceGroup/InputResourceGroup.d.ts +28 -0
  52. package/dist/ui/forms/InputResourceGroup/index.d.ts +2 -0
  53. package/dist/ui/forms/InputSelect/Async.d.ts +1 -1
  54. package/dist/ui/{hook-form → forms/InputSelect}/HookedInputSelect.d.ts +4 -4
  55. package/dist/ui/forms/InputSelect/InputSelect.d.ts +91 -0
  56. package/dist/ui/forms/InputSelect/Select.d.ts +1 -1
  57. package/dist/ui/forms/InputSelect/index.d.ts +2 -91
  58. package/dist/ui/forms/InputSimpleSelect/HookedInputSimpleSelect.d.ts +21 -0
  59. package/dist/ui/forms/InputSimpleSelect/InputSimpleSelect.d.ts +12 -0
  60. package/dist/ui/forms/InputSimpleSelect/index.d.ts +2 -0
  61. package/dist/ui/{hook-form → forms/InputSpinner}/HookedInputSpinner.d.ts +4 -4
  62. package/dist/ui/forms/{InputSpinner.d.ts → InputSpinner/InputSpinner.d.ts} +2 -3
  63. package/dist/ui/forms/InputSpinner/index.d.ts +2 -0
  64. package/dist/ui/{hook-form/HookedInputToggleBox.d.ts → forms/InputSwitch/HookedInputSwitch.d.ts} +6 -6
  65. package/dist/ui/forms/InputSwitch/InputSwitch.d.ts +5 -0
  66. package/dist/ui/forms/InputSwitch/index.d.ts +2 -0
  67. package/dist/ui/forms/InputTextArea.d.ts +2 -2
  68. package/dist/ui/forms/InputToggleButton/HookedInputToggleButton.d.ts +18 -0
  69. package/dist/ui/forms/{ToggleButtons.d.ts → InputToggleButton/InputToggleButton.d.ts} +7 -6
  70. package/dist/ui/forms/InputToggleButton/index.d.ts +2 -0
  71. package/dist/ui/forms/Label.d.ts +6 -3
  72. package/dist/ui/forms/Legend.d.ts +14 -0
  73. package/dist/ui/{hook-form → forms/ReactHookForm}/HookedValidationApiError.d.ts +3 -3
  74. package/dist/ui/{hook-form → forms/ReactHookForm}/HookedValidationError.d.ts +3 -3
  75. package/dist/ui/forms/ReactHookForm/index.d.ts +4 -0
  76. package/dist/ui/{hook-form → forms/ReactHookForm}/useValidationFeedback.d.ts +1 -1
  77. package/dist/ui/internals/InputWrapper.d.ts +6 -1
  78. package/dist/ui/resources/Filters/types.d.ts +4 -4
  79. package/dist/ui/resources/Filters/useFilters.d.ts +2 -1
  80. package/dist/ui/resources/ResourceList/ResourceList.d.ts +64 -0
  81. package/dist/ui/resources/ResourceList/index.d.ts +1 -45
  82. package/dist/{unsupportedIterableToArray-0f93b40f.js → unsupportedIterableToArray-a3020d44.js} +1 -1
  83. package/dist/utils/children.d.ts +4 -3
  84. package/dist/utils/extractHeaders.d.ts +2 -1
  85. package/dist/utils/text.d.ts +8 -1
  86. package/package.json +26 -26
  87. package/dist/ui/atoms/Legend.d.ts +0 -32
  88. package/dist/ui/atoms/tables/Td.d.ts +0 -9
  89. package/dist/ui/forms/InputToggleBox.d.ts +0 -9
  90. package/dist/ui/forms/InputToggleListBox.d.ts +0 -15
  91. package/dist/ui/forms/RadioButtons.d.ts +0 -19
  92. package/dist/ui/hook-form/HookedInputToggleListBox.d.ts +0 -21
  93. package/dist/ui/hook-form/HookedRelationshipSelector.d.ts +0 -18
  94. package/dist/ui/hook-form/HookedToggleButtons.d.ts +0 -18
  95. package/dist/ui/resources/RelationshipSelector/index.d.ts +0 -26
  96. package/dist/ui/resources/ResourceList/index.test.d.ts +0 -1
  97. package/dist/ui/tables/Table.d.ts +0 -10
  98. package/dist/ui/tables/TableData.d.ts +0 -14
  99. package/dist/utils/tests.d.ts +0 -1
  100. /package/dist/ui/atoms/{Legend.test.d.ts → Section.test.d.ts} +0 -0
  101. /package/dist/ui/{tables → atoms/Table}/Table.test.d.ts +0 -0
  102. /package/dist/ui/atoms/{tables → Table}/Th.d.ts +0 -0
  103. /package/dist/ui/atoms/{tables → Table}/Tr.d.ts +0 -0
  104. /package/dist/ui/{lists → composite}/List.d.ts +0 -0
  105. /package/dist/ui/{lists → composite}/List.test.d.ts +0 -0
  106. /package/dist/ui/{lists → composite}/ListDetails.test.d.ts +0 -0
  107. /package/dist/ui/{lists → composite}/ListDetailsItem.d.ts +0 -0
  108. /package/dist/ui/{lists → composite}/ListDetailsItem.test.d.ts +0 -0
  109. /package/dist/ui/{lists → composite}/ListItem.d.ts +0 -0
  110. /package/dist/ui/{lists → composite}/ListItem.test.d.ts +0 -0
  111. /package/dist/ui/{tables → composite}/TableData.test.d.ts +0 -0
  112. /package/dist/ui/{hook-form → forms/Form}/HookedForm.d.ts +0 -0
  113. /package/dist/ui/forms/{Input.test.d.ts → Input/Input.test.d.ts} +0 -0
  114. /package/dist/ui/forms/{InputCheckbox.test.d.ts → InputCheckbox/InputCheckbox.test.d.ts} +0 -0
  115. /package/dist/ui/forms/InputCurrency/{index.test.d.ts → InputCurrency.test.d.ts} +0 -0
  116. /package/dist/ui/forms/InputDate/{InputDate.test.d.ts → InputDateComponent.test.d.ts} +0 -0
  117. /package/dist/ui/forms/{InputDateRange.test.d.ts → InputDateRange/InputDateRange.test.d.ts} +0 -0
  118. /package/dist/ui/{resources/RelationshipSelector → forms/InputResourceGroup}/FullList.d.ts +0 -0
  119. /package/dist/ui/{resources/RelationshipSelector → forms/InputResourceGroup}/utils.d.ts +0 -0
  120. /package/dist/ui/{resources/RelationshipSelector → forms/InputResourceGroup}/utils.test.d.ts +0 -0
  121. /package/dist/ui/forms/InputSelect/{index.test.d.ts → InputSelect.test.d.ts} +0 -0
  122. /package/dist/ui/forms/{InputSpinner.test.d.ts → InputSimpleSelect/InputSimpleSelect.test.d.ts} +0 -0
  123. /package/dist/ui/forms/{InputToggleBox.test.d.ts → InputSpinner/InputSpinner.test.d.ts} +0 -0
  124. /package/dist/ui/forms/{InputToggleListBox.test.d.ts → InputSwitch/InputSwitch.test.d.ts} +0 -0
  125. /package/dist/ui/forms/{RadioButtons.test.d.ts → InputToggleButton/InputToggleButton.test.d.ts} +0 -0
  126. /package/dist/ui/{hook-form → forms/ReactHookForm}/setApiFormErrors.d.ts +0 -0
  127. /package/dist/ui/{hook-form → forms/ReactHookForm}/setApiFormErrors.test.d.ts +0 -0
  128. /package/dist/ui/{forms/ToggleButtons.test.d.ts → resources/ResourceList/ResourceList.test.d.ts} +0 -0
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { type InputWrapperBaseProps } from '../../internals/InputWrapper';
3
+ export interface InputSimpleSelectOption {
4
+ value: string;
5
+ label: string;
6
+ }
7
+ export interface InputSimpleSelectProps extends InputWrapperBaseProps, Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'value' | 'onSelect'> {
8
+ value?: string;
9
+ options: InputSimpleSelectOption[];
10
+ className?: string;
11
+ }
12
+ export declare const InputSimpleSelect: import("react").ForwardRefExoticComponent<InputSimpleSelectProps & import("react").RefAttributes<HTMLSelectElement>>;
@@ -0,0 +1,2 @@
1
+ export { HookedInputSimpleSelect } from './HookedInputSimpleSelect';
2
+ export { InputSimpleSelect } from './InputSimpleSelect';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type InputSpinnerProps } from '../forms/InputSpinner';
2
+ import { type InputSpinnerProps } from './InputSpinner';
3
3
  interface Props extends Omit<InputSpinnerProps, 'onChange' | 'defaultValues'> {
4
4
  /**
5
5
  * field name to match hook-form state
@@ -10,8 +10,8 @@ interface Props extends Omit<InputSpinnerProps, 'onChange' | 'defaultValues'> {
10
10
  * `InputSpinner` component ready to be used with the `react-hook-form` context.
11
11
  * @see InputSpinner
12
12
  */
13
- declare function HookedInputSpinner({ name, ...props }: Props): JSX.Element;
14
- declare namespace HookedInputSpinner {
13
+ export declare function HookedInputSpinner({ name, ...props }: Props): JSX.Element;
14
+ export declare namespace HookedInputSpinner {
15
15
  var displayName: string;
16
16
  }
17
- export { HookedInputSpinner };
17
+ export {};
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type InputWrapperBaseProps } from '../internals/InputWrapper';
2
+ import { type InputWrapperBaseProps } from '../../internals/InputWrapper';
3
3
  export interface InputSpinnerProps extends InputWrapperBaseProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'onChange'> {
4
4
  min?: number;
5
5
  max?: number;
@@ -15,5 +15,4 @@ export interface InputSpinnerProps extends InputWrapperBaseProps, Omit<React.Inp
15
15
  */
16
16
  disabled?: boolean;
17
17
  }
18
- declare const InputSpinner: import("react").ForwardRefExoticComponent<InputSpinnerProps & import("react").RefAttributes<HTMLInputElement>>;
19
- export { InputSpinner };
18
+ export declare const InputSpinner: import("react").ForwardRefExoticComponent<InputSpinnerProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,2 @@
1
+ export { HookedInputSpinner } from './HookedInputSpinner';
2
+ export { InputSpinner } from './InputSpinner';
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { type InputToggleBoxProps } from '../forms/InputToggleBox';
3
- interface Props extends InputToggleBoxProps {
2
+ import { type InputSwitchProps } from './InputSwitch';
3
+ interface Props extends InputSwitchProps {
4
4
  /**
5
5
  * field name to match hook-form state
6
6
  */
@@ -12,10 +12,10 @@ interface Props extends InputToggleBoxProps {
12
12
  }
13
13
  /**
14
14
  * `InputToggleBox` component ready to be used with the `react-hook-form` context.
15
- * @see InputToggleBox
15
+ * @see InputSwitch
16
16
  */
17
- declare function HookedInputToggleBox({ name, showValidation, ...props }: Props): JSX.Element;
18
- declare namespace HookedInputToggleBox {
17
+ export declare function HookedInputSwitch({ name, showValidation, ...props }: Props): JSX.Element;
18
+ export declare namespace HookedInputSwitch {
19
19
  var displayName: string;
20
20
  }
21
- export { HookedInputToggleBox };
21
+ export {};
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { type InputWrapperBaseProps } from '../../internals/InputWrapper';
3
+ export interface InputSwitchProps extends InputWrapperBaseProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'value'> {
4
+ }
5
+ export declare const InputSwitch: import("react").ForwardRefExoticComponent<InputSwitchProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,2 @@
1
+ export { HookedInputSwitch } from './HookedInputSwitch';
2
+ export { InputSwitch } from './InputSwitch';
@@ -2,5 +2,5 @@
2
2
  import { type InputWrapperBaseProps } from '../internals/InputWrapper';
3
3
  interface InputTextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement>, InputWrapperBaseProps {
4
4
  }
5
- declare const InputTextArea: import("react").ForwardRefExoticComponent<InputTextAreaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
6
- export { InputTextArea };
5
+ export declare const InputTextArea: import("react").ForwardRefExoticComponent<InputTextAreaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
6
+ export {};
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import { type InputToggleButtonProps } from './InputToggleButton';
3
+ type Props = Omit<InputToggleButtonProps, 'value' | 'onChange'> & {
4
+ /**
5
+ * field name to match hook-form state
6
+ */
7
+ name: string;
8
+ };
9
+ /**
10
+ * `InputToggleButton` component ready to be used with the `react-hook-form` context.
11
+ * Stored value will be a string when used as `mode="single"` or an array of strings when `mode="multiple"`.
12
+ * @see InputToggleButton
13
+ */
14
+ export declare function HookedInputToggleButton({ name, ...props }: Props): JSX.Element;
15
+ export declare namespace HookedInputToggleButton {
16
+ var displayName: string;
17
+ }
18
+ export {};
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { type InputWrapperBaseProps } from '../internals/InputWrapper';
2
+ import { type InputWrapperBaseProps } from '../../internals/InputWrapper';
3
3
  import { type Simplify } from 'type-fest';
4
- export type ToggleButtonValue = string | boolean | number;
4
+ type ToggleButtonValue = string | boolean | number;
5
5
  export interface ToggleButtonOption {
6
6
  label: string;
7
7
  value: ToggleButtonValue;
@@ -20,9 +20,10 @@ interface MultiValuesProps {
20
20
  value?: ToggleButtonValue[];
21
21
  onChange: (values: ToggleButtonValue[]) => void;
22
22
  }
23
- export type ToggleButtonsProps = Simplify<BaseProps & (SingleValueProps | MultiValuesProps)>;
24
- declare function ToggleButtons({ options, value, mode, onChange, label, hint, feedback, ...rest }: ToggleButtonsProps): JSX.Element;
25
- declare namespace ToggleButtons {
23
+ export type InputToggleButtonProps = Simplify<BaseProps & (SingleValueProps | MultiValuesProps)>;
24
+ /** A Toggle Button can be used to group related options. */
25
+ export declare function InputToggleButton({ options, value, mode, onChange, label, hint, feedback, ...rest }: InputToggleButtonProps): JSX.Element;
26
+ export declare namespace InputToggleButton {
26
27
  var displayName: string;
27
28
  }
28
- export { ToggleButtons };
29
+ export {};
@@ -0,0 +1,2 @@
1
+ export { HookedInputToggleButton } from './HookedInputToggleButton';
2
+ export { InputToggleButton, type InputToggleButtonProps, type ToggleButtonOption } from './InputToggleButton';
@@ -2,8 +2,11 @@
2
2
  interface Props extends React.LabelHTMLAttributes<HTMLLabelElement> {
3
3
  gap?: boolean;
4
4
  }
5
- declare function Label({ gap, children, className, ...rest }: Props): JSX.Element;
6
- declare namespace Label {
5
+ /**
6
+ * The Label component represents a caption for an item in a user interface.
7
+ */
8
+ export declare function Label({ gap, children, className, ...rest }: Props): JSX.Element;
9
+ export declare namespace Label {
7
10
  var displayName: string;
8
11
  }
9
- export { Label };
12
+ export {};
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ interface Props extends React.HTMLAttributes<HTMLLegendElement> {
3
+ gap?: boolean;
4
+ }
5
+ /**
6
+ * The Legend component represents a caption for the content of its parent <fieldset>.
7
+ *
8
+ * It is styled exactly like the `<Label>` component.
9
+ */
10
+ export declare function Legend({ gap, children, className, ...rest }: Props): JSX.Element;
11
+ export declare namespace Legend {
12
+ var displayName: string;
13
+ }
14
+ export {};
@@ -15,8 +15,8 @@ interface ValidationApiErrorProps {
15
15
  */
16
16
  fieldMap?: Record<string, string>;
17
17
  }
18
- declare function HookedValidationApiError({ apiError, fieldMap }: ValidationApiErrorProps): JSX.Element;
19
- declare namespace HookedValidationApiError {
18
+ export declare function HookedValidationApiError({ apiError, fieldMap }: ValidationApiErrorProps): JSX.Element;
19
+ export declare namespace HookedValidationApiError {
20
20
  var displayName: string;
21
21
  }
22
- export { HookedValidationApiError };
22
+ export {};
@@ -5,8 +5,8 @@ interface Props {
5
5
  */
6
6
  name: string;
7
7
  }
8
- declare function HookedValidationError({ name }: Props): JSX.Element | null;
9
- declare namespace HookedValidationError {
8
+ export declare function HookedValidationError({ name }: Props): JSX.Element | null;
9
+ export declare namespace HookedValidationError {
10
10
  var displayName: string;
11
11
  }
12
- export { HookedValidationError };
12
+ export {};
@@ -0,0 +1,4 @@
1
+ export { HookedValidationApiError } from './HookedValidationApiError';
2
+ export { HookedValidationError } from './HookedValidationError';
3
+ export { setApiFormErrors } from './setApiFormErrors';
4
+ export { useValidationFeedback } from './useValidationFeedback';
@@ -1,4 +1,4 @@
1
- import { type InputFeedbackProps } from '../forms/InputFeedback';
1
+ import { type InputFeedbackProps } from '../../forms/InputFeedback';
2
2
  type MaybeFeedback = Omit<InputFeedbackProps, 'className'> | undefined;
3
3
  export declare function useValidationFeedback(name: string): MaybeFeedback;
4
4
  export {};
@@ -17,6 +17,11 @@ export interface InputWrapperBaseProps {
17
17
  * optional hint to be rendered below
18
18
  */
19
19
  feedback?: Omit<InputFeedbackProps, 'className'>;
20
+ /**
21
+ * show label and input on the same line
22
+ * @default false
23
+ */
24
+ inline?: boolean;
20
25
  }
21
26
  export interface InputWrapperProps extends InputWrapperBaseProps {
22
27
  /**
@@ -26,7 +31,7 @@ export interface InputWrapperProps extends InputWrapperBaseProps {
26
31
  name?: string;
27
32
  children: React.ReactNode;
28
33
  }
29
- declare function InputWrapper({ label, children, className, hint, feedback, name, ...rest }: InputWrapperProps): JSX.Element;
34
+ declare function InputWrapper({ label, children, className, hint, feedback, name, inline, ...rest }: InputWrapperProps): JSX.Element;
30
35
  declare namespace InputWrapper {
31
36
  var displayName: string;
32
37
  }
@@ -1,5 +1,5 @@
1
1
  import { type InputCurrencyRangeProps } from '../../forms/InputCurrencyRange';
2
- import { type RelationshipSelectorProps } from '../../resources/RelationshipSelector';
2
+ import { type InputResourceGroupProps } from '../../forms/InputResourceGroup';
3
3
  export declare const filtrableTimeRangePreset: readonly ["today", "last7days", "last30days", "custom"];
4
4
  export type UiFilterName = string;
5
5
  export type UiFilterValue = string | string[] | boolean | Date | undefined;
@@ -55,7 +55,7 @@ export type FilterItemOptions = BaseFilterItem & {
55
55
  /**
56
56
  * UI component to render
57
57
  */
58
- component: 'toggleButtons';
58
+ component: 'inputToggleButton';
59
59
  /**
60
60
  * props required for the UI component
61
61
  */
@@ -75,11 +75,11 @@ export type FilterItemOptions = BaseFilterItem & {
75
75
  /**
76
76
  * UI component to render
77
77
  */
78
- component: 'relationshipSelector';
78
+ component: 'inputResourceGroup';
79
79
  /**
80
80
  * props required for the UI component
81
81
  */
82
- props: Omit<RelationshipSelectorProps, 'onChange' | 'defaultValues' | 'title'>;
82
+ props: Omit<InputResourceGroupProps, 'onChange' | 'defaultValues' | 'title'>;
83
83
  };
84
84
  };
85
85
  export interface FilterItemTextSearch extends Omit<BaseFilterItem, 'sdk'> {
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { type ResourceListProps } from '../../resources/ResourceList';
3
+ import { type ResourceListItem } from '../../resources/ResourceList/ResourceList';
3
4
  import { type ListableResourceType } from '@commercelayer/sdk/lib/cjs/api';
4
5
  import { type QueryFilter } from '@commercelayer/sdk/lib/cjs/query';
5
6
  import { type FiltersFormProps } from './FiltersForm';
@@ -40,7 +41,7 @@ interface UseFiltersHook {
40
41
  /**
41
42
  * Filtered ResourceList component based on current active filters
42
43
  */
43
- FilteredList: <TResource extends ListableResourceType>(props: Pick<ResourceListProps<TResource>, 'Item' | 'type' | 'query' | 'emptyState' | 'actionButton'>) => JSX.Element;
44
+ FilteredList: <TResource extends ListableResourceType>(props: Pick<ResourceListProps<TResource>, 'type' | 'query' | 'emptyState' | 'actionButton'> & ResourceListItem<TResource>) => JSX.Element;
44
45
  /**
45
46
  * SDK filters object to be used in the sdk query
46
47
  */
@@ -0,0 +1,64 @@
1
+ import { type SectionProps } from '../../atoms/Section';
2
+ import { type SkeletonTemplateProps } from '../../atoms/SkeletonTemplate';
3
+ import { type FetcherResponse } from '../../resources/ResourceList/infiniteFetcher';
4
+ import { type QueryParamsList } from '@commercelayer/sdk';
5
+ import { type ListableResourceType } from '@commercelayer/sdk/lib/cjs/api';
6
+ import { type FC } from 'react';
7
+ import { type Resource } from './infiniteFetcher';
8
+ export interface ResourceListItemProps<TResource extends ListableResourceType> extends SkeletonTemplateProps<{
9
+ /**
10
+ * The fetched resource
11
+ */
12
+ resource?: Resource<TResource>;
13
+ /**
14
+ * callback to be used to remove the item from the list as UI element.
15
+ * This needs to be used after a successful API call to delete the resource, since it just affects the current UI rendering and not the server data.
16
+ */
17
+ remove?: () => void;
18
+ }> {
19
+ }
20
+ export interface ResourceListItem<TResource extends ListableResourceType> {
21
+ /**
22
+ * A react component to be used to render each item in the list.
23
+ * For best results, pass as `Item` a component already wrapped in a `SkeletonTemplate` (or `withSkeletonTemplate` HOC).
24
+ * In this way the loading state will be handled automatically.
25
+ */
26
+ Item: FC<ResourceListItemProps<TResource>>;
27
+ }
28
+ export type ResourceListProps<TResource extends ListableResourceType> = Pick<SectionProps, 'title' | 'actionButton'> & {
29
+ /**
30
+ * The resource type to be fetched in the list
31
+ */
32
+ type: TResource;
33
+ /**
34
+ * SDK query object to be used to fetch the list, excluding the pageNumber that is handled internally for infinite scrolling.
35
+ */
36
+ query?: Omit<QueryParamsList, 'pageNumber'>;
37
+ /**
38
+ * An element to be rendered when the list is empty.
39
+ */
40
+ emptyState: JSX.Element;
41
+ } & (ResourceListItem<TResource> | {
42
+ /**
43
+ * Children as a function to render a custom element.
44
+ * @example
45
+ * ```
46
+ * <ResourceList type='customers'>
47
+ * {({ isLoading, data }) => <ol>{data?.list.map(customer => <li>{customer.email}</li>)}</ol>
48
+ * </ResourceList>
49
+ * ```
50
+ */
51
+ children: (childrenProps: {
52
+ isLoading: boolean;
53
+ data?: FetcherResponse<Resource<TResource>>;
54
+ }) => React.ReactNode;
55
+ });
56
+ /**
57
+ * Renders a list of resources of a given type with infinite scrolling.
58
+ * It's possible to specify a query to filter the list and either
59
+ * a React component to be used as `Item` template for the list or a function as `children` to render a custom element.
60
+ */
61
+ export declare function ResourceList<TResource extends ListableResourceType>({ type, query, title, actionButton, emptyState, ...props }: ResourceListProps<TResource>): JSX.Element;
62
+ export declare namespace ResourceList {
63
+ var displayName: string;
64
+ }
@@ -1,45 +1 @@
1
- import { type LegendProps } from '../../atoms/Legend';
2
- import { type SkeletonTemplateProps } from '../../atoms/SkeletonTemplate';
3
- import { type CommerceLayerClient, type QueryParamsList } from '@commercelayer/sdk';
4
- import { type ListableResourceType } from '@commercelayer/sdk/lib/cjs/api';
5
- import { type FC } from 'react';
6
- import { type Resource } from './infiniteFetcher';
7
- export interface ResourceListItemProps<TResource extends ListableResourceType> extends SkeletonTemplateProps<{
8
- /**
9
- * The fetched resource
10
- */
11
- resource?: Resource<TResource>;
12
- /**
13
- * callback to be used to remove the item from the list as UI element.
14
- * This needs to be used after a successful API call to delete the resource, since it just affects the current UI rendering and not the server data.
15
- */
16
- remove?: () => void;
17
- }> {
18
- }
19
- export interface ResourceListProps<TResource extends ListableResourceType> extends Pick<LegendProps, 'title' | 'actionButton'> {
20
- /**
21
- * The resource type to be fetched in the list
22
- */
23
- type: TResource;
24
- /**
25
- * SDK query object to be used to fetch the list, excluding the pageNumber that is handled internally for infinite scrolling.
26
- */
27
- query?: Omit<QueryParamsList, 'pageNumber'>;
28
- /**
29
- * A react component to be used to render each item in the list.
30
- */
31
- Item: FC<ResourceListItemProps<TResource>>;
32
- /**
33
- * An element to be rendered when the list is empty.
34
- */
35
- emptyState: JSX.Element;
36
- /**
37
- * A valid CommerceLayer SDK client instance.
38
- */
39
- sdkClient?: CommerceLayerClient;
40
- }
41
- declare function ResourceList<TResource extends ListableResourceType>({ type, query, title, Item, actionButton, sdkClient, emptyState }: ResourceListProps<TResource>): JSX.Element;
42
- declare namespace ResourceList {
43
- var displayName: string;
44
- }
45
- export { ResourceList };
1
+ export { ResourceList, type ResourceListProps } from './ResourceList';
@@ -1,4 +1,4 @@
1
- import { _ as i } from "./main-dd440dc6.js";
1
+ import { _ as i } from "./main-795be39b.js";
2
2
  function p(e, t) {
3
3
  if (i(e) !== "object" || e === null)
4
4
  return e;
@@ -1,10 +1,10 @@
1
1
  import { type ReactNode } from 'react';
2
- export declare function isFunctionComponent(child: any): child is {
2
+ export declare function isFunctionComponent(reactNode: any): reactNode is {
3
3
  type: React.FunctionComponent<any>;
4
4
  };
5
5
  /**
6
6
  * Checks if a ReactNode matches a specific component display name.
7
- * @param child - a ReactNode single child
7
+ * @param reactNode - a ReactNode single child
8
8
  * @param displayNames - a list of names of the components we would like to match
9
9
  * @returns a boolean value indicating argument match the passed displayNames
10
10
  *
@@ -16,4 +16,5 @@ export declare function isFunctionComponent(child: any): child is {
16
16
  * // will return an array of true/false values depending if some child is a button
17
17
  * ```
18
18
  */
19
- export declare function isSpecificReactComponent(child: ReactNode, displayNames: string[]): boolean;
19
+ export declare function isSpecificReactComponent(reactNode: ReactNode, displayNames: string[]): boolean;
20
+ export declare function getInnerText(reactNode: ReactNode): string;
@@ -1,6 +1,7 @@
1
+ import type { JsonObject } from 'type-fest';
1
2
  /**
2
3
  * Extract all keys from an array of objects of different shapes,
3
4
  * @param data - array of objects of different shapes
4
5
  * @returns an array of string values
5
6
  */
6
- export declare function extractHeaders(data: Array<Record<string, any>>): string[];
7
+ export declare function extractHeaders(data: JsonObject[]): string[];
@@ -1,8 +1,9 @@
1
+ import type { JsonPrimitive } from 'type-fest';
1
2
  /**
2
3
  * Given a `text` and a list of `values` it returns always the same value given the same `text`.
3
4
  * For example this is used when you need to map a fullname with a color.
4
5
  */
5
- export declare function getDeterministicValue(text: string, values: string[]): string;
6
+ export declare function getDeterministicValue(text: string, values: readonly [string, ...string[]]): string;
6
7
  /**
7
8
  * Get initials given a text.
8
9
  * @example getInitials('Ringo Starr') -> 'RS'
@@ -13,3 +14,9 @@ export declare function getInitials(text: string): string;
13
14
  * @example humanizeString('--First_Name') -> 'First name'
14
15
  */
15
16
  export declare function humanizeString(str: string): string;
17
+ /**
18
+ * Check whether a given value is a valid JSON primitive (`string | number | boolean | null`)
19
+ * @param value anything
20
+ * @returns value is a JSON primitive
21
+ */
22
+ export declare function isJsonPrimitive(value: any): value is JsonPrimitive;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/app-elements",
3
- "version": "0.0.80",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -20,10 +20,10 @@
20
20
  "pnpm": ">=7"
21
21
  },
22
22
  "dependencies": {
23
- "@commercelayer/sdk": "5.10.0",
24
- "@types/lodash": "^4.14.195",
25
- "@types/react": "^18.2.15",
26
- "@types/react-datepicker": "^4.11.2",
23
+ "@commercelayer/sdk": "5.13.2",
24
+ "@types/lodash": "^4.14.198",
25
+ "@types/react": "^18.2.21",
26
+ "@types/react-datepicker": "^4.15.0",
27
27
  "@types/react-dom": "^18.2.7",
28
28
  "classnames": "^2.3.2",
29
29
  "jwt-decode": "^3.1.2",
@@ -33,37 +33,37 @@
33
33
  "react-currency-input-field": "^3.6.11",
34
34
  "react-datepicker": "^4.16.0",
35
35
  "react-dom": "^18.2.0",
36
- "react-hook-form": "^7.45.2",
36
+ "react-hook-form": "^7.46.1",
37
37
  "react-select": "^5.7.4",
38
- "swr": "^2.2.0",
38
+ "swr": "^2.2.2",
39
39
  "ts-invariant": "^0.10.3",
40
- "type-fest": "^4.0.0",
41
- "zod": "^3.21.4"
40
+ "type-fest": "^4.3.1",
41
+ "zod": "^3.22.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@commercelayer/eslint-config-ts-react": "^1.0.1",
45
- "@hookform/resolvers": "^3.1.1",
44
+ "@commercelayer/eslint-config-ts-react": "^1.1.0",
45
+ "@hookform/resolvers": "^3.3.1",
46
46
  "@phosphor-icons/react": "v2.0.10",
47
- "@tailwindcss/forms": "^0.5.4",
48
- "@testing-library/jest-dom": "^5.17.0",
47
+ "@tailwindcss/forms": "^0.5.6",
48
+ "@testing-library/jest-dom": "^6.1.3",
49
49
  "@testing-library/react": "^14.0.0",
50
- "@types/node": "^20.4.2",
51
- "@types/testing-library__jest-dom": "^5.14.8",
52
- "@vitejs/plugin-react": "^4.0.3",
53
- "autoprefixer": "^10.4.14",
50
+ "@types/node": "^20.5.9",
51
+ "@types/testing-library__jest-dom": "^5.14.9",
52
+ "@vitejs/plugin-react": "^4.0.4",
53
+ "autoprefixer": "^10.4.15",
54
54
  "cross-fetch": "^4.0.0",
55
55
  "date-fns": "^2.30.0",
56
56
  "date-fns-tz": "^2.0.0",
57
- "eslint": "^8.45.0",
57
+ "eslint": "^8.48.0",
58
58
  "jsdom": "^22.1.0",
59
- "msw": "^1.2.3",
59
+ "msw": "^1.3.0",
60
60
  "polished": "^4.2.2",
61
- "postcss": "^8.4.27",
61
+ "postcss": "^8.4.29",
62
62
  "tailwindcss": "^3.3.3",
63
- "typescript": "^5.1.6",
64
- "vite": "^4.4.6",
65
- "vite-plugin-dts": "^3.3.1",
66
- "vitest": "^0.33.0",
63
+ "typescript": "^5.2.2",
64
+ "vite": "^4.4.9",
65
+ "vite-plugin-dts": "^3.5.3",
66
+ "vitest": "^0.34.4",
67
67
  "wouter": "^2.11.0"
68
68
  },
69
69
  "peerDependencies": {
@@ -76,8 +76,8 @@
76
76
  },
77
77
  "scripts": {
78
78
  "build": "tsc && vite build",
79
- "lint": "eslint src",
80
- "lint:fix": "eslint src --fix",
79
+ "lint": "eslint src --ext .ts,.tsx",
80
+ "lint:fix": "eslint src --ext .ts,.tsx --fix",
81
81
  "test": "vitest run",
82
82
  "test:watch": "vitest",
83
83
  "ts:check": "tsc --noEmit"
@@ -1,32 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- export interface LegendProps {
3
- /**
4
- * Main section title
5
- */
6
- title?: ReactNode;
7
- /**
8
- * Size for the title prop
9
- */
10
- titleSize?: 'normal' | 'small';
11
- /**
12
- * Specify `none` to remove border
13
- */
14
- border?: 'none';
15
- /**
16
- * This will render a button on the right side of the row
17
- */
18
- actionButton?: ReactNode;
19
- /**
20
- * CSS classes
21
- */
22
- className?: string;
23
- }
24
- export declare const Legend: import('../atoms/SkeletonTemplate').SkeletonTemplateComponent<{
25
- title?: ReactNode;
26
- titleSize?: "small" | "normal" | undefined;
27
- border?: "none" | undefined;
28
- actionButton?: ReactNode;
29
- className?: string | undefined;
30
- delayMs?: number | undefined;
31
- isLoading?: boolean | undefined;
32
- }>;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- interface Props extends React.TdHTMLAttributes<HTMLElement> {
3
- children?: React.ReactNode;
4
- }
5
- declare function Td({ children, className, ...rest }: Props): JSX.Element;
6
- declare namespace Td {
7
- var displayName: string;
8
- }
9
- export { Td };
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- export interface InputToggleBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'value'> {
3
- id: string;
4
- label: string;
5
- description?: React.ReactNode;
6
- className?: string;
7
- }
8
- declare const InputToggleBox: import("react").ForwardRefExoticComponent<InputToggleBoxProps & import("react").RefAttributes<HTMLInputElement>>;
9
- export { InputToggleBox };
@@ -1,15 +0,0 @@
1
- /// <reference types="react" />
2
- export interface InputToggleListBoxOption {
3
- value: string;
4
- label: string;
5
- }
6
- export interface InputToggleListBoxProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'value' | 'onSelect'> {
7
- id: string;
8
- label: string;
9
- description?: React.ReactNode;
10
- value?: string;
11
- options: InputToggleListBoxOption[];
12
- className?: string;
13
- }
14
- declare const InputToggleListBox: import("react").ForwardRefExoticComponent<InputToggleListBoxProps & import("react").RefAttributes<HTMLSelectElement>>;
15
- export { InputToggleListBox };