@akinon/ui-select 0.4.0 → 0.5.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.
@@ -0,0 +1,68 @@
1
+ export interface BaseOptionType {
2
+ disabled?: boolean;
3
+ className?: string;
4
+ title?: string;
5
+ [name: string]: unknown;
6
+ }
7
+
8
+ export interface DefaultOptionType extends BaseOptionType {
9
+ label?: React.ReactNode;
10
+ value?: string | number | null;
11
+ children?: Omit<DefaultOptionType, 'children'>[];
12
+ }
13
+
14
+ export type SelectHandler<ValueType, OptionType> = (
15
+ value: ValueType,
16
+ option: OptionType
17
+ ) => void;
18
+
19
+ export type ArrayElementType<T> = T extends (infer E)[] ? E : T;
20
+
21
+ export interface SelectProps<
22
+ ValueType = string | number | boolean,
23
+ OptionType extends BaseOptionType = DefaultOptionType
24
+ > extends BaseSelectPropsWithoutPrivate {
25
+ placeholder?: string;
26
+ allowClear?: boolean;
27
+ prefixCls?: string;
28
+ id?: string;
29
+ fieldNames?: FieldNames;
30
+ searchValue?: string;
31
+ onSearch?: (value: string) => void;
32
+ autoClearSearchValue?: boolean;
33
+ onSelect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
34
+ onDeselect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
35
+ filterOption?: boolean | FilterFunc<OptionType>;
36
+ filterSort?: (optionA: OptionType, optionB: OptionType) => number;
37
+ optionFilterProp?: string;
38
+ optionLabelProp?: string;
39
+ size?: 'small' | 'middle' | 'large';
40
+ options?: OptionType[];
41
+ optionRender?: (
42
+ oriOption: FlattenOptionData<BaseOptionType>,
43
+ info: {
44
+ index: number;
45
+ }
46
+ ) => React.ReactNode;
47
+ defaultActiveFirstOption?: boolean;
48
+ virtual?: boolean;
49
+ direction?: 'ltr' | 'rtl';
50
+ listHeight?: number;
51
+ listItemHeight?: number;
52
+ labelRender?: (props: LabelInValueType) => React.ReactNode;
53
+ menuItemSelectedIcon?: RenderNode;
54
+ mode?: 'combobox' | 'multiple' | 'tags';
55
+ labelInValue?: boolean;
56
+ value?: ValueType | null;
57
+ defaultValue?: ValueType | null;
58
+ maxCount?: number;
59
+ onChange?: (value: ValueType, option?: OptionType | OptionType[]) => void;
60
+ rootClassName?: string;
61
+ suffixIcon?: React.ReactNode;
62
+ disabled?: boolean;
63
+ showArrow?: boolean;
64
+ /**
65
+ * @default "outlined"
66
+ */
67
+ variant?: 'outlined' | 'borderless' | 'filled';
68
+ }
@@ -0,0 +1,68 @@
1
+ export interface BaseOptionType {
2
+ disabled?: boolean;
3
+ className?: string;
4
+ title?: string;
5
+ [name: string]: unknown;
6
+ }
7
+
8
+ export interface DefaultOptionType extends BaseOptionType {
9
+ label?: React.ReactNode;
10
+ value?: string | number | null;
11
+ children?: Omit<DefaultOptionType, 'children'>[];
12
+ }
13
+
14
+ export type SelectHandler<ValueType, OptionType> = (
15
+ value: ValueType,
16
+ option: OptionType
17
+ ) => void;
18
+
19
+ export type ArrayElementType<T> = T extends (infer E)[] ? E : T;
20
+
21
+ export interface SelectProps<
22
+ ValueType = string | number | boolean,
23
+ OptionType extends BaseOptionType = DefaultOptionType
24
+ > extends BaseSelectPropsWithoutPrivate {
25
+ placeholder?: string;
26
+ allowClear?: boolean;
27
+ prefixCls?: string;
28
+ id?: string;
29
+ fieldNames?: FieldNames;
30
+ searchValue?: string;
31
+ onSearch?: (value: string) => void;
32
+ autoClearSearchValue?: boolean;
33
+ onSelect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
34
+ onDeselect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
35
+ filterOption?: boolean | FilterFunc<OptionType>;
36
+ filterSort?: (optionA: OptionType, optionB: OptionType) => number;
37
+ optionFilterProp?: string;
38
+ optionLabelProp?: string;
39
+ size?: 'small' | 'middle' | 'large';
40
+ options?: OptionType[];
41
+ optionRender?: (
42
+ oriOption: FlattenOptionData<BaseOptionType>,
43
+ info: {
44
+ index: number;
45
+ }
46
+ ) => React.ReactNode;
47
+ defaultActiveFirstOption?: boolean;
48
+ virtual?: boolean;
49
+ direction?: 'ltr' | 'rtl';
50
+ listHeight?: number;
51
+ listItemHeight?: number;
52
+ labelRender?: (props: LabelInValueType) => React.ReactNode;
53
+ menuItemSelectedIcon?: RenderNode;
54
+ mode?: 'combobox' | 'multiple' | 'tags';
55
+ labelInValue?: boolean;
56
+ value?: ValueType | null;
57
+ defaultValue?: ValueType | null;
58
+ maxCount?: number;
59
+ onChange?: (value: ValueType, option?: OptionType | OptionType[]) => void;
60
+ rootClassName?: string;
61
+ suffixIcon?: React.ReactNode;
62
+ disabled?: boolean;
63
+ showArrow?: boolean;
64
+ /**
65
+ * @default "outlined"
66
+ */
67
+ variant?: 'outlined' | 'borderless' | 'filled';
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-select",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
@@ -16,7 +16,7 @@
16
16
  "copyfiles": "^2.4.1",
17
17
  "rimraf": "^5.0.5",
18
18
  "typescript": "^5.2.2",
19
- "@akinon/typescript-config": "0.3.0"
19
+ "@akinon/typescript-config": "0.4.0"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "react": ">=18",
@@ -36,7 +36,7 @@
36
36
  "build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
37
37
  "build:esm": "tsc --outDir dist/esm",
38
38
  "build:commonjs": "tsc --module commonjs --outDir dist/cjs",
39
- "copy:files": "copyfiles -u 1 src/**/*.css dist/esm && copyfiles -u 1 src/**/*.css dist/cjs",
39
+ "copy:files": "copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/esm && copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/cjs",
40
40
  "clean": "rimraf dist/",
41
41
  "typecheck": "tsc --noEmit"
42
42
  }