@contentful/f36-autocomplete 4.2.11 → 4.3.11
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 +44 -105
- package/README.mdx +1 -1
- package/dist/main.js +13 -3
- package/dist/main.js.map +1 -1
- package/dist/module.js +13 -3
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -11
- package/LICENSE.md +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,220 +1,159 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
3
|
+
## 4.3.11
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
### Patch Changes
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
- Updated dependencies [[`edd15d01`](https://github.com/contentful/forma-36/commit/edd15d016be65430e4a1ceb6c617a7b8bdb98585)]:
|
|
8
|
+
- @contentful/f36-forms@4.3.11
|
|
9
|
+
- @contentful/f36-button@4.3.11
|
|
10
|
+
- @contentful/f36-icons@4.3.11
|
|
11
|
+
- @contentful/f36-popover@4.3.11
|
|
12
|
+
- @contentful/f36-skeleton@4.3.11
|
|
13
|
+
- @contentful/f36-typography@4.3.11
|
|
14
|
+
- @contentful/f36-utils@4.3.11
|
|
15
|
+
- @contentful/f36-core@4.3.11
|
|
9
16
|
|
|
17
|
+
## 4.3.10
|
|
10
18
|
|
|
19
|
+
### Patch Changes
|
|
11
20
|
|
|
21
|
+
- [#1969](https://github.com/contentful/forma-36/pull/1969) [`0c5a4b60`](https://github.com/contentful/forma-36/commit/0c5a4b60f8df76e1f75d98b7ea28dd0fd6307fc3) Thanks [@denkristoffer](https://github.com/denkristoffer)! - don't put cursor to the end on every change event
|
|
12
22
|
|
|
23
|
+
- Updated dependencies [[`0c5a4b60`](https://github.com/contentful/forma-36/commit/0c5a4b60f8df76e1f75d98b7ea28dd0fd6307fc3)]:
|
|
24
|
+
- @contentful/f36-forms@4.3.10
|
|
25
|
+
- @contentful/f36-button@4.3.10
|
|
26
|
+
- @contentful/f36-icons@4.3.10
|
|
27
|
+
- @contentful/f36-popover@4.3.10
|
|
28
|
+
- @contentful/f36-skeleton@4.3.10
|
|
29
|
+
- @contentful/f36-typography@4.3.10
|
|
30
|
+
- @contentful/f36-utils@4.3.10
|
|
31
|
+
- @contentful/f36-core@4.3.10
|
|
13
32
|
|
|
14
|
-
##
|
|
33
|
+
## 4.3.9
|
|
15
34
|
|
|
16
|
-
|
|
35
|
+
### Patch Changes
|
|
17
36
|
|
|
37
|
+
- [#1953](https://github.com/contentful/forma-36/pull/1953) [`df985087`](https://github.com/contentful/forma-36/commit/df98508780f63754e29df09d4f6239bdc84982a8) Thanks [@massao](https://github.com/massao)! - bump packages versions to have consistent versioning
|
|
18
38
|
|
|
39
|
+
- Updated dependencies [[`df985087`](https://github.com/contentful/forma-36/commit/df98508780f63754e29df09d4f6239bdc84982a8)]:
|
|
40
|
+
- @contentful/f36-button@4.3.9
|
|
41
|
+
- @contentful/f36-forms@4.3.9
|
|
42
|
+
- @contentful/f36-icons@4.3.9
|
|
43
|
+
- @contentful/f36-popover@4.3.9
|
|
44
|
+
- @contentful/f36-skeleton@4.3.9
|
|
45
|
+
- @contentful/f36-typography@4.3.9
|
|
46
|
+
- @contentful/f36-core@4.3.9
|
|
47
|
+
- @contentful/f36-utils@4.3.9
|
|
19
48
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [4.2.9](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.8...@contentful/f36-autocomplete@4.2.9) (2022-03-09)
|
|
49
|
+
## [4.2.11](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.10...@contentful/f36-autocomplete@4.2.11) (2022-03-14)
|
|
23
50
|
|
|
24
51
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
25
52
|
|
|
53
|
+
## [4.2.10](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.9...@contentful/f36-autocomplete@4.2.10) (2022-03-10)
|
|
26
54
|
|
|
55
|
+
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
27
56
|
|
|
57
|
+
## [4.2.9](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.8...@contentful/f36-autocomplete@4.2.9) (2022-03-09)
|
|
28
58
|
|
|
59
|
+
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
29
60
|
|
|
30
61
|
## [4.2.8](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.7...@contentful/f36-autocomplete@4.2.8) (2022-03-09)
|
|
31
62
|
|
|
32
63
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
33
64
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
65
|
## [4.2.7](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.6...@contentful/f36-autocomplete@4.2.7) (2022-03-03)
|
|
39
66
|
|
|
40
|
-
|
|
41
67
|
### Bug Fixes
|
|
42
68
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
69
|
+
- migrate links from master to main ([#1923](https://github.com/contentful/forma-36/issues/1923)) ([607301d](https://github.com/contentful/forma-36/commit/607301d57a2e83190d2aa298120ddb8493e8c429))
|
|
48
70
|
|
|
49
71
|
## [4.2.6](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.5...@contentful/f36-autocomplete@4.2.6) (2022-03-02)
|
|
50
72
|
|
|
51
73
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
52
74
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
75
|
## [4.2.5](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.4...@contentful/f36-autocomplete@4.2.5) (2022-03-01)
|
|
58
76
|
|
|
59
|
-
|
|
60
77
|
### Bug Fixes
|
|
61
78
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
- autocomplete method documentation ([#1914](https://github.com/contentful/forma-36/issues/1914)) ([0596bd7](https://github.com/contentful/forma-36/commit/0596bd7e86398f4a15cac7e8e5a5943ca6c61fe0))
|
|
67
80
|
|
|
68
81
|
## [4.2.4](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.3...@contentful/f36-autocomplete@4.2.4) (2022-02-22)
|
|
69
82
|
|
|
70
83
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
85
|
## [4.2.3](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.2...@contentful/f36-autocomplete@4.2.3) (2022-02-22)
|
|
77
86
|
|
|
78
87
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
79
88
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
89
|
## [4.2.2](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.1...@contentful/f36-autocomplete@4.2.2) (2022-02-17)
|
|
85
90
|
|
|
86
91
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
87
92
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
93
|
## [4.2.1](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.2.0...@contentful/f36-autocomplete@4.2.1) (2022-02-09)
|
|
93
94
|
|
|
94
95
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
97
|
# [4.2.0](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.11...@contentful/f36-autocomplete@4.2.0) (2022-02-09)
|
|
101
98
|
|
|
102
|
-
|
|
103
99
|
### Features
|
|
104
100
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
- by default render Popover only when it's open ([#1873](https://github.com/contentful/forma-36/issues/1873)) ([48a511b](https://github.com/contentful/forma-36/commit/48a511bc48c17d3e4bf0cbfb8d16da8c3cbc29b2))
|
|
110
102
|
|
|
111
103
|
## [4.1.11](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.10...@contentful/f36-autocomplete@4.1.11) (2022-02-07)
|
|
112
104
|
|
|
113
105
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
114
106
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
107
|
## [4.1.10](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.9...@contentful/f36-autocomplete@4.1.10) (2022-02-07)
|
|
120
108
|
|
|
121
109
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
122
110
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
111
|
## [4.1.9](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.8...@contentful/f36-autocomplete@4.1.9) (2022-02-07)
|
|
128
112
|
|
|
129
113
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
130
114
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
115
|
## [4.1.8](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.7...@contentful/f36-autocomplete@4.1.8) (2022-02-02)
|
|
136
116
|
|
|
137
117
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
138
118
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
119
|
## [4.1.7](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.6...@contentful/f36-autocomplete@4.1.7) (2022-01-31)
|
|
144
120
|
|
|
145
121
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
146
122
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
123
|
## [4.1.6](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.5...@contentful/f36-autocomplete@4.1.6) (2022-01-31)
|
|
152
124
|
|
|
153
125
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
154
126
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
127
|
## [4.1.5](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.4...@contentful/f36-autocomplete@4.1.5) (2022-01-28)
|
|
160
128
|
|
|
161
129
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
162
130
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
131
|
## [4.1.4](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.3...@contentful/f36-autocomplete@4.1.4) (2022-01-26)
|
|
168
132
|
|
|
169
133
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
170
134
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
135
|
## [4.1.3](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.2...@contentful/f36-autocomplete@4.1.3) (2022-01-25)
|
|
176
136
|
|
|
177
137
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
178
138
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
139
|
## [4.1.2](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.1...@contentful/f36-autocomplete@4.1.2) (2022-01-19)
|
|
184
140
|
|
|
185
141
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
186
142
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
143
|
## [4.1.1](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.1.0...@contentful/f36-autocomplete@4.1.1) (2022-01-19)
|
|
192
144
|
|
|
193
145
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
194
146
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
147
|
# [4.1.0](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.0.2...@contentful/f36-autocomplete@4.1.0) (2022-01-13)
|
|
200
148
|
|
|
201
|
-
|
|
202
149
|
### Features
|
|
203
150
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
151
|
+
- implement props list redesign [BAU-535](<[#1756](https://github.com/contentful/forma-36/issues/1756)>) ([21c57e7](https://github.com/contentful/forma-36/commit/21c57e72008b75990d03af4e7500edc1c7f3d26d))
|
|
209
152
|
|
|
210
153
|
## [4.0.2](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.0.1...@contentful/f36-autocomplete@4.0.2) (2022-01-12)
|
|
211
154
|
|
|
212
155
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
|
213
156
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
157
|
## [4.0.1](https://github.com/contentful/forma-36/compare/@contentful/f36-autocomplete@4.0.0...@contentful/f36-autocomplete@4.0.1) (2022-01-11)
|
|
219
158
|
|
|
220
159
|
**Note:** Version bump only for package @contentful/f36-autocomplete
|
package/README.mdx
CHANGED
|
@@ -6,7 +6,7 @@ storybook: 'https://v4-f36-storybook.netlify.app/?path=/story/components-autocom
|
|
|
6
6
|
typescript: ./src/Autocomplete.tsx
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Search through a long list of options.
|
|
10
10
|
|
|
11
11
|
## Import
|
|
12
12
|
|
package/dist/main.js
CHANGED
|
@@ -139,6 +139,12 @@ function $56e6e764f18116b7$var$_Autocomplete(props, ref) {
|
|
|
139
139
|
onInputValueChange === null || onInputValueChange === void 0 ? void 0 : onInputValueChange(value);
|
|
140
140
|
}, [
|
|
141
141
|
onInputValueChange
|
|
142
|
+
]); // Handle manually to avoid a jumping cursor, see https://github.com/downshift-js/downshift/issues/1108#issuecomment-842407759
|
|
143
|
+
const handleNativeChangeEvent = $hVoOH$react.useCallback((event)=>{
|
|
144
|
+
const value = event.target.value;
|
|
145
|
+
handleInputValueChange(value);
|
|
146
|
+
}, [
|
|
147
|
+
handleInputValueChange
|
|
142
148
|
]);
|
|
143
149
|
const flattenItems = $56e6e764f18116b7$var$isUsingGroups(isGrouped, items) ? items.reduce((acc, group)=>[
|
|
144
150
|
...acc,
|
|
@@ -151,8 +157,8 @@ function $56e6e764f18116b7$var$_Autocomplete(props, ref) {
|
|
|
151
157
|
items: flattenItems,
|
|
152
158
|
inputValue: inputValue1,
|
|
153
159
|
itemToString: itemToString,
|
|
154
|
-
onInputValueChange: ({ inputValue: inputValue })=>{
|
|
155
|
-
handleInputValueChange(inputValue);
|
|
160
|
+
onInputValueChange: ({ type: type , inputValue: inputValue })=>{
|
|
161
|
+
if (type !== '__input_change__') handleInputValueChange(inputValue);
|
|
156
162
|
},
|
|
157
163
|
onStateChange: ({ type: type , selectedItem: selectedItem })=>{
|
|
158
164
|
switch(type){
|
|
@@ -199,7 +205,11 @@ function $56e6e764f18116b7$var$_Autocomplete(props, ref) {
|
|
|
199
205
|
isReadOnly: isReadOnly,
|
|
200
206
|
ref: $hVoOH$contentfulf36core.mergeRefs(inputProps.ref, inputRef),
|
|
201
207
|
testId: "cf-autocomplete-input",
|
|
202
|
-
placeholder: placeholder
|
|
208
|
+
placeholder: placeholder,
|
|
209
|
+
onChange: (event)=>{
|
|
210
|
+
inputProps.onChange(event);
|
|
211
|
+
handleNativeChangeEvent(event);
|
|
212
|
+
}
|
|
203
213
|
}), /*#__PURE__*/ ($parcel$interopDefault($hVoOH$react)).createElement($hVoOH$contentfulf36button.IconButton, {
|
|
204
214
|
...toggleProps,
|
|
205
215
|
ref: $hVoOH$cont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,WAAD;YACX,iBAAA,EAAmB6D,iBAAD;;QAIxBA,iBAAiB,IAAIxB,KAAK,CAAC/C,OAAN,CAAckD,MAAnC;QACA,MAAA,CAAOgC,MAAP;IACD,CA1BD,IA4BAzD,SAAD,KACEmB,mCAAa,CAACxC,SAAD,EAAYD,KAAZ,KACdA,KAAK,CAAC+C,MAAN,GAAe,CAFhB,uEAGI,yCAAiB;QAChB,KAAA,EAAO/C,KAAD;QACN,iBAAA,EAAmBoE,iBAAD;QAClB,gBAAA,EAAkBf,gBAAD;QACjB,YAAA,EAAcH,YAAD;QACb,UAAA,EAAY5C,UAAD;QACX,UAAA,EAAYC,WAAD;;AAO1B,CAAA;AAED,KAAA,CAAMyE,0CAAoB,OAAS,CAAnC;IACE,MAAA,oEACG,8CAAD;QAAmB,SAAA,EAAW,EAAD;0EAC1B,6CAAD;QAAkB,aAAA,EAAe,CAAD;;AAGrC,CAND,CAQA,CAFC,AAED,EAFC,AAED,gFAFC;SAGQvC,mCAAa,CACpBxC,SADF,EAEED,KAFF,EAGyC,CAHzC;IAIE,MAAA,CAAOC,SAAP;AACD,CAAA;AAOM,KAAA,CAAM3B,yCAAY,iBAAGE,sCAAK,CAACyG,UAAN,CAAiBzD,mCAAjB","sources":["packages/components/autocomplete/src/index.ts","packages/components/autocomplete/src/Autocomplete.tsx","packages/components/autocomplete/src/AutocompleteItems.tsx","packages/components/autocomplete/src/Autocomplete.styles.ts"],"sourcesContent":["export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n","import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport { mergeRefs } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput } from '@contentful/f36-forms';\nimport type { TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { SkeletonContainer, SkeletonBodyText } from '@contentful/f36-skeleton';\nimport { Popover } from '@contentful/f36-popover';\nimport { Subheading, SectionHeading } from '@contentful/f36-typography';\n\nimport { AutocompleteItems } from './AutocompleteItems';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\n\nexport interface GenericGroupType<ItemType> {\n groupTitle: string;\n options: ItemType[];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface AutocompleteProps<ItemType>\n extends CommonProps,\n Pick<\n TextInputProps,\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'isRequired'\n | 'id'\n | 'defaultValue'\n > {\n /**\n * It’s an array of data to be used as \"options\" by the autocomplete component.\n * This can either be a plain list of items or a list of groups of items.\n */\n items: ItemType[] | GenericGroupType<ItemType>[];\n\n /**\n * Tells if the item is a object with groups\n */\n isGrouped?: boolean;\n\n /**\n * Function called whenever the input value changes\n */\n onInputValueChange?: (value: string) => void;\n /**\n * This is the function that will be called when the user selects one of the \"options\" in the list.\n * The component will pass the selected \"item\" as an argument to the function..\n */\n onSelectItem: (item: ItemType) => void;\n /**\n * This is the function that will be called for each \"item\" passed in the `items` prop.\n * It receives the \"item\" and \"inputValue\" as arguments and returns a ReactNode.\n * The inputValue is passed in case you want to highlight the match on the render.\n */\n renderItem?: (item: ItemType, inputValue: string) => React.ReactNode;\n /**\n * When using objects as `items`, we recommend passing a function that tells Downshift how to extract a string\n * from those objetcs to be used as inputValue\n */\n itemToString?: (item: ItemType) => string;\n /**\n * If this is set to `true` the text input will be cleared after an item is selected\n * @default false\n */\n clearAfterSelect?: boolean;\n /**\n * This is the value will be passed to the `placeholder` prop of the input.\n * @default \"Search\"\n */\n placeholder?: string;\n /**\n * A message that will be shown when it is not possible to find any option that matches the input value\n * @default \"No matches\"\n */\n noMatchesMessage?: string;\n /**\n * Use this prop to get a ref to the input element of the component\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Use this prop to get a ref to the toggle button of the component\n */\n toggleRef?: React.Ref<HTMLButtonElement>;\n /**\n * Use this prop to get a ref to the list of items of the component\n */\n listRef?: React.Ref<HTMLUListElement>;\n /**\n * It sets the width of the list\n * @default \"auto\"\n */\n listWidth?: 'auto' | 'full';\n /**\n * It sets the max-height, in pixels, of the list\n * The default value is the height of 5 single line items\n * @default 180\n */\n listMaxHeight?: number;\n /**\n * Sets the list to show its loading state\n * @default false\n */\n isLoading?: boolean;\n /**\n * Boolean to control whether or not to render the suggestions box in a React Portal.\n * Rendering content inside a Portal allows the suggestions box to escape the bounds\n * of its parent while still being positioned correctly.\n * Defaults to `false`\n */\n usePortal?: boolean;\n}\n\nfunction _Autocomplete<ItemType>(\n props: AutocompleteProps<ItemType>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const {\n id,\n className,\n clearAfterSelect = false,\n defaultValue = '',\n items,\n onInputValueChange,\n onSelectItem,\n renderItem,\n itemToString = (item: ItemType) => (item as unknown) as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n noMatchesMessage = 'No matches found',\n placeholder = 'Search',\n inputRef,\n toggleRef,\n listRef,\n listWidth = 'auto',\n listMaxHeight = 180,\n isGrouped = false,\n isLoading = false,\n usePortal = false,\n testId = 'cf-autocomplete',\n } = props;\n\n type GroupType = GenericGroupType<ItemType>;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n const [inputValue, setInputValue] = useState(defaultValue);\n\n const handleInputValueChange = useCallback(\n (value) => {\n setInputValue(value);\n\n onInputValueChange?.(value);\n },\n [onInputValueChange],\n );\n\n const flattenItems = isUsingGroups(isGrouped, items)\n ? items.reduce(\n (acc: ItemType[], group: GroupType) => [...acc, ...group.options],\n [],\n )\n : items;\n\n const isShowingNoMatches = isUsingGroups(isGrouped, items)\n ? items.every((group: GroupType) => group.options.length === 0)\n : items.length === 0;\n\n const {\n getComboboxProps,\n getInputProps,\n getItemProps,\n getMenuProps,\n getToggleButtonProps,\n highlightedIndex,\n isOpen,\n toggleMenu,\n } = useCombobox({\n items: flattenItems,\n inputValue,\n itemToString,\n onInputValueChange: ({ inputValue }) => {\n handleInputValueChange(inputValue);\n },\n onStateChange: ({ type, selectedItem }) => {\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n if (selectedItem) {\n onSelectItem(selectedItem);\n }\n if (clearAfterSelect) {\n handleInputValueChange('');\n }\n break;\n default:\n break;\n }\n },\n });\n\n const {\n 'aria-labelledby': _labelledby,\n id: _inputId,\n ...inputProps\n } = getInputProps();\n const comboboxProps = getComboboxProps();\n const toggleProps = getToggleButtonProps();\n const menuProps = getMenuProps();\n let elementStartIndex = 0;\n\n return (\n <div\n data-test-id={testId}\n className={cx(styles.autocomplete, className)}\n ref={ref}\n >\n <Popover\n usePortal={usePortal}\n isOpen={isOpen}\n isFullWidth={listWidth === 'full'}\n renderOnlyWhenOpen={false}\n // This is necessary, otherwise the focus will change from the input to the Popover\n // and the user won't be able to type in the input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={false}\n id={menuProps.id}\n >\n <Popover.Trigger>\n <div {...comboboxProps} className={styles.combobox}>\n <TextInput\n {...inputProps}\n onFocus={() => {\n if (!isOpen) {\n toggleMenu();\n }\n }}\n id={id}\n isInvalid={isInvalid}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n ref={mergeRefs(inputProps.ref, inputRef)}\n testId=\"cf-autocomplete-input\"\n placeholder={placeholder}\n />\n <IconButton\n {...toggleProps}\n ref={mergeRefs(toggleProps.ref, toggleRef)}\n aria-label=\"toggle menu\"\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={\n inputValue ? (\n <CloseIcon aria-label=\"Clear\" variant=\"muted\" />\n ) : (\n <ChevronDownIcon aria-label=\"Show list\" variant=\"muted\" />\n )\n }\n onClick={() => {\n if (inputValue) {\n handleInputValueChange('');\n } else {\n toggleMenu();\n }\n }}\n isDisabled={isDisabled}\n size=\"small\"\n />\n </div>\n </Popover.Trigger>\n\n <Popover.Content\n {...menuProps}\n ref={mergeRefs(menuProps.ref, listRef)}\n className={styles.content}\n testId=\"cf-autocomplete-container\"\n >\n {isLoading &&\n [...Array(3)].map((_, index) => (\n <div key={index} className={cx(styles.item, styles.disabled)}>\n <ListItemLoadingState />\n </div>\n ))}\n\n {!isLoading && isShowingNoMatches && (\n <div className={styles.item}>\n <Subheading className={styles.noMatchesTitle}>\n {noMatchesMessage}\n </Subheading>\n </div>\n )}\n\n {!isLoading &&\n isUsingGroups(isGrouped, items) &&\n items.map((group: GroupType, index: number) => {\n if (group.options.length < 1) {\n return;\n }\n const render = (\n <div key={index}>\n <SectionHeading\n key={index}\n data-test-id=\"cf-autocomplete-grouptitle\"\n marginBottom=\"none\"\n className={styles.groupTitle}\n >\n {group.groupTitle}\n </SectionHeading>\n <AutocompleteItems<ItemType>\n items={group.options}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n elementStartIndex={elementStartIndex}\n />\n </div>\n );\n elementStartIndex += group.options.length;\n return render;\n })}\n\n {!isLoading &&\n !isUsingGroups(isGrouped, items) &&\n items.length > 0 && (\n <AutocompleteItems<ItemType>\n items={items}\n elementStartIndex={elementStartIndex}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n />\n )}\n </Popover.Content>\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <SkeletonContainer svgHeight={16}>\n <SkeletonBodyText numberOfLines={1} />\n </SkeletonContainer>\n );\n};\n\n// This is required to infer correct typings when differentiating groups and items\nfunction isUsingGroups<ItemType>(\n isGrouped: boolean,\n items: ItemType[] | GenericGroupType<ItemType>[],\n): items is GenericGroupType<ItemType>[] {\n return isGrouped;\n}\n\n/**\n * The Autocomplete is a component that will show a `TextInput` where a user can type any word which will be used\n * to filter a list of items. That list of filtered items will be shown to the user as possible options for the input.\n * Once one of the options is selected, that option becomes the value of the `TextInput`.\n */\nexport const Autocomplete = React.forwardRef(_Autocomplete) as <T>(\n props: ExpandProps<AutocompleteProps<T>> & {\n ref?: React.Ref<HTMLDivElement>;\n },\n) => ReturnType<typeof _Autocomplete>;\n","import React, { HTMLAttributes } from 'react';\nimport { cx } from 'emotion';\n\nimport { getStringMatch } from '@contentful/f36-utils';\nimport { Text } from '@contentful/f36-typography';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\n\ninterface AutocompleteItemsProps<ItemType> {\n items: ItemType[];\n elementStartIndex: number;\n highlightedIndex: number;\n getItemProps: (\n options: UseComboboxGetItemPropsOptions<ItemType>,\n ) => HTMLAttributes<HTMLLIElement>;\n renderItem: (item: ItemType, inputValue: string) => React.ReactNode;\n inputValue: string;\n listMaxHeight?: number;\n}\n\nexport function AutocompleteItems<ItemType>(\n props: AutocompleteItemsProps<ItemType>,\n) {\n const {\n items,\n elementStartIndex,\n highlightedIndex,\n getItemProps,\n renderItem,\n inputValue,\n listMaxHeight = 180,\n } = props;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n return (\n <ul className={styles.list} data-test-id=\"cf-autocomplete-list\">\n {items.map((item: ItemType, index: number) => {\n const itemIndex = elementStartIndex + index;\n const itemProps = getItemProps({ item, index: itemIndex });\n return (\n <Text\n {...itemProps}\n as=\"li\"\n key={itemIndex}\n className={cx([\n styles.item,\n highlightedIndex === itemIndex && styles.highlighted,\n ])}\n data-test-id={`cf-autocomplete-list-item-${itemIndex}`}\n >\n {renderItem ? (\n renderItem(item, inputValue)\n ) : typeof item === 'string' ? (\n <HighlightedItem item={item} inputValue={inputValue} />\n ) : (\n item\n )}\n </Text>\n );\n })}\n </ul>\n );\n}\n\nAutocompleteItems.displayName = 'AutocompleteItems';\n\nfunction HighlightedItem({\n item,\n inputValue,\n}: {\n item: string;\n inputValue: string;\n}) {\n const { before, match, after } = getStringMatch(item, inputValue);\n\n return (\n <>\n {before}\n <b>{match}</b>\n {after}\n </>\n );\n}\n\nHighlightedItem.displayName = 'HighlightedItem';\n","import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getAutocompleteStyles = (listMaxHeight: number) => ({\n autocomplete: css({\n position: 'relative',\n width: '100%',\n }),\n combobox: css({\n position: 'relative',\n }),\n toggleButton: css({\n position: 'absolute',\n top: '4px',\n right: '4px',\n zIndex: 1,\n padding: tokens.spacing2Xs,\n }),\n content: css({\n overflow: 'auto',\n maxHeight: `${listMaxHeight}px`,\n }),\n list: css({\n listStyle: 'none',\n padding: `${tokens.spacingXs} 0`,\n margin: 0,\n }),\n groupTitle: css({\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n lineHeight: tokens.lineHeightM,\n }),\n noMatchesTitle: css({\n color: tokens.gray500,\n margin: `${tokens.spacingM} 0 ${tokens.spacingM} 0`,\n }),\n item: css({\n display: 'block',\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n wordBreak: 'break-word',\n whiteSpace: 'break-spaces',\n cursor: 'pointer',\n hyphens: 'auto',\n\n '&:focus, &:hover': {\n backgroundColor: tokens.gray100,\n },\n '&:active': {\n backgroundColor: tokens.gray200,\n },\n }),\n disabled: css({\n opacity: 0.5,\n pointerEvents: 'none',\n }),\n highlighted: css({\n backgroundColor: tokens.gray100,\n }),\n});\n"],"names":["Autocomplete","AutocompleteProps","React","useCallback","useState","useCombobox","mergeRefs","CommonProps","ExpandProps","IconButton","TextInput","TextInputProps","CloseIcon","ChevronDownIcon","SkeletonContainer","SkeletonBodyText","Popover","Subheading","SectionHeading","AutocompleteItems","getAutocompleteStyles","GenericGroupType","groupTitle","options","ItemType","Pick","items","isGrouped","onInputValueChange","value","onSelectItem","item","renderItem","inputValue","ReactNode","itemToString","clearAfterSelect","placeholder","noMatchesMessage","inputRef","Ref","HTMLInputElement","toggleRef","HTMLButtonElement","listRef","HTMLUListElement","listWidth","listMaxHeight","isLoading","usePortal","_Autocomplete","props","ref","HTMLDivElement","id","className","defaultValue","isInvalid","isDisabled","isRequired","isReadOnly","testId","GroupType","styles","setInputValue","handleInputValueChange","flattenItems","isUsingGroups","reduce","acc","group","isShowingNoMatches","every","length","getComboboxProps","getInputProps","getItemProps","getMenuProps","getToggleButtonProps","highlightedIndex","isOpen","toggleMenu","onStateChange","type","selectedItem","stateChangeTypes","InputKeyDownEnter","ItemClick","_labelledby","_inputId","inputProps","comboboxProps","toggleProps","menuProps","elementStartIndex","autocomplete","combobox","toggleButton","content","Array","map","_","index","disabled","noMatchesTitle","render","ListItemLoadingState","forwardRef","T","ReturnType","HTMLAttributes","getStringMatch","Text","UseComboboxGetItemPropsOptions","AutocompleteItemsProps","HTMLLIElement","list","itemIndex","itemProps","highlighted","displayName","HighlightedItem","before","match","after","tokens","position","top","right","zIndex","padding","spacing2Xs","overflow","maxHeight","listStyle","spacingXs","margin","spacingM","lineHeight","lineHeightM","color","gray500","display","wordBreak","whiteSpace","cursor","hyphens","backgroundColor","gray100","gray200"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGGO,KAAA,CAAMoB,yCAAqB,IAAI2B,aAAD,IAA4B,CAAjE;QACEqD,YAAY,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,kBAAdA,CAAAA,CAAAA;YAAc,IAAA,EAAA,CAAA;YAAA,MAAA,EAAA,CAAA;QAAA,CAAA;QAIdC,QAAQ,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,kBAAVA,CAAAA,CAAAA;YAAU,IAAA,EAAA,CAAA;YAAA,MAAA,EAAA,CAAA;QAAA,CAAA;QAGVE,YAAY,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,kBAAA,CAAI,CAAlBA;YACE6B,QAAQ,EAAE,CADM;YAEhBC,GAAG,EAAE,CAFW;YAGhBC,KAAK,EAAE,CAHS;YAIhBC,MAAM,EAAE,CAJQ;YAKhBC,OAAO,EAAEL,oDAAM,CAACM,UA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AChB,KAAA,EAAOpD,KAAD;QACN,iBAAA,EAAmByE,iBAAD;QAClB,gBAAA,EAAkBf,gBAAD;QACjB,YAAA,EAAcH,YAAD;QACb,UAAA,EAAYjD,UAAD;QACX,UAAA,EAAYC,WAAD;;AAO1B,CAAA;AAED,KAAA,CAAM+E,0CAAoB,OAAS,CAAnC;IACE,MAAA,oEACG,8CAAD;QAAmB,SAAA,EAAW,EAAD;0EAC1B,6CAAD;QAAkB,aAAA,EAAe,CAAD;;AAGrC,CAND,CAQA,CAFC,AAED,EAFC,AAED,gFAFC;SAGQxC,mCAAa,CACpB7C,SADF,EAEED,KAFF,EAGyC,CAHzC;IAIE,MAAA,CAAOC,SAAP;AACD,CAAA;AAOM,KAAA,CAAM3B,yCAAY,iBAAGE,sCAAK,CAAC+G,UAAN,CAAiB/D,mCAAjB","sources":["packages/components/autocomplete/src/index.ts","packages/components/autocomplete/src/Autocomplete.tsx","packages/components/autocomplete/src/AutocompleteItems.tsx","packages/components/autocomplete/src/Autocomplete.styles.ts"],"sourcesContent":["export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n","import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport { mergeRefs } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput } from '@contentful/f36-forms';\nimport type { TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { SkeletonContainer, SkeletonBodyText } from '@contentful/f36-skeleton';\nimport { Popover } from '@contentful/f36-popover';\nimport { Subheading, SectionHeading } from '@contentful/f36-typography';\n\nimport { AutocompleteItems } from './AutocompleteItems';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\n\nexport interface GenericGroupType<ItemType> {\n groupTitle: string;\n options: ItemType[];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface AutocompleteProps<ItemType>\n extends CommonProps,\n Pick<\n TextInputProps,\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'isRequired'\n | 'id'\n | 'defaultValue'\n > {\n /**\n * It’s an array of data to be used as \"options\" by the autocomplete component.\n * This can either be a plain list of items or a list of groups of items.\n */\n items: ItemType[] | GenericGroupType<ItemType>[];\n\n /**\n * Tells if the item is a object with groups\n */\n isGrouped?: boolean;\n\n /**\n * Function called whenever the input value changes\n */\n onInputValueChange?: (value: string) => void;\n /**\n * This is the function that will be called when the user selects one of the \"options\" in the list.\n * The component will pass the selected \"item\" as an argument to the function..\n */\n onSelectItem: (item: ItemType) => void;\n /**\n * This is the function that will be called for each \"item\" passed in the `items` prop.\n * It receives the \"item\" and \"inputValue\" as arguments and returns a ReactNode.\n * The inputValue is passed in case you want to highlight the match on the render.\n */\n renderItem?: (item: ItemType, inputValue: string) => React.ReactNode;\n /**\n * When using objects as `items`, we recommend passing a function that tells Downshift how to extract a string\n * from those objetcs to be used as inputValue\n */\n itemToString?: (item: ItemType) => string;\n /**\n * If this is set to `true` the text input will be cleared after an item is selected\n * @default false\n */\n clearAfterSelect?: boolean;\n /**\n * This is the value will be passed to the `placeholder` prop of the input.\n * @default \"Search\"\n */\n placeholder?: string;\n /**\n * A message that will be shown when it is not possible to find any option that matches the input value\n * @default \"No matches\"\n */\n noMatchesMessage?: string;\n /**\n * Use this prop to get a ref to the input element of the component\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Use this prop to get a ref to the toggle button of the component\n */\n toggleRef?: React.Ref<HTMLButtonElement>;\n /**\n * Use this prop to get a ref to the list of items of the component\n */\n listRef?: React.Ref<HTMLUListElement>;\n /**\n * It sets the width of the list\n * @default \"auto\"\n */\n listWidth?: 'auto' | 'full';\n /**\n * It sets the max-height, in pixels, of the list\n * The default value is the height of 5 single line items\n * @default 180\n */\n listMaxHeight?: number;\n /**\n * Sets the list to show its loading state\n * @default false\n */\n isLoading?: boolean;\n /**\n * Boolean to control whether or not to render the suggestions box in a React Portal.\n * Rendering content inside a Portal allows the suggestions box to escape the bounds\n * of its parent while still being positioned correctly.\n * Defaults to `false`\n */\n usePortal?: boolean;\n}\n\nfunction _Autocomplete<ItemType>(\n props: AutocompleteProps<ItemType>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const {\n id,\n className,\n clearAfterSelect = false,\n defaultValue = '',\n items,\n onInputValueChange,\n onSelectItem,\n renderItem,\n itemToString = (item: ItemType) => (item as unknown) as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n noMatchesMessage = 'No matches found',\n placeholder = 'Search',\n inputRef,\n toggleRef,\n listRef,\n listWidth = 'auto',\n listMaxHeight = 180,\n isGrouped = false,\n isLoading = false,\n usePortal = false,\n testId = 'cf-autocomplete',\n } = props;\n\n type GroupType = GenericGroupType<ItemType>;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n const [inputValue, setInputValue] = useState(defaultValue);\n\n const handleInputValueChange = useCallback(\n (value: string) => {\n setInputValue(value);\n\n onInputValueChange?.(value);\n },\n [onInputValueChange],\n );\n\n // Handle manually to avoid a jumping cursor, see https://github.com/downshift-js/downshift/issues/1108#issuecomment-842407759\n const handleNativeChangeEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = event.target.value;\n handleInputValueChange(value);\n },\n [handleInputValueChange],\n );\n\n const flattenItems = isUsingGroups(isGrouped, items)\n ? items.reduce(\n (acc: ItemType[], group: GroupType) => [...acc, ...group.options],\n [],\n )\n : items;\n\n const isShowingNoMatches = isUsingGroups(isGrouped, items)\n ? items.every((group: GroupType) => group.options.length === 0)\n : items.length === 0;\n\n const {\n getComboboxProps,\n getInputProps,\n getItemProps,\n getMenuProps,\n getToggleButtonProps,\n highlightedIndex,\n isOpen,\n toggleMenu,\n } = useCombobox({\n items: flattenItems,\n inputValue,\n itemToString,\n onInputValueChange: ({ type, inputValue }) => {\n if (type !== '__input_change__') {\n handleInputValueChange(inputValue);\n }\n },\n onStateChange: ({ type, selectedItem }) => {\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n if (selectedItem) {\n onSelectItem(selectedItem);\n }\n if (clearAfterSelect) {\n handleInputValueChange('');\n }\n break;\n default:\n break;\n }\n },\n });\n\n const {\n 'aria-labelledby': _labelledby,\n id: _inputId,\n ...inputProps\n } = getInputProps();\n const comboboxProps = getComboboxProps();\n const toggleProps = getToggleButtonProps();\n const menuProps = getMenuProps();\n let elementStartIndex = 0;\n\n return (\n <div\n data-test-id={testId}\n className={cx(styles.autocomplete, className)}\n ref={ref}\n >\n <Popover\n usePortal={usePortal}\n isOpen={isOpen}\n isFullWidth={listWidth === 'full'}\n renderOnlyWhenOpen={false}\n // This is necessary, otherwise the focus will change from the input to the Popover\n // and the user won't be able to type in the input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={false}\n id={menuProps.id}\n >\n <Popover.Trigger>\n <div {...comboboxProps} className={styles.combobox}>\n <TextInput\n {...inputProps}\n onFocus={() => {\n if (!isOpen) {\n toggleMenu();\n }\n }}\n id={id}\n isInvalid={isInvalid}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n ref={mergeRefs(inputProps.ref, inputRef)}\n testId=\"cf-autocomplete-input\"\n placeholder={placeholder}\n onChange={(event) => {\n inputProps.onChange(event);\n handleNativeChangeEvent(event);\n }}\n />\n <IconButton\n {...toggleProps}\n ref={mergeRefs(toggleProps.ref, toggleRef)}\n aria-label=\"toggle menu\"\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={\n inputValue ? (\n <CloseIcon aria-label=\"Clear\" variant=\"muted\" />\n ) : (\n <ChevronDownIcon aria-label=\"Show list\" variant=\"muted\" />\n )\n }\n onClick={() => {\n if (inputValue) {\n handleInputValueChange('');\n } else {\n toggleMenu();\n }\n }}\n isDisabled={isDisabled}\n size=\"small\"\n />\n </div>\n </Popover.Trigger>\n\n <Popover.Content\n {...menuProps}\n ref={mergeRefs(menuProps.ref, listRef)}\n className={styles.content}\n testId=\"cf-autocomplete-container\"\n >\n {isLoading &&\n [...Array(3)].map((_, index) => (\n <div key={index} className={cx(styles.item, styles.disabled)}>\n <ListItemLoadingState />\n </div>\n ))}\n\n {!isLoading && isShowingNoMatches && (\n <div className={styles.item}>\n <Subheading className={styles.noMatchesTitle}>\n {noMatchesMessage}\n </Subheading>\n </div>\n )}\n\n {!isLoading &&\n isUsingGroups(isGrouped, items) &&\n items.map((group: GroupType, index: number) => {\n if (group.options.length < 1) {\n return;\n }\n const render = (\n <div key={index}>\n <SectionHeading\n key={index}\n data-test-id=\"cf-autocomplete-grouptitle\"\n marginBottom=\"none\"\n className={styles.groupTitle}\n >\n {group.groupTitle}\n </SectionHeading>\n <AutocompleteItems<ItemType>\n items={group.options}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n elementStartIndex={elementStartIndex}\n />\n </div>\n );\n elementStartIndex += group.options.length;\n return render;\n })}\n\n {!isLoading &&\n !isUsingGroups(isGrouped, items) &&\n items.length > 0 && (\n <AutocompleteItems<ItemType>\n items={items}\n elementStartIndex={elementStartIndex}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n />\n )}\n </Popover.Content>\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <SkeletonContainer svgHeight={16}>\n <SkeletonBodyText numberOfLines={1} />\n </SkeletonContainer>\n );\n};\n\n// This is required to infer correct typings when differentiating groups and items\nfunction isUsingGroups<ItemType>(\n isGrouped: boolean,\n items: ItemType[] | GenericGroupType<ItemType>[],\n): items is GenericGroupType<ItemType>[] {\n return isGrouped;\n}\n\n/**\n * The Autocomplete is a component that will show a `TextInput` where a user can type any word which will be used\n * to filter a list of items. That list of filtered items will be shown to the user as possible options for the input.\n * Once one of the options is selected, that option becomes the value of the `TextInput`.\n */\nexport const Autocomplete = React.forwardRef(_Autocomplete) as <T>(\n props: ExpandProps<AutocompleteProps<T>> & {\n ref?: React.Ref<HTMLDivElement>;\n },\n) => ReturnType<typeof _Autocomplete>;\n","import React, { HTMLAttributes } from 'react';\nimport { cx } from 'emotion';\n\nimport { getStringMatch } from '@contentful/f36-utils';\nimport { Text } from '@contentful/f36-typography';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\n\ninterface AutocompleteItemsProps<ItemType> {\n items: ItemType[];\n elementStartIndex: number;\n highlightedIndex: number;\n getItemProps: (\n options: UseComboboxGetItemPropsOptions<ItemType>,\n ) => HTMLAttributes<HTMLLIElement>;\n renderItem: (item: ItemType, inputValue: string) => React.ReactNode;\n inputValue: string;\n listMaxHeight?: number;\n}\n\nexport function AutocompleteItems<ItemType>(\n props: AutocompleteItemsProps<ItemType>,\n) {\n const {\n items,\n elementStartIndex,\n highlightedIndex,\n getItemProps,\n renderItem,\n inputValue,\n listMaxHeight = 180,\n } = props;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n return (\n <ul className={styles.list} data-test-id=\"cf-autocomplete-list\">\n {items.map((item: ItemType, index: number) => {\n const itemIndex = elementStartIndex + index;\n const itemProps = getItemProps({ item, index: itemIndex });\n return (\n <Text\n {...itemProps}\n as=\"li\"\n key={itemIndex}\n className={cx([\n styles.item,\n highlightedIndex === itemIndex && styles.highlighted,\n ])}\n data-test-id={`cf-autocomplete-list-item-${itemIndex}`}\n >\n {renderItem ? (\n renderItem(item, inputValue)\n ) : typeof item === 'string' ? (\n <HighlightedItem item={item} inputValue={inputValue} />\n ) : (\n item\n )}\n </Text>\n );\n })}\n </ul>\n );\n}\n\nAutocompleteItems.displayName = 'AutocompleteItems';\n\nfunction HighlightedItem({\n item,\n inputValue,\n}: {\n item: string;\n inputValue: string;\n}) {\n const { before, match, after } = getStringMatch(item, inputValue);\n\n return (\n <>\n {before}\n <b>{match}</b>\n {after}\n </>\n );\n}\n\nHighlightedItem.displayName = 'HighlightedItem';\n","import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getAutocompleteStyles = (listMaxHeight: number) => ({\n autocomplete: css({\n position: 'relative',\n width: '100%',\n }),\n combobox: css({\n position: 'relative',\n }),\n toggleButton: css({\n position: 'absolute',\n top: '4px',\n right: '4px',\n zIndex: 1,\n padding: tokens.spacing2Xs,\n }),\n content: css({\n overflow: 'auto',\n maxHeight: `${listMaxHeight}px`,\n }),\n list: css({\n listStyle: 'none',\n padding: `${tokens.spacingXs} 0`,\n margin: 0,\n }),\n groupTitle: css({\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n lineHeight: tokens.lineHeightM,\n }),\n noMatchesTitle: css({\n color: tokens.gray500,\n margin: `${tokens.spacingM} 0 ${tokens.spacingM} 0`,\n }),\n item: css({\n display: 'block',\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n wordBreak: 'break-word',\n whiteSpace: 'break-spaces',\n cursor: 'pointer',\n hyphens: 'auto',\n\n '&:focus, &:hover': {\n backgroundColor: tokens.gray100,\n },\n '&:active': {\n backgroundColor: tokens.gray200,\n },\n }),\n disabled: css({\n opacity: 0.5,\n pointerEvents: 'none',\n }),\n highlighted: css({\n backgroundColor: tokens.gray100,\n }),\n});\n"],"names":["Autocomplete","AutocompleteProps","React","useCallback","useState","useCombobox","mergeRefs","CommonProps","ExpandProps","IconButton","TextInput","TextInputProps","CloseIcon","ChevronDownIcon","SkeletonContainer","SkeletonBodyText","Popover","Subheading","SectionHeading","AutocompleteItems","getAutocompleteStyles","GenericGroupType","groupTitle","options","ItemType","Pick","items","isGrouped","onInputValueChange","value","onSelectItem","item","renderItem","inputValue","ReactNode","itemToString","clearAfterSelect","placeholder","noMatchesMessage","inputRef","Ref","HTMLInputElement","toggleRef","HTMLButtonElement","listRef","HTMLUListElement","listWidth","listMaxHeight","isLoading","usePortal","_Autocomplete","props","ref","HTMLDivElement","id","className","defaultValue","isInvalid","isDisabled","isRequired","isReadOnly","testId","GroupType","styles","setInputValue","handleInputValueChange","handleNativeChangeEvent","event","ChangeEvent","HTMLTextAreaElement","target","flattenItems","isUsingGroups","reduce","acc","group","isShowingNoMatches","every","length","getComboboxProps","getInputProps","getItemProps","getMenuProps","getToggleButtonProps","highlightedIndex","isOpen","toggleMenu","type","onStateChange","selectedItem","stateChangeTypes","InputKeyDownEnter","ItemClick","_labelledby","_inputId","inputProps","comboboxProps","toggleProps","menuProps","elementStartIndex","autocomplete","combobox","onChange","toggleButton","content","Array","map","_","index","disabled","noMatchesTitle","render","ListItemLoadingState","forwardRef","T","ReturnType","HTMLAttributes","getStringMatch","Text","UseComboboxGetItemPropsOptions","AutocompleteItemsProps","HTMLLIElement","list","itemIndex","itemProps","highlighted","displayName","HighlightedItem","before","match","after","tokens","position","top","right","zIndex","padding","spacing2Xs","overflow","maxHeight","listStyle","spacingXs","margin","spacingM","lineHeight","lineHeightM","color","gray500","display","wordBreak","whiteSpace","cursor","hyphens","backgroundColor","gray100","gray200"],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -131,6 +131,12 @@ function $7cd5ba9838c72bf9$var$_Autocomplete(props, ref) {
|
|
|
131
131
|
onInputValueChange === null || onInputValueChange === void 0 ? void 0 : onInputValueChange(value);
|
|
132
132
|
}, [
|
|
133
133
|
onInputValueChange
|
|
134
|
+
]); // Handle manually to avoid a jumping cursor, see https://github.com/downshift-js/downshift/issues/1108#issuecomment-842407759
|
|
135
|
+
const handleNativeChangeEvent = $7oe8x$useCallback((event)=>{
|
|
136
|
+
const value = event.target.value;
|
|
137
|
+
handleInputValueChange(value);
|
|
138
|
+
}, [
|
|
139
|
+
handleInputValueChange
|
|
134
140
|
]);
|
|
135
141
|
const flattenItems = $7cd5ba9838c72bf9$var$isUsingGroups(isGrouped, items) ? items.reduce((acc, group)=>[
|
|
136
142
|
...acc,
|
|
@@ -143,8 +149,8 @@ function $7cd5ba9838c72bf9$var$_Autocomplete(props, ref) {
|
|
|
143
149
|
items: flattenItems,
|
|
144
150
|
inputValue: inputValue1,
|
|
145
151
|
itemToString: itemToString,
|
|
146
|
-
onInputValueChange: ({ inputValue: inputValue })=>{
|
|
147
|
-
handleInputValueChange(inputValue);
|
|
152
|
+
onInputValueChange: ({ type: type , inputValue: inputValue })=>{
|
|
153
|
+
if (type !== '__input_change__') handleInputValueChange(inputValue);
|
|
148
154
|
},
|
|
149
155
|
onStateChange: ({ type: type , selectedItem: selectedItem })=>{
|
|
150
156
|
switch(type){
|
|
@@ -191,7 +197,11 @@ function $7cd5ba9838c72bf9$var$_Autocomplete(props, ref) {
|
|
|
191
197
|
isReadOnly: isReadOnly,
|
|
192
198
|
ref: $7oe8x$mergeRefs(inputProps.ref, inputRef),
|
|
193
199
|
testId: "cf-autocomplete-input",
|
|
194
|
-
placeholder: placeholder
|
|
200
|
+
placeholder: placeholder,
|
|
201
|
+
onChange: (event)=>{
|
|
202
|
+
inputProps.onChange(event);
|
|
203
|
+
handleNativeChangeEvent(event);
|
|
204
|
+
}
|
|
195
205
|
}), /*#__PURE__*/ $7oe8x$react.createElement($7oe8x$IconButton, {
|
|
196
206
|
...toggleProps,
|
|
197
207
|
ref: $7oe8x$mergeRefs(toggleProps.ref, toggleRef),
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGGO,KAAA,CAAMoB,yCAAqB,IAAI2B,aAAD,IAA4B,CAAjE;QACEgD,YAAY,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,UAAdA,CAAAA,CAAAA;YAAc,IAAA,EAAA,CAAA;YAAA,MAAA,EAAA,CAAA;QAAA,CAAA;QAIdC,QAAQ,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,UAAVA,CAAAA,CAAAA;YAAU,IAAA,EAAA,CAAA;YAAA,MAAA,EAAA,CAAA;QAAA,CAAA;QAGV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AW,EAAD;gDAC1B,uBAAD;QAAkB,aAAA,EAAe,CAAD;;AAGrC,CAND,CAQA,CAFC,AAED,EAFC,AAED,gFAFC;SAGQvC,mCAAa,CACpBxC,SADF,EAEED,KAFF,EAGyC,CAHzC;IAIE,MAAA,CAAOC,SAAP;AACD,CAAA;AAOM,KAAA,CAAM3B,yCAAY,iBAAGE,YAAK,CAACyG,UAAN,CAAiBzD,mCAAjB","sources":["packages/components/autocomplete/src/index.ts","packages/components/autocomplete/src/Autocomplete.tsx","packages/components/autocomplete/src/AutocompleteItems.tsx","packages/components/autocomplete/src/Autocomplete.styles.ts"],"sourcesContent":["export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n","import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport { mergeRefs } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput } from '@contentful/f36-forms';\nimport type { TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { SkeletonContainer, SkeletonBodyText } from '@contentful/f36-skeleton';\nimport { Popover } from '@contentful/f36-popover';\nimport { Subheading, SectionHeading } from '@contentful/f36-typography';\n\nimport { AutocompleteItems } from './AutocompleteItems';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\n\nexport interface GenericGroupType<ItemType> {\n groupTitle: string;\n options: ItemType[];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface AutocompleteProps<ItemType>\n extends CommonProps,\n Pick<\n TextInputProps,\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'isRequired'\n | 'id'\n | 'defaultValue'\n > {\n /**\n * It’s an array of data to be used as \"options\" by the autocomplete component.\n * This can either be a plain list of items or a list of groups of items.\n */\n items: ItemType[] | GenericGroupType<ItemType>[];\n\n /**\n * Tells if the item is a object with groups\n */\n isGrouped?: boolean;\n\n /**\n * Function called whenever the input value changes\n */\n onInputValueChange?: (value: string) => void;\n /**\n * This is the function that will be called when the user selects one of the \"options\" in the list.\n * The component will pass the selected \"item\" as an argument to the function..\n */\n onSelectItem: (item: ItemType) => void;\n /**\n * This is the function that will be called for each \"item\" passed in the `items` prop.\n * It receives the \"item\" and \"inputValue\" as arguments and returns a ReactNode.\n * The inputValue is passed in case you want to highlight the match on the render.\n */\n renderItem?: (item: ItemType, inputValue: string) => React.ReactNode;\n /**\n * When using objects as `items`, we recommend passing a function that tells Downshift how to extract a string\n * from those objetcs to be used as inputValue\n */\n itemToString?: (item: ItemType) => string;\n /**\n * If this is set to `true` the text input will be cleared after an item is selected\n * @default false\n */\n clearAfterSelect?: boolean;\n /**\n * This is the value will be passed to the `placeholder` prop of the input.\n * @default \"Search\"\n */\n placeholder?: string;\n /**\n * A message that will be shown when it is not possible to find any option that matches the input value\n * @default \"No matches\"\n */\n noMatchesMessage?: string;\n /**\n * Use this prop to get a ref to the input element of the component\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Use this prop to get a ref to the toggle button of the component\n */\n toggleRef?: React.Ref<HTMLButtonElement>;\n /**\n * Use this prop to get a ref to the list of items of the component\n */\n listRef?: React.Ref<HTMLUListElement>;\n /**\n * It sets the width of the list\n * @default \"auto\"\n */\n listWidth?: 'auto' | 'full';\n /**\n * It sets the max-height, in pixels, of the list\n * The default value is the height of 5 single line items\n * @default 180\n */\n listMaxHeight?: number;\n /**\n * Sets the list to show its loading state\n * @default false\n */\n isLoading?: boolean;\n /**\n * Boolean to control whether or not to render the suggestions box in a React Portal.\n * Rendering content inside a Portal allows the suggestions box to escape the bounds\n * of its parent while still being positioned correctly.\n * Defaults to `false`\n */\n usePortal?: boolean;\n}\n\nfunction _Autocomplete<ItemType>(\n props: AutocompleteProps<ItemType>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const {\n id,\n className,\n clearAfterSelect = false,\n defaultValue = '',\n items,\n onInputValueChange,\n onSelectItem,\n renderItem,\n itemToString = (item: ItemType) => (item as unknown) as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n noMatchesMessage = 'No matches found',\n placeholder = 'Search',\n inputRef,\n toggleRef,\n listRef,\n listWidth = 'auto',\n listMaxHeight = 180,\n isGrouped = false,\n isLoading = false,\n usePortal = false,\n testId = 'cf-autocomplete',\n } = props;\n\n type GroupType = GenericGroupType<ItemType>;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n const [inputValue, setInputValue] = useState(defaultValue);\n\n const handleInputValueChange = useCallback(\n (value) => {\n setInputValue(value);\n\n onInputValueChange?.(value);\n },\n [onInputValueChange],\n );\n\n const flattenItems = isUsingGroups(isGrouped, items)\n ? items.reduce(\n (acc: ItemType[], group: GroupType) => [...acc, ...group.options],\n [],\n )\n : items;\n\n const isShowingNoMatches = isUsingGroups(isGrouped, items)\n ? items.every((group: GroupType) => group.options.length === 0)\n : items.length === 0;\n\n const {\n getComboboxProps,\n getInputProps,\n getItemProps,\n getMenuProps,\n getToggleButtonProps,\n highlightedIndex,\n isOpen,\n toggleMenu,\n } = useCombobox({\n items: flattenItems,\n inputValue,\n itemToString,\n onInputValueChange: ({ inputValue }) => {\n handleInputValueChange(inputValue);\n },\n onStateChange: ({ type, selectedItem }) => {\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n if (selectedItem) {\n onSelectItem(selectedItem);\n }\n if (clearAfterSelect) {\n handleInputValueChange('');\n }\n break;\n default:\n break;\n }\n },\n });\n\n const {\n 'aria-labelledby': _labelledby,\n id: _inputId,\n ...inputProps\n } = getInputProps();\n const comboboxProps = getComboboxProps();\n const toggleProps = getToggleButtonProps();\n const menuProps = getMenuProps();\n let elementStartIndex = 0;\n\n return (\n <div\n data-test-id={testId}\n className={cx(styles.autocomplete, className)}\n ref={ref}\n >\n <Popover\n usePortal={usePortal}\n isOpen={isOpen}\n isFullWidth={listWidth === 'full'}\n renderOnlyWhenOpen={false}\n // This is necessary, otherwise the focus will change from the input to the Popover\n // and the user won't be able to type in the input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={false}\n id={menuProps.id}\n >\n <Popover.Trigger>\n <div {...comboboxProps} className={styles.combobox}>\n <TextInput\n {...inputProps}\n onFocus={() => {\n if (!isOpen) {\n toggleMenu();\n }\n }}\n id={id}\n isInvalid={isInvalid}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n ref={mergeRefs(inputProps.ref, inputRef)}\n testId=\"cf-autocomplete-input\"\n placeholder={placeholder}\n />\n <IconButton\n {...toggleProps}\n ref={mergeRefs(toggleProps.ref, toggleRef)}\n aria-label=\"toggle menu\"\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={\n inputValue ? (\n <CloseIcon aria-label=\"Clear\" variant=\"muted\" />\n ) : (\n <ChevronDownIcon aria-label=\"Show list\" variant=\"muted\" />\n )\n }\n onClick={() => {\n if (inputValue) {\n handleInputValueChange('');\n } else {\n toggleMenu();\n }\n }}\n isDisabled={isDisabled}\n size=\"small\"\n />\n </div>\n </Popover.Trigger>\n\n <Popover.Content\n {...menuProps}\n ref={mergeRefs(menuProps.ref, listRef)}\n className={styles.content}\n testId=\"cf-autocomplete-container\"\n >\n {isLoading &&\n [...Array(3)].map((_, index) => (\n <div key={index} className={cx(styles.item, styles.disabled)}>\n <ListItemLoadingState />\n </div>\n ))}\n\n {!isLoading && isShowingNoMatches && (\n <div className={styles.item}>\n <Subheading className={styles.noMatchesTitle}>\n {noMatchesMessage}\n </Subheading>\n </div>\n )}\n\n {!isLoading &&\n isUsingGroups(isGrouped, items) &&\n items.map((group: GroupType, index: number) => {\n if (group.options.length < 1) {\n return;\n }\n const render = (\n <div key={index}>\n <SectionHeading\n key={index}\n data-test-id=\"cf-autocomplete-grouptitle\"\n marginBottom=\"none\"\n className={styles.groupTitle}\n >\n {group.groupTitle}\n </SectionHeading>\n <AutocompleteItems<ItemType>\n items={group.options}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n elementStartIndex={elementStartIndex}\n />\n </div>\n );\n elementStartIndex += group.options.length;\n return render;\n })}\n\n {!isLoading &&\n !isUsingGroups(isGrouped, items) &&\n items.length > 0 && (\n <AutocompleteItems<ItemType>\n items={items}\n elementStartIndex={elementStartIndex}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n />\n )}\n </Popover.Content>\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <SkeletonContainer svgHeight={16}>\n <SkeletonBodyText numberOfLines={1} />\n </SkeletonContainer>\n );\n};\n\n// This is required to infer correct typings when differentiating groups and items\nfunction isUsingGroups<ItemType>(\n isGrouped: boolean,\n items: ItemType[] | GenericGroupType<ItemType>[],\n): items is GenericGroupType<ItemType>[] {\n return isGrouped;\n}\n\n/**\n * The Autocomplete is a component that will show a `TextInput` where a user can type any word which will be used\n * to filter a list of items. That list of filtered items will be shown to the user as possible options for the input.\n * Once one of the options is selected, that option becomes the value of the `TextInput`.\n */\nexport const Autocomplete = React.forwardRef(_Autocomplete) as <T>(\n props: ExpandProps<AutocompleteProps<T>> & {\n ref?: React.Ref<HTMLDivElement>;\n },\n) => ReturnType<typeof _Autocomplete>;\n","import React, { HTMLAttributes } from 'react';\nimport { cx } from 'emotion';\n\nimport { getStringMatch } from '@contentful/f36-utils';\nimport { Text } from '@contentful/f36-typography';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\n\ninterface AutocompleteItemsProps<ItemType> {\n items: ItemType[];\n elementStartIndex: number;\n highlightedIndex: number;\n getItemProps: (\n options: UseComboboxGetItemPropsOptions<ItemType>,\n ) => HTMLAttributes<HTMLLIElement>;\n renderItem: (item: ItemType, inputValue: string) => React.ReactNode;\n inputValue: string;\n listMaxHeight?: number;\n}\n\nexport function AutocompleteItems<ItemType>(\n props: AutocompleteItemsProps<ItemType>,\n) {\n const {\n items,\n elementStartIndex,\n highlightedIndex,\n getItemProps,\n renderItem,\n inputValue,\n listMaxHeight = 180,\n } = props;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n return (\n <ul className={styles.list} data-test-id=\"cf-autocomplete-list\">\n {items.map((item: ItemType, index: number) => {\n const itemIndex = elementStartIndex + index;\n const itemProps = getItemProps({ item, index: itemIndex });\n return (\n <Text\n {...itemProps}\n as=\"li\"\n key={itemIndex}\n className={cx([\n styles.item,\n highlightedIndex === itemIndex && styles.highlighted,\n ])}\n data-test-id={`cf-autocomplete-list-item-${itemIndex}`}\n >\n {renderItem ? (\n renderItem(item, inputValue)\n ) : typeof item === 'string' ? (\n <HighlightedItem item={item} inputValue={inputValue} />\n ) : (\n item\n )}\n </Text>\n );\n })}\n </ul>\n );\n}\n\nAutocompleteItems.displayName = 'AutocompleteItems';\n\nfunction HighlightedItem({\n item,\n inputValue,\n}: {\n item: string;\n inputValue: string;\n}) {\n const { before, match, after } = getStringMatch(item, inputValue);\n\n return (\n <>\n {before}\n <b>{match}</b>\n {after}\n </>\n );\n}\n\nHighlightedItem.displayName = 'HighlightedItem';\n","import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getAutocompleteStyles = (listMaxHeight: number) => ({\n autocomplete: css({\n position: 'relative',\n width: '100%',\n }),\n combobox: css({\n position: 'relative',\n }),\n toggleButton: css({\n position: 'absolute',\n top: '4px',\n right: '4px',\n zIndex: 1,\n padding: tokens.spacing2Xs,\n }),\n content: css({\n overflow: 'auto',\n maxHeight: `${listMaxHeight}px`,\n }),\n list: css({\n listStyle: 'none',\n padding: `${tokens.spacingXs} 0`,\n margin: 0,\n }),\n groupTitle: css({\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n lineHeight: tokens.lineHeightM,\n }),\n noMatchesTitle: css({\n color: tokens.gray500,\n margin: `${tokens.spacingM} 0 ${tokens.spacingM} 0`,\n }),\n item: css({\n display: 'block',\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n wordBreak: 'break-word',\n whiteSpace: 'break-spaces',\n cursor: 'pointer',\n hyphens: 'auto',\n\n '&:focus, &:hover': {\n backgroundColor: tokens.gray100,\n },\n '&:active': {\n backgroundColor: tokens.gray200,\n },\n }),\n disabled: css({\n opacity: 0.5,\n pointerEvents: 'none',\n }),\n highlighted: css({\n backgroundColor: tokens.gray100,\n }),\n});\n"],"names":["Autocomplete","AutocompleteProps","React","useCallback","useState","useCombobox","mergeRefs","CommonProps","ExpandProps","IconButton","TextInput","TextInputProps","CloseIcon","ChevronDownIcon","SkeletonContainer","SkeletonBodyText","Popover","Subheading","SectionHeading","AutocompleteItems","getAutocompleteStyles","GenericGroupType","groupTitle","options","ItemType","Pick","items","isGrouped","onInputValueChange","value","onSelectItem","item","renderItem","inputValue","ReactNode","itemToString","clearAfterSelect","placeholder","noMatchesMessage","inputRef","Ref","HTMLInputElement","toggleRef","HTMLButtonElement","listRef","HTMLUListElement","listWidth","listMaxHeight","isLoading","usePortal","_Autocomplete","props","ref","HTMLDivElement","id","className","defaultValue","isInvalid","isDisabled","isRequired","isReadOnly","testId","GroupType","styles","setInputValue","handleInputValueChange","flattenItems","isUsingGroups","reduce","acc","group","isShowingNoMatches","every","length","getComboboxProps","getInputProps","getItemProps","getMenuProps","getToggleButtonProps","highlightedIndex","isOpen","toggleMenu","onStateChange","type","selectedItem","stateChangeTypes","InputKeyDownEnter","ItemClick","_labelledby","_inputId","inputProps","comboboxProps","toggleProps","menuProps","elementStartIndex","autocomplete","combobox","toggleButton","content","Array","map","_","index","disabled","noMatchesTitle","render","ListItemLoadingState","forwardRef","T","ReturnType","HTMLAttributes","getStringMatch","Text","UseComboboxGetItemPropsOptions","AutocompleteItemsProps","HTMLLIElement","list","itemIndex","itemProps","highlighted","displayName","HighlightedItem","before","match","after","tokens","position","top","right","zIndex","padding","spacing2Xs","overflow","maxHeight","listStyle","spacingXs","margin","spacingM","lineHeight","lineHeightM","color","gray500","display","wordBreak","whiteSpace","cursor","hyphens","backgroundColor","gray100","gray200"],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGGO,KAAA,CAAMoB,yCAAqB,IAAI2B,aAAD,IAA4B,CAAjE;QACEqD,YAAY,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,UAAdA,CAAAA,CAAAA;YAAc,IAAA,EAAA,CAAA;YAAA,MAAA,EAAA,CAAA;QAAA,CAAA;QAIdC,QAAQ,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,UAAVA,CAAAA,CAAAA;YAAU,IAAA,EAAA,CAAA;YAAA,MAAA,EAAA,CAAA;QAAA,CAAA;QAGVE,YAAY,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,UAAA,CAAI,CAAlBA;YACE6B,QAAQ,EAAE,CADM;YAEhBC,GAAG,EAAE,CAFW;YAGhBC,KAAK,EAAE,CAHS;YAIhBC,MAAM,EAAE,CAJQ;YAKhBC,OAAO,EAAEL,0BAAM,CAACM,UAAhBD;QALgB,CAAJ;QAOdhC,OAAO,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,UAAA,CAAI,CAAbA;YACEkC,QAAQ,EAAE,CADC;YAEXC,SAAS,KAAK5F,aAAc,CAA5B4F,EAAAA;QAFW,CAAJ;QAITjB,IAAI,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,UAAA,CAAI,CAAVA;YACEkB,SAAS,EAAE,CADH;YAERJ,OAAO,KAAKL,0BAAM,CAACU,SAAU,CAAA,EAAA;YAC7BC,MAAM,EAAE,CAARA;QAHQ,CAAJ;QAKNxH,UAAU,EAAA,EAAE,AAAF,SAAE,AAAF,EAAE,CAAA,UAAA,CAAI,CAAhBA;YACEkH,OAAO,KAAKL,0BAAM,CAACU,SAAU,CAAA,CAAA,EAAGV,0BAAM,CAAC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src/index.ts","packages/components/autocomplete/src/Autocomplete.tsx","packages/components/autocomplete/src/AutocompleteItems.tsx","packages/components/autocomplete/src/Autocomplete.styles.ts"],"sourcesContent":["export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n","import React, { useCallback, useState } from 'react';\nimport { cx } from 'emotion';\nimport { useCombobox } from 'downshift';\n\nimport { mergeRefs } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { IconButton } from '@contentful/f36-button';\nimport { TextInput } from '@contentful/f36-forms';\nimport type { TextInputProps } from '@contentful/f36-forms';\nimport { CloseIcon, ChevronDownIcon } from '@contentful/f36-icons';\nimport { SkeletonContainer, SkeletonBodyText } from '@contentful/f36-skeleton';\nimport { Popover } from '@contentful/f36-popover';\nimport { Subheading, SectionHeading } from '@contentful/f36-typography';\n\nimport { AutocompleteItems } from './AutocompleteItems';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\n\nexport interface GenericGroupType<ItemType> {\n groupTitle: string;\n options: ItemType[];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface AutocompleteProps<ItemType>\n extends CommonProps,\n Pick<\n TextInputProps,\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'isRequired'\n | 'id'\n | 'defaultValue'\n > {\n /**\n * It’s an array of data to be used as \"options\" by the autocomplete component.\n * This can either be a plain list of items or a list of groups of items.\n */\n items: ItemType[] | GenericGroupType<ItemType>[];\n\n /**\n * Tells if the item is a object with groups\n */\n isGrouped?: boolean;\n\n /**\n * Function called whenever the input value changes\n */\n onInputValueChange?: (value: string) => void;\n /**\n * This is the function that will be called when the user selects one of the \"options\" in the list.\n * The component will pass the selected \"item\" as an argument to the function..\n */\n onSelectItem: (item: ItemType) => void;\n /**\n * This is the function that will be called for each \"item\" passed in the `items` prop.\n * It receives the \"item\" and \"inputValue\" as arguments and returns a ReactNode.\n * The inputValue is passed in case you want to highlight the match on the render.\n */\n renderItem?: (item: ItemType, inputValue: string) => React.ReactNode;\n /**\n * When using objects as `items`, we recommend passing a function that tells Downshift how to extract a string\n * from those objetcs to be used as inputValue\n */\n itemToString?: (item: ItemType) => string;\n /**\n * If this is set to `true` the text input will be cleared after an item is selected\n * @default false\n */\n clearAfterSelect?: boolean;\n /**\n * This is the value will be passed to the `placeholder` prop of the input.\n * @default \"Search\"\n */\n placeholder?: string;\n /**\n * A message that will be shown when it is not possible to find any option that matches the input value\n * @default \"No matches\"\n */\n noMatchesMessage?: string;\n /**\n * Use this prop to get a ref to the input element of the component\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Use this prop to get a ref to the toggle button of the component\n */\n toggleRef?: React.Ref<HTMLButtonElement>;\n /**\n * Use this prop to get a ref to the list of items of the component\n */\n listRef?: React.Ref<HTMLUListElement>;\n /**\n * It sets the width of the list\n * @default \"auto\"\n */\n listWidth?: 'auto' | 'full';\n /**\n * It sets the max-height, in pixels, of the list\n * The default value is the height of 5 single line items\n * @default 180\n */\n listMaxHeight?: number;\n /**\n * Sets the list to show its loading state\n * @default false\n */\n isLoading?: boolean;\n /**\n * Boolean to control whether or not to render the suggestions box in a React Portal.\n * Rendering content inside a Portal allows the suggestions box to escape the bounds\n * of its parent while still being positioned correctly.\n * Defaults to `false`\n */\n usePortal?: boolean;\n}\n\nfunction _Autocomplete<ItemType>(\n props: AutocompleteProps<ItemType>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const {\n id,\n className,\n clearAfterSelect = false,\n defaultValue = '',\n items,\n onInputValueChange,\n onSelectItem,\n renderItem,\n itemToString = (item: ItemType) => (item as unknown) as string,\n isInvalid,\n isDisabled,\n isRequired,\n isReadOnly,\n noMatchesMessage = 'No matches found',\n placeholder = 'Search',\n inputRef,\n toggleRef,\n listRef,\n listWidth = 'auto',\n listMaxHeight = 180,\n isGrouped = false,\n isLoading = false,\n usePortal = false,\n testId = 'cf-autocomplete',\n } = props;\n\n type GroupType = GenericGroupType<ItemType>;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n const [inputValue, setInputValue] = useState(defaultValue);\n\n const handleInputValueChange = useCallback(\n (value: string) => {\n setInputValue(value);\n\n onInputValueChange?.(value);\n },\n [onInputValueChange],\n );\n\n // Handle manually to avoid a jumping cursor, see https://github.com/downshift-js/downshift/issues/1108#issuecomment-842407759\n const handleNativeChangeEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const value = event.target.value;\n handleInputValueChange(value);\n },\n [handleInputValueChange],\n );\n\n const flattenItems = isUsingGroups(isGrouped, items)\n ? items.reduce(\n (acc: ItemType[], group: GroupType) => [...acc, ...group.options],\n [],\n )\n : items;\n\n const isShowingNoMatches = isUsingGroups(isGrouped, items)\n ? items.every((group: GroupType) => group.options.length === 0)\n : items.length === 0;\n\n const {\n getComboboxProps,\n getInputProps,\n getItemProps,\n getMenuProps,\n getToggleButtonProps,\n highlightedIndex,\n isOpen,\n toggleMenu,\n } = useCombobox({\n items: flattenItems,\n inputValue,\n itemToString,\n onInputValueChange: ({ type, inputValue }) => {\n if (type !== '__input_change__') {\n handleInputValueChange(inputValue);\n }\n },\n onStateChange: ({ type, selectedItem }) => {\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n if (selectedItem) {\n onSelectItem(selectedItem);\n }\n if (clearAfterSelect) {\n handleInputValueChange('');\n }\n break;\n default:\n break;\n }\n },\n });\n\n const {\n 'aria-labelledby': _labelledby,\n id: _inputId,\n ...inputProps\n } = getInputProps();\n const comboboxProps = getComboboxProps();\n const toggleProps = getToggleButtonProps();\n const menuProps = getMenuProps();\n let elementStartIndex = 0;\n\n return (\n <div\n data-test-id={testId}\n className={cx(styles.autocomplete, className)}\n ref={ref}\n >\n <Popover\n usePortal={usePortal}\n isOpen={isOpen}\n isFullWidth={listWidth === 'full'}\n renderOnlyWhenOpen={false}\n // This is necessary, otherwise the focus will change from the input to the Popover\n // and the user won't be able to type in the input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={false}\n id={menuProps.id}\n >\n <Popover.Trigger>\n <div {...comboboxProps} className={styles.combobox}>\n <TextInput\n {...inputProps}\n onFocus={() => {\n if (!isOpen) {\n toggleMenu();\n }\n }}\n id={id}\n isInvalid={isInvalid}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isReadOnly={isReadOnly}\n ref={mergeRefs(inputProps.ref, inputRef)}\n testId=\"cf-autocomplete-input\"\n placeholder={placeholder}\n onChange={(event) => {\n inputProps.onChange(event);\n handleNativeChangeEvent(event);\n }}\n />\n <IconButton\n {...toggleProps}\n ref={mergeRefs(toggleProps.ref, toggleRef)}\n aria-label=\"toggle menu\"\n className={styles.toggleButton}\n variant=\"transparent\"\n icon={\n inputValue ? (\n <CloseIcon aria-label=\"Clear\" variant=\"muted\" />\n ) : (\n <ChevronDownIcon aria-label=\"Show list\" variant=\"muted\" />\n )\n }\n onClick={() => {\n if (inputValue) {\n handleInputValueChange('');\n } else {\n toggleMenu();\n }\n }}\n isDisabled={isDisabled}\n size=\"small\"\n />\n </div>\n </Popover.Trigger>\n\n <Popover.Content\n {...menuProps}\n ref={mergeRefs(menuProps.ref, listRef)}\n className={styles.content}\n testId=\"cf-autocomplete-container\"\n >\n {isLoading &&\n [...Array(3)].map((_, index) => (\n <div key={index} className={cx(styles.item, styles.disabled)}>\n <ListItemLoadingState />\n </div>\n ))}\n\n {!isLoading && isShowingNoMatches && (\n <div className={styles.item}>\n <Subheading className={styles.noMatchesTitle}>\n {noMatchesMessage}\n </Subheading>\n </div>\n )}\n\n {!isLoading &&\n isUsingGroups(isGrouped, items) &&\n items.map((group: GroupType, index: number) => {\n if (group.options.length < 1) {\n return;\n }\n const render = (\n <div key={index}>\n <SectionHeading\n key={index}\n data-test-id=\"cf-autocomplete-grouptitle\"\n marginBottom=\"none\"\n className={styles.groupTitle}\n >\n {group.groupTitle}\n </SectionHeading>\n <AutocompleteItems<ItemType>\n items={group.options}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n elementStartIndex={elementStartIndex}\n />\n </div>\n );\n elementStartIndex += group.options.length;\n return render;\n })}\n\n {!isLoading &&\n !isUsingGroups(isGrouped, items) &&\n items.length > 0 && (\n <AutocompleteItems<ItemType>\n items={items}\n elementStartIndex={elementStartIndex}\n highlightedIndex={highlightedIndex}\n getItemProps={getItemProps}\n renderItem={renderItem}\n inputValue={inputValue}\n />\n )}\n </Popover.Content>\n </Popover>\n </div>\n );\n}\n\nconst ListItemLoadingState = () => {\n return (\n <SkeletonContainer svgHeight={16}>\n <SkeletonBodyText numberOfLines={1} />\n </SkeletonContainer>\n );\n};\n\n// This is required to infer correct typings when differentiating groups and items\nfunction isUsingGroups<ItemType>(\n isGrouped: boolean,\n items: ItemType[] | GenericGroupType<ItemType>[],\n): items is GenericGroupType<ItemType>[] {\n return isGrouped;\n}\n\n/**\n * The Autocomplete is a component that will show a `TextInput` where a user can type any word which will be used\n * to filter a list of items. That list of filtered items will be shown to the user as possible options for the input.\n * Once one of the options is selected, that option becomes the value of the `TextInput`.\n */\nexport const Autocomplete = React.forwardRef(_Autocomplete) as <T>(\n props: ExpandProps<AutocompleteProps<T>> & {\n ref?: React.Ref<HTMLDivElement>;\n },\n) => ReturnType<typeof _Autocomplete>;\n","import React, { HTMLAttributes } from 'react';\nimport { cx } from 'emotion';\n\nimport { getStringMatch } from '@contentful/f36-utils';\nimport { Text } from '@contentful/f36-typography';\nimport { getAutocompleteStyles } from './Autocomplete.styles';\nimport type { UseComboboxGetItemPropsOptions } from 'downshift';\n\ninterface AutocompleteItemsProps<ItemType> {\n items: ItemType[];\n elementStartIndex: number;\n highlightedIndex: number;\n getItemProps: (\n options: UseComboboxGetItemPropsOptions<ItemType>,\n ) => HTMLAttributes<HTMLLIElement>;\n renderItem: (item: ItemType, inputValue: string) => React.ReactNode;\n inputValue: string;\n listMaxHeight?: number;\n}\n\nexport function AutocompleteItems<ItemType>(\n props: AutocompleteItemsProps<ItemType>,\n) {\n const {\n items,\n elementStartIndex,\n highlightedIndex,\n getItemProps,\n renderItem,\n inputValue,\n listMaxHeight = 180,\n } = props;\n\n const styles = getAutocompleteStyles(listMaxHeight);\n\n return (\n <ul className={styles.list} data-test-id=\"cf-autocomplete-list\">\n {items.map((item: ItemType, index: number) => {\n const itemIndex = elementStartIndex + index;\n const itemProps = getItemProps({ item, index: itemIndex });\n return (\n <Text\n {...itemProps}\n as=\"li\"\n key={itemIndex}\n className={cx([\n styles.item,\n highlightedIndex === itemIndex && styles.highlighted,\n ])}\n data-test-id={`cf-autocomplete-list-item-${itemIndex}`}\n >\n {renderItem ? (\n renderItem(item, inputValue)\n ) : typeof item === 'string' ? (\n <HighlightedItem item={item} inputValue={inputValue} />\n ) : (\n item\n )}\n </Text>\n );\n })}\n </ul>\n );\n}\n\nAutocompleteItems.displayName = 'AutocompleteItems';\n\nfunction HighlightedItem({\n item,\n inputValue,\n}: {\n item: string;\n inputValue: string;\n}) {\n const { before, match, after } = getStringMatch(item, inputValue);\n\n return (\n <>\n {before}\n <b>{match}</b>\n {after}\n </>\n );\n}\n\nHighlightedItem.displayName = 'HighlightedItem';\n","import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getAutocompleteStyles = (listMaxHeight: number) => ({\n autocomplete: css({\n position: 'relative',\n width: '100%',\n }),\n combobox: css({\n position: 'relative',\n }),\n toggleButton: css({\n position: 'absolute',\n top: '4px',\n right: '4px',\n zIndex: 1,\n padding: tokens.spacing2Xs,\n }),\n content: css({\n overflow: 'auto',\n maxHeight: `${listMaxHeight}px`,\n }),\n list: css({\n listStyle: 'none',\n padding: `${tokens.spacingXs} 0`,\n margin: 0,\n }),\n groupTitle: css({\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n lineHeight: tokens.lineHeightM,\n }),\n noMatchesTitle: css({\n color: tokens.gray500,\n margin: `${tokens.spacingM} 0 ${tokens.spacingM} 0`,\n }),\n item: css({\n display: 'block',\n padding: `${tokens.spacingXs} ${tokens.spacingM}`,\n wordBreak: 'break-word',\n whiteSpace: 'break-spaces',\n cursor: 'pointer',\n hyphens: 'auto',\n\n '&:focus, &:hover': {\n backgroundColor: tokens.gray100,\n },\n '&:active': {\n backgroundColor: tokens.gray200,\n },\n }),\n disabled: css({\n opacity: 0.5,\n pointerEvents: 'none',\n }),\n highlighted: css({\n backgroundColor: tokens.gray100,\n }),\n});\n"],"names":["Autocomplete","AutocompleteProps","React","useCallback","useState","useCombobox","mergeRefs","CommonProps","ExpandProps","IconButton","TextInput","TextInputProps","CloseIcon","ChevronDownIcon","SkeletonContainer","SkeletonBodyText","Popover","Subheading","SectionHeading","AutocompleteItems","getAutocompleteStyles","GenericGroupType","groupTitle","options","ItemType","Pick","items","isGrouped","onInputValueChange","value","onSelectItem","item","renderItem","inputValue","ReactNode","itemToString","clearAfterSelect","placeholder","noMatchesMessage","inputRef","Ref","HTMLInputElement","toggleRef","HTMLButtonElement","listRef","HTMLUListElement","listWidth","listMaxHeight","isLoading","usePortal","_Autocomplete","props","ref","HTMLDivElement","id","className","defaultValue","isInvalid","isDisabled","isRequired","isReadOnly","testId","GroupType","styles","setInputValue","handleInputValueChange","handleNativeChangeEvent","event","ChangeEvent","HTMLTextAreaElement","target","flattenItems","isUsingGroups","reduce","acc","group","isShowingNoMatches","every","length","getComboboxProps","getInputProps","getItemProps","getMenuProps","getToggleButtonProps","highlightedIndex","isOpen","toggleMenu","type","onStateChange","selectedItem","stateChangeTypes","InputKeyDownEnter","ItemClick","_labelledby","_inputId","inputProps","comboboxProps","toggleProps","menuProps","elementStartIndex","autocomplete","combobox","onChange","toggleButton","content","Array","map","_","index","disabled","noMatchesTitle","render","ListItemLoadingState","forwardRef","T","ReturnType","HTMLAttributes","getStringMatch","Text","UseComboboxGetItemPropsOptions","AutocompleteItemsProps","HTMLLIElement","list","itemIndex","itemProps","highlighted","displayName","HighlightedItem","before","match","after","tokens","position","top","right","zIndex","padding","spacing2Xs","overflow","maxHeight","listStyle","spacingXs","margin","spacingM","lineHeight","lineHeightM","color","gray500","display","wordBreak","whiteSpace","cursor","hyphens","backgroundColor","gray100","gray200"],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AEiBA,2BAAkC,QAAQ;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,QAAQ,EAAE,CAAC;CACrB;AAGD,mCAAmC,QAAQ,CACzC,SAAQ,WAAW,EACjB,IAAI,CACF,cAAc,EACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,IAAI,GACJ,cAAc,CACjB;IACH;;;OAGG;IACH,KAAK,EAAE,QAAQ,EAAE,GAAG,iBAAiB,QAAQ,CAAC,EAAE,CAAC;IAEjD;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,SAAS,CAAC;IACrE;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,MAAM,CAAC;IAC1C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACvC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,iBAAiB,CAAC,C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CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACvC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACzC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,+BAAuB,QAAQ,EAC7B,KAAK,EAAE,kBAAkB,QAAQ,CAAC,EAClC,GAAG,EAAE,MAAM,GAAG,CAAC,cAAc,CAAC,eAiP/B;AAkBD;;;;GAIG;AACH,OAAO,MAAM;UAEH,MAAM,GAAG,CAAC,cAAc,CAAC;MAE9B,WAAW,oBAAoB,CAAC,CAAC","sources":["packages/components/autocomplete/src/src/Autocomplete.styles.ts","packages/components/autocomplete/src/src/AutocompleteItems.tsx","packages/components/autocomplete/src/src/Autocomplete.tsx","packages/components/autocomplete/src/src/index.ts","packages/components/autocomplete/src/index.ts"],"sourcesContent":[null,null,null,null,"export { Autocomplete } from './Autocomplete';\nexport type { AutocompleteProps } from './Autocomplete';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/f36-autocomplete",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.11",
|
|
4
4
|
"description": "Forma 36: Autocomplete component",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "parcel build"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@babel/runtime": "^7.6.2",
|
|
10
|
-
"@contentful/f36-button": "^4.3.
|
|
11
|
-
"@contentful/f36-core": "^4.3.
|
|
12
|
-
"@contentful/f36-forms": "^4.3.
|
|
13
|
-
"@contentful/f36-icons": "^4.
|
|
14
|
-
"@contentful/f36-popover": "^4.
|
|
15
|
-
"@contentful/f36-skeleton": "^4.
|
|
10
|
+
"@contentful/f36-button": "^4.3.11",
|
|
11
|
+
"@contentful/f36-core": "^4.3.11",
|
|
12
|
+
"@contentful/f36-forms": "^4.3.11",
|
|
13
|
+
"@contentful/f36-icons": "^4.3.11",
|
|
14
|
+
"@contentful/f36-popover": "^4.3.11",
|
|
15
|
+
"@contentful/f36-skeleton": "^4.3.11",
|
|
16
16
|
"@contentful/f36-tokens": "^4.0.1",
|
|
17
|
-
"@contentful/f36-typography": "^4.
|
|
18
|
-
"@contentful/f36-utils": "^4.
|
|
17
|
+
"@contentful/f36-typography": "^4.3.11",
|
|
18
|
+
"@contentful/f36-utils": "^4.3.11",
|
|
19
19
|
"downshift": "^6.1.7",
|
|
20
20
|
"emotion": "^10.0.17"
|
|
21
21
|
},
|
|
@@ -38,6 +38,5 @@
|
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
|
-
}
|
|
42
|
-
"gitHead": "a5e41bc0a1c0259bd2ab2e55c80c6ae0e33ec254"
|
|
41
|
+
}
|
|
43
42
|
}
|
package/LICENSE.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2018-present Contentful GmbH
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|