@choc-ui/chakra-autocomplete 5.1.8 → 5.2.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/types.d.ts CHANGED
@@ -1,124 +1,128 @@
1
- import { BoxProps, FlexProps, InputProps, SystemStyleObject, WrapProps } from "@chakra-ui/react";
2
- import { MaybeRenderProp } from "@chakra-ui/react-utils";
3
- import React, { Dispatch, SetStateAction } from "react";
4
- import { AutoCompleteGroupProps } from "./autocomplete-group";
5
- import { AutoCompleteInputProps } from "./autocomplete-input";
6
- import { AutoCompleteProps } from "./autocomplete";
7
- import { AutoCompleteItemProps } from "./autocomplete-item";
8
- export interface Item {
9
- value: any;
10
- label?: any;
11
- fixed?: boolean;
12
- disabled?: boolean;
13
- itemVal?: any;
14
- noFilter?: boolean;
15
- creatable?: boolean;
16
- originalValue?: any;
17
- }
18
- export declare type UseAutoCompleteProps = Partial<{
19
- closeOnBlur: boolean;
20
- closeOnSelect: boolean;
21
- creatable: boolean;
22
- defaultIsOpen: boolean;
23
- defaultValue: Item["value"];
24
- defaultValues: Item["value"][];
25
- disableFilter: boolean;
26
- emphasize: boolean | SystemStyleObject;
27
- emptyState: boolean | MaybeRenderProp<{
28
- query: Item["value"];
29
- }>;
30
- filter: (query: string, optionValue: Item["value"], optionLabel: Item["label"]) => boolean;
31
- focusInputOnSelect: boolean;
32
- freeSolo: boolean;
33
- isReadOnly: boolean;
34
- listAllValuesOnFocus: boolean;
35
- maxSelections: number;
36
- maxSuggestions: number;
37
- multiple: boolean;
38
- onChange: (value: Item["value"] | Item["value"][], item: Item | Item[]) => void;
39
- onCreateOption: (params: {
40
- item: Item;
41
- selectMethod: "mouse" | "keyboard" | null;
42
- }) => boolean | void;
43
- onSelectOption: (params: {
44
- item: Item;
45
- selectMethod: "mouse" | "keyboard" | null;
46
- isNewInput?: boolean;
47
- }) => boolean | void;
48
- onOptionFocus: (params: {
49
- item: Item;
50
- focusMethod: "mouse" | "keyboard" | null;
51
- isNewInput?: boolean;
52
- }) => boolean | void;
53
- onTagRemoved: (removedTag: Item["value"], item: Item, tags: ItemTag[]) => void;
54
- onReady: (params: OnReadyProps) => void;
55
- openOnFocus: boolean;
56
- restoreOnBlurIfEmpty: boolean;
57
- rollNavigation: boolean;
58
- selectOnFocus: boolean;
59
- shouldRenderSuggestions: (value: string) => boolean;
60
- submitKeys: string[];
61
- suggestWhenEmpty: boolean;
62
- value: Item["value"];
63
- values: Item["value"][];
64
- }>;
65
- export declare type ItemTag = {
66
- label: any;
67
- onRemove: () => void;
68
- };
69
- export declare type OnReadyProps = {
70
- tags: ItemTag[];
71
- };
72
- export declare type InputReturnProps = {
73
- wrapper: {
74
- onClick: React.MouseEventHandler<HTMLDivElement>;
75
- ref: React.RefObject<HTMLDivElement>;
76
- } & WrapProps;
77
- input: InputProps;
78
- };
79
- export declare type ItemReturnProps = {
80
- item: FlexProps;
81
- root: {
82
- isValidSuggestion: boolean;
83
- value: AutoCompleteItemProps["value"];
84
- };
85
- };
86
- export declare type ListReturnProps = {
87
- width: number;
88
- };
89
- export declare type GroupReturnProps = {
90
- divider: {
91
- hasFirstChild: boolean;
92
- hasLastChild: boolean;
93
- };
94
- group: BoxProps;
95
- };
96
- export declare type UseAutoCompleteReturn = {
97
- autoCompleteProps: AutoCompleteProps;
98
- children: React.ReactNode;
99
- filteredList: Item[];
100
- filteredResults: Item[];
101
- focusedValue: Item["value"];
102
- getEmptyStateProps: (component: any) => any;
103
- getGroupProps: (props: AutoCompleteGroupProps) => GroupReturnProps;
104
- getInputProps: (props: AutoCompleteInputProps, themeInput?: any) => InputReturnProps;
105
- getItemProps: (props: AutoCompleteItemProps, creatable?: boolean) => ItemReturnProps;
106
- getListProps: () => ListReturnProps;
107
- inputRef: React.RefObject<HTMLInputElement>;
108
- interactionRef: React.RefObject<"mouse" | "keyboard" | null>;
109
- isOpen: boolean;
110
- itemList: Item[];
111
- listRef: React.RefObject<HTMLDivElement>;
112
- onClose: () => void;
113
- onOpen: () => void;
114
- query: string;
115
- removeItem: (valueToRemove?: Item["value"], focusInput?: boolean) => void;
116
- resetItems: (focusInput?: boolean) => void;
117
- setQuery: Dispatch<SetStateAction<any>>;
118
- tags: ItemTag[];
119
- values: Item["value"][];
120
- };
121
- export declare type AutoCompleteRefMethods = {
122
- removeItem: UseAutoCompleteReturn["removeItem"];
123
- resetItems: UseAutoCompleteReturn["resetItems"];
124
- } | undefined;
1
+ import { BoxProps, FlexProps, InputProps, SystemStyleObject, WrapProps, PlacementWithLogical } from "@chakra-ui/react";
2
+ import { MaybeRenderProp } from "@chakra-ui/react-utils";
3
+ import React, { Dispatch, SetStateAction } from "react";
4
+ import { AutoCompleteGroupProps } from "./autocomplete-group";
5
+ import { AutoCompleteInputProps } from "./autocomplete-input";
6
+ import { AutoCompleteProps } from "./autocomplete";
7
+ import { AutoCompleteItemProps } from "./autocomplete-item";
8
+ export interface Item {
9
+ value: any;
10
+ label?: any;
11
+ fixed?: boolean;
12
+ disabled?: boolean;
13
+ itemVal?: any;
14
+ noFilter?: boolean;
15
+ creatable?: boolean;
16
+ originalValue?: any;
17
+ }
18
+ export declare type UseAutoCompleteProps = Partial<{
19
+ closeOnBlur: boolean;
20
+ closeOnSelect: boolean;
21
+ creatable: boolean;
22
+ defaultIsOpen: boolean;
23
+ defaultValue: Item["value"];
24
+ defaultValues: Item["value"][];
25
+ disableFilter: boolean;
26
+ emphasize: boolean | SystemStyleObject;
27
+ emptyState: boolean | MaybeRenderProp<{
28
+ query: Item["value"];
29
+ }>;
30
+ filter: (query: string, optionValue: Item["value"], optionLabel: Item["label"]) => boolean;
31
+ focusInputOnSelect: boolean;
32
+ freeSolo: boolean;
33
+ isLoading: boolean;
34
+ isReadOnly: boolean;
35
+ listAllValuesOnFocus: boolean;
36
+ maxSelections: number;
37
+ maxSuggestions: number;
38
+ multiple: boolean;
39
+ onChange: (value: Item["value"] | Item["value"][], item: Item | Item[]) => void;
40
+ onCreateOption: (params: {
41
+ item: Item;
42
+ selectMethod: "mouse" | "keyboard" | null;
43
+ }) => boolean | void;
44
+ onSelectOption: (params: {
45
+ item: Item;
46
+ selectMethod: "mouse" | "keyboard" | null;
47
+ isNewInput?: boolean;
48
+ }) => boolean | void;
49
+ onOptionFocus: (params: {
50
+ item: Item;
51
+ focusMethod: "mouse" | "keyboard" | null;
52
+ isNewInput?: boolean;
53
+ }) => boolean | void;
54
+ onTagRemoved: (removedTag: Item["value"], item: Item, tags: ItemTag[]) => void;
55
+ onReady: (params: OnReadyProps) => void;
56
+ openOnFocus: boolean;
57
+ placement: PlacementWithLogical;
58
+ restoreOnBlurIfEmpty: boolean;
59
+ rollNavigation: boolean;
60
+ selectOnFocus: boolean;
61
+ shouldRenderSuggestions: (value: string) => boolean;
62
+ submitKeys: string[];
63
+ suggestWhenEmpty: boolean;
64
+ value: Item["value"];
65
+ values: Item["value"][];
66
+ }>;
67
+ export declare type ItemTag = {
68
+ label: any;
69
+ onRemove: () => void;
70
+ };
71
+ export declare type OnReadyProps = {
72
+ tags: ItemTag[];
73
+ };
74
+ export declare type InputReturnProps = {
75
+ wrapper: {
76
+ onClick: React.MouseEventHandler<HTMLDivElement>;
77
+ ref: React.RefObject<HTMLDivElement>;
78
+ } & WrapProps;
79
+ input: InputProps;
80
+ };
81
+ export declare type ItemReturnProps = {
82
+ item: FlexProps;
83
+ root: {
84
+ isValidSuggestion: boolean;
85
+ value: AutoCompleteItemProps["value"];
86
+ };
87
+ };
88
+ export declare type ListReturnProps = {
89
+ width: number;
90
+ };
91
+ export declare type GroupReturnProps = {
92
+ divider: {
93
+ hasFirstChild: boolean;
94
+ hasLastChild: boolean;
95
+ };
96
+ group: BoxProps;
97
+ };
98
+ export declare type UseAutoCompleteReturn = {
99
+ autoCompleteProps: AutoCompleteProps;
100
+ children: React.ReactNode;
101
+ filteredList: Item[];
102
+ filteredResults: Item[];
103
+ focusedValue: Item["value"];
104
+ getEmptyStateProps: (component: any) => any;
105
+ getGroupProps: (props: AutoCompleteGroupProps) => GroupReturnProps;
106
+ getInputProps: (props: AutoCompleteInputProps, themeInput?: any) => InputReturnProps;
107
+ getItemProps: (props: AutoCompleteItemProps, creatable?: boolean) => ItemReturnProps;
108
+ getListProps: () => ListReturnProps;
109
+ inputRef: React.RefObject<HTMLInputElement>;
110
+ interactionRef: React.RefObject<"mouse" | "keyboard" | null>;
111
+ isOpen: boolean;
112
+ isLoading: boolean;
113
+ itemList: Item[];
114
+ listRef: React.RefObject<HTMLDivElement>;
115
+ onClose: () => void;
116
+ onOpen: () => void;
117
+ placement: PlacementWithLogical;
118
+ query: string;
119
+ removeItem: (valueToRemove?: Item["value"], focusInput?: boolean) => void;
120
+ resetItems: (focusInput?: boolean) => void;
121
+ setQuery: Dispatch<SetStateAction<any>>;
122
+ tags: ItemTag[];
123
+ values: Item["value"][];
124
+ };
125
+ export declare type AutoCompleteRefMethods = {
126
+ removeItem: UseAutoCompleteReturn["removeItem"];
127
+ resetItems: UseAutoCompleteReturn["resetItems"];
128
+ } | undefined;
@@ -1,8 +1,8 @@
1
- import { AutoCompleteProps } from "./autocomplete";
2
- import { UseAutoCompleteReturn } from "./types";
3
- /**
4
- * useAutoComplete that provides all the state and focus management logic
5
- * for the autocomplete component. It is consumed by the `Autocomplete` component
6
- *
7
- */
8
- export declare function useAutoComplete(autoCompleteProps: AutoCompleteProps): UseAutoCompleteReturn;
1
+ import { AutoCompleteProps } from "./autocomplete";
2
+ import { UseAutoCompleteReturn } from "./types";
3
+ /**
4
+ * useAutoComplete that provides all the state and focus management logic
5
+ * for the autocomplete component. It is consumed by the `Autocomplete` component
6
+ *
7
+ */
8
+ export declare function useAutoComplete(autoCompleteProps: AutoCompleteProps): UseAutoCompleteReturn;
package/package.json CHANGED
@@ -1,83 +1,83 @@
1
- {
2
- "version": "5.1.8",
3
- "license": "MIT",
4
- "main": "dist/index.js",
5
- "typings": "dist/index.d.ts",
6
- "module": "dist/index.js",
7
- "files": [
8
- "dist"
9
- ],
10
- "engines": {
11
- "node": ">=10"
12
- },
13
- "scripts": {
14
- "start": "vite watch",
15
- "build": "vite build",
16
- "test": "tsdx test --passWithNoTests",
17
- "lint": "tsdx lint",
18
- "postbuild": "tsc --emitDeclarationOnly",
19
- "size": "size-limit",
20
- "analyze": "size-limit --why"
21
- },
22
- "peerDependencies": {
23
- "@chakra-ui/react": "^2.5.5",
24
- "@emotion/react": "^11.10.0",
25
- "@emotion/styled": "^11.10.0",
26
- "framer-motion": ">7.6.14",
27
- "react": "^18.2.0"
28
- },
29
- "husky": {
30
- "hooks": {
31
- "pre-commit": "tsdx lint"
32
- }
33
- },
34
- "prettier": {
35
- "printWidth": 80,
36
- "semi": true,
37
- "singleQuote": false,
38
- "trailingComma": "es5"
39
- },
40
- "name": "@choc-ui/chakra-autocomplete",
41
- "author": "anubra266",
42
- "repository": {
43
- "type": "git",
44
- "url": "git+https://github.com/anubra266/choc-autocomplete.git"
45
- },
46
- "size-limit": [
47
- {
48
- "path": "dist/chakra-autocomplete.cjs.production.min.js",
49
- "limit": "10 KB"
50
- },
51
- {
52
- "path": "dist/chakra-autocomplete.esm.js",
53
- "limit": "10 KB"
54
- }
55
- ],
56
- "devDependencies": {
57
- "@babel/core": "^7.18.10",
58
- "@chakra-ui/react": "^2.5.5",
59
- "@emotion/react": "^11.10.6",
60
- "@emotion/styled": "^11.10.6",
61
- "@size-limit/preset-small-lib": "^5.0.1",
62
- "@types/react": "^18.0.17",
63
- "@types/react-dom": "^18.0.6",
64
- "@vitejs/plugin-react": "2.0.1",
65
- "babel-loader": "^8.2.5",
66
- "framer-motion": ">7.6.14",
67
- "husky": "^7.0.1",
68
- "react": "^18.2.0",
69
- "react-dom": "^18.2.0",
70
- "size-limit": "^5.0.1",
71
- "tsdx": "^0.14.1",
72
- "tslib": "^2.3.0",
73
- "typescript": "^4.7.4",
74
- "vite": "3.0.8"
75
- },
76
- "dependencies": {
77
- "@chakra-ui/layout": "^2.1.5",
78
- "@chakra-ui/react-utils": "^2.0.5",
79
- "@chakra-ui/tag": "^2.0.8",
80
- "@chakra-ui/utils": "^2.0.8",
81
- "react-nanny": "2.15.0"
82
- }
1
+ {
2
+ "version": "5.2.0",
3
+ "license": "MIT",
4
+ "main": "dist/index.js",
5
+ "typings": "dist/index.d.ts",
6
+ "module": "dist/index.js",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "engines": {
11
+ "node": ">=10"
12
+ },
13
+ "scripts": {
14
+ "start": "vite watch",
15
+ "build": "vite build",
16
+ "test": "tsdx test --passWithNoTests",
17
+ "lint": "tsdx lint",
18
+ "postbuild": "tsc --emitDeclarationOnly",
19
+ "size": "size-limit",
20
+ "analyze": "size-limit --why"
21
+ },
22
+ "peerDependencies": {
23
+ "@chakra-ui/react": "^2.5.5",
24
+ "@emotion/react": "^11.10.0",
25
+ "@emotion/styled": "^11.10.0",
26
+ "framer-motion": ">7.6.14",
27
+ "react": "^18.2.0"
28
+ },
29
+ "husky": {
30
+ "hooks": {
31
+ "pre-commit": "tsdx lint"
32
+ }
33
+ },
34
+ "prettier": {
35
+ "printWidth": 80,
36
+ "semi": true,
37
+ "singleQuote": false,
38
+ "trailingComma": "es5"
39
+ },
40
+ "name": "@choc-ui/chakra-autocomplete",
41
+ "author": "anubra266",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/anubra266/choc-autocomplete.git"
45
+ },
46
+ "size-limit": [
47
+ {
48
+ "path": "dist/chakra-autocomplete.cjs.production.min.js",
49
+ "limit": "10 KB"
50
+ },
51
+ {
52
+ "path": "dist/chakra-autocomplete.esm.js",
53
+ "limit": "10 KB"
54
+ }
55
+ ],
56
+ "devDependencies": {
57
+ "@babel/core": "^7.18.10",
58
+ "@chakra-ui/react": "^2.5.5",
59
+ "@emotion/react": "^11.10.6",
60
+ "@emotion/styled": "^11.10.6",
61
+ "@size-limit/preset-small-lib": "^5.0.1",
62
+ "@types/react": "^18.0.17",
63
+ "@types/react-dom": "^18.0.6",
64
+ "@vitejs/plugin-react": "2.0.1",
65
+ "babel-loader": "^8.2.5",
66
+ "framer-motion": ">7.6.14",
67
+ "husky": "^7.0.1",
68
+ "react": "^18.2.0",
69
+ "react-dom": "^18.2.0",
70
+ "size-limit": "^5.0.1",
71
+ "tsdx": "^0.14.1",
72
+ "tslib": "^2.3.0",
73
+ "typescript": "^4.7.4",
74
+ "vite": "3.0.8"
75
+ },
76
+ "dependencies": {
77
+ "@chakra-ui/layout": "^2.1.5",
78
+ "@chakra-ui/react-utils": "^2.0.5",
79
+ "@chakra-ui/tag": "^2.0.8",
80
+ "@chakra-ui/utils": "^2.0.8",
81
+ "react-nanny": "2.15.0"
82
+ }
83
83
  }