@choc-ui/chakra-autocomplete 5.2.0 → 5.2.1

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 (38) hide show
  1. package/README.md +12 -0
  2. package/dist/autocomplete-context.d.ts +1 -0
  3. package/dist/autocomplete-context.d.ts.map +1 -0
  4. package/dist/autocomplete-creatable.d.ts +2 -2
  5. package/dist/autocomplete-creatable.d.ts.map +1 -0
  6. package/dist/autocomplete-group.d.ts +1 -0
  7. package/dist/autocomplete-group.d.ts.map +1 -0
  8. package/dist/autocomplete-input.d.ts +1 -0
  9. package/dist/autocomplete-input.d.ts.map +1 -0
  10. package/dist/autocomplete-item.d.ts +1 -0
  11. package/dist/autocomplete-item.d.ts.map +1 -0
  12. package/dist/autocomplete-list.d.ts +1 -0
  13. package/dist/autocomplete-list.d.ts.map +1 -0
  14. package/dist/autocomplete-tag.d.ts +3 -2
  15. package/dist/autocomplete-tag.d.ts.map +1 -0
  16. package/dist/autocomplete.d.ts +2 -1
  17. package/dist/autocomplete.d.ts.map +1 -0
  18. package/dist/components/empty-state.d.ts +2 -2
  19. package/dist/components/empty-state.d.ts.map +1 -0
  20. package/dist/helpers/fuzzySearch.d.ts +1 -0
  21. package/dist/helpers/fuzzySearch.d.ts.map +1 -0
  22. package/dist/helpers/group.d.ts +1 -0
  23. package/dist/helpers/group.d.ts.map +1 -0
  24. package/dist/helpers/input.d.ts +1 -0
  25. package/dist/helpers/input.d.ts.map +1 -0
  26. package/dist/helpers/items.d.ts +1 -0
  27. package/dist/helpers/items.d.ts.map +1 -0
  28. package/dist/helpers/list.d.ts +2 -1
  29. package/dist/helpers/list.d.ts.map +1 -0
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.es.js +2401 -2642
  33. package/dist/index.js +9 -9
  34. package/dist/types.d.ts +10 -9
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/use-autocomplete.d.ts +1 -0
  37. package/dist/use-autocomplete.d.ts.map +1 -0
  38. package/package.json +20 -16
package/README.md CHANGED
@@ -385,6 +385,18 @@ Then add the `AutoCompleteCreatable` component to the bottom of the list. Refer
385
385
 
386
386
  <img width="517" alt="CleanShot 2021-07-29 at 02 29 20@2x" src="https://user-images.githubusercontent.com/30869823/127417453-e78b9b48-26e8-4ff0-a264-1d6bb4717ab0.png">
387
387
 
388
+ ### Loading State
389
+
390
+ Need to pull data from API, but don't want your users to see a blank screen? You can enable the loading state by passing the `isLoading` prop to `AutoComplete`. By doing this, 2 other props will be enabled
391
+
392
+ 1. `loadingIcon` on `AutoCompleteInput` will display some sort of loading icon on the right side of the input. By default, a `Spinner` will be displayed, but you can pass in any custom element to be rendered
393
+
394
+ 2. `loadingState` on `AutoCompleteList` can display custom loading content when `isLoading` is `true`. All content will be rendered in the center of the list. By default, a `Spinner` will be displayed, but you can pass in any custom element to be rendered.
395
+
396
+ Best practice is to combine `setTimeout` and `useEffect` to create a debounce effect. This will prevent un-necessary API calls if your user types relatively quickly.
397
+
398
+ A working code demo can be found [here](https://codesandbox.io/s/choc-ui-chakra-autocomplete-loading-tfc8jz)
399
+
388
400
  ### Autocomplete methods
389
401
 
390
402
  Assign a ref to the `AutoComplete` component and call the available methods with:
@@ -1,3 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { UseAutoCompleteReturn } from "./types";
3
3
  export declare const AutoCompleteProvider: import("react").Provider<UseAutoCompleteReturn>, useAutoCompleteContext: () => UseAutoCompleteReturn;
4
+ //# sourceMappingURL=autocomplete-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-context.d.ts","sourceRoot":"","sources":["../src/autocomplete-context.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAO,oBAAoB,mDAAE,sBAAsB,6BAMxD,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { FlexProps } from "@chakra-ui/react";
3
2
  import { MaybeRenderProp } from "@chakra-ui/react-utils";
4
3
  interface AutoCompleteCreatableProps extends Omit<FlexProps, "children"> {
@@ -7,8 +6,9 @@ interface AutoCompleteCreatableProps extends Omit<FlexProps, "children"> {
7
6
  }>;
8
7
  alwaysDisplay?: boolean;
9
8
  }
10
- export declare function AutoCompleteCreatable(props: AutoCompleteCreatableProps): JSX.Element | null;
9
+ export declare function AutoCompleteCreatable(props: AutoCompleteCreatableProps): import("react/jsx-runtime").JSX.Element | null;
11
10
  export declare namespace AutoCompleteCreatable {
12
11
  var displayName: string;
13
12
  }
14
13
  export {};
14
+ //# sourceMappingURL=autocomplete-creatable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-creatable.d.ts","sourceRoot":"","sources":["../src/autocomplete-creatable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAQzD,UAAU,0BAA2B,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IACtE,QAAQ,CAAC,EAAE,eAAe,CAAC;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,kDA8BtE;yBA9Be,qBAAqB"}
@@ -7,3 +7,4 @@ export interface AutoCompleteGroupProps extends BoxProps {
7
7
  }
8
8
  export declare const AutoCompleteGroup: import("@chakra-ui/system/dist/system.types").ComponentWithAs<"div", AutoCompleteGroupProps>;
9
9
  export declare const AutoCompleteGroupTitle: import("@chakra-ui/system/dist/system.types").ComponentWithAs<"div", FlexProps>;
10
+ //# sourceMappingURL=autocomplete-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-group.d.ts","sourceRoot":"","sources":["../src/autocomplete-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIR,SAAS,EAEV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,sBAAuB,SAAQ,QAAQ;IACtD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,iBAAiB,8FAmB7B,CAAC;AAEF,eAAO,MAAM,sBAAsB,iFAIlC,CAAC"}
@@ -11,3 +11,4 @@ export interface AutoCompleteInputProps extends Omit<InputProps, "children"> {
11
11
  loadingIcon?: React.ReactNode;
12
12
  }
13
13
  export declare const AutoCompleteInput: import("@chakra-ui/system/dist/system.types").ComponentWithAs<"input", AutoCompleteInputProps>;
14
+ //# sourceMappingURL=autocomplete-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-input.d.ts","sourceRoot":"","sources":["../src/autocomplete-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAIV,iBAAiB,EAMlB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;IAC1E,QAAQ,CAAC,EAAE,eAAe,CAAC;QAAE,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IACpE,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC9B;AAgBD,eAAO,MAAM,iBAAiB,gGAgD7B,CAAC"}
@@ -10,3 +10,4 @@ export interface AutoCompleteItemProps extends FlexProps {
10
10
  }
11
11
  export declare const AutoCompleteItem: import("@chakra-ui/system/dist/system.types").ComponentWithAs<"div", AutoCompleteItemProps>;
12
12
  export declare const baseItemStyles: FlexProps;
13
+ //# sourceMappingURL=autocomplete-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-item.d.ts","sourceRoot":"","sources":["../src/autocomplete-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAET,SAAS,EAGV,MAAM,kBAAkB,CAAC;AAM1B,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACtD,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC;CAC1D;AAED,eAAO,MAAM,gBAAgB,6FA6C5B,CAAC;AAIF,eAAO,MAAM,cAAc,EAAE,SAM5B,CAAC"}
@@ -4,3 +4,4 @@ export interface AutoCompleteListProps extends PopoverContentProps {
4
4
  loadingState?: React.ReactNode;
5
5
  }
6
6
  export declare const AutoCompleteList: import("@chakra-ui/system/dist/system.types").ComponentWithAs<"div", AutoCompleteListProps>;
7
+ //# sourceMappingURL=autocomplete-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-list.d.ts","sourceRoot":"","sources":["../src/autocomplete-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,mBAAmB,EAGpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC/B;AAED,eAAO,MAAM,gBAAgB,6FAyB5B,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import { TagProps } from "@chakra-ui/tag";
2
2
  import React from "react";
3
- declare type AutoCompleteTagProps = {
3
+ type AutoCompleteTagProps = {
4
4
  disabled?: boolean;
5
5
  label: string;
6
6
  onRemove?: () => void;
7
7
  } & TagProps;
8
- export declare const AutoCompleteTag: React.MemoExoticComponent<(props: AutoCompleteTagProps) => JSX.Element>;
8
+ export declare const AutoCompleteTag: React.MemoExoticComponent<(props: AutoCompleteTagProps) => import("react/jsx-runtime").JSX.Element>;
9
9
  export {};
10
+ //# sourceMappingURL=autocomplete-tag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-tag.d.ts","sourceRoot":"","sources":["../src/autocomplete-tag.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiC,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAe,MAAM,OAAO,CAAC;AAEpC,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,GAAG,QAAQ,CAAC;AAEb,eAAO,MAAM,eAAe,oCAAgB,oBAAoB,6CAoB9D,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { MaybeRenderProp } from "@chakra-ui/react-utils";
3
3
  import { AutoCompleteRefMethods, UseAutoCompleteProps } from "./types";
4
- export declare type AutoCompleteChildProps = {
4
+ export type AutoCompleteChildProps = {
5
5
  isOpen: boolean;
6
6
  onClose: () => void;
7
7
  onOpen: () => void;
@@ -11,3 +11,4 @@ export interface AutoCompleteProps extends UseAutoCompleteProps {
11
11
  ref?: React.RefObject<AutoCompleteRefMethods>;
12
12
  }
13
13
  export declare const AutoComplete: import("@chakra-ui/system/dist/system.types").ComponentWithAs<"div", AutoCompleteProps>;
14
+ //# sourceMappingURL=autocomplete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../src/autocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAKzD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEvE,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AACF,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D,QAAQ,EAAE,eAAe,CAAC,sBAAsB,CAAC,CAAC;IAClD,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC;CAC/C;AAED,eAAO,MAAM,YAAY,yFAuCxB,CAAC"}
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BoxProps } from "@chakra-ui/layout";
3
- export declare const EmptyState: (props: BoxProps) => JSX.Element;
2
+ export declare const EmptyState: (props: BoxProps) => import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=empty-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-state.d.ts","sourceRoot":"","sources":["../../src/components/empty-state.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAmB,MAAM,mBAAmB,CAAC;AAInE,eAAO,MAAM,UAAU,UAAW,QAAQ,4CAQzC,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare function fuzzyScore(str1: string, str2: string, gramSize?: number): number;
2
+ //# sourceMappingURL=fuzzySearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fuzzySearch.d.ts","sourceRoot":"","sources":["../../src/helpers/fuzzySearch.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,UA+B1E"}
@@ -2,3 +2,4 @@ import { ReactNode } from "react";
2
2
  export declare const hasFirstItem: (children: ReactNode, firstItem: any) => any;
3
3
  export declare const hasLastItem: (children: ReactNode, lastItem: any) => any;
4
4
  export declare const hasChildren: (children: any, filteredList: any[]) => boolean;
5
+ //# sourceMappingURL=group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/helpers/group.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,eAAO,MAAM,YAAY,aAAc,SAAS,aAAa,GAAG,QAS/D,CAAC;AACF,eAAO,MAAM,WAAW,aAAc,SAAS,YAAY,GAAG,QAQ7D,CAAC;AAEF,eAAO,MAAM,WAAW,aAAc,GAAG,gBAAgB,GAAG,EAAE,YAU7D,CAAC"}
@@ -1 +1,2 @@
1
1
  export declare const getMultipleWrapStyles: (themeInput: any, multiple?: boolean) => any;
2
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/helpers/input.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,eAAgB,GAAG,aAAa,OAAO,QAyCxE,CAAC"}
@@ -7,3 +7,4 @@ export declare const setEmphasis: (children: any, query: string) => any;
7
7
  export declare const getItemList: (children: ReactNode) => Item[];
8
8
  export declare const getFocusedStyles: () => FlexProps;
9
9
  export declare const defaultFilterMethod: (query: string, itemValue: Item["value"], itemLabel: Item["label"]) => boolean;
10
+ //# sourceMappingURL=items.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../src/helpers/items.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,eAAO,MAAM,eAAe,SAAU,qBAAqB,CAAC,OAAO,CAAC,QACoC,CAAC;AAEzG,eAAO,MAAM,WAAW,aAAc,GAAG,SAAS,MAAM,QAWvD,CAAC;AAEF,eAAO,MAAM,WAAW,aAAc,SAAS,KAAG,IAAI,EAerD,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAO,SAOnC,CAAC;AAEF,eAAO,MAAM,mBAAmB,UACvB,MAAM,aACF,IAAI,CAAC,OAAO,CAAC,aACb,IAAI,CAAC,OAAO,CAAC,YAQzB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  import React from "react";
2
- export declare const siblingInfo: (children: React.ReactNode) => readonly [(string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | React.ReactPortal)[], (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | React.ReactPortal)[]];
2
+ export declare const siblingInfo: (children: React.ReactNode) => readonly [(string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[], (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal)[]];
3
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/helpers/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,eAAO,MAAM,WAAW,aAAc,MAAM,SAAS,kSA8BpD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from "./autocomplete-list";
8
8
  export * from "./autocomplete-tag";
9
9
  export * from "./use-autocomplete";
10
10
  export * from "./types";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}