@true-engineering/true-react-common-ui-kit 1.8.1 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Input/Input.styles.d.ts +1 -0
- package/dist/components/Select/Select.d.ts +12 -3
- package/dist/components/Select/Select.styles.d.ts +10 -0
- package/dist/components/Select/SelectList/SelectList.d.ts +6 -4
- package/dist/components/Select/SelectList/SelectList.styles.d.ts +5 -0
- package/dist/components/Select/SelectListItem/SelectListItem.d.ts +14 -0
- package/dist/components/Select/SelectListItem/SelectListItem.styles.d.ts +2 -0
- package/dist/components/Select/constants.d.ts +2 -0
- package/dist/components/Select/helpers.d.ts +4 -1
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/Select/types.d.ts +1 -0
- package/dist/helpers/utils.d.ts +3 -1
- package/dist/true-react-common-ui-kit.js +1133 -217
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +1105 -188
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/components/Button/Button.tsx +1 -1
- package/src/components/FiltersPane/FilterSelect/locales.ts +1 -1
- package/src/components/FiltersPane/locales.ts +1 -1
- package/src/components/Input/Input.styles.ts +2 -0
- package/src/components/Input/Input.tsx +4 -1
- package/src/components/MultiSelectList/locales.ts +1 -1
- package/src/components/Select/MultiSelect.stories.tsx +262 -0
- package/src/components/Select/Select.styles.ts +13 -0
- package/src/components/Select/Select.tsx +218 -117
- package/src/components/Select/SelectList/SelectList.styles.ts +6 -2
- package/src/components/Select/SelectList/SelectList.tsx +64 -39
- package/src/components/Select/SelectListItem/SelectListItem.styles.ts +14 -0
- package/src/components/Select/SelectListItem/SelectListItem.tsx +73 -0
- package/src/components/Select/constants.ts +2 -0
- package/src/components/Select/helpers.ts +16 -8
- package/src/components/Select/index.ts +1 -0
- package/src/components/Select/types.ts +1 -0
- package/src/helpers/utils.ts +33 -2
- package/src/hooks/use-theme.ts +1 -1
- package/src/hooks/use-tweak-styles.ts +1 -1
|
@@ -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
|
|
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
|
|
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
|
|
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;
|
|
@@ -47,6 +47,16 @@ export declare const styles: {
|
|
|
47
47
|
input: {
|
|
48
48
|
paddingRight: number;
|
|
49
49
|
};
|
|
50
|
+
withUnits: {
|
|
51
|
+
paddingRight: number;
|
|
52
|
+
};
|
|
53
|
+
unitsWrapper: {
|
|
54
|
+
position: string;
|
|
55
|
+
padding: number[];
|
|
56
|
+
};
|
|
57
|
+
fakeValue: {
|
|
58
|
+
display: string;
|
|
59
|
+
};
|
|
50
60
|
disabled: {
|
|
51
61
|
'& $input': {
|
|
52
62
|
cursor: string;
|
|
@@ -5,18 +5,20 @@ 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;
|
|
14
15
|
shouldScrollToList?: boolean;
|
|
15
16
|
customListHeader?: ReactNode;
|
|
16
|
-
|
|
17
|
+
onOptionSelect(index: number, event: MouseEvent<HTMLElement>): void;
|
|
18
|
+
onToggleCheckbox?(index: number, isSelected: boolean): void;
|
|
17
19
|
isOptionDisabled(value: Value): boolean;
|
|
18
20
|
convertValueToString(value: Value): string | undefined;
|
|
19
21
|
convertValueToReactNode?(value: Value, isDisabled: boolean): ReactNode;
|
|
20
|
-
convertValueToId
|
|
22
|
+
convertValueToId(value: Value): string | undefined;
|
|
21
23
|
}
|
|
22
|
-
export declare function SelectList<Value>({ options, focusedIndex, activeValue, defaultOptionLabel, noMatchesLabel, isLoading, loadingLabel, tweakStyles, testId, shouldScrollToList, customListHeader, isOptionDisabled,
|
|
24
|
+
export declare function SelectList<Value>({ options, focusedIndex, activeValue, defaultOptionLabel, noMatchesLabel, isLoading, loadingLabel, tweakStyles, testId, shouldScrollToList, 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>;
|
|
@@ -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
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type IMultipleSelectValue<Value> = Array<NonNullable<Value>>;
|
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IDataAttributes } from '../types';
|
|
|
2
2
|
import { HTMLAttributes, KeyboardEvent, MouseEvent } from 'react';
|
|
3
3
|
export declare const transformToKebab: (string: string) => string;
|
|
4
4
|
export declare const hasExactParent: (element: Element, parent: Element) => boolean;
|
|
5
|
-
export declare const getParentNode: (element: Element | ShadowRoot) => Element;
|
|
5
|
+
export declare const getParentNode: (element: Element | ShadowRoot | Document) => Element;
|
|
6
6
|
export declare const getStyleComputedProperty: (element: Element) => Partial<CSSStyleDeclaration>;
|
|
7
7
|
export declare const getScrollParent: (element: Element | Document) => Element;
|
|
8
8
|
export declare const isElementOffScreen: (element: HTMLElement, input?: HTMLElement) => boolean;
|
|
@@ -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[];
|