@carto/meridian-ds 1.5.0-alpha-virtual-autocomplete.1 → 1.5.0-alpha-virtual-autocomplete.3
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/CHANGELOG.md +1 -0
- package/dist/{MenuItem-D6wJym7Z.js → MenuItem-C1DvWMry.js} +1 -1
- package/dist/{MenuItem-lAxlHrDp.cjs → MenuItem-C4bG5WHw.cjs} +1 -1
- package/dist/components/index.cjs +235 -56
- package/dist/components/index.js +237 -58
- package/dist/theme/index.cjs +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/types/components/atoms/SplitButton.d.ts +9 -5
- package/dist/types/components/atoms/SplitButton.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/types/components/molecules/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts +13 -0
- package/dist/types/components/molecules/Autocomplete/AutocompleteList.d.ts.map +1 -0
- package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts +1 -1
- package/dist/types/components/molecules/Autocomplete/CreatableAutocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts +1 -1
- package/dist/types/components/molecules/Autocomplete/MultipleAutocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/index.d.ts +3 -0
- package/dist/types/components/molecules/Autocomplete/index.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/types.d.ts +73 -40
- package/dist/types/components/molecules/Autocomplete/types.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts +11 -0
- package/dist/types/components/molecules/Autocomplete/useAutocomplete.d.ts.map +1 -0
- package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts +6 -1
- package/dist/types/components/molecules/Autocomplete/useAutocompleteRenderOption.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts +24 -1
- package/dist/types/components/molecules/Autocomplete/useMultipleAutocomplete.d.ts.map +1 -1
- package/dist/types/components/molecules/Autocomplete/utils.d.ts +58 -3
- package/dist/types/components/molecules/Autocomplete/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts +0 -35
- package/dist/types/components/molecules/Autocomplete/ListBoxWithFilter.d.ts.map +0 -1
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
import { ChipTypeMap, AutocompleteProps as MUIAutocompleteProps } from '@mui/material';
|
|
2
2
|
import { MenuItemProps } from '../Menu/MenuItem';
|
|
3
|
+
import { HTMLAttributes } from 'react';
|
|
3
4
|
type BaseAutocompleteProps<Value, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<MUIAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'ref'> & {
|
|
4
5
|
loading?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export type AutocompleteProps<Value, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<BaseAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'multiple'>;
|
|
7
|
-
export type MultipleAutocompleteProps<Value, Multiple extends boolean | undefined = true, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = BaseAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent> & {
|
|
8
|
-
/**
|
|
9
|
-
* If true, the popup will display a filter option for multiple selection.
|
|
10
|
-
* @default false
|
|
11
|
-
*/
|
|
12
|
-
showFilters?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* If true, the menu will not close when an option is selected.
|
|
15
|
-
* @default true
|
|
16
|
-
*/
|
|
17
|
-
disableCloseOnSelect?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* If true, displays a counter (e.g., "3 items selected") instead of individual tags.
|
|
20
|
-
* @default false
|
|
21
|
-
*/
|
|
22
|
-
showCounter?: boolean;
|
|
23
6
|
/**
|
|
24
7
|
* Height of each item in pixels when virtualized.
|
|
25
8
|
* @default 32
|
|
@@ -35,16 +18,30 @@ export type MultipleAutocompleteProps<Value, Multiple extends boolean | undefine
|
|
|
35
18
|
* @default false
|
|
36
19
|
*/
|
|
37
20
|
extended?: boolean;
|
|
38
|
-
};
|
|
39
|
-
export type CreatableAutocompleteProps<Value, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = BaseAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent> & {
|
|
40
|
-
/**
|
|
41
|
-
* Text for "create new item" option. String (used directly), function (for custom formatting), or undefined (uses translated "Add" text).
|
|
42
|
-
*/
|
|
43
|
-
newItemLabel?: string | ((value: string) => React.ReactNode);
|
|
44
21
|
/**
|
|
45
|
-
*
|
|
22
|
+
* @deprecated since v1.6.0 - This prop breaks virtualization.
|
|
23
|
+
* Use createAutocompleteGroupByList instead to create a flat list with group headers:
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* import { createAutocompleteGroupByList } from "@carto/meridian-ds"
|
|
28
|
+
*
|
|
29
|
+
* const groupedOptions = createAutocompleteGroupByList(
|
|
30
|
+
* rawOptions,
|
|
31
|
+
* (option) => option.category
|
|
32
|
+
* )
|
|
33
|
+
*
|
|
34
|
+
* <MultipleAutocomplete
|
|
35
|
+
* options={groupedOptions}
|
|
36
|
+
* // ... other props
|
|
37
|
+
* />
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* This approach maintains virtualization performance while providing proper grouping.
|
|
46
41
|
*/
|
|
47
|
-
|
|
42
|
+
groupBy?: (option: Value) => string;
|
|
43
|
+
};
|
|
44
|
+
type BaseMultipleAutocompleteProps<Value, Multiple extends boolean | undefined = true, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = BaseAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent> & {
|
|
48
45
|
/**
|
|
49
46
|
* If true, the popup will display a filter option for multiple selection.
|
|
50
47
|
* @default false
|
|
@@ -55,32 +52,52 @@ export type CreatableAutocompleteProps<Value, Multiple extends boolean | undefin
|
|
|
55
52
|
* @default true
|
|
56
53
|
*/
|
|
57
54
|
disableCloseOnSelect?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* If true, the input accepts multiple values. The default is `false`.
|
|
60
|
-
* @default false
|
|
61
|
-
*/
|
|
62
|
-
multiple?: Multiple;
|
|
63
55
|
/**
|
|
64
56
|
* If true, displays a counter (e.g., "3 items selected") instead of individual tags.
|
|
65
|
-
* Only applies when multiple is true.
|
|
66
57
|
* @default false
|
|
67
58
|
*/
|
|
68
59
|
showCounter?: boolean;
|
|
69
60
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
61
|
+
* Custom formatter function for counter tags. Takes precedence over counterText/allSelectedText.
|
|
62
|
+
* If not provided, will use counterText and allSelectedText to create a simple formatter.
|
|
63
|
+
* Only applies when showCounter is true.
|
|
72
64
|
*/
|
|
73
|
-
|
|
65
|
+
counterFormatter?: (params: {
|
|
66
|
+
selectedCount: number;
|
|
67
|
+
totalCount: number;
|
|
68
|
+
selectedItems: readonly unknown[];
|
|
69
|
+
allItems: readonly unknown[];
|
|
70
|
+
getOptionLabel: (option: unknown) => string;
|
|
71
|
+
}) => string;
|
|
74
72
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
73
|
+
* Text to display with the counter (e.g., "selected", "chosen").
|
|
74
|
+
* Only used if counterFormatter is not provided and showCounter is true.
|
|
75
|
+
* @default "selected"
|
|
77
76
|
*/
|
|
78
|
-
|
|
77
|
+
counterText?: string;
|
|
79
78
|
/**
|
|
80
|
-
*
|
|
79
|
+
* Text to display when all items are selected (e.g., "All selected", "All chosen").
|
|
80
|
+
* Only used if counterFormatter is not provided and showCounter is true.
|
|
81
|
+
* @default "All selected"
|
|
82
|
+
*/
|
|
83
|
+
allSelectedText?: string;
|
|
84
|
+
};
|
|
85
|
+
export type AutocompleteProps<Value, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<BaseAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'multiple'>;
|
|
86
|
+
export type MultipleAutocompleteProps<Value, Multiple extends boolean | undefined = true, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = BaseAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent> & BaseMultipleAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent>;
|
|
87
|
+
export type CreatableAutocompleteProps<Value, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = BaseMultipleAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo, ChipComponent> & {
|
|
88
|
+
/**
|
|
89
|
+
* Text for "create new item" option. String (used directly), function (for custom formatting), or undefined (uses translated "Add" text).
|
|
90
|
+
*/
|
|
91
|
+
newItemLabel?: string | ((value: string) => React.ReactNode);
|
|
92
|
+
/**
|
|
93
|
+
* Icon to display next to the "Create new item" option.
|
|
94
|
+
*/
|
|
95
|
+
newItemIcon?: React.ReactNode;
|
|
96
|
+
/**
|
|
97
|
+
* If true, the input accepts multiple values. The default is `false`.
|
|
81
98
|
* @default false
|
|
82
99
|
*/
|
|
83
|
-
|
|
100
|
+
multiple?: Multiple;
|
|
84
101
|
};
|
|
85
102
|
export type CreatableValueProps = {
|
|
86
103
|
inputValue: string;
|
|
@@ -96,5 +113,21 @@ export type AutocompleteRenderOptionProps = Pick<MenuItemProps, 'dense' | 'disab
|
|
|
96
113
|
secondaryText?: string;
|
|
97
114
|
multiple?: boolean;
|
|
98
115
|
};
|
|
116
|
+
export type AutocompleteListProps = HTMLAttributes<HTMLElement> & {
|
|
117
|
+
showFilters?: boolean;
|
|
118
|
+
allSelected?: boolean;
|
|
119
|
+
someSelected?: boolean;
|
|
120
|
+
handleSelectAll?: () => void;
|
|
121
|
+
multiple?: boolean;
|
|
122
|
+
extended?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Height of each item in pixels
|
|
125
|
+
*/
|
|
126
|
+
itemHeight?: number;
|
|
127
|
+
/**
|
|
128
|
+
* Maximum height of the listbox in pixels
|
|
129
|
+
*/
|
|
130
|
+
maxListHeight?: number;
|
|
131
|
+
};
|
|
99
132
|
export {};
|
|
100
133
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,IAAI,oBAAoB,EAC1C,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,IAAI,oBAAoB,EAC1C,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AA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tB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAA;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type UseAutocompleteProps<Value> = {
|
|
2
|
+
getOptionLabel?: (option: Value) => string;
|
|
3
|
+
};
|
|
4
|
+
export default function useAutocomplete<Value>({ getOptionLabel, }: UseAutocompleteProps<Value>): {
|
|
5
|
+
singleRenderOption: (props: React.HTMLAttributes<HTMLLIElement>, option: Value, state: {
|
|
6
|
+
selected: boolean;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
getOptionLabel: (option: Value) => string;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=useAutocomplete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutocomplete.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/useAutocomplete.tsx"],"names":[],"mappings":"AAGA,KAAK,oBAAoB,CAAC,KAAK,IAAI;IACjC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,KAAK,MAAM,CAAA;CAC3C,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,EAC7C,cAAsC,GACvC,EAAE,oBAAoB,CAAC,KAAK,CAAC;gCAmBnB,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,UAClC,KAAK,SACN;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE;6BAhBU,KAAK;EAgC9C"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { HTMLAttributes, Key, ReactNode } from 'react';
|
|
2
|
+
type GroupHeaderOption = {
|
|
3
|
+
__isGroupHeader: true;
|
|
4
|
+
title: string;
|
|
5
|
+
};
|
|
2
6
|
export default function useAutocompleteRenderOption<Value>(): {
|
|
3
7
|
renderOption: (props: HTMLAttributes<HTMLLIElement> & {
|
|
4
8
|
key?: Key;
|
|
5
|
-
}, option: Value, state: {
|
|
9
|
+
}, option: Value | GroupHeaderOption, state: {
|
|
6
10
|
selected: boolean;
|
|
7
11
|
}, getOptionLabel?: (option: Value) => string, customIcon?: ReactNode) => import("react/jsx-runtime").JSX.Element;
|
|
8
12
|
};
|
|
13
|
+
export {};
|
|
9
14
|
//# sourceMappingURL=useAutocompleteRenderOption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutocompleteRenderOption.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/useAutocompleteRenderOption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQhE,MAAM,CAAC,OAAO,UAAU,2BAA2B,CAAC,KAAK;0BAE9C,cAAc,CAAC,aAAa,CAAC,GAAG;QAAE,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,UAC5C,KAAK,
|
|
1
|
+
{"version":3,"file":"useAutocompleteRenderOption.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/useAutocompleteRenderOption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQhE,KAAK,iBAAiB,GAAG;IAAE,eAAe,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjE,MAAM,CAAC,OAAO,UAAU,2BAA2B,CAAC,KAAK;0BAE9C,cAAc,CAAC,aAAa,CAAC,GAAG;QAAE,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,UAC5C,KAAK,GAAG,iBAAiB,SAC1B;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,mBACX,CAAC,MAAM,EAAE,KAAK,KAAK,MAAM,eAC7B,SAAS;EAyHzB"}
|
|
@@ -6,8 +6,31 @@ type UseMultipleAutocompleteProps<Value, Multiple extends boolean | undefined =
|
|
|
6
6
|
onChange?: (event: SyntheticEvent, value: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<Value>) => void;
|
|
7
7
|
getOptionLabel?: (option: Value) => string;
|
|
8
8
|
size?: 'small' | 'medium';
|
|
9
|
+
/**
|
|
10
|
+
* Custom formatter function for counter tags. Takes precedence over counterText/allSelectedText.
|
|
11
|
+
* If not provided, will use counterText and allSelectedText to create a simple formatter.
|
|
12
|
+
*/
|
|
13
|
+
counterFormatter?: (params: {
|
|
14
|
+
selectedCount: number;
|
|
15
|
+
totalCount: number;
|
|
16
|
+
selectedItems: readonly unknown[];
|
|
17
|
+
allItems: readonly unknown[];
|
|
18
|
+
getOptionLabel: (option: unknown) => string;
|
|
19
|
+
}) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Text to display with the counter (e.g., "selected", "chosen").
|
|
22
|
+
* Only used if counterFormatter is not provided.
|
|
23
|
+
* @default Localized string from 'c4r.form.selected'
|
|
24
|
+
*/
|
|
25
|
+
counterText?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Text to display when all items are selected (e.g., "All selected", "All chosen").
|
|
28
|
+
* Only used if counterFormatter is not provided.
|
|
29
|
+
* @default Localized string from 'c4r.form.allSelected'
|
|
30
|
+
*/
|
|
31
|
+
allSelectedText?: string;
|
|
9
32
|
};
|
|
10
|
-
export default function useMultipleAutocomplete<Value, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>({ options, value, onChange, getOptionLabel, size, }: UseMultipleAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo>): {
|
|
33
|
+
export default function useMultipleAutocomplete<Value, Multiple extends boolean | undefined = undefined, DisableClearable extends boolean | undefined = undefined, FreeSolo extends boolean | undefined = undefined>({ options, value, onChange, getOptionLabel, size, counterFormatter, counterText, allSelectedText, }: UseMultipleAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo>): {
|
|
11
34
|
multipleValue: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>;
|
|
12
35
|
allSelected: boolean;
|
|
13
36
|
someSelected: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMultipleAutocomplete.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/useMultipleAutocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,OAAO,CAAA;AAC3D,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"useMultipleAutocomplete.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/useMultipleAutocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,OAAO,CAAA;AAC3D,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,eAAe,CAAA;AAWtB,KAAK,4BAA4B,CAC/B,KAAK,EACL,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAChD,gBAAgB,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EACxD,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,IAC9C;IACF,OAAO,EAAE,SAAS,KAAK,EAAE,CAAA;IACzB,KAAK,CAAC,EAAE,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAA;IACtE,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EACrE,MA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,SACN;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE;;EA0C/B"}
|
|
@@ -3,11 +3,66 @@ export declare const createOptionWithMultiple: <Value>(option: Value, multiple:
|
|
|
3
3
|
export declare const getDefaultLimitTagsText: (more: number) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
/**
|
|
5
5
|
* Creates a renderTags function that displays a counter instead of individual tags
|
|
6
|
-
* @param
|
|
6
|
+
* @param formatCounter - Function that receives selection state and returns the display text
|
|
7
7
|
* @param options - Array of all available options to determine total count
|
|
8
8
|
* @param size - Size variant for typography ('small' or 'medium')
|
|
9
9
|
* @param getOptionLabel - Function to get the label for an option
|
|
10
|
-
* @returns renderTags function that shows
|
|
10
|
+
* @returns renderTags function that shows custom formatted text based on selection state
|
|
11
|
+
*/
|
|
12
|
+
export declare function createCounterRenderTags(formatCounter: (params: {
|
|
13
|
+
selectedCount: number;
|
|
14
|
+
totalCount: number;
|
|
15
|
+
selectedItems: readonly unknown[];
|
|
16
|
+
allItems: readonly unknown[];
|
|
17
|
+
getOptionLabel: (option: unknown) => string;
|
|
18
|
+
}) => string, options?: readonly unknown[], size?: 'small' | 'medium', getOptionLabel?: (option: unknown) => string): (value: readonly unknown[]) => import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
+
/**
|
|
20
|
+
* Helper function that creates a simple counter formatter
|
|
21
|
+
* @param counterText - Text to display with the counter (e.g., "selected")
|
|
22
|
+
* @param allText - Text to display when all items are selected (e.g., "All selected")
|
|
23
|
+
* @param showSingleItemText - Whether to show the actual item text for single selection
|
|
24
|
+
* @returns A formatter function that can be used with createCounterRenderTags
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Basic usage with custom text
|
|
28
|
+
* const formatter = createCounterFormatter('items', 'All items')
|
|
29
|
+
* const renderTags = createCounterRenderTags(formatter, options)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // I18N-friendly usage
|
|
33
|
+
* const formatter = createCounterFormatter(
|
|
34
|
+
* intl.formatMessage({ id: 'autocomplete.selected' }),
|
|
35
|
+
* intl.formatMessage({ id: 'autocomplete.allSelected' })
|
|
36
|
+
* )
|
|
37
|
+
* const renderTags = createCounterRenderTags(formatter, options)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Using with useMultipleAutocomplete hook
|
|
41
|
+
* const { getCounterRenderTags } = useMultipleAutocomplete({
|
|
42
|
+
* options,
|
|
43
|
+
* counterText: intl.formatMessage({ id: 'autocomplete.selected' }),
|
|
44
|
+
* allSelectedText: intl.formatMessage({ id: 'autocomplete.allSelected' })
|
|
45
|
+
* })
|
|
46
|
+
*/
|
|
47
|
+
export declare function createCounterFormatter(counterText: string, allText: string, showSingleItemText?: boolean): ({ selectedCount, totalCount, selectedItems, getOptionLabel, }: {
|
|
48
|
+
selectedCount: number;
|
|
49
|
+
totalCount: number;
|
|
50
|
+
selectedItems: readonly unknown[];
|
|
51
|
+
getOptionLabel: (option: unknown) => string;
|
|
52
|
+
}) => string;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a grouped options list with group headers for direct use in autocomplete options
|
|
55
|
+
* @param options - Array of options to group
|
|
56
|
+
* @param groupBy - Function that returns the group key for each option
|
|
57
|
+
* @returns Flat array with group headers and options ready for autocomplete
|
|
58
|
+
*/
|
|
59
|
+
export declare function createAutocompleteGroupByList<T>(options: T[], groupBy: (option: T) => string): (T | {
|
|
60
|
+
__isGroupHeader: true;
|
|
61
|
+
title: string;
|
|
62
|
+
})[];
|
|
63
|
+
/**
|
|
64
|
+
* Shows a runtime warning for deprecated groupBy prop usage
|
|
65
|
+
* @param componentName - Name of the component (e.g., 'Autocomplete', 'MultipleAutocomplete')
|
|
11
66
|
*/
|
|
12
|
-
export declare function
|
|
67
|
+
export declare function warnDeprecatedGroupBy(componentName: string): void;
|
|
13
68
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/utils.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/utils.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,GAAI,KAAK,UAAW,KAAK,KAAG,MAI7D,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,KAAK,UACpC,KAAK,YACH,OAAO,KAChB,MAAM,CAAC,MAAM,EAAE,OAAO,CAIxB,CAAA;AAGD,eAAO,MAAM,uBAAuB,SAAU,MAAM,4CAEnD,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,CAAC,MAAM,EAAE;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,SAAS,OAAO,EAAE,CAAA;IACjC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAA;IAC5B,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAA;CAC5C,KAAK,MAAM,EACZ,OAAO,GAAE,SAAS,OAAO,EAAO,EAChC,IAAI,GAAE,OAAO,GAAG,QAAkB,EAClC,cAAc,GAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAA8B,WAEjC,SAAS,OAAO,EAAE,oDA+BrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,kBAAkB,UAAO,mEAOtB;IACD,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,SAAS,OAAO,EAAE,CAAA;IACjC,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAA;CAC5C,YASF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,EAC7C,OAAO,EAAE,CAAC,EAAE,EACZ,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,GAC7B,CAAC,CAAC,GAAG;IAAE,eAAe,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CA+BlD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAejE"}
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
2
|
-
export type ListboxWithFilterProps = HTMLAttributes<HTMLElement> & {
|
|
3
|
-
showFilters?: boolean;
|
|
4
|
-
allSelected?: boolean;
|
|
5
|
-
someSelected?: boolean;
|
|
6
|
-
handleSelectAll?: () => void;
|
|
7
|
-
multiple?: boolean;
|
|
8
|
-
extended?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Height of each item in pixels
|
|
11
|
-
*/
|
|
12
|
-
itemHeight?: number;
|
|
13
|
-
/**
|
|
14
|
-
* Maximum height of the listbox in pixels
|
|
15
|
-
*/
|
|
16
|
-
maxListHeight?: number;
|
|
17
|
-
};
|
|
18
|
-
declare const ListboxWithFilter: import('react').ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & {
|
|
19
|
-
showFilters?: boolean;
|
|
20
|
-
allSelected?: boolean;
|
|
21
|
-
someSelected?: boolean;
|
|
22
|
-
handleSelectAll?: () => void;
|
|
23
|
-
multiple?: boolean;
|
|
24
|
-
extended?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Height of each item in pixels
|
|
27
|
-
*/
|
|
28
|
-
itemHeight?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Maximum height of the listbox in pixels
|
|
31
|
-
*/
|
|
32
|
-
maxListHeight?: number;
|
|
33
|
-
} & import('react').RefAttributes<HTMLUListElement>>;
|
|
34
|
-
export default ListboxWithFilter;
|
|
35
|
-
//# sourceMappingURL=ListBoxWithFilter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListBoxWithFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Autocomplete/ListBoxWithFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAW,MAAM,OAAO,CAAA;AAUzE,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG;IACjE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAA;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AA2FD,QAAA,MAAM,iBAAiB;kBAzGP,OAAO;kBACP,OAAO;mBACN,OAAO;sBACJ,MAAM,IAAI;eACjB,OAAO;eACP,OAAO;IAClB;;OAEG;iBACU,MAAM;IACnB;;OAEG;oBACa,MAAM;oDA4FgC,CAAA;AACxD,eAAe,iBAAiB,CAAA"}
|