@australiangreens/ag-internal-components 0.0.73 → 0.0.74

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.
@@ -1,7 +1,14 @@
1
1
  import { SxProps, Theme } from '@mui/material';
2
2
  import { ReactNode, SyntheticEvent } from 'react';
3
3
  import { AutocompleteGenericEntity, FetchAutocompleteChangeReason } from '../types';
4
- export interface FetchAutocompleteProps<EntityType extends AutocompleteGenericEntity> {
4
+ export declare const useAutocompleteOptions: <EntityType extends AutocompleteGenericEntity>({ minLength, preLoadedOptions, lookup, label, inputValue, }: {
5
+ minLength: number;
6
+ preLoadedOptions: EntityType[] | undefined;
7
+ lookup: (lookupValue: string) => Promise<void | EntityType[] | null | undefined>;
8
+ label: string;
9
+ inputValue: string;
10
+ }) => import("@tanstack/react-query").UseQueryResult<void | EntityType[] | null | undefined, unknown>;
11
+ export type FetchAutocompleteProps<EntityType extends AutocompleteGenericEntity> = {
5
12
  /**
6
13
  * Callback fired when the value changes. This is passed directly to the
7
14
  * underlying Autocomplete, but it is triggered by the Autocomplete's own
@@ -46,7 +53,7 @@ export interface FetchAutocompleteProps<EntityType extends AutocompleteGenericEn
46
53
  sx?: SxProps<Theme>;
47
54
  textFieldColor?: 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
48
55
  textFieldVariant?: 'filled' | 'outlined' | 'standard';
49
- }
56
+ };
50
57
  /**
51
58
  * A wrapper around MUI's Autocomplete component, specifically for use with live
52
59
  * as-you-type fetching from an api and styled the way we want it across the app
@@ -1 +1 @@
1
- {"version":3,"file":"FetchAutocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/FetchAutocomplete/FetchAutocomplete.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,OAAO,EAEP,KAAK,EAGN,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAY,MAAM,OAAO,CAAC;AAG5D,OAAO,EACL,yBAAyB,EAEzB,6BAA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S,yBAAyB,EAAE,EACtF,MAAuB,EACvB,kBAAyB,EACzB,QAAQ,EACR,SAAS,EACT,KAAK,EACL,KAAK,EACL,aAAa,EAAE,UAAU,EACzB,EAAE,EACF,cAAc,EACd,gBAA2B,EAC3B,WAA0B,EAC1B,aAA4B,EAC5B,SAAgC,EAChC,KAAa,EACb,UAAe,EACf,gBAA4B,EAC5B,aAAqB,GACtB,EAAE,sBAAsB,CAAC,UAAU,CAAC,eA2KpC"}
1
+ {"version":3,"file":"FetchAutocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/FetchAutocomplete/FetchAutocomplete.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,OAAO,EAEP,KAAK,EAGN,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAY,MAAM,OAAO,CAAC;AAG5D,OAAO,EACL,yBAAyB,EAEzB,6BAA6B,EAC9B,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,sBAAsB;eAOtB,MAAM;;0BAEK,MAAM;WACrB,MAAM;gBACD,MAAM;qGAanB,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,UAAU,SAAS,yBAAyB,IAAI;IACjF;;;;OAIG;IACH,QAAQ,EAAE,CACR,QAAQ,EAAE,UAAU,EAAE,EACtB,MAAM,EAAE,6BAA6B,EACrC,KAAK,EAAE,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,KAClC,OAAO,CAAC;IAEb,6CAA6C;IAC7C,KAAK,EAAE,UAAU,EAAE,CAAC;IAEpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IAEd,qFAAqF;IACrF,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,EAAE,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IAElF;;;OAGG;IACH,gBAAgB,CAAC,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;IAE5C,qBAAqB;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;6EACyE;IACzE,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,cAAc,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IACpF,gBAAgB,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;CACvD,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,UAAU,SAAS,yBAAyB,EAAE,EACtF,MAAuB,EACvB,kBAAyB,EACzB,QAAQ,EACR,SAAa,EACb,KAAK,EACL,KAAK,EACL,aAAa,EAAE,UAAU,EACzB,EAAE,EACF,cAAc,EACd,gBAA2B,EAC3B,WAA0B,EAC1B,aAA4B,EAC5B,SAAgC,EAChC,KAAa,EACb,UAAe,EACf,gBAA4B,EAC5B,aAAqB,GACtB,EAAE,sBAAsB,CAAC,UAAU,CAAC,eAyKpC"}
@@ -10,10 +10,19 @@ type Props<EntityType extends AutocompleteGenericEntity> = {
10
10
  */
11
11
  onChange: (event: SyntheticEvent<Element, Event>, newValue: EntityType | null) => unknown;
12
12
  value: EntityType | null;
13
+ /**
14
+ * A minimum length of characters in the Autocomplete before the lookup is called. If not set,
15
+ * then the lookup is called every time.
16
+ */
17
+ minLength?: number;
13
18
  /** A nice label for the autocomplete. */
14
19
  label: string;
15
20
  /** The lookup function, for looking up EntityType options from a remote resource. */
16
- lookup: (lookupValue: string, abortSignal: AbortSignal) => Promise<EntityType[] | undefined | null | void>;
21
+ lookup: (lookupValue: string) => Promise<EntityType[] | undefined | null | void>;
22
+ preLoadedOptions?: EntityType[] | undefined;
23
+ /**If true, the Popper content will be under the DOM hierarchy of the parent
24
+ * component. Passed directly to underlying MUI Autocomplete component.*/
25
+ disablePortal?: boolean;
17
26
  /**
18
27
  * Used for the data-testid value of the outer most component. The underlying
19
28
  * AutoComplete component has the id of this, followed by a colon then
@@ -23,16 +32,12 @@ type Props<EntityType extends AutocompleteGenericEntity> = {
23
32
  * simply be 'FetchAutocomplete' if that is not an issue.
24
33
  */
25
34
  'data-testid'?: string;
26
- /**If true, the Popper content will be under the DOM hierarchy of the parent
27
- * component. Passed directly to underlying MUI Autocomplete component.*/
28
- disablePortal?: boolean;
29
- noOptionsText?: string;
30
- minLength?: number;
31
35
  hideButton?: boolean;
36
+ noOptionsText?: string;
32
37
  sx?: SxProps<Theme>;
33
38
  textFieldColor?: 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
34
39
  textFieldVariant?: 'filled' | 'outlined' | 'standard';
35
40
  };
36
- declare const SingleAutocomplete: <EntityType extends AutocompleteGenericEntity>({ lookup, onChange, label, value, sx, textFieldColor, textFieldVariant, "data-testid": dataTestId, noOptionsText, minLength, disablePortal, }: Props<EntityType>) => JSX.Element;
41
+ declare const SingleAutocomplete: <EntityType extends AutocompleteGenericEntity>({ lookup, onChange, label, value, sx, textFieldColor, textFieldVariant, "data-testid": dataTestId, noOptionsText, minLength, disablePortal, preLoadedOptions, }: Props<EntityType>) => JSX.Element;
37
42
  export default SingleAutocomplete;
38
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SingleAutocomplete/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,OAAO,EAAa,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/E,O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