@edvisor/product-language 0.3.1 → 0.4.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.
@@ -13,5 +13,6 @@ export * from './tabs';
13
13
  export * from './icon';
14
14
  export * from './flag';
15
15
  export * from './spinner';
16
+ export * from './select';
16
17
  export * from './molecules';
17
18
  export * from './organisms';
@@ -0,0 +1,3 @@
1
+ import { FC } from '@helpers';
2
+ import { IMenuContainerProps } from '../types';
3
+ export declare const MenuContainer: FC<IMenuContainerProps>;
@@ -0,0 +1,9 @@
1
+ import { CSSProperties } from 'react';
2
+ import { IMenuComponentProps } from '../types';
3
+ interface IMenuRowProps {
4
+ index: number;
5
+ style: CSSProperties;
6
+ data: IMenuComponentProps;
7
+ }
8
+ export declare const MenuRow: import("react").MemoExoticComponent<({ index, style, data }: IMenuRowProps) => JSX.Element>;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ import { IMenuComponentProps } from '../types';
2
+ export declare const Menu: (props: IMenuComponentProps) => JSX.Element;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { IOptionComponentProps } from '../types';
3
+ interface IOptionItemProps {
4
+ active?: IOptionComponentProps['active'];
5
+ selected?: IOptionComponentProps['selected'];
6
+ height?: IOptionComponentProps['height'];
7
+ }
8
+ export declare const OptionItem: import("styled-components").StyledComponent<"div", any, IOptionItemProps, never>;
9
+ export declare const OptionComponent: import("react").MemoExoticComponent<(props: IOptionComponentProps) => JSX.Element>;
10
+ export {};
@@ -0,0 +1 @@
1
+ export declare const SelectLabel: import("styled-components").StyledComponent<import("../../../helpers").FC<import("components/typography").ITextComponentProps & import("../../../foundations").ILabelProps, {}>, any, {}, never>;
@@ -0,0 +1,3 @@
1
+ import { IValueComponentMultiProps } from '../types';
2
+ declare const _default: <T>(props: IValueComponentMultiProps<T>) => JSX.Element;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { IValueComponentSingleProps } from '../types';
2
+ import { FC } from '@helpers';
3
+ declare const _default: FC<IValueComponentSingleProps<any>, {}>;
4
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { FC } from '@helpers';
2
+ import { IValueProps } from '../types';
3
+ declare const _default: FC<IValueProps, {}>;
4
+ export default _default;
@@ -0,0 +1 @@
1
+ export * from './select';
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { PropsWithChildren } from '@helpers';
3
+ import { ISelectProps } from './types';
4
+ export declare const SelectImpl: <T>(props: ISelectProps<T>, ref: React.ForwardedRef<HTMLDivElement>) => JSX.Element;
5
+ export declare const Select: <T>(props: ISelectProps<T> & {
6
+ children?: import("react").ReactNode;
7
+ } & {
8
+ ref?: import("react").ForwardedRef<HTMLDivElement> | undefined;
9
+ }) => ReturnType<typeof SelectImpl>;
@@ -0,0 +1,124 @@
1
+ /// <reference types="react" />
2
+ import { FC } from '@helpers';
3
+ export interface ISelectProps<T = any> {
4
+ className?: string;
5
+ options?: IOption<T>[];
6
+ value?: T | T[];
7
+ placeholder?: string;
8
+ emptyText?: string;
9
+ clearable?: boolean;
10
+ searchable?: boolean;
11
+ disabled?: boolean;
12
+ multi?: boolean;
13
+ invalid?: boolean;
14
+ errors?: {
15
+ message: string;
16
+ }[];
17
+ rowHeight?: number;
18
+ menuHeight?: number;
19
+ menuPosition?: 'top' | 'bottom';
20
+ label?: string;
21
+ labelPosition?: 'top' | 'side';
22
+ labelComponent?: FC<LabelComponentProps<T>>;
23
+ menuComponent?: FC<IMenuComponentProps>;
24
+ onChange?(value: T[] | T | undefined, option?: IOption<T>): void;
25
+ onSearch?(value: string): void;
26
+ onOpen?(): void;
27
+ onClose?(): void;
28
+ }
29
+ export interface IValueProps {
30
+ options: ISelectProps['options'];
31
+ value: ISelectProps['value'];
32
+ placeholder: ISelectProps['placeholder'];
33
+ clearable: ISelectProps['clearable'];
34
+ searchable: ISelectProps['searchable'];
35
+ labelComponent: ISelectProps['labelComponent'];
36
+ multi: ISelectProps['multi'];
37
+ disabled: ISelectProps['disabled'];
38
+ invalid: ISelectProps['invalid'];
39
+ errors: ISelectProps['errors'];
40
+ search?: string;
41
+ open: boolean;
42
+ focused?: boolean;
43
+ label: ISelectProps['label'];
44
+ labelPosition: ISelectProps['labelPosition'];
45
+ onClear(): void;
46
+ onClick(): void;
47
+ onSearch(search: string): void;
48
+ onSearchFocus(): void;
49
+ onSearchBlur(): void;
50
+ onOptionRemove(value: any): void;
51
+ }
52
+ export interface IMenuContainerProps {
53
+ className?: string;
54
+ menuTop?: number;
55
+ menuHeight?: RectSize;
56
+ menuPosition?: ISelectProps['menuPosition'];
57
+ invalid?: boolean;
58
+ labelPosition?: string;
59
+ label?: string;
60
+ children?: React.ReactNode;
61
+ onRef?(el: HTMLDivElement | undefined): void;
62
+ onClick?(el: React.MouseEvent<HTMLDivElement>): void;
63
+ }
64
+ declare type RectSize = number | 'auto';
65
+ export interface IRect {
66
+ left: number;
67
+ top: number;
68
+ width: RectSize;
69
+ height: RectSize;
70
+ }
71
+ export interface IValueComponentMultiProps<T = any> extends IValueComponentSingleProps<T> {
72
+ options: IOption<T>[];
73
+ onRemove(value: T): void;
74
+ }
75
+ export declare type LabelComponentProps<T = any> = IOption<T> & {
76
+ active: boolean;
77
+ type: 'value-single' | 'value-multi' | 'option';
78
+ };
79
+ export interface IValueComponentSingleProps<T = any> {
80
+ className?: string;
81
+ option: IOption<T>;
82
+ labelComponent: ISelectProps['labelComponent'];
83
+ }
84
+ export interface IOptionComponentProps<T extends IOption = any> {
85
+ className?: string;
86
+ option: T;
87
+ active?: boolean;
88
+ selected?: boolean;
89
+ height?: number;
90
+ labelComponent: ISelectProps['labelComponent'];
91
+ search?: string;
92
+ onSelect(value: T['value'], option?: T): void;
93
+ }
94
+ export interface IOption<T = any> {
95
+ value: T;
96
+ disabled?: boolean;
97
+ label: string;
98
+ [key: string]: any;
99
+ }
100
+ export interface IMenuComponentProps<T = any> {
101
+ options: ISelectProps['options'];
102
+ value: ISelectProps['value'];
103
+ labelComponent: ISelectProps['labelComponent'];
104
+ menuComponent: ISelectProps['menuComponent'];
105
+ emptyText: ISelectProps['emptyText'];
106
+ multi: ISelectProps['multi'];
107
+ rowHeight: ISelectProps['rowHeight'];
108
+ menuHeight: ISelectProps['menuHeight'];
109
+ menuPosition: ISelectProps['menuPosition'];
110
+ invalid: ISelectProps['invalid'];
111
+ selectedIndex?: number;
112
+ open: boolean;
113
+ search?: string;
114
+ labelPosition?: string;
115
+ label?: string;
116
+ onSelect(value: T extends any[] ? T[] : T, option?: T): void;
117
+ }
118
+ export interface IPosition {
119
+ menuPosition?: 'top' | 'bottom';
120
+ menuHeight?: RectSize;
121
+ label?: string;
122
+ labelPosition?: string;
123
+ }
124
+ export {};
@@ -0,0 +1,15 @@
1
+ import { IOption, IPosition } from './types';
2
+ export declare function getDocument(): Document | undefined;
3
+ export declare function equal(valueA: any, valueB: any): boolean;
4
+ export declare function getValueOptions(options: IOption[], value: any, multi: boolean | undefined): IOption<any>[];
5
+ export declare const keys: {
6
+ ARROW_UP: string;
7
+ ARROW_DOWN: string;
8
+ ENTER: string;
9
+ TAB: string;
10
+ ESC: string;
11
+ BACKSPACE: string;
12
+ SPACE: string;
13
+ };
14
+ export declare function toKey(value: any): string | number;
15
+ export declare const topPosition: (props: IPosition) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edvisor/product-language",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "description": "Edvisor.io product-language components",
6
6
  "repository": "https://github.com/edvisor-io/front-end/",
@@ -14,6 +14,7 @@
14
14
  "release": "*",
15
15
  "styled-components": "5.3.5",
16
16
  "react": "18.2.0",
17
+ "react-window": "^1.8.8",
17
18
  "@storybook/addon-docs": "^6.5.10"
18
19
  },
19
20
  "release-it": {