@true-engineering/true-react-common-ui-kit 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/components/Input/Input.styles.d.ts +1 -0
  2. package/dist/components/Select/Select.d.ts +12 -3
  3. package/dist/components/Select/Select.styles.d.ts +9 -0
  4. package/dist/components/Select/SelectList/SelectList.d.ts +7 -4
  5. package/dist/components/Select/SelectList/SelectList.styles.d.ts +5 -0
  6. package/dist/components/Select/SelectListItem/SelectListItem.d.ts +14 -0
  7. package/dist/components/Select/SelectListItem/SelectListItem.styles.d.ts +2 -0
  8. package/dist/components/Select/constants.d.ts +2 -0
  9. package/dist/components/Select/helpers.d.ts +4 -1
  10. package/dist/components/Select/index.d.ts +1 -0
  11. package/dist/components/Select/types.d.ts +1 -0
  12. package/dist/helpers/utils.d.ts +2 -0
  13. package/dist/true-react-common-ui-kit.js +365 -163
  14. package/dist/true-react-common-ui-kit.js.map +1 -1
  15. package/dist/true-react-common-ui-kit.umd.cjs +365 -163
  16. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  17. package/package.json +1 -1
  18. package/src/components/Input/Input.styles.ts +2 -0
  19. package/src/components/Input/Input.tsx +4 -1
  20. package/src/components/Select/MultiSelect.stories.tsx +263 -0
  21. package/src/components/Select/Select.styles.ts +11 -0
  22. package/src/components/Select/Select.tsx +234 -114
  23. package/src/components/Select/SelectList/SelectList.styles.ts +6 -2
  24. package/src/components/Select/SelectList/SelectList.tsx +65 -39
  25. package/src/components/Select/SelectListItem/SelectListItem.styles.ts +14 -0
  26. package/src/components/Select/SelectListItem/SelectListItem.tsx +73 -0
  27. package/src/components/Select/constants.ts +2 -0
  28. package/src/components/Select/helpers.ts +16 -8
  29. package/src/components/Select/index.ts +1 -0
  30. package/src/components/Select/types.ts +1 -0
  31. package/src/helpers/utils.ts +29 -0
@@ -242,6 +242,7 @@ export declare const styles: {
242
242
  paddingLeft: number;
243
243
  };
244
244
  loading: {};
245
+ withUnits: {};
245
246
  tweakPreloader: {};
246
247
  };
247
248
  export declare type InputStyles = ComponentStyles<typeof styles>;
@@ -4,9 +4,11 @@ import { IIconType } from '../Icon';
4
4
  import { IDropdownWithPopperOptions } from '../../types';
5
5
  import { SelectStyles } from './Select.styles';
6
6
  import { ISearchInputProps } from '../SearchInput';
7
+ import { IMultipleSelectValue } from './types';
7
8
  export interface ISelectProps<Value> extends Omit<IInputProps, 'value' | 'onChange' | 'onBlur' | 'type'> {
8
9
  tweakStyles?: SelectStyles;
9
10
  defaultOptionLabel?: string;
11
+ allOptionsLabel?: string;
10
12
  noMatchesLabel?: string;
11
13
  loadingLabel?: ReactNode;
12
14
  optionsMode?: 'search' | 'dynamic' | 'normal';
@@ -17,18 +19,25 @@ export interface ISelectProps<Value> extends Omit<IInputProps, 'value' | 'onChan
17
19
  options: Value[];
18
20
  value: Value | undefined;
19
21
  shouldScrollToList?: boolean;
22
+ isMultiSelect?: boolean;
20
23
  searchInput?: {
21
24
  shouldRenderInList: true;
22
25
  } & Pick<ISearchInputProps, 'placeholder'>;
23
26
  isOptionDisabled?(option: Value): boolean;
24
- onChange(value: Value | undefined): void;
27
+ onChange(value?: Value): void;
25
28
  onBlur?(event: Event | SyntheticEvent): void;
26
29
  onType?(value: string): Promise<void>;
27
30
  optionsFilter?(options: Value[], query: string): Value[];
28
31
  onOpen?(): void;
29
- compareValuesOnChange?(v1: Value | undefined, v2: Value | undefined): boolean;
32
+ compareValuesOnChange?(v1?: Value, v2?: Value): boolean;
30
33
  convertValueToString?(value: Value): string | undefined;
31
34
  convertValueToReactNode?(value: Value, isDisabled: boolean): ReactNode;
32
35
  convertValueToId?(value: Value): string | undefined;
33
36
  }
34
- export declare function Select<Value>({ options, value, defaultOptionLabel, debounceTime, optionsMode, noMatchesLabel, loadingLabel, tweakStyles, testId, isReadonly, isDisabled, dropdownOptions, minSymbolsCountToOpenList, dropdownIcon, shouldScrollToList, searchInput, onChange, onFocus, onBlur, onType, onOpen, isOptionDisabled, compareValuesOnChange, convertValueToString, convertValueToId, convertValueToReactNode, optionsFilter, ...inputProps }: ISelectProps<Value>): JSX.Element;
37
+ export interface IMultipleSelectProps<Value> extends Omit<ISelectProps<Value>, 'value' | 'onChange' | 'compareValuesOnChange'> {
38
+ isMultiSelect: true;
39
+ value: IMultipleSelectValue<Value> | undefined;
40
+ onChange(value?: IMultipleSelectValue<Value>): void;
41
+ compareValuesOnChange?(v1?: IMultipleSelectValue<Value>, v2?: IMultipleSelectValue<Value>): boolean;
42
+ }
43
+ export declare function Select<Value>(props: ISelectProps<Value> | IMultipleSelectProps<Value>): JSX.Element;
@@ -43,6 +43,15 @@ export declare const styles: {
43
43
  cursor: string;
44
44
  };
45
45
  };
46
+ counter: {
47
+ '&:not(:last-child)': {
48
+ paddingRight: number;
49
+ };
50
+ };
51
+ icon: {
52
+ width: number;
53
+ height: number;
54
+ };
46
55
  tweakInput: {
47
56
  input: {
48
57
  paddingRight: number;
@@ -5,18 +5,21 @@ export interface ISelectListProps<Value> extends ICommonProps {
5
5
  tweakStyles?: SelectListStyles;
6
6
  options: Value[];
7
7
  focusedIndex?: number;
8
- activeValue?: Value;
8
+ activeValue?: Value | Value[];
9
9
  noMatchesLabel?: string;
10
10
  isLoading?: boolean;
11
11
  loadingLabel?: ReactNode;
12
12
  defaultOptionLabel?: string;
13
13
  testId?: string;
14
+ allOptionsLabel?: string;
15
+ areAllOptionsSelected?: boolean;
14
16
  shouldScrollToList?: boolean;
15
17
  customListHeader?: ReactNode;
16
- onOptionClick(index: number, event: MouseEvent<HTMLElement>): void;
18
+ onOptionSelect(index: number, event: MouseEvent<HTMLElement>): void;
19
+ onToggleCheckbox?(index: number, isSelected: boolean): void;
17
20
  isOptionDisabled(value: Value): boolean;
18
21
  convertValueToString(value: Value): string | undefined;
19
22
  convertValueToReactNode?(value: Value, isDisabled: boolean): ReactNode;
20
- convertValueToId?(value: Value): string | undefined;
23
+ convertValueToId(value: Value): string | undefined;
21
24
  }
22
- export declare function SelectList<Value>({ options, focusedIndex, activeValue, defaultOptionLabel, noMatchesLabel, isLoading, loadingLabel, tweakStyles, testId, shouldScrollToList, customListHeader, isOptionDisabled, onOptionClick, convertValueToString, convertValueToReactNode, convertValueToId, }: ISelectListProps<Value>): JSX.Element;
25
+ export declare function SelectList<Value>({ options, focusedIndex, activeValue, defaultOptionLabel, noMatchesLabel, isLoading, loadingLabel, tweakStyles, testId, shouldScrollToList, areAllOptionsSelected, customListHeader, isOptionDisabled, allOptionsLabel, onOptionSelect, onToggleCheckbox, convertValueToString, convertValueToReactNode, convertValueToId, }: ISelectListProps<Value>): JSX.Element;
@@ -1,5 +1,7 @@
1
1
  import { ComponentStyles } from '../../../types';
2
2
  export declare const ROW_HEIGHT = 40;
3
+ export declare const CONTAINER_PADDING = 10;
4
+ export declare const CELL_PADDING: number[];
3
5
  export declare const styles: {
4
6
  root: {
5
7
  borderRadius: 6;
@@ -38,6 +40,9 @@ export declare const styles: {
38
40
  boxSizing: string;
39
41
  fontSize: number;
40
42
  };
43
+ cellWithCheckbox: {
44
+ padding: number;
45
+ };
41
46
  noMatchesLabel: {
42
47
  pointerEvents: string;
43
48
  };
@@ -0,0 +1,14 @@
1
+ import { ReactNode, MouseEvent, FC } from 'react';
2
+ import { Classes } from 'jss';
3
+ export interface ISelectListItemProps {
4
+ index: number;
5
+ isSemiChecked?: boolean;
6
+ isDisabled?: boolean;
7
+ isActive?: boolean;
8
+ isFocused?: boolean;
9
+ children: ReactNode;
10
+ classes: Classes<'cellWithCheckbox' | 'cell' | 'focused' | 'active' | 'disabled'>;
11
+ onOptionSelect(index: number, event: MouseEvent<HTMLElement>): void;
12
+ onToggleCheckbox?(index: number, isSelected: boolean): void;
13
+ }
14
+ export declare const SelectListItem: FC<ISelectListItemProps>;
@@ -0,0 +1,2 @@
1
+ import { CheckboxStyles } from '../../Checkbox';
2
+ export declare const checkboxStyles: CheckboxStyles;
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_OPTION_INDEX = -2;
2
+ export declare const ALL_OPTION_INDEX = -1;
@@ -1,4 +1,7 @@
1
+ import type { IMultipleSelectProps, ISelectProps } from './Select';
2
+ import { IMultipleSelectValue } from './types';
1
3
  export declare const defaultIsOptionDisabled: <Value>(option: Value) => boolean;
2
4
  export declare const defaultConvertFunction: (v: unknown) => string | undefined;
3
5
  export declare const defaultCompareFunction: <Value>(v1: Value, v2: Value) => boolean;
4
- export declare const getActiveValueIndex: <Value>(options: Value[], value: Value | undefined, convertFunc: (v: Value) => string | undefined) => number;
6
+ export declare const getDefaultConvertToIdFunction: <Value>(convertValueToString: (value: Value) => string | undefined) => (value: Value) => string | undefined;
7
+ export declare const isMultiSelectValue: <Value>(props: ISelectProps<Value> | IMultipleSelectProps<Value>, _value: Value | IMultipleSelectValue<Value> | undefined) => _value is IMultipleSelectValue<Value> | undefined;
@@ -1,3 +1,4 @@
1
1
  export * from './Select';
2
+ export type { IMultipleSelectValue } from './types';
2
3
  export type { SelectStyles } from './Select.styles';
3
4
  export type { SelectListStyles } from './SelectList/SelectList.styles';
@@ -0,0 +1 @@
1
+ export declare type IMultipleSelectValue<Value> = Array<NonNullable<Value>>;
@@ -16,6 +16,7 @@ export declare const isSpaceChar: (char?: string) => boolean;
16
16
  export declare const isInt: (n: number) => boolean;
17
17
  export declare const getNumberLength: (n?: number) => number;
18
18
  export declare const isNotEmpty: <T>(val: T | null | undefined) => val is T;
19
+ export declare const isStringNotEmpty: <T extends string>(value: T | null | undefined) => value is T;
19
20
  export declare const trimStringToMaxLength: (val: string, maxLength: number) => string;
20
21
  export declare const addDataAttributes: (data?: IDataAttributes) => IDataAttributes;
21
22
  export declare const addDataTestId: (testId: string | undefined, postfix?: string | number | undefined) => {
@@ -24,3 +25,4 @@ export declare const addDataTestId: (testId: string | undefined, postfix?: strin
24
25
  export declare const getTestId: (testId: string | undefined, postfix?: string | number) => string | undefined;
25
26
  export declare const getSelectKeyHandler: (cb: (e: KeyboardEvent) => void) => (e: KeyboardEvent) => void;
26
27
  export declare const addClickHandler: (cb?: ((e: MouseEvent | KeyboardEvent) => void) | undefined, hasAction?: boolean) => HTMLAttributes<unknown>;
28
+ export declare const createFilter: <T>(getter: (item: T) => Array<string | undefined>) => (items: T[], query: string) => T[];