ag-grid-autocomplete 1.0.0 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -34
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +13 -7
- package/types/ag-grid-autocomplete.d.ts +44 -25
- package/types/index.d.ts +1 -0
- package/types/src/autocomplete-input.d.ts +40 -0
- package/types/types.d.ts +18 -9
package/README.md
CHANGED
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
A powerful autocomplete cell editor for [ag-Grid](https://github.com/ag-grid/ag-grid) that enhances data selection with typeahead functionality, grouping capabilities, and flexible data retrieval.
|
|
9
9
|
|
|
10
|
-
> **Note:** This package is a direct, drop-in replacement for `ag-grid-autocomplete-editor` with enhanced compatibility for AG Grid v23-
|
|
10
|
+
> **Note:** This package is a direct, drop-in replacement for `ag-grid-autocomplete-editor` with enhanced compatibility for AG Grid v23-v35. All imports, APIs, and configurations work exactly the same - just update your package name!
|
|
11
|
+
>
|
|
12
|
+
> **v2 and AG Grid v33:** Version 2 of this library was released to support AG Grid v33+, which requires the `ag-grid-community` package (the modular `@ag-grid-community/*` packages were discontinued after v32). Choose your path:
|
|
13
|
+
>
|
|
14
|
+
> - **v2** — requires `ag-grid-community` package (supports AG Grid v23-v35+)
|
|
15
|
+
> - **v1** — requires `@ag-grid-community/core` package (supports AG Grid v23-v32)
|
|
16
|
+
>
|
|
17
|
+
> See the [official AG Grid migration guide](https://ag-grid.com/javascript-data-grid/upgrading-to-ag-grid-33/) for details on the package changes.
|
|
11
18
|
|
|
12
19
|
## Why ag-grid-autocomplete?
|
|
13
20
|
|
|
@@ -17,7 +24,7 @@ Data grids often struggle with selection interfaces for large datasets. Traditio
|
|
|
17
24
|
- Support for grouped options with visual hierarchy
|
|
18
25
|
- Local and remote data source flexibility
|
|
19
26
|
- Keyboard navigation and accessibility features
|
|
20
|
-
- Full compatibility with all AG Grid versions from v23 to
|
|
27
|
+
- Full compatibility with all AG Grid versions from v23 to v35
|
|
21
28
|
|
|
22
29
|
## Installation
|
|
23
30
|
|
|
@@ -36,12 +43,12 @@ Then update your imports:
|
|
|
36
43
|
|
|
37
44
|
```js
|
|
38
45
|
// Old import
|
|
39
|
-
import { AutocompleteSelectCellEditor } from 'ag-grid-autocomplete-editor'
|
|
40
|
-
import 'ag-grid-autocomplete-editor/dist/main.css'
|
|
46
|
+
import { AutocompleteSelectCellEditor } from 'ag-grid-autocomplete-editor'
|
|
47
|
+
import 'ag-grid-autocomplete-editor/dist/main.css'
|
|
41
48
|
|
|
42
49
|
// New import
|
|
43
|
-
import { AutocompleteSelectCellEditor } from 'ag-grid-autocomplete'
|
|
44
|
-
import 'ag-grid-autocomplete/dist/main.css'
|
|
50
|
+
import { AutocompleteSelectCellEditor } from 'ag-grid-autocomplete'
|
|
51
|
+
import 'ag-grid-autocomplete/dist/main.css'
|
|
45
52
|
```
|
|
46
53
|
|
|
47
54
|
## Key Features
|
|
@@ -50,7 +57,7 @@ import 'ag-grid-autocomplete/dist/main.css';
|
|
|
50
57
|
- **Remote Data** - Fetch options from APIs with built-in debouncing
|
|
51
58
|
- **Grouped Options** - Organize related choices with intuitive grouping
|
|
52
59
|
- **Free Text Support** - Allow users to enter custom values when needed
|
|
53
|
-
- **Broad Compatibility** - Works with AG Grid v23 through
|
|
60
|
+
- **Broad Compatibility** - Works with AG Grid v23 through v35
|
|
54
61
|
|
|
55
62
|
## Usage Examples
|
|
56
63
|
|
|
@@ -97,10 +104,10 @@ import 'ag-grid-autocomplete/dist/main.css';
|
|
|
97
104
|
fetch(`https://restcountries.com/v3.1/name/${match}`)
|
|
98
105
|
.then(response => response.json())
|
|
99
106
|
.then(data => {
|
|
100
|
-
const items = data.map(country => ({
|
|
101
|
-
value: country.cca3,
|
|
107
|
+
const items = data.map(country => ({
|
|
108
|
+
value: country.cca3,
|
|
102
109
|
label: country.name.common,
|
|
103
|
-
group: country.region
|
|
110
|
+
group: country.region
|
|
104
111
|
}));
|
|
105
112
|
update(items);
|
|
106
113
|
})
|
|
@@ -150,37 +157,37 @@ import 'ag-grid-autocomplete/dist/main.css';
|
|
|
150
157
|
|
|
151
158
|
### Cell Editor Parameters
|
|
152
159
|
|
|
153
|
-
| Parameter
|
|
154
|
-
|
|
155
|
-
| `selectData`
|
|
156
|
-
| `placeholder`
|
|
157
|
-
| `required`
|
|
158
|
-
| `autocomplete` | Object
|
|
160
|
+
| Parameter | Type | Description |
|
|
161
|
+
| -------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
|
|
162
|
+
| `selectData` | `Array` or `fn(params: IAutocompleteSelectCellEditorParams)` | Data source for autocomplete suggestions with format `{value: string, label: string, group?: string}` |
|
|
163
|
+
| `placeholder` | String | Input field placeholder text |
|
|
164
|
+
| `required` | `boolean` | Whether to cancel changes if no selection made (default: `false`) |
|
|
165
|
+
| `autocomplete` | Object | Configuration for the autocomplete behavior (see below) |
|
|
159
166
|
|
|
160
167
|
### Autocomplete Options
|
|
161
168
|
|
|
162
|
-
| Option
|
|
163
|
-
|
|
164
|
-
| `className`
|
|
165
|
-
| `minLength`
|
|
166
|
-
| `showOnFocus`
|
|
167
|
-
| `emptyMsg`
|
|
168
|
-
| `strict`
|
|
169
|
-
| `autoselectfirst`
|
|
170
|
-
| `debounceWaitMs`
|
|
171
|
-
| `onFreeTextSelect` | Function
|
|
169
|
+
| Option | Type | Default | Description |
|
|
170
|
+
| ------------------ | --------- | ------------------------------- | --------------------------------------------------------------------------- |
|
|
171
|
+
| `className` | `string` | `'ag-cell-editor-autocomplete'` | CSS class for the autocomplete dropdown |
|
|
172
|
+
| `minLength` | `number` | `1` | Minimum character length to trigger suggestions |
|
|
173
|
+
| `showOnFocus` | `boolean` | `false` | Show suggestions when input is focused |
|
|
174
|
+
| `emptyMsg` | `string` | `'None'` | Message when no results match |
|
|
175
|
+
| `strict` | `boolean` | `true` | Only allow selection from the dropdown |
|
|
176
|
+
| `autoselectfirst` | `boolean` | `true` | Auto-select first item in dropdown |
|
|
177
|
+
| `debounceWaitMs` | `number` | `200` | Debounce time for fetch requests |
|
|
178
|
+
| `onFreeTextSelect` | Function | - | Called when user selects text not in suggestions (requires `strict: false`) |
|
|
172
179
|
|
|
173
180
|
### Custom Rendering Functions
|
|
174
181
|
|
|
175
182
|
The following functions can be customized for advanced control:
|
|
176
183
|
|
|
177
|
-
| Function
|
|
178
|
-
|
|
179
|
-
| `render`
|
|
180
|
-
| `renderGroup` | `(cellEditor, groupName)`
|
|
181
|
-
| `onSelect`
|
|
182
|
-
| `fetch`
|
|
183
|
-
| `customize`
|
|
184
|
+
| Function | Parameters | Description |
|
|
185
|
+
| ------------- | ------------------------------------------------------ | ------------------------------------------------------- |
|
|
186
|
+
| `render` | `(cellEditor, item, currentValue)` | Customize rendering of each suggestion |
|
|
187
|
+
| `renderGroup` | `(cellEditor, groupName)` | Customize rendering of group headers |
|
|
188
|
+
| `onSelect` | `(cellEditor, item)` | Called when an item is selected |
|
|
189
|
+
| `fetch` | `(cellEditor, text, update)` | Custom function to retrieve and filter suggestions |
|
|
190
|
+
| `customize` | `(cellEditor, input, inputRect, container, maxHeight)` | Customize autocomplete dropdown position and appearance |
|
|
184
191
|
|
|
185
192
|
```js
|
|
186
193
|
cellEditorParams: {
|
|
@@ -211,4 +218,4 @@ cellEditorParams: {
|
|
|
211
218
|
|
|
212
219
|
## License
|
|
213
220
|
|
|
214
|
-
MIT
|
|
221
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@ag-grid-community/core"));else if("function"==typeof define&&define.amd)define(["@ag-grid-community/core"],t);else{var n="object"==typeof exports?t(require("@ag-grid-community/core")):t(e["@ag-grid-community/core"]);for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(self,(e=>(()=>{"use strict";var t={104:(e,t,n)=>{n.r(t)},151:t=>{t.exports=e}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var r=n[e]={exports:{}};return t[e](r,r.exports,i),r.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};i.r(o),i.d(o,{AutocompleteSelectCellEditor:()=>w,default:()=>O});var r=i(151);class s{constructor(){this.version=24}isEnableCellEditingOnBackspace(){return!0}}class c{constructor(e){this.gridOptionsWrapper=e,this.version="function"==typeof this.gridOptionsWrapper.isEnableCellEditingOnBackspace?28:27}isEnableCellEditingOnBackspace(){return this.version<28||this.gridOptionsWrapper.isEnableCellEditingOnBackspace()}}class a{constructor(e){this.gridOptionsService=e,this.version=29}isEnableCellEditingOnBackspace(){return this.gridOptionsService.is("enableCellEditingOnBackspace")}}class u{constructor(e){this.gridOptionsService=e,this.version=31}isEnableCellEditingOnBackspace(){return this.gridOptionsService.get("enableCellEditingOnBackspace")}}function l(e){const t=document.createElement("div");return t.textContent=e,t.className="group",t}function d(e){const t=document.createElement("div");return t.textContent=e.label||"",t}function p(e,t,n,i,o=d,r=l){const s=document.createDocumentFragment(),c=[];let a="#9?$";for(const s of e){if(s.group&&s.group!==a){a=s.group;const e=r(s.group,n);c.push(e)}const e=o(s,n);e.addEventListener("click",(e=>i(s,e))),s===t&&e.classList.add("selected"),c.push(e)}return s.append(...c),s}function f(e){let t=e;return[()=>t,e=>(t=e,t)]}const g="input",h=new Set([38,13,27,39,37,16,17,18,20,91,9]),v=2;function m(e){const[t,n]=f(e.input.ownerDocument||globalThis.document),[i,o]=f([]),[r,s]=f(""),[c,a]=f(void 0),[u,l]=f(0),[d,m]=f(void 0),{strict:y,autoselectfirst:E,onFreeTextSelect:b,minLength:S=v,showOnFocus:w,input:O,className:x,customize:C,emptyMsg:T,render:L,renderGroup:A}=e,k=e.debounceWaitMs||0,D=S,I=document.createElement("div"),M=I.style;I.className=`autocomplete ${x||""}`,M.position="fixed";const N=()=>{l(u()+1)};function B(){const e=d();void 0!==e&&(globalThis.clearTimeout(e),m(void 0))}function P(){return!!I.parentNode}function K(){N(),o([]),s(""),a(void 0),I&&I.remove()}function W(t,n){n.preventDefault(),n.stopPropagation(),e.onSelect(t,O,n),K()}function $(){!function(e){for(;e.firstChild;)e.firstChild.remove()}(I);const e=i(),o=p(e,c(),r(),W,L,A);if(I.append(o),0===e.length&&y){if(!T)return void K();{const e=document.createElement("div");e.className="empty",e.textContent=T,I.append(e),a(void 0)}}n(O.ownerDocument||globalThis.document),I.parentNode||t().body.append(I),function(){if(P()){const e=t();M.height="auto",M.width=`${O.offsetWidth}px`;const n=O.getBoundingClientRect(),i=n.top+O.offsetHeight;let o=e.defaultView.innerHeight-i;o<0&&(o=0),M.top=`${i}px`,M.bottom="",M.left=`${n.left}px`,M.maxHeight=`${o}px`,C&&C(O,n,I,o)}}(),function(){let e=I.querySelector(".selected");if(e){const t=e.previousElementSibling;if(t&&null===t.previousElementSibling&&t.className.includes("group")&&(e=t),e.offsetTop<I.scrollTop)I.scrollTop=e.offsetTop;else{const t=e.offsetTop+e.offsetHeight,n=I.scrollTop+I.offsetHeight;t>n&&(I.scrollTop+=t-n)}}}()}function q(){P()&&$()}function F(){q()}function H(e){e.target===I?e.preventDefault():q()}function j(t){N();const{value:n}=O;n.length>=D||1===t?(B(),m(function(t){const n=u(),i=0===t?k:0,{value:r}=O,c=e=>{u()===n&&e&&(o(e),s(r),a(e.length>0&&E?e[0]:void 0),$())};return globalThis.setTimeout((()=>{e.fetch(r,c,t)}),i)}(t))):K()}function z(e){const t=e.which||e.keyCode||0;h.has(t)||40===t&&P()||j(0)}function G(t){const n=t.which||t.keyCode||0;if(38===n||40===n||27===n||13===n||9===n){if(t.preventDefault(),P()&&t.stopPropagation(),38===n||40===n||27===n)return void(27===n?(e.onSelect(void 0,O,t),K()):function(e){if(P()&&i().length>0){switch(e){case 38:!function(){const e=i(),t=c();if(0!==e.length)if(void 0!==t&&t!==e[0]){for(let n=e.length-1;n>0;n-=1)if(t===e[n]||1===n)return void a(e[n-1])}else a(e.at(-1));else a(void 0)}();break;case 40:!function(){const e=i(),t=c();if(0!==e.length)if(void 0!==t&&t!==e.at(-1)){for(let n=0;n<e.length-1;n+=1)if(t===e[n])return void a(e[n+1])}else a(e[0]);else a(void 0)}()}$()}}(n));13!==n&&9!==n||function(t){const n=c();if(y)e.onSelect(n,O,t);else{const i={label:O.value};if(n)return void e.onSelect(n,O,t);b&&b(i,O),e.onSelect(i,O,t)}K()}(t)}}function V(){w&&j(1)}function R(e){e.preventDefault(),e.stopPropagation(),setTimeout((()=>{t().activeElement!==O&&K()}),200)}return function(){const e=t();O.addEventListener("keydown",G),O.addEventListener(g,z),O.addEventListener("focusout",R),O.addEventListener("focus",V),e.addEventListener("resize",F),e.addEventListener("scroll",H,!0)}(),{destroy:function(){!function(){const e=t();O.removeEventListener("focus",V),O.removeEventListener("keydown",G),O.removeEventListener(g,z),O.removeEventListener("focusout",R),e.removeEventListener("resize",F),e.removeEventListener("scroll",H,!0)}(),B(),K(),N()}}}i(104);const y="Backspace",E="Delete",b=new Set([8,46,13,9,38,40]),S=new Set([y,E,"Enter","Tab","ArrowUp","ArrowDown"]);class w extends r.PopupComponent{static getSelectData(e){return"function"==typeof e.selectData?e.selectData(e):Array.isArray(e.selectData)?e.selectData:[]}static getDefaultAutocompleteSettings(e){return{showOnFocus:!1,render(e,t,n){const i=document.createElement("div"),o=(n??"").replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),r=new RegExp(o,"gi"),s=document.createElement("span");s.innerHTML=t.label.replace(r,(function(e){return`<strong>${e}</strong>`})),i.append(s);const c=n=>{e.currentItem=t,n.stopPropagation()};return"addManagedListeners"in e?e.addManagedListeners(i,{mousedown:c}):e.addManagedListener(i,"mousedown",c),i},renderGroup(e,t){const n=document.createElement("div");return n.textContent=t,n.className="group",n},className:"ag-cell-editor-autocomplete",minLength:1,emptyMsg:"None",strict:!0,autoselectfirst:!0,onFreeTextSelect(){},onSelect(e,t){e.currentItem=t},fetch:(t,n,i)=>{const o=w.getSelectData(e),r=n.toLowerCase()||t.eInput.value.toLowerCase();i(o.filter((function(e){return e.label.toLowerCase().includes(r)})))},debounceWaitMs:200,customize(e,t,n,i,o){o<100&&(i.style.top="10px",i.style.bottom=`${window.innerHeight-n.bottom+t.offsetHeight}px`,i.style.maxHeight="140px")}}}static suppressKeyboardEvent(e,t=!1,n=!0,i=!1){const{keyCode:o}=e.event,{key:r}=e.event;return!(!e.editing||!(r?S.has(r):b.has(o)))||!(!i||!t||e.editing)&&((r?r===E:46===o)||!n&&(r?r===y:8===o))}static getStartValue(e){const t=e.eventKey,n=e.keyPress;return(t?t===y:8===n)||(t?t===E:46===n)?"":1===e.eventKey?.length?e.eventKey:e.formatValue(e.value)}constructor(){super('<div class="ag-wrapper ag-input-wrapper ag-text-field-input-wrapper ag-cell-editor-autocomplete-wrapper" style="padding: 0 !important;"><input class="ag-input-field-input ag-text-field-input ag-cell-editor-autocomplete-input" type="text"/></div>'),this.focusAfterAttached=!1,this.required=!1,this.backspaceTriggersEdit=!0,this.eInput=this.getGui().querySelector("input"),this.currentItem&&(this.eInput.value=this.currentItem.label||this.currentItem.value)}init(e){this.gridApi=e.api,this.stopEditing=e.stopEditing;const t=w.getDefaultAutocompleteSettings(e);this.focusAfterAttached=e.cellStartedEdit,this.eInput.placeholder=e.placeholder||"",this.eInput.value=w.getStartValue(e);const n={...t,...e.autocomplete};var i;this.autocompleter=m({input:this.eInput,render:(e,t)=>n.render(this,e,t),renderGroup:(e,t)=>n.renderGroup(this,e,t),className:n.className,minLength:n.minLength,emptyMsg:n.emptyMsg,strict:n.strict,autoselectfirst:n.autoselectfirst,showOnFocus:n.showOnFocus,onFreeTextSelect:(e,t)=>n.onFreeTextSelect(this,e,t),onSelect:(e,t,i)=>{const o=n.onSelect(this,e,t);return i instanceof KeyboardEvent||i instanceof i.view.document.defaultView.KeyboardEvent?this.handleTabEvent(i):this.destroy(),o},fetch:(e,t,i)=>n.fetch(this,e,t,i),debounceWaitMs:n.debounceWaitMs,customize:(e,t,i,o)=>n.customize(this,e,t,i,o)}),e.required&&(this.required=!0),this.gridOptionsAdapter="gos"in(i=this)?new u(i.gos):"gridOptionsService"in i?"in"in i.gridOptionsService?new a(i.gridOptionsService):new u(i.gridOptionsService):"gridOptionsWrapper"in i?new c(i.gridOptionsWrapper):new s,e.colDef.suppressKeyboardEvent||(e.colDef.suppressKeyboardEvent=e=>w.suppressKeyboardEvent(e,this.required,this.backspaceTriggersEdit,this.gridOptionsAdapter.version>=28)),this.gridOptionsAdapter.version>=28&&(this.backspaceTriggersEdit=this.gridOptionsAdapter.isEnableCellEditingOnBackspace())}handleTabEvent(e){9===(e.which||e.keyCode||0)&&this.gridApi?e.shiftKey?this.gridApi.tabToPreviousCell():this.gridApi.tabToNextCell():this.destroy()}afterGuiAttached(){if(!this.focusAfterAttached)return;const{eInput:e}=this;e.focus(),e.select();const t=e.value?e.value.length:0;t>0&&e.setSelectionRange(t,t)}focusIn(){this.eInput.focus(),this.eInput.select()}focusOut(){this.eInput.blur(),this.autocompleter.destroy()}destroy(){this.focusOut(),this.stopEditing&&this.stopEditing()}getValue(){return this.currentItem}isCancelAfterEnd(){return!!this.required&&!this.currentItem}isCancelBeforeStart(){return!1}isPopup(){return!1}}const O=w;return o})()));
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("ag-grid-community"));else if("function"==typeof define&&define.amd)define(["ag-grid-community"],t);else{var n="object"==typeof exports?t(require("ag-grid-community")):t(e["ag-grid-community"]);for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(self,e=>(()=>{"use strict";var t={104:(e,t,n)=>{n.r(t)},743:t=>{t.exports=e}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var s=n[e]={exports:{}};return t[e](s,s.exports,i),s.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};i.r(o),i.d(o,{AutocompleteInput:()=>E,AutocompleteSelectCellEditor:()=>C,default:()=>x});var s=i(743);class r{constructor(){this.version=24}isEnableCellEditingOnBackspace(){return!0}}class c{constructor(e){this.gridOptionsWrapper=e,this.version="function"==typeof this.gridOptionsWrapper.isEnableCellEditingOnBackspace?28:25}isEnableCellEditingOnBackspace(){return this.version<28||this.gridOptionsWrapper.isEnableCellEditingOnBackspace()}}class a{constructor(e){this.gridOptionsService=e,this.version=29}isEnableCellEditingOnBackspace(){return this.gridOptionsService.is("enableCellEditingOnBackspace")}}class l{constructor(e){this.gridOptionsService=e,this.version=30}isEnableCellEditingOnBackspace(){return this.gridOptionsService.get("enableCellEditingOnBackspace")}}class u{constructor(e){this.gridApi=e,this.version=32}isEnableCellEditingOnBackspace(){return this.gridApi.getGridOption("enableCellEditingOnBackspace")}}function p(e){const t=document.createElement("div");return t.textContent=e,t.className="group",t}function d(e){const t=document.createElement("div");return t.textContent=e.label||"",t}function h(e,t,n,i,o=d,s=p){const r=document.createDocumentFragment(),c=[];let a="#9?$";for(const r of e){if(r.group&&r.group!==a){a=r.group;const e=s(r.group,n);c.push(e)}const e=o(r,n);e.addEventListener("click",e=>i(r,e)),r===t&&e.classList.add("selected"),c.push(e)}return r.append(...c),r}function g(e){let t=e;return[()=>t,e=>(t=e,t)]}const f="input",m=new Set([38,13,27,39,37,16,17,18,20,91,9]),v=2;function y(e){const[t,n]=g(e.input.ownerDocument||globalThis.document),[i,o]=g([]),[s,r]=g(""),[c,a]=g(void 0),[l,u]=g(0),[p,d]=g(void 0),{strict:y,autoselectfirst:E,onFreeTextSelect:b,minLength:S=v,showOnFocus:w,input:A,className:I,customize:C,emptyMsg:x,render:O,renderGroup:k}=e,T=e.debounceWaitMs||0,L=S,D=document.createElement("div"),M=D.style;D.className=`autocomplete ${I||""}`,M.position="fixed";const B=()=>{u(l()+1)};function N(){const e=p();void 0!==e&&(globalThis.clearTimeout(e),d(void 0))}function F(){return!!D.parentNode}function K(){B(),o([]),r(""),a(void 0),D&&D.remove()}function V(t,n){n.preventDefault(),n.stopPropagation(),e.onSelect(t,A,n),K()}function G(){!function(e){for(;e.firstChild;)e.firstChild.remove()}(D);const e=i(),o=h(e,c(),s(),V,O,k);if(D.append(o),0===e.length&&y){if(!x)return void K();{const e=document.createElement("div");e.className="empty",e.textContent=x,D.append(e),a(void 0)}}n(A.ownerDocument||globalThis.document),D.parentNode||t().body.append(D),function(){if(F()){const e=t();M.height="auto",M.width=`${A.offsetWidth}px`;const n=A.getBoundingClientRect(),i=n.top+A.offsetHeight;let o=e.defaultView.innerHeight-i;o<0&&(o=0),M.top=`${i}px`,M.bottom="",M.left=`${n.left}px`,M.maxHeight=`${o}px`,C&&C(A,n,D,o)}}(),function(){let e=D.querySelector(".selected");if(e){const t=e.previousElementSibling;if(t&&null===t.previousElementSibling&&t.className.includes("group")&&(e=t),e.offsetTop<D.scrollTop)D.scrollTop=e.offsetTop;else{const t=e.offsetTop+e.offsetHeight,n=D.scrollTop+D.offsetHeight;t>n&&(D.scrollTop+=t-n)}}}()}function W(){F()&&G()}function P(){W()}function q(e){e.target===D?e.preventDefault():W()}function H(t){B();const{value:n}=A;n.length>=L||1===t?(N(),d(function(t){const n=l(),i=0===t?T:0,{value:s}=A,c=e=>{l()===n&&e&&(o(e),r(s),a(e.length>0&&E?e[0]:void 0),G())};return globalThis.setTimeout(()=>{e.fetch(s,c,t)},i)}(t))):K()}function $(e){const t=e.which||e.keyCode||0;m.has(t)||40===t&&F()||H(0)}function z(t){const n=t.which||t.keyCode||0;if(38===n||40===n||27===n||13===n||9===n){if(t.preventDefault(),F()&&t.stopPropagation(),38===n||40===n||27===n)return void(27===n?(e.onSelect(void 0,A,t),K()):function(e){if(F()&&i().length>0){switch(e){case 38:!function(){const e=i(),t=c();if(0!==e.length)if(void 0!==t&&t!==e[0]){for(let n=e.length-1;n>0;n-=1)if(t===e[n]||1===n)return void a(e[n-1])}else a(e.at(-1));else a(void 0)}();break;case 40:!function(){const e=i(),t=c();if(0!==e.length)if(void 0!==t&&t!==e.at(-1)){for(let n=0;n<e.length-1;n+=1)if(t===e[n])return void a(e[n+1])}else a(e[0]);else a(void 0)}()}G()}}(n));13!==n&&9!==n||function(t){const n=c();if(y)e.onSelect(n,A,t);else{const i={label:A.value};if(n)return void e.onSelect(n,A,t);b&&b(i,A),e.onSelect(i,A,t)}K()}(t)}}function j(){w&&H(1)}function R(e){e.preventDefault(),e.stopPropagation(),setTimeout(()=>{t().activeElement!==A&&K()},200)}return function(){const e=t();A.addEventListener("keydown",z),A.addEventListener(f,$),A.addEventListener("focusout",R),A.addEventListener("focus",j),e.addEventListener("resize",P),e.addEventListener("scroll",q,!0)}(),{destroy:function(){!function(){const e=t();A.removeEventListener("focus",j),A.removeEventListener("keydown",z),A.removeEventListener(f,$),A.removeEventListener("focusout",R),e.removeEventListener("resize",P),e.removeEventListener("scroll",q,!0)}(),N(),K(),B()}}}class E{get currentItem(){return this.selectedItem}set currentItem(e){this.selectedItem=e}constructor(e){if(this.config=e,e.inputElement)this.eInput=e.inputElement;else{const e=document.createElement("template");e.innerHTML='<div class="ag-wrapper ag-input-wrapper ag-text-field-input-wrapper ag-cell-editor-autocomplete-wrapper" style="padding: 0 !important;">\n <input class="ag-input-field-input ag-text-field-input ag-cell-editor-autocomplete-input" type="text"/>\n</div>'.trim(),this.container=e.content.firstChild,this.eInput=this.container.querySelector("input")}this.eInput.placeholder=e.placeholder??"",e.initialValue&&(this.eInput.value=e.initialValue),this.setupAutocomplete()}getGui(){return this.container}getInputElement(){return this.eInput}getValue(){return this.selectedItem}setValue(e){this.eInput.value=e}focus(){this.eInput.focus()}select(){this.eInput.select()}blur(){this.eInput.blur()}focusAndSelect(){this.focus(),this.select()}setCaretAtEnd(){const e=this.eInput.value?.length??0;e>0&&this.eInput.setSelectionRange(e,e)}triggerAutocomplete(){this.eInput.dispatchEvent(new Event("input",{bubbles:!0}))}destroy(){this.autocompleter?.destroy()}getSelectData(){const{selectData:e}=this.config;return"function"==typeof e?e():Array.isArray(e)?e:[]}setupAutocomplete(){const e={...this.getDefaultAutocompleteSettings(),...this.config.autocompleteSettings};this.autocompleter=y({input:this.eInput,render:e.render,renderGroup:e.renderGroup,className:e.className,minLength:e.minLength,emptyMsg:e.emptyMsg,strict:e.strict,autoselectfirst:e.autoselectfirst,showOnFocus:e.showOnFocus,onFreeTextSelect:e.onFreeTextSelect,onSelect:(t,n,i)=>{this.selectedItem=t,e.onSelect(t,n,i),this.config.onSelect?.(t,i)},fetch:e.fetch,debounceWaitMs:e.debounceWaitMs,customize:e.customize})}getDefaultAutocompleteSettings(){return{showOnFocus:!1,render:(e,t)=>{const n=document.createElement("div"),i=(t??"").replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),o=new RegExp(i,"gi"),s=document.createElement("span");return s.innerHTML=e.label.replace(o,e=>`<strong>${e}</strong>`),n.append(s),n.addEventListener("mousedown",t=>{this.selectedItem=e,t.stopPropagation(),this.config.onItemMousedown?.(e,t)}),n},renderGroup:(e,t)=>{const n=document.createElement("div");return n.textContent=e,n.className="group",n},className:"ag-cell-editor-autocomplete",minLength:1,emptyMsg:"None",strict:!0,autoselectfirst:!0,onFreeTextSelect:()=>{},onSelect:()=>{},fetch:(e,t)=>{const n=this.getSelectData(),i=e.toLowerCase()||this.eInput.value.toLowerCase();t(n.filter(e=>e.label.toLowerCase().includes(i)))},debounceWaitMs:200,customize:(e,t,n,i)=>{i<100&&(n.style.top="10px",n.style.bottom=`${window.innerHeight-t.bottom+e.offsetHeight}px`,n.style.maxHeight="140px")}}}}i(104);const b="Backspace",S="Delete",w="Enter",A=new Set([8,46,13,9,38,40]),I=new Set([b,S,w,"Tab","ArrowUp","ArrowDown"]);class C extends s.Component{constructor(){super('<div class="ag-wrapper ag-input-wrapper ag-text-field-input-wrapper ag-cell-editor-autocomplete-wrapper" style="padding: 0 !important;"><input class="ag-input-field-input ag-text-field-input ag-cell-editor-autocomplete-input" type="text"/></div>'),this.focusAfterAttached=!1,this.startedByEnter=!1,this.required=!1,this.backspaceTriggersEdit=!0}init(e){var t;this.gridApi=e.api,this.stopEditing=e.stopEditing,this.focusAfterAttached=e.cellStartedEdit,this.startedByEnter=e.eventKey===w,this.required=e.required??!1,this.gridOptionsAdapter="context"in(t=this.gridApi)?"gos"in t?new l(t.gos):"gridOptionsService"in t?new a(t.gridOptionsService):"setGridAriaProperty"in t?new c(t.gridOptionsWrapper):new r:new u(t),this.gridOptionsAdapter.version>=28&&(this.backspaceTriggersEdit=this.gridOptionsAdapter.isEnableCellEditingOnBackspace());const n=this.getGui().querySelector("input");this.autocompleteInput=new E({placeholder:e.placeholder,initialValue:C.getStartValue(e),selectData:()=>C.getSelectData(e),autocompleteSettings:this.transformAutocompleteSettings(e),onSelect:(e,t)=>{this.handleSelection(e,t)},onItemMousedown:e=>{this.autocompleteInput.currentItem=e},inputElement:n}),e.colDef.suppressKeyboardEvent||(e.colDef.suppressKeyboardEvent=e=>C.suppressKeyboardEvent(e,this.required,this.backspaceTriggersEdit,this.gridOptionsAdapter.version>=28))}afterGuiAttached(){this.focusAfterAttached&&(this.autocompleteInput.focusAndSelect(),this.autocompleteInput.setCaretAtEnd()),this.startedByEnter&&setTimeout(()=>{this.autocompleteInput.triggerAutocomplete()})}focusIn(){this.autocompleteInput.focusAndSelect()}focusOut(){this.autocompleteInput.blur(),this.autocompleteInput.destroy()}getValue(){return this.autocompleteInput.getValue()}isCancelAfterEnd(){return this.required&&!this.autocompleteInput.getValue()}get currentItem(){return this.autocompleteInput?.currentItem}set currentItem(e){this.autocompleteInput&&(this.autocompleteInput.currentItem=e)}handleSelection(e,t){t instanceof KeyboardEvent||t instanceof t.view.document.defaultView.KeyboardEvent?this.handleKeyboardSelection(t):e&&this.selectAndClose()}handleKeyboardSelection(e){9===(e.which||e.keyCode||0)&&this.gridApi?e.shiftKey?this.gridApi.tabToPreviousCell():this.gridApi.tabToNextCell():this.selectAndClose()}selectAndClose(){this.focusOut(),this.stopEditing&&this.stopEditing()}wrapCallback(e){return(...t)=>e(this,...t)}transformAutocompleteSettings(e){const t=e.autocomplete;if(!t)return{};const n={};return t.render&&(n.render=this.wrapCallback(t.render)),t.renderGroup&&(n.renderGroup=this.wrapCallback(t.renderGroup)),t.onFreeTextSelect&&(n.onFreeTextSelect=this.wrapCallback(t.onFreeTextSelect)),t.onSelect&&(n.onSelect=this.wrapCallback(t.onSelect)),t.fetch&&(n.fetch=this.wrapCallback(t.fetch)),t.customize&&(n.customize=this.wrapCallback(t.customize)),void 0!==t.className&&(n.className=t.className),void 0!==t.minLength&&(n.minLength=t.minLength),void 0!==t.emptyMsg&&(n.emptyMsg=t.emptyMsg),void 0!==t.strict&&(n.strict=t.strict),void 0!==t.autoselectfirst&&(n.autoselectfirst=t.autoselectfirst),void 0!==t.showOnFocus&&(n.showOnFocus=t.showOnFocus),void 0!==t.debounceWaitMs&&(n.debounceWaitMs=t.debounceWaitMs),n}static getSelectData(e){return"function"==typeof e.selectData?e.selectData(e):Array.isArray(e.selectData)?e.selectData:[]}static getStartValue(e){const t=e.eventKey,n=e.keyPress;return(t?t===b:8===n)||(t?t===S:46===n)?"":1===e.eventKey?.length?e.eventKey:e.formatValue(e.value)??""}static suppressKeyboardEvent(e,t=!1,n=!0,i=!1){const{keyCode:o}=e.event,{key:s}=e.event;return!(!e.editing||!(s?I.has(s):A.has(o)))||!(!i||!t||e.editing)&&((s?s===S:46===o)||!n&&(s?s===b:8===o))}}const x=C;return o})());
|
|
2
2
|
//# s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KAAKoM,QAAQmB,oBAEbvN,KAAKoM,QAAQoB,gBAGfxN,KAAK8I,SAET,CAEA,gBAAA2E,GACE,IAAKzN,KAAKgM,mBACR,OAGF,MAAM,OAAEd,GAAWlL,KACnBkL,EAAOwC,QACPxC,EAAOyC,SAKP,MAAMpI,EAAS2F,EAAOzL,MAAQyL,EAAOzL,MAAM8F,OAAS,EAChDA,EAAS,GACX2F,EAAO0C,kBAAkBrI,EAAQA,EAErC,CAEA,OAAAsI,GACE7N,KAAKkL,OAAOwC,QACZ1N,KAAKkL,OAAOyC,QACd,CAEA,QAAAG,GACE9N,KAAKkL,OAAO6C,OACZ/N,KAAK4M,cAAc9D,SACrB,CAEA,OAAAA,GACE9I,KAAK8N,WACD9N,KAAKsM,aACPtM,KAAKsM,aAET,CAEA,QAAA0B,GACE,OAAOhO,KAAKyK,WACd,CAEA,gBAAAwD,GACE,QAAIjO,KAAKiM,WACCjM,KAAKyK,WAGjB,CAGA,mBAAAyD,GACE,OAAO,CACT,CAGA,OAAAC,GACE,OAAO,CACT,EEtVF,U","sources":["webpack://ag-grid-autocomplete/webpack/universalModuleDefinition","webpack://ag-grid-autocomplete/external umd \"@ag-grid-community/core\"","webpack://ag-grid-autocomplete/webpack/bootstrap","webpack://ag-grid-autocomplete/webpack/runtime/define property getters","webpack://ag-grid-autocomplete/webpack/runtime/hasOwnProperty shorthand","webpack://ag-grid-autocomplete/webpack/runtime/make namespace object","webpack://ag-grid-autocomplete/./src/adapters/grid-options-v24-adapter.ts","webpack://ag-grid-autocomplete/./src/adapters/grid-options-v28-adapter.ts","webpack://ag-grid-autocomplete/./src/adapters/grid-options-v29-adapter.ts","webpack://ag-grid-autocomplete/./src/adapters/grid-options-v31-adapter.ts","webpack://ag-grid-autocomplete/./autocompleter/rendering.ts","webpack://ag-grid-autocomplete/./autocompleter/singleton.ts","webpack://ag-grid-autocomplete/./autocompleter/autocomplete.ts","webpack://ag-grid-autocomplete/./ag-grid-autocomplete.ts","webpack://ag-grid-autocomplete/./src/adapters/grid-options-adapter.ts","webpack://ag-grid-autocomplete/./index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@ag-grid-community/core\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"@ag-grid-community/core\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"@ag-grid-community/core\")) : factory(root[\"@ag-grid-community/core\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(self, (__WEBPACK_EXTERNAL_MODULE__151__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__151__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Adapter implementation for AG Grid v24\n */\nexport default class GridOptionsV24Adapter implements IGridOptionsAdapter {\n version = 24\n\n // eslint-disable-next-line class-methods-use-this\n isEnableCellEditingOnBackspace(): boolean {\n return true\n }\n}\n","import { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Adapter implementation for AG Grid v28\n * Uses gridOptionsWrapper\n */\nexport default class GridOptionsV28Adapter implements IGridOptionsAdapter {\n version: 27 | 28\n\n constructor(private readonly gridOptionsWrapper: any) {\n // isEnableCellEditingOnBackspace is new on version 28, so it is safe to assume v28+\n this.version = typeof this.gridOptionsWrapper.isEnableCellEditingOnBackspace === 'function' ? 28 : 27\n }\n\n isEnableCellEditingOnBackspace(): boolean {\n // This option didn't exist before v28, the original behavior is as it was always set to true\n if (this.version < 28) return true\n return this.gridOptionsWrapper.isEnableCellEditingOnBackspace()\n }\n}\n","import { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Adapter implementation for AG Grid v29\n * Uses gridOptionsService\n */\nexport default class GridOptionsV29Adapter implements IGridOptionsAdapter {\n version = 29\n\n constructor(private readonly gridOptionsService: any) {}\n\n isEnableCellEditingOnBackspace(): boolean {\n return this.gridOptionsService.is('enableCellEditingOnBackspace')\n }\n}\n","import { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Adapter implementation for AG Grid v31\n * Uses gridOptionsService\n */\nexport default class GridOptionsV31Adapter implements IGridOptionsAdapter {\n version = 31\n\n constructor(private readonly gridOptionsService: any) {}\n\n isEnableCellEditingOnBackspace(): boolean {\n return this.gridOptionsService.get('enableCellEditingOnBackspace')\n }\n}\n","import { AutocompleteItem, RenderFunction, RenderGroupFunction } from './types'\n\nexport function removeChildren(container: Node) {\n while (container.firstChild) {\n container.firstChild.remove()\n }\n}\n\nexport function defaultRenderGroup(groupName: string): HTMLDivElement {\n const groupDiv = document.createElement('div')\n groupDiv.textContent = groupName\n groupDiv.className = 'group'\n return groupDiv\n}\n\nexport function defaultRender(item: AutocompleteItem): HTMLDivElement {\n const itemElement = document.createElement('div')\n itemElement.textContent = item.label || ''\n return itemElement\n}\n\nexport function renderItems<T extends AutocompleteItem>(\n items: T[],\n selected: T | undefined,\n inputValue: string,\n clickHandler: (item: T, event: MouseEvent) => void,\n render: RenderFunction<T> = defaultRender,\n renderGroup: RenderGroupFunction = defaultRenderGroup,\n): DocumentFragment {\n const fragment = document.createDocumentFragment()\n const elements: HTMLElement[] = []\n let previousGroup = '#9?$'\n // eslint-disable-next-line no-restricted-syntax\n for (const item of items) {\n if (item.group && item.group !== previousGroup) {\n previousGroup = item.group\n const groupDiv = renderGroup(item.group, inputValue)\n elements.push(groupDiv)\n }\n const div = render(item, inputValue)\n div.addEventListener('click', (event: MouseEvent) => clickHandler(item, event))\n if (item === selected) {\n div.classList.add('selected')\n }\n elements.push(div)\n }\n fragment.append(...elements)\n return fragment\n}\n","/**\n * Simple function to create typed and scope safe singletons inspired by react hooks\n * @param initialValue: The initial value of the singleton\n * @example\n * // declare and use a new singleton\n * const [getValue, setValue] = singleton(0)\n * // increment the singleton value\n * setValue(getValue() + 1)\n * @returns [singletonGetter, singletonSetter]\n */\nexport default function singleton<T>(initialValue: T) {\n let value = initialValue\n const setValue = (newValue: T) => {\n value = newValue\n return value\n }\n const getValue = () => {\n return value\n }\n return [getValue, setValue] as const\n}\n","import { removeChildren, renderItems } from './rendering'\nimport { AutocompleteItem, EventTrigger, AutocompleteSettings, AutocompleteResult } from './types'\nimport singleton from './singleton'\n\nconst enum Keys {\n Enter = 13,\n Esc = 27,\n Up = 38,\n Down = 40,\n Left = 37,\n Right = 39,\n Shift = 16,\n Ctrl = 17,\n Alt = 18,\n CapsLock = 20,\n WindowsKey = 91,\n Tab = 9,\n}\n\nconst KEYUP_EVENT_NAME = 'input'\n\nconst KEYS_TO_IGNORE = new Set([\n Keys.Up,\n Keys.Enter,\n Keys.Esc,\n Keys.Right,\n Keys.Left,\n Keys.Shift,\n Keys.Ctrl,\n Keys.Alt,\n Keys.CapsLock,\n Keys.WindowsKey,\n Keys.Tab,\n])\nconst DEFAULT_MIN_LENGTH = 2\n\nexport default function autocomplete<T extends AutocompleteItem>(\n settings: AutocompleteSettings<T>,\n): AutocompleteResult {\n /* eslint-disable unicorn/no-useless-undefined */\n const [getDocument, setDocument] = singleton(settings.input.ownerDocument || globalThis.document)\n const [getItems, setItems] = singleton<T[]>([])\n const [getInputValue, setInputValue] = singleton('')\n const [getSelected, setSelected] = singleton<T | undefined>(undefined)\n const [getKeypressCounter, setKeypressCounter] = singleton(0)\n const [getDebounceTimer, setDebounceTimer] = singleton<NodeJS.Timeout | undefined>(undefined)\n /* eslint-enable */\n\n const {\n strict,\n autoselectfirst,\n onFreeTextSelect,\n minLength = DEFAULT_MIN_LENGTH,\n showOnFocus,\n input,\n className,\n customize,\n emptyMsg,\n render,\n renderGroup,\n } = settings\n const debounceWaitMs = settings.debounceWaitMs || 0\n const minimumInputLength = minLength\n const container: HTMLDivElement = document.createElement('div')\n const containerStyle = container.style\n\n container.className = `autocomplete ${className || ''}`\n containerStyle.position = 'fixed'\n\n const incrementKeypressCounter = () => {\n setKeypressCounter(getKeypressCounter() + 1)\n }\n\n /**\n * Detach the container from DOM\n */\n function detach() {\n if (container) {\n container.remove()\n }\n }\n\n /**\n * Clear debouncing timer if assigned\n */\n function clearDebounceTimer() {\n const debounceTimer = getDebounceTimer()\n if (debounceTimer !== undefined) {\n globalThis.clearTimeout(debounceTimer)\n // eslint-disable-next-line unicorn/no-useless-undefined\n setDebounceTimer(undefined)\n }\n }\n\n /**\n * Attach the container to DOM\n */\n function attach() {\n setDocument(input.ownerDocument || globalThis.document)\n if (!container.parentNode) {\n getDocument().body.append(container)\n }\n }\n\n /**\n * Check if container for autocomplete is displayed\n */\n function containerDisplayed(): boolean {\n return !!container.parentNode\n }\n\n /**\n * Clear autocomplete state and hide container\n */\n function clear() {\n incrementKeypressCounter()\n setItems([])\n setInputValue('')\n // eslint-disable-next-line unicorn/no-useless-undefined\n setSelected(undefined)\n detach()\n }\n\n /**\n * Update autocomplete position to put it under the input field\n */\n function updatePosition() {\n if (containerDisplayed()) {\n const document = getDocument()\n\n containerStyle.height = 'auto'\n containerStyle.width = `${input.offsetWidth}px`\n\n const inputRect = input.getBoundingClientRect()\n const top = inputRect.top + input.offsetHeight\n let maxHeight = document.defaultView!.innerHeight - top\n\n if (maxHeight < 0) {\n maxHeight = 0\n }\n\n containerStyle.top = `${top}px`\n containerStyle.bottom = ''\n containerStyle.left = `${inputRect.left}px`\n containerStyle.maxHeight = `${maxHeight}px`\n\n if (customize) {\n customize(input, inputRect, container, maxHeight)\n }\n }\n }\n\n /**\n * Automatically move scroll bar if selected item is not visible\n */\n function updateScroll() {\n let element = container.querySelector('.selected') as HTMLDivElement\n if (element) {\n // make group visible\n const previous = element.previousElementSibling\n if (previous && previous.previousElementSibling === null && previous.className.includes('group')) {\n element = previous as HTMLDivElement\n }\n\n if (element.offsetTop < container.scrollTop) {\n container.scrollTop = element.offsetTop\n } else {\n const selectBottom = element.offsetTop + element.offsetHeight\n const containerBottom = container.scrollTop + container.offsetHeight\n if (selectBottom > containerBottom) {\n container.scrollTop += selectBottom - containerBottom\n }\n }\n }\n }\n\n /**\n * Handle the click on an item of the selection list\n * @param item: data of the clicked item\n * @param event: MouseEvent who has triggered the selection\n */\n function itemClickHandler(item: T, event: MouseEvent) {\n event.preventDefault()\n event.stopPropagation()\n settings.onSelect(item, input, event)\n clear()\n }\n\n /**\n * Redraw the autocomplete div element with suggestions\n */\n function update() {\n // Clear all child from container\n removeChildren(container)\n\n const items = getItems()\n const fragment = renderItems<T>(items, getSelected(), getInputValue(), itemClickHandler, render, renderGroup)\n container.append(fragment)\n if (items.length === 0 && strict) {\n // if no items display empty message\n if (emptyMsg) {\n const empty = document.createElement('div')\n empty.className = 'empty'\n empty.textContent = emptyMsg\n container.append(empty)\n // eslint-disable-next-line unicorn/no-useless-undefined\n setSelected(undefined)\n } else {\n clear()\n return\n }\n }\n\n attach()\n updatePosition()\n updateScroll()\n }\n\n function updateIfDisplayed() {\n if (containerDisplayed()) {\n update()\n }\n }\n\n function resizeEventHandler() {\n updateIfDisplayed()\n }\n\n function scrollEventHandler(event: Event) {\n if (event.target === container) {\n event.preventDefault()\n } else {\n updateIfDisplayed()\n }\n }\n\n function debouncedFetch(trigger: EventTrigger) {\n const savedKeypressCounter = getKeypressCounter()\n const debouncingTime = trigger === EventTrigger.Keyboard ? debounceWaitMs : 0\n const { value } = input\n // Hydrate this.items with retrieved items\n const handleFetchResult = (elements: T[] | false) => {\n if (getKeypressCounter() === savedKeypressCounter && elements) {\n setItems(elements)\n setInputValue(value)\n setSelected(elements.length > 0 && autoselectfirst ? elements[0] : undefined)\n update()\n }\n }\n return globalThis.setTimeout(() => {\n settings.fetch(value, handleFetchResult, trigger)\n }, debouncingTime)\n }\n\n function startFetch(trigger: EventTrigger) {\n // if multiple keys were pressed, before we get update from server,\n // this may cause redrawing our autocomplete multiple times after the last key press.\n // to avoid this, the number of times keyboard was pressed will be\n // saved and checked before redraw our autocomplete box.\n incrementKeypressCounter()\n\n const { value } = input\n if (value.length >= minimumInputLength || trigger === EventTrigger.Focus) {\n clearDebounceTimer()\n setDebounceTimer(debouncedFetch(trigger))\n } else {\n clear()\n }\n }\n\n function keyupEventHandler(event: KeyboardEvent) {\n // eslint-disable-next-line sonarjs/deprecation\n const keyCode = event.which || event.keyCode || 0\n\n if (KEYS_TO_IGNORE.has(keyCode)) {\n return\n }\n\n // the down key is used to open autocomplete\n if (keyCode === Keys.Down && containerDisplayed()) {\n return\n }\n\n startFetch(EventTrigger.Keyboard)\n }\n\n /**\n * Select the previous item in suggestions\n */\n function selectPreviousItem() {\n const items = getItems()\n const selected = getSelected()\n if (items.length === 0) {\n // eslint-disable-next-line unicorn/no-useless-undefined\n setSelected(undefined)\n return\n }\n if (selected === undefined || selected === items[0]) {\n setSelected(items.at(-1))\n return\n }\n for (let index = items.length - 1; index > 0; index -= 1) {\n if (selected === items[index] || index === 1) {\n setSelected(items[index - 1])\n return\n }\n }\n }\n\n /**\n * Select the next item in suggestions\n */\n function selectNextItem() {\n const items = getItems()\n const selected = getSelected()\n if (items.length === 0) {\n // eslint-disable-next-line unicorn/no-useless-undefined\n setSelected(undefined)\n return\n }\n if (selected === undefined || selected === items.at(-1)) {\n // eslint-disable-next-line prefer-destructuring\n setSelected(items[0])\n return\n }\n for (let index = 0; index < items.length - 1; index += 1) {\n if (selected === items[index]) {\n setSelected(items[index + 1])\n return\n }\n }\n }\n\n function handleArrowKeysDown(arrowKey: Keys.Up | Keys.Down) {\n const containerIsDisplayed = containerDisplayed()\n if (containerIsDisplayed && getItems().length > 0) {\n switch (arrowKey) {\n case Keys.Up: {\n selectPreviousItem()\n break\n }\n case Keys.Down: {\n selectNextItem()\n break\n }\n default:\n }\n update()\n }\n }\n\n function handleSelectKeysDown(event: KeyboardEvent) {\n const selected = getSelected()\n if (strict) {\n settings.onSelect(selected, input, event)\n } else {\n const freeTextSelect = { label: input.value } as T\n if (selected) {\n settings.onSelect(selected, input, event)\n return\n }\n if (onFreeTextSelect) {\n onFreeTextSelect(freeTextSelect, input)\n }\n settings.onSelect(freeTextSelect, input, event)\n }\n clear()\n }\n\n function keydownEventHandler(event: KeyboardEvent) {\n // eslint-disable-next-line sonarjs/deprecation\n const keyCode = event.which || event.keyCode || 0\n\n if (\n keyCode === Keys.Up ||\n keyCode === Keys.Down ||\n keyCode === Keys.Esc ||\n keyCode === Keys.Enter ||\n keyCode === Keys.Tab\n ) {\n event.preventDefault()\n if (containerDisplayed()) {\n event.stopPropagation()\n }\n if (keyCode === Keys.Up || keyCode === Keys.Down || keyCode === Keys.Esc) {\n if (keyCode === Keys.Esc) {\n settings.onSelect(undefined, input, event)\n clear()\n } else {\n handleArrowKeysDown(keyCode)\n }\n return\n }\n\n if (keyCode === Keys.Enter || keyCode === Keys.Tab) {\n handleSelectKeysDown(event)\n }\n }\n }\n\n function focusEventHandler() {\n if (showOnFocus) {\n startFetch(EventTrigger.Focus)\n }\n }\n\n function focusOutEventHandler(event: Event) {\n // we need to delay clear, because when we click on an item, blur will be called before click and remove items from DOM\n event.preventDefault()\n event.stopPropagation()\n setTimeout(() => {\n if (getDocument().activeElement !== input) {\n clear()\n }\n }, 200)\n }\n\n function removeEventListeners() {\n const document = getDocument()\n\n input.removeEventListener('focus', focusEventHandler)\n input.removeEventListener('keydown', keydownEventHandler)\n input.removeEventListener(KEYUP_EVENT_NAME, keyupEventHandler as EventListenerOrEventListenerObject)\n input.removeEventListener('focusout', focusOutEventHandler)\n document.removeEventListener('resize', resizeEventHandler)\n document.removeEventListener('scroll', scrollEventHandler, true)\n }\n\n function addEventListeners() {\n const document = getDocument()\n\n input.addEventListener('keydown', keydownEventHandler)\n input.addEventListener(KEYUP_EVENT_NAME, keyupEventHandler as EventListenerOrEventListenerObject)\n input.addEventListener('focusout', focusOutEventHandler)\n input.addEventListener('focus', focusEventHandler)\n document.addEventListener('resize', resizeEventHandler)\n document.addEventListener('scroll', scrollEventHandler, true)\n }\n\n /**\n * This function will remove DOM elements and clear event handlers\n */\n function destroy() {\n removeEventListeners()\n clearDebounceTimer()\n clear()\n\n // prevent the update call if there are pending AJAX requests\n incrementKeypressCounter()\n }\n\n addEventListeners()\n return {\n destroy,\n }\n}\n\nexport { AutocompleteItem, AutocompleteSettings, EventTrigger } from './types'\n","import { GridApi, ICellEditorComp, PopupComponent, SuppressKeyboardEventParams } from '@ag-grid-community/core'\nimport { IAutocompleteSelectCellEditorParameters, DataFormat, IAutocompleterSettings } from './types'\nimport createGridOptionsAdapter from './src/adapters/grid-options-adapter'\nimport { IGridOptionsAdapter } from './src/adapters/grid-options-interfaces'\n\nimport autocomplete from './autocompleter/autocomplete'\n\n// use require instead of import to generate the .css file with webpack but avoid import into the .d.ts file\n// eslint-disable-next-line unicorn/prefer-module\nrequire('./ag-grid-autocomplete.scss')\n\nconst KEY_BACKSPACE = 8\nconst KEY_DELETE = 46\nconst KEY_ENTER = 13\nconst KEY_TAB = 9\nconst KEY_UP = 38\nconst KEY_DOWN = 40\n\n// New key string constants for eventKey\nconst KEY_BACKSPACE_STRING = 'Backspace'\nconst KEY_DELETE_STRING = 'Delete'\nconst KEY_ENTER_STRING = 'Enter'\nconst KEY_TAB_STRING = 'Tab'\nconst KEY_UP_STRING = 'ArrowUp'\nconst KEY_DOWN_STRING = 'ArrowDown'\n\nconst KeysHandled = new Set([KEY_BACKSPACE, KEY_DELETE, KEY_ENTER, KEY_TAB, KEY_UP, KEY_DOWN])\nconst KeysHandledStrings = new Set([\n KEY_BACKSPACE_STRING,\n KEY_DELETE_STRING,\n KEY_ENTER_STRING,\n KEY_TAB_STRING,\n KEY_UP_STRING,\n KEY_DOWN_STRING,\n])\nexport default class AutocompleteSelectCellEditor extends PopupComponent implements ICellEditorComp {\n public currentItem?: DataFormat\n\n private focusAfterAttached: boolean = false\n\n private readonly eInput: HTMLInputElement\n\n private autocompleter?: any\n\n private required: boolean = false\n\n private stopEditing?: (cancel?: boolean) => void\n\n /**\n * Originally AgGrid would always trigger cell editing when backspace was hit\n */\n private backspaceTriggersEdit = true\n\n private gridApi?: GridApi\n\n private gridOptionsAdapter!: IGridOptionsAdapter\n\n private static getSelectData(\n parameters: IAutocompleteSelectCellEditorParameters<AutocompleteSelectCellEditor>,\n ): Array<DataFormat> {\n if (typeof parameters.selectData === 'function') {\n return parameters.selectData(parameters)\n }\n\n if (Array.isArray(parameters.selectData)) {\n return parameters.selectData as Array<DataFormat>\n }\n return []\n }\n\n private static getDefaultAutocompleteSettings(\n parameters: IAutocompleteSelectCellEditorParameters<AutocompleteSelectCellEditor>,\n ): Required<IAutocompleterSettings<DataFormat, AutocompleteSelectCellEditor>> {\n return {\n showOnFocus: false,\n render(cellEditor, item, value) {\n const itemElement = document.createElement('div')\n const escapedValue = (value ?? '').replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, String.raw`\\$&`)\n const regex = new RegExp(escapedValue, 'gi')\n const fieldItem = document.createElement('span')\n fieldItem.innerHTML = item.label.replace(regex, function strongify(match: string) {\n return `<strong>${match}</strong>`\n })\n itemElement.append(fieldItem)\n const eventFunction = (event: MouseEvent) => {\n // eslint-disable-next-line no-param-reassign\n cellEditor.currentItem = item\n event.stopPropagation()\n }\n if ('addManagedListeners' in cellEditor) {\n // ag-grid v32+\n ;(cellEditor as any).addManagedListeners(itemElement, { mousedown: eventFunction })\n } else {\n ;(cellEditor as any).addManagedListener(itemElement, 'mousedown', eventFunction)\n }\n return itemElement\n },\n renderGroup(_, name) {\n const div = document.createElement('div')\n div.textContent = name\n div.className = 'group'\n return div\n },\n className: 'ag-cell-editor-autocomplete',\n minLength: 1,\n emptyMsg: 'None',\n strict: true,\n autoselectfirst: true,\n onFreeTextSelect() {},\n onSelect(cellEditor, item: DataFormat | undefined) {\n // eslint-disable-next-line no-param-reassign\n cellEditor.currentItem = item\n },\n fetch: (cellEditor, text, callback) => {\n const items = AutocompleteSelectCellEditor.getSelectData(parameters)\n const match = text.toLowerCase() || cellEditor.eInput.value.toLowerCase()\n callback(\n items.filter(function caseInsensitiveIncludes(n) {\n return n.label.toLowerCase().includes(match)\n }),\n )\n },\n debounceWaitMs: 200,\n customize(_, input, inputRect, container, maxHeight) {\n if (maxHeight < 100) {\n /* eslint-disable no-param-reassign */\n container.style.top = '10px'\n container.style.bottom = `${window.innerHeight - inputRect.bottom + input.offsetHeight}px`\n container.style.maxHeight = '140px'\n /* eslint-enable no-param-reassign */\n }\n },\n }\n }\n\n /**\n * Determines whether a keyboard event should be suppressed in a grid cell.\n * Supports both modern (key-based) and legacy (keyCode-based) keyboard event handling.\n *\n * @param parameters - Event parameters from ag-grid\n * @param isRequired - Whether the cell represents a required field\n * @param backspaceTriggersEdit - Whether pressing backspace should trigger cell editing\n * @param isVersionGte28 - Whether using ag-grid version 28 or greater (which changed edit behavior)\n * @returns True if the event should be suppressed, false otherwise\n */\n private static suppressKeyboardEvent(\n parameters: SuppressKeyboardEventParams,\n isRequired = false,\n backspaceTriggersEdit = true,\n isVersionGte28 = false,\n ): boolean {\n // Check for both keyCode (deprecated) and key (new string-based approach)\n // eslint-disable-next-line sonarjs/deprecation\n const { keyCode } = parameters.event\n const { key } = parameters.event\n\n // Handle both numeric keyCode and string key approaches\n if (parameters.editing && (key ? KeysHandledStrings.has(key) : KeysHandled.has(keyCode))) {\n return true\n }\n\n // Logic below this point is required only if we are using ag-grid>=28, field is required, and is not in edit mode\n if (!isVersionGte28 || !isRequired || parameters.editing) {\n return false\n }\n\n // If the user hits delete, prevent it as it doesn't trigger a cell edit anymore\n if (key ? key === KEY_DELETE_STRING : keyCode === KEY_DELETE) {\n return true\n }\n\n // If the user hits backspace and cell editing is not enabled, prevent it\n return !backspaceTriggersEdit && (key ? key === KEY_BACKSPACE_STRING : keyCode === KEY_BACKSPACE)\n }\n\n private static getStartValue(parameters: IAutocompleteSelectCellEditorParameters<AutocompleteSelectCellEditor>) {\n // Check for new eventKey (v27+) or fall back to keyPress for backward compatibility\n // Use type assertion with 'as any' to access potentially undefined properties\n // without modifying the interface definition\n const eventKey = (parameters as any).eventKey as string\n const keyPress = (parameters as any).keyPress as number\n\n // Check for backspace or delete using either the string eventKey or numeric keyPress\n const isBackspace = eventKey ? eventKey === KEY_BACKSPACE_STRING : keyPress === KEY_BACKSPACE\n const isDelete = eventKey ? eventKey === KEY_DELETE_STRING : keyPress === KEY_DELETE\n const keyPressBackspaceOrDelete = isBackspace || isDelete\n\n if (keyPressBackspaceOrDelete) {\n return ''\n }\n // Detecting if the pressed key is a character\n if (parameters.eventKey?.length === 1) {\n return parameters.eventKey\n }\n return parameters.formatValue(parameters.value)\n }\n\n constructor() {\n super(\n '<div class=\"ag-wrapper ag-input-wrapper ag-text-field-input-wrapper ag-cell-editor-autocomplete-wrapper\" style=\"padding: 0 !important;\"><input class=\"ag-input-field-input ag-text-field-input ag-cell-editor-autocomplete-input\" type=\"text\"/></div>',\n )\n this.eInput = this.getGui().querySelector('input') as HTMLInputElement\n if (this.currentItem) {\n this.eInput.value = this.currentItem.label || (this.currentItem.value as string)\n }\n }\n\n public init(parameters: IAutocompleteSelectCellEditorParameters<AutocompleteSelectCellEditor>) {\n this.gridApi = parameters.api\n this.stopEditing = parameters.stopEditing\n const defaultSettings = AutocompleteSelectCellEditor.getDefaultAutocompleteSettings(parameters)\n this.focusAfterAttached = parameters.cellStartedEdit\n\n this.eInput.placeholder = parameters.placeholder || ''\n this.eInput.value = AutocompleteSelectCellEditor.getStartValue(parameters)\n\n const autocompleteParameters = { ...defaultSettings, ...parameters.autocomplete }\n\n this.autocompleter = autocomplete<DataFormat>({\n input: this.eInput,\n render: (item: DataFormat, currentValue: string) => {\n return autocompleteParameters.render(this, item, currentValue)\n },\n renderGroup: (name: string, currentValue: string) => {\n return autocompleteParameters.renderGroup(this, name, currentValue)\n },\n className: autocompleteParameters.className,\n minLength: autocompleteParameters.minLength,\n emptyMsg: autocompleteParameters.emptyMsg,\n strict: autocompleteParameters.strict,\n autoselectfirst: autocompleteParameters.autoselectfirst,\n showOnFocus: autocompleteParameters.showOnFocus,\n onFreeTextSelect: (item: DataFormat, input: HTMLInputElement) => {\n return autocompleteParameters.onFreeTextSelect(this, item, input)\n },\n onSelect: (item: DataFormat | undefined, input: HTMLInputElement, event: KeyboardEvent | MouseEvent) => {\n const result = autocompleteParameters.onSelect(this, item, input)\n // need the second argument because of cypress testing changing the view context\n if (event instanceof KeyboardEvent || event instanceof event.view!.document.defaultView!.KeyboardEvent) {\n this.handleTabEvent(event)\n } else {\n this.destroy()\n }\n return result\n },\n fetch: (text: string, update: (items: DataFormat[] | false) => void, trigger) => {\n return autocompleteParameters.fetch(this, text, update, trigger)\n },\n debounceWaitMs: autocompleteParameters.debounceWaitMs,\n customize: (input: HTMLInputElement, inputRect: DOMRect, container: HTMLDivElement, maxHeight: number) => {\n return autocompleteParameters.customize(this, input, inputRect, container, maxHeight)\n },\n })\n\n if (parameters.required) {\n this.required = true\n }\n\n // Create the grid options adapter based on the instance\n this.gridOptionsAdapter = createGridOptionsAdapter(this)\n\n if (!parameters.colDef.suppressKeyboardEvent) {\n // eslint-disable-next-line no-param-reassign\n parameters.colDef.suppressKeyboardEvent = (suppressParameters) =>\n AutocompleteSelectCellEditor.suppressKeyboardEvent(\n suppressParameters,\n this.required,\n this.backspaceTriggersEdit,\n this.gridOptionsAdapter.version >= 28,\n )\n }\n\n // The behavior for deleting cell values changed from v28 and beyond, so we need to track this option's value\n if (this.gridOptionsAdapter.version >= 28) {\n this.backspaceTriggersEdit = this.gridOptionsAdapter.isEnableCellEditingOnBackspace()\n }\n }\n\n handleTabEvent(event: KeyboardEvent) {\n // eslint-disable-next-line sonarjs/deprecation\n const keyCode = event.which || event.keyCode || 0\n\n if (keyCode === KEY_TAB && this.gridApi) {\n if (event.shiftKey) {\n this.gridApi.tabToPreviousCell()\n } else {\n this.gridApi.tabToNextCell()\n }\n } else {\n this.destroy()\n }\n }\n\n afterGuiAttached(): void {\n if (!this.focusAfterAttached) {\n return\n }\n\n const { eInput } = this\n eInput.focus()\n eInput.select()\n // when we started editing, we want the caret at the end, not the start.\n // this comes into play in two scenarios: a) when user hits F2 and b)\n // when user hits a printable character, then on IE (and only IE) the caret\n // was placed after the first character, thus 'apply' would end up as 'pplea'\n const length = eInput.value ? eInput.value.length : 0\n if (length > 0) {\n eInput.setSelectionRange(length, length)\n }\n }\n\n focusIn(): void {\n this.eInput.focus()\n this.eInput.select()\n }\n\n focusOut(): void {\n this.eInput.blur()\n this.autocompleter.destroy()\n }\n\n destroy(): void {\n this.focusOut()\n if (this.stopEditing) {\n this.stopEditing()\n }\n }\n\n getValue(): DataFormat | undefined {\n return this.currentItem\n }\n\n isCancelAfterEnd(): boolean {\n if (this.required) {\n return !this.currentItem\n }\n return false\n }\n\n // eslint-disable-next-line class-methods-use-this\n isCancelBeforeStart(): boolean {\n return false\n }\n\n // eslint-disable-next-line class-methods-use-this\n isPopup(): boolean {\n return false\n }\n}\n","import GridOptionsV24Adapter from './grid-options-v24-adapter'\nimport GridOptionsV28Adapter from './grid-options-v28-adapter'\nimport GridOptionsV29Adapter from './grid-options-v29-adapter'\nimport GridOptionsV31Adapter from './grid-options-v31-adapter'\nimport { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Factory function to create the appropriate adapter based on the available properties\n */\nexport default function createGridOptionsAdapter(gridInstance: any): IGridOptionsAdapter {\n if ('gos' in gridInstance) {\n // gridOptionsService was renamed to gos on v31.3.0\n return new GridOptionsV31Adapter(gridInstance.gos)\n }\n if ('gridOptionsService' in gridInstance) {\n if ('in' in gridInstance.gridOptionsService) {\n return new GridOptionsV29Adapter(gridInstance.gridOptionsService)\n }\n // Method `in` was removed from `gridOptionsService` on V31.0.0\n return new GridOptionsV31Adapter(gridInstance.gridOptionsService)\n }\n if ('gridOptionsWrapper' in gridInstance) {\n return new GridOptionsV28Adapter(gridInstance.gridOptionsWrapper)\n }\n return new GridOptionsV24Adapter()\n}\n","import AutocompleteSelectCellEditor from './ag-grid-autocomplete'\n\nexport { DataFormat, IAutocompleteSelectCellEditorParameters } from './types'\nexport { default as AutocompleteSelectCellEditor } from './ag-grid-autocomplete'\n// eslint-disable-next-line unicorn/prefer-export-from\nexport default AutocompleteSelectCellEditor\n"],"names":["root","factory","exports","module","require","define","amd","a","i","self","__WEBPACK_EXTERNAL_MODULE__151__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","GridOptionsV24Adapter","version","isEnableCellEditingOnBackspace","GridOptionsV28Adapter","constructor","gridOptionsWrapper","this","GridOptionsV29Adapter","gridOptionsService","is","GridOptionsV31Adapter","defaultRenderGroup","groupName","groupDiv","document","createElement","textContent","className","defaultRender","item","itemElement","label","renderItems","items","selected","inputValue","clickHandler","render","renderGroup","fragment","createDocumentFragment","elements","previousGroup","group","push","div","addEventListener","event","classList","add","append","singleton","initialValue","newValue","KEYUP_EVENT_NAME","KEYS_TO_IGNORE","Set","DEFAULT_MIN_LENGTH","autocomplete","settings","getDocument","setDocument","input","ownerDocument","globalThis","getItems","setItems","getInputValue","setInputValue","getSelected","setSelected","getKeypressCounter","setKeypressCounter","getDebounceTimer","setDebounceTimer","strict","autoselectfirst","onFreeTextSelect","minLength","showOnFocus","customize","emptyMsg","debounceWaitMs","minimumInputLength","container","containerStyle","style","position","incrementKeypressCounter","clearDebounceTimer","debounceTimer","clearTimeout","containerDisplayed","parentNode","clear","remove","itemClickHandler","preventDefault","stopPropagation","onSelect","update","firstChild","removeChildren","length","empty","body","height","width","offsetWidth","inputRect","getBoundingClientRect","top","offsetHeight","maxHeight","defaultView","innerHeight","bottom","left","updatePosition","element","querySelector","previous","previousElementSibling","includes","offsetTop","scrollTop","selectBottom","containerBottom","updateScroll","updateIfDisplayed","resizeEventHandler","scrollEventHandler","target","startFetch","trigger","savedKeypressCounter","debouncingTime","handleFetchResult","setTimeout","fetch","debouncedFetch","keyupEventHandler","keyCode","which","has","keydownEventHandler","arrowKey","index","at","selectPreviousItem","selectNextItem","handleArrowKeysDown","freeTextSelect","handleSelectKeysDown","focusEventHandler","focusOutEventHandler","activeElement","addEventListeners","destroy","removeEventListener","removeEventListeners","KEY_BACKSPACE_STRING","KEY_DELETE_STRING","KeysHandled","KeysHandledStrings","AutocompleteSelectCellEditor","PopupComponent","getSelectData","parameters","selectData","Array","isArray","getDefaultAutocompleteSettings","cellEditor","escapedValue","replaceAll","String","raw","regex","RegExp","fieldItem","innerHTML","replace","match","eventFunction","currentItem","addManagedListeners","mousedown","addManagedListener","_","name","text","callback","toLowerCase","eInput","filter","n","window","suppressKeyboardEvent","isRequired","backspaceTriggersEdit","isVersionGte28","editing","getStartValue","eventKey","keyPress","formatValue","super","focusAfterAttached","required","getGui","init","gridApi","api","stopEditing","defaultSettings","cellStartedEdit","placeholder","autocompleteParameters","gridInstance","autocompleter","currentValue","result","KeyboardEvent","view","handleTabEvent","gridOptionsAdapter","gos","colDef","suppressParameters","shiftKey","tabToPreviousCell","tabToNextCell","afterGuiAttached","focus","select","setSelectionRange","focusIn","focusOut","blur","getValue","isCancelAfterEnd","isCancelBeforeStart","isPopup"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,2BAC7B,GAAqB,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,qBAAsBJ,OAC1B,CACJ,IAAIM,EAAuB,iBAAZL,QAAuBD,EAAQG,QAAQ,sBAAwBH,EAAQD,EAAK,sBAC3F,IAAI,IAAIQ,KAAKD,GAAuB,iBAAZL,QAAuBA,QAAUF,GAAMQ,GAAKD,EAAEC,EACvE,CACA,CATD,CASGC,KAAOC,G,wDCTVP,EAAOD,QAAUQ,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaZ,QAGrB,IAAIC,EAASQ,EAAyBE,GAAY,CAGjDX,QAAS,CAAC,GAOX,OAHAc,EAAoBH,GAAUV,EAAQA,EAAOD,QAASU,GAG/CT,EAAOD,OACf,CCrBAU,EAAoBK,EAAI,CAACf,EAASgB,KACjC,IAAI,IAAIC,KAAOD,EACXN,EAAoBQ,EAAEF,EAAYC,KAASP,EAAoBQ,EAAElB,EAASiB,IAC5EE,OAAOC,eAAepB,EAASiB,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EP,EAAoBQ,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFd,EAAoBkB,EAAK5B,IACH,oBAAX6B,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAepB,EAAS6B,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAAepB,EAAS,aAAc,CAAE+B,OAAO,K,+GCAxC,MAAMC,EA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GbL,EAAW+B,YAAY/B,EAAW7N,QAAU,EACrD,CAMQ,4BAAO0O,CACbC,EACAkB,GAAa,EACblC,GAAwB,EACxBmC,GAAiB,GAGjB,MAAM,QAAEtH,GAAYmG,EAAmBlM,OACjC,IAAEvD,GAAQyP,EAAmBlM,MAGnC,SAAIkM,EAAmBoB,WAAY7Q,EAAMkO,EAAmB1E,IAAIxJ,GAAOiO,EAAYzE,IAAIF,SAKlFsH,IAAmBD,GAAclB,EAAmBoB,YAKrD7Q,EAAMA,IAAQ+N,EA/TH,KA+TuBzE,KAK9BmF,IAA0BzO,EAAMA,IAAQ8N,EArU9B,IAqUqDxE,GACzE,EE3UF,U","sources":["webpack://ag-grid-autocomplete/webpack/universalModuleDefinition","webpack://ag-grid-autocomplete/external umd \"ag-grid-community\"","webpack://ag-grid-autocomplete/webpack/bootstrap","webpack://ag-grid-autocomplete/webpack/runtime/define property getters","webpack://ag-grid-autocomplete/webpack/runtime/hasOwnProperty shorthand","webpack://ag-grid-autocomplete/webpack/runtime/make namespace object","webpack://ag-grid-autocomplete/./src/adapters/grid-options-v24-adapter.ts","webpack://ag-grid-autocomplete/./src/adapters/grid-options-v25-adapter.ts","webpack://ag-grid-autocomplete/./src/adapters/grid-options-v29-adapter.ts","webpack://ag-grid-autocomplete/./src/adapters/grid-options-v30-adapter.ts","webpack://ag-grid-autocomplete/./src/adapters/grid-options-v32-adapter.ts","webpack://ag-grid-autocomplete/./autocompleter/rendering.ts","webpack://ag-grid-autocomplete/./autocompleter/singleton.ts","webpack://ag-grid-autocomplete/./autocompleter/autocomplete.ts","webpack://ag-grid-autocomplete/./src/autocomplete-input.ts","webpack://ag-grid-autocomplete/./ag-grid-autocomplete.ts","webpack://ag-grid-autocomplete/./src/adapters/grid-options-adapter.ts","webpack://ag-grid-autocomplete/./index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"ag-grid-community\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"ag-grid-community\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"ag-grid-community\")) : factory(root[\"ag-grid-community\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(self, (__WEBPACK_EXTERNAL_MODULE__743__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__743__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Adapter implementation for AG Grid v24\n */\nexport default class GridOptionsV24Adapter implements IGridOptionsAdapter {\n version = 24\n\n // eslint-disable-next-line class-methods-use-this\n isEnableCellEditingOnBackspace(): boolean {\n return true\n }\n}\n","import { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Adapter implementation for AG Grid v25-28\n * Uses gridOptionsWrapper\n */\nexport default class GridOptionsV25Adapter implements IGridOptionsAdapter {\n version: 25 | 28\n\n constructor(private readonly gridOptionsWrapper: any) {\n // isEnableCellEditingOnBackspace is new on version 28, so it is safe to assume v28+\n this.version = typeof this.gridOptionsWrapper.isEnableCellEditingOnBackspace === 'function' ? 28 : 25\n }\n\n isEnableCellEditingOnBackspace(): boolean {\n // This option didn't exist before v28, the original behavior is as it was always set to true\n if (this.version < 28) return true\n return this.gridOptionsWrapper.isEnableCellEditingOnBackspace()\n }\n}\n","import { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Adapter implementation for AG Grid v29\n * Uses gridOptionsService\n */\nexport default class GridOptionsV29Adapter implements IGridOptionsAdapter {\n version = 29\n\n constructor(private readonly gridOptionsService: any) {}\n\n isEnableCellEditingOnBackspace(): boolean {\n return this.gridOptionsService.is('enableCellEditingOnBackspace')\n }\n}\n","import { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Adapter implementation for AG Grid v30\n * Uses gridOptionsService\n */\nexport default class GridOptionsV30Adapter implements IGridOptionsAdapter {\n version = 30\n\n constructor(private readonly gridOptionsService: any) {}\n\n isEnableCellEditingOnBackspace(): boolean {\n return this.gridOptionsService.get('enableCellEditingOnBackspace')\n }\n}\n","import { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Adapter implementation for AG Grid v32\n * Reads options directly from gridApi\n */\nexport default class GridOptionsV32Adapter implements IGridOptionsAdapter {\n version = 32\n\n constructor(private readonly gridApi: any) {}\n\n isEnableCellEditingOnBackspace(): boolean {\n return this.gridApi.getGridOption('enableCellEditingOnBackspace')\n }\n}\n","import { AutocompleteItem, RenderFunction, RenderGroupFunction } from './types'\n\nexport function removeChildren(container: Node) {\n while (container.firstChild) {\n container.firstChild.remove()\n }\n}\n\nexport function defaultRenderGroup(groupName: string): HTMLDivElement {\n const groupDiv = document.createElement('div')\n groupDiv.textContent = groupName\n groupDiv.className = 'group'\n return groupDiv\n}\n\nexport function defaultRender(item: AutocompleteItem): HTMLDivElement {\n const itemElement = document.createElement('div')\n itemElement.textContent = item.label || ''\n return itemElement\n}\n\nexport function renderItems<T extends AutocompleteItem>(\n items: T[],\n selected: T | undefined,\n inputValue: string,\n clickHandler: (item: T, event: MouseEvent) => void,\n render: RenderFunction<T> = defaultRender,\n renderGroup: RenderGroupFunction = defaultRenderGroup,\n): DocumentFragment {\n const fragment = document.createDocumentFragment()\n const elements: HTMLElement[] = []\n let previousGroup = '#9?$'\n // eslint-disable-next-line no-restricted-syntax\n for (const item of items) {\n if (item.group && item.group !== previousGroup) {\n previousGroup = item.group\n const groupDiv = renderGroup(item.group, inputValue)\n elements.push(groupDiv)\n }\n const div = render(item, inputValue)\n div.addEventListener('click', (event: MouseEvent) => clickHandler(item, event))\n if (item === selected) {\n div.classList.add('selected')\n }\n elements.push(div)\n }\n fragment.append(...elements)\n return fragment\n}\n","/**\n * Simple function to create typed and scope safe singletons inspired by react hooks\n * @param initialValue: The initial value of the singleton\n * @example\n * // declare and use a new singleton\n * const [getValue, setValue] = singleton(0)\n * // increment the singleton value\n * setValue(getValue() + 1)\n * @returns [singletonGetter, singletonSetter]\n */\nexport default function singleton<T>(initialValue: T) {\n let value = initialValue\n const setValue = (newValue: T) => {\n value = newValue\n return value\n }\n const getValue = () => {\n return value\n }\n return [getValue, setValue] as const\n}\n","import { removeChildren, renderItems } from './rendering'\nimport { AutocompleteItem, EventTrigger, AutocompleteSettings, AutocompleteResult } from './types'\nimport singleton from './singleton'\n\nconst enum Keys {\n Enter = 13,\n Esc = 27,\n Up = 38,\n Down = 40,\n Left = 37,\n Right = 39,\n Shift = 16,\n Ctrl = 17,\n Alt = 18,\n CapsLock = 20,\n WindowsKey = 91,\n Tab = 9,\n}\n\nconst KEYUP_EVENT_NAME = 'input'\n\nconst KEYS_TO_IGNORE = new Set([\n Keys.Up,\n Keys.Enter,\n Keys.Esc,\n Keys.Right,\n Keys.Left,\n Keys.Shift,\n Keys.Ctrl,\n Keys.Alt,\n Keys.CapsLock,\n Keys.WindowsKey,\n Keys.Tab,\n])\nconst DEFAULT_MIN_LENGTH = 2\n\nexport default function autocomplete<T extends AutocompleteItem>(\n settings: AutocompleteSettings<T>,\n): AutocompleteResult {\n /* eslint-disable unicorn/no-useless-undefined */\n const [getDocument, setDocument] = singleton(settings.input.ownerDocument || globalThis.document)\n const [getItems, setItems] = singleton<T[]>([])\n const [getInputValue, setInputValue] = singleton('')\n const [getSelected, setSelected] = singleton<T | undefined>(undefined)\n const [getKeypressCounter, setKeypressCounter] = singleton(0)\n const [getDebounceTimer, setDebounceTimer] = singleton<NodeJS.Timeout | undefined>(undefined)\n /* eslint-enable */\n\n const {\n strict,\n autoselectfirst,\n onFreeTextSelect,\n minLength = DEFAULT_MIN_LENGTH,\n showOnFocus,\n input,\n className,\n customize,\n emptyMsg,\n render,\n renderGroup,\n } = settings\n const debounceWaitMs = settings.debounceWaitMs || 0\n const minimumInputLength = minLength\n const container: HTMLDivElement = document.createElement('div')\n const containerStyle = container.style\n\n container.className = `autocomplete ${className || ''}`\n containerStyle.position = 'fixed'\n\n const incrementKeypressCounter = () => {\n setKeypressCounter(getKeypressCounter() + 1)\n }\n\n /**\n * Detach the container from DOM\n */\n function detach() {\n if (container) {\n container.remove()\n }\n }\n\n /**\n * Clear debouncing timer if assigned\n */\n function clearDebounceTimer() {\n const debounceTimer = getDebounceTimer()\n if (debounceTimer !== undefined) {\n globalThis.clearTimeout(debounceTimer)\n // eslint-disable-next-line unicorn/no-useless-undefined\n setDebounceTimer(undefined)\n }\n }\n\n /**\n * Attach the container to DOM\n */\n function attach() {\n setDocument(input.ownerDocument || globalThis.document)\n if (!container.parentNode) {\n getDocument().body.append(container)\n }\n }\n\n /**\n * Check if container for autocomplete is displayed\n */\n function containerDisplayed(): boolean {\n return !!container.parentNode\n }\n\n /**\n * Clear autocomplete state and hide container\n */\n function clear() {\n incrementKeypressCounter()\n setItems([])\n setInputValue('')\n // eslint-disable-next-line unicorn/no-useless-undefined\n setSelected(undefined)\n detach()\n }\n\n /**\n * Update autocomplete position to put it under the input field\n */\n function updatePosition() {\n if (containerDisplayed()) {\n const document = getDocument()\n\n containerStyle.height = 'auto'\n containerStyle.width = `${input.offsetWidth}px`\n\n const inputRect = input.getBoundingClientRect()\n const top = inputRect.top + input.offsetHeight\n let maxHeight = document.defaultView!.innerHeight - top\n\n if (maxHeight < 0) {\n maxHeight = 0\n }\n\n containerStyle.top = `${top}px`\n containerStyle.bottom = ''\n containerStyle.left = `${inputRect.left}px`\n containerStyle.maxHeight = `${maxHeight}px`\n\n if (customize) {\n customize(input, inputRect, container, maxHeight)\n }\n }\n }\n\n /**\n * Automatically move scroll bar if selected item is not visible\n */\n function updateScroll() {\n let element = container.querySelector('.selected') as HTMLDivElement\n if (element) {\n // make group visible\n const previous = element.previousElementSibling\n if (previous && previous.previousElementSibling === null && previous.className.includes('group')) {\n element = previous as HTMLDivElement\n }\n\n if (element.offsetTop < container.scrollTop) {\n container.scrollTop = element.offsetTop\n } else {\n const selectBottom = element.offsetTop + element.offsetHeight\n const containerBottom = container.scrollTop + container.offsetHeight\n if (selectBottom > containerBottom) {\n container.scrollTop += selectBottom - containerBottom\n }\n }\n }\n }\n\n /**\n * Handle the click on an item of the selection list\n * @param item: data of the clicked item\n * @param event: MouseEvent who has triggered the selection\n */\n function itemClickHandler(item: T, event: MouseEvent) {\n event.preventDefault()\n event.stopPropagation()\n settings.onSelect(item, input, event)\n clear()\n }\n\n /**\n * Redraw the autocomplete div element with suggestions\n */\n function update() {\n // Clear all child from container\n removeChildren(container)\n\n const items = getItems()\n const fragment = renderItems<T>(items, getSelected(), getInputValue(), itemClickHandler, render, renderGroup)\n container.append(fragment)\n if (items.length === 0 && strict) {\n // if no items display empty message\n if (emptyMsg) {\n const empty = document.createElement('div')\n empty.className = 'empty'\n empty.textContent = emptyMsg\n container.append(empty)\n // eslint-disable-next-line unicorn/no-useless-undefined\n setSelected(undefined)\n } else {\n clear()\n return\n }\n }\n\n attach()\n updatePosition()\n updateScroll()\n }\n\n function updateIfDisplayed() {\n if (containerDisplayed()) {\n update()\n }\n }\n\n function resizeEventHandler() {\n updateIfDisplayed()\n }\n\n function scrollEventHandler(event: Event) {\n if (event.target === container) {\n event.preventDefault()\n } else {\n updateIfDisplayed()\n }\n }\n\n function debouncedFetch(trigger: EventTrigger) {\n const savedKeypressCounter = getKeypressCounter()\n const debouncingTime = trigger === EventTrigger.Keyboard ? debounceWaitMs : 0\n const { value } = input\n // Hydrate this.items with retrieved items\n const handleFetchResult = (elements: T[] | false) => {\n if (getKeypressCounter() === savedKeypressCounter && elements) {\n setItems(elements)\n setInputValue(value)\n setSelected(elements.length > 0 && autoselectfirst ? elements[0] : undefined)\n update()\n }\n }\n return globalThis.setTimeout(() => {\n settings.fetch(value, handleFetchResult, trigger)\n }, debouncingTime)\n }\n\n function startFetch(trigger: EventTrigger) {\n // if multiple keys were pressed, before we get update from server,\n // this may cause redrawing our autocomplete multiple times after the last key press.\n // to avoid this, the number of times keyboard was pressed will be\n // saved and checked before redraw our autocomplete box.\n incrementKeypressCounter()\n\n const { value } = input\n if (value.length >= minimumInputLength || trigger === EventTrigger.Focus) {\n clearDebounceTimer()\n setDebounceTimer(debouncedFetch(trigger))\n } else {\n clear()\n }\n }\n\n function keyupEventHandler(event: KeyboardEvent) {\n // eslint-disable-next-line sonarjs/deprecation\n const keyCode = event.which || event.keyCode || 0\n\n if (KEYS_TO_IGNORE.has(keyCode)) {\n return\n }\n\n // the down key is used to open autocomplete\n if (keyCode === Keys.Down && containerDisplayed()) {\n return\n }\n\n startFetch(EventTrigger.Keyboard)\n }\n\n /**\n * Select the previous item in suggestions\n */\n function selectPreviousItem() {\n const items = getItems()\n const selected = getSelected()\n if (items.length === 0) {\n // eslint-disable-next-line unicorn/no-useless-undefined\n setSelected(undefined)\n return\n }\n if (selected === undefined || selected === items[0]) {\n setSelected(items.at(-1))\n return\n }\n for (let index = items.length - 1; index > 0; index -= 1) {\n if (selected === items[index] || index === 1) {\n setSelected(items[index - 1])\n return\n }\n }\n }\n\n /**\n * Select the next item in suggestions\n */\n function selectNextItem() {\n const items = getItems()\n const selected = getSelected()\n if (items.length === 0) {\n // eslint-disable-next-line unicorn/no-useless-undefined\n setSelected(undefined)\n return\n }\n if (selected === undefined || selected === items.at(-1)) {\n // eslint-disable-next-line prefer-destructuring\n setSelected(items[0])\n return\n }\n for (let index = 0; index < items.length - 1; index += 1) {\n if (selected === items[index]) {\n setSelected(items[index + 1])\n return\n }\n }\n }\n\n function handleArrowKeysDown(arrowKey: Keys.Up | Keys.Down) {\n const containerIsDisplayed = containerDisplayed()\n if (containerIsDisplayed && getItems().length > 0) {\n switch (arrowKey) {\n case Keys.Up: {\n selectPreviousItem()\n break\n }\n case Keys.Down: {\n selectNextItem()\n break\n }\n default:\n }\n update()\n }\n }\n\n function handleSelectKeysDown(event: KeyboardEvent) {\n const selected = getSelected()\n if (strict) {\n settings.onSelect(selected, input, event)\n } else {\n const freeTextSelect = { label: input.value } as T\n if (selected) {\n settings.onSelect(selected, input, event)\n return\n }\n if (onFreeTextSelect) {\n onFreeTextSelect(freeTextSelect, input)\n }\n settings.onSelect(freeTextSelect, input, event)\n }\n clear()\n }\n\n function keydownEventHandler(event: KeyboardEvent) {\n // eslint-disable-next-line sonarjs/deprecation\n const keyCode = event.which || event.keyCode || 0\n\n if (\n keyCode === Keys.Up ||\n keyCode === Keys.Down ||\n keyCode === Keys.Esc ||\n keyCode === Keys.Enter ||\n keyCode === Keys.Tab\n ) {\n event.preventDefault()\n if (containerDisplayed()) {\n event.stopPropagation()\n }\n if (keyCode === Keys.Up || keyCode === Keys.Down || keyCode === Keys.Esc) {\n if (keyCode === Keys.Esc) {\n settings.onSelect(undefined, input, event)\n clear()\n } else {\n handleArrowKeysDown(keyCode)\n }\n return\n }\n\n if (keyCode === Keys.Enter || keyCode === Keys.Tab) {\n handleSelectKeysDown(event)\n }\n }\n }\n\n function focusEventHandler() {\n if (showOnFocus) {\n startFetch(EventTrigger.Focus)\n }\n }\n\n function focusOutEventHandler(event: Event) {\n // we need to delay clear, because when we click on an item, blur will be called before click and remove items from DOM\n event.preventDefault()\n event.stopPropagation()\n setTimeout(() => {\n if (getDocument().activeElement !== input) {\n clear()\n }\n }, 200)\n }\n\n function removeEventListeners() {\n const document = getDocument()\n\n input.removeEventListener('focus', focusEventHandler)\n input.removeEventListener('keydown', keydownEventHandler)\n input.removeEventListener(KEYUP_EVENT_NAME, keyupEventHandler as EventListenerOrEventListenerObject)\n input.removeEventListener('focusout', focusOutEventHandler)\n document.removeEventListener('resize', resizeEventHandler)\n document.removeEventListener('scroll', scrollEventHandler, true)\n }\n\n function addEventListeners() {\n const document = getDocument()\n\n input.addEventListener('keydown', keydownEventHandler)\n input.addEventListener(KEYUP_EVENT_NAME, keyupEventHandler as EventListenerOrEventListenerObject)\n input.addEventListener('focusout', focusOutEventHandler)\n input.addEventListener('focus', focusEventHandler)\n document.addEventListener('resize', resizeEventHandler)\n document.addEventListener('scroll', scrollEventHandler, true)\n }\n\n /**\n * This function will remove DOM elements and clear event handlers\n */\n function destroy() {\n removeEventListeners()\n clearDebounceTimer()\n clear()\n\n // prevent the update call if there are pending AJAX requests\n incrementKeypressCounter()\n }\n\n addEventListeners()\n return {\n destroy,\n }\n}\n\nexport { AutocompleteItem, AutocompleteSettings, EventTrigger } from './types'\n","import autocomplete from '../autocompleter/autocomplete'\nimport { AutocompleteResult, AutocompleteSettings } from '../autocompleter/types'\nimport { DataFormat } from '../types'\n\nexport interface AutocompleteInputConfig {\n placeholder?: string\n initialValue?: string\n selectData: DataFormat[] | (() => DataFormat[])\n autocompleteSettings?: Partial<AutocompleteSettings<DataFormat>>\n onSelect?: (item: DataFormat | undefined, event: KeyboardEvent | MouseEvent) => void\n onItemMousedown?: (item: DataFormat, event: MouseEvent) => void\n /** Optional existing input element to use instead of creating one */\n inputElement?: HTMLInputElement\n}\n\nconst TEMPLATE = `<div class=\"ag-wrapper ag-input-wrapper ag-text-field-input-wrapper ag-cell-editor-autocomplete-wrapper\" style=\"padding: 0 !important;\">\n <input class=\"ag-input-field-input ag-text-field-input ag-cell-editor-autocomplete-input\" type=\"text\"/>\n</div>`\n\n/**\n * Autocomplete input component - handles autocomplete UI and selection logic.\n * This is separated from the cell editor to allow for cleaner AG Grid version compatibility.\n */\nexport class AutocompleteInput {\n private readonly container?: HTMLDivElement\n\n private readonly eInput: HTMLInputElement\n\n private autocompleter?: AutocompleteResult\n\n private config: AutocompleteInputConfig\n\n private selectedItem?: DataFormat\n\n public get currentItem(): DataFormat | undefined {\n return this.selectedItem\n }\n\n public set currentItem(value: DataFormat | undefined) {\n this.selectedItem = value\n }\n\n constructor(config: AutocompleteInputConfig) {\n this.config = config\n\n // Use provided input element or create new DOM structure\n if (config.inputElement) {\n this.eInput = config.inputElement\n } else {\n const template = document.createElement('template')\n template.innerHTML = TEMPLATE.trim()\n this.container = template.content.firstChild as HTMLDivElement\n this.eInput = this.container.querySelector('input') as HTMLInputElement\n }\n\n // Setup input\n this.eInput.placeholder = config.placeholder ?? ''\n if (config.initialValue) {\n this.eInput.value = config.initialValue\n }\n\n // Setup autocomplete\n this.setupAutocomplete()\n }\n\n public getGui(): HTMLElement | undefined {\n return this.container\n }\n\n public getInputElement(): HTMLInputElement {\n return this.eInput\n }\n\n public getValue(): DataFormat | undefined {\n return this.selectedItem\n }\n\n public setValue(value: string): void {\n this.eInput.value = value\n }\n\n public focus(): void {\n this.eInput.focus()\n }\n\n public select(): void {\n this.eInput.select()\n }\n\n public blur(): void {\n this.eInput.blur()\n }\n\n public focusAndSelect(): void {\n this.focus()\n this.select()\n }\n\n public setCaretAtEnd(): void {\n const length = this.eInput.value?.length ?? 0\n if (length > 0) {\n this.eInput.setSelectionRange(length, length)\n }\n }\n\n public triggerAutocomplete(): void {\n this.eInput.dispatchEvent(new Event('input', { bubbles: true }))\n }\n\n public destroy(): void {\n this.autocompleter?.destroy()\n }\n\n private getSelectData(): DataFormat[] {\n const { selectData } = this.config\n if (typeof selectData === 'function') {\n return selectData()\n }\n if (Array.isArray(selectData)) {\n return selectData\n }\n return []\n }\n\n private setupAutocomplete(): void {\n const defaultSettings = this.getDefaultAutocompleteSettings()\n const mergedSettings = { ...defaultSettings, ...this.config.autocompleteSettings }\n\n this.autocompleter = autocomplete<DataFormat>({\n input: this.eInput,\n render: mergedSettings.render,\n renderGroup: mergedSettings.renderGroup,\n className: mergedSettings.className,\n minLength: mergedSettings.minLength,\n emptyMsg: mergedSettings.emptyMsg,\n strict: mergedSettings.strict,\n autoselectfirst: mergedSettings.autoselectfirst,\n showOnFocus: mergedSettings.showOnFocus,\n onFreeTextSelect: mergedSettings.onFreeTextSelect,\n onSelect: (item: DataFormat | undefined, input: HTMLInputElement, event: KeyboardEvent | MouseEvent) => {\n this.selectedItem = item\n mergedSettings.onSelect(item, input, event)\n this.config.onSelect?.(item, event)\n },\n fetch: mergedSettings.fetch,\n debounceWaitMs: mergedSettings.debounceWaitMs,\n customize: mergedSettings.customize,\n })\n }\n\n private getDefaultAutocompleteSettings(): Required<Omit<AutocompleteSettings<DataFormat>, 'input'>> {\n return {\n showOnFocus: false,\n render: (item, value) => {\n const itemElement = document.createElement('div')\n const escapedValue = (value ?? '').replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, String.raw`\\$&`)\n const regex = new RegExp(escapedValue, 'gi')\n const fieldItem = document.createElement('span')\n fieldItem.innerHTML = item.label.replace(regex, (match: string) => `<strong>${match}</strong>`)\n itemElement.append(fieldItem)\n\n // Handle mousedown for item selection\n const eventFunction = (event: MouseEvent) => {\n this.selectedItem = item\n event.stopPropagation()\n this.config.onItemMousedown?.(item, event)\n }\n itemElement.addEventListener('mousedown', eventFunction)\n\n return itemElement\n },\n renderGroup: (name, _currentValue) => {\n const div = document.createElement('div')\n div.textContent = name\n div.className = 'group'\n return div\n },\n className: 'ag-cell-editor-autocomplete',\n minLength: 1,\n emptyMsg: 'None',\n strict: true,\n autoselectfirst: true,\n onFreeTextSelect: () => {},\n onSelect: () => {},\n fetch: (text, callback) => {\n const items = this.getSelectData()\n const match = text.toLowerCase() || this.eInput.value.toLowerCase()\n callback(items.filter((n) => n.label.toLowerCase().includes(match)))\n },\n debounceWaitMs: 200,\n customize: (input, inputRect, dropdownContainer, maxHeight) => {\n if (maxHeight < 100) {\n /* eslint-disable no-param-reassign */\n dropdownContainer.style.top = '10px'\n dropdownContainer.style.bottom = `${window.innerHeight - inputRect.bottom + input.offsetHeight}px`\n dropdownContainer.style.maxHeight = '140px'\n /* eslint-enable no-param-reassign */\n }\n },\n }\n }\n}\n","import { Component, GridApi, ICellEditorComp, SuppressKeyboardEventParams } from 'ag-grid-community'\nimport { IAutocompleteSelectCellEditorParameters, DataFormat } from './types'\nimport createGridOptionsAdapter from './src/adapters/grid-options-adapter'\nimport { IGridOptionsAdapter } from './src/adapters/grid-options-interfaces'\nimport { AutocompleteInput, AutocompleteInputConfig } from './src/autocomplete-input'\n\n// use require instead of import to generate the .css file with webpack but avoid import into the .d.ts file\n// eslint-disable-next-line unicorn/prefer-module\nrequire('./ag-grid-autocomplete.scss')\n\n// Key codes (legacy numeric for v23-v26)\nconst KEY_BACKSPACE = 8\nconst KEY_DELETE = 46\nconst KEY_ENTER = 13\nconst KEY_TAB = 9\nconst KEY_UP = 38\nconst KEY_DOWN = 40\n\n// Key strings (modern for v27+)\nconst KEY_BACKSPACE_STRING = 'Backspace'\nconst KEY_DELETE_STRING = 'Delete'\nconst KEY_ENTER_STRING = 'Enter'\nconst KEY_TAB_STRING = 'Tab'\nconst KEY_UP_STRING = 'ArrowUp'\nconst KEY_DOWN_STRING = 'ArrowDown'\n\nconst KeysHandled = new Set([KEY_BACKSPACE, KEY_DELETE, KEY_ENTER, KEY_TAB, KEY_UP, KEY_DOWN])\nconst KeysHandledStrings = new Set([\n KEY_BACKSPACE_STRING,\n KEY_DELETE_STRING,\n KEY_ENTER_STRING,\n KEY_TAB_STRING,\n KEY_UP_STRING,\n KEY_DOWN_STRING,\n])\n\ntype AutocompleteParameters = IAutocompleteSelectCellEditorParameters<AutocompleteSelectCellEditor>\n\n/**\n * Autocomplete cell editor for AG Grid.\n * This is a thin wrapper around AutocompleteInput that handles AG Grid integration.\n */\nexport default class AutocompleteSelectCellEditor extends Component implements ICellEditorComp {\n // The autocomplete input component\n private autocompleteInput!: AutocompleteInput\n\n // AG Grid integration\n private focusAfterAttached: boolean = false\n\n private startedByEnter: boolean = false\n\n private required: boolean = false\n\n private gridApi?: GridApi\n\n private gridOptionsAdapter!: IGridOptionsAdapter\n\n private stopEditing?: (cancel?: boolean) => void\n\n /**\n * Originally AgGrid would always trigger cell editing when backspace was hit\n */\n private backspaceTriggersEdit = true\n\n constructor() {\n // Use the same wrapper structure as the original implementation\n // This matches the template in AutocompleteInput for consistency\n super(\n '<div class=\"ag-wrapper ag-input-wrapper ag-text-field-input-wrapper ag-cell-editor-autocomplete-wrapper\" style=\"padding: 0 !important;\"><input class=\"ag-input-field-input ag-text-field-input ag-cell-editor-autocomplete-input\" type=\"text\"/></div>',\n )\n }\n\n /**\n * Initialize the cell editor\n * @param parameters - Cell editor parameters from AG Grid\n */\n public init(parameters: AutocompleteParameters): void {\n this.gridApi = parameters.api\n this.stopEditing = parameters.stopEditing\n this.focusAfterAttached = parameters.cellStartedEdit\n this.startedByEnter = parameters.eventKey === KEY_ENTER_STRING\n this.required = parameters.required ?? false\n\n // Create the grid options adapter based on the instance\n this.gridOptionsAdapter = createGridOptionsAdapter(this.gridApi)\n\n // The behavior for deleting cell values changed from v28 and beyond\n if (this.gridOptionsAdapter.version >= 28) {\n this.backspaceTriggersEdit = this.gridOptionsAdapter.isEnableCellEditingOnBackspace()\n }\n\n // Get the input element from our template\n const inputElement = this.getGui().querySelector('input') as HTMLInputElement\n\n // Create the autocomplete input component, passing our existing input element\n this.autocompleteInput = new AutocompleteInput({\n placeholder: parameters.placeholder,\n initialValue: AutocompleteSelectCellEditor.getStartValue(parameters),\n selectData: () => AutocompleteSelectCellEditor.getSelectData(parameters),\n autocompleteSettings: this.transformAutocompleteSettings(parameters),\n onSelect: (item, event) => {\n this.handleSelection(item, event)\n },\n onItemMousedown: (item) => {\n this.autocompleteInput.currentItem = item\n },\n inputElement,\n })\n\n // Setup keyboard suppression if not already configured\n if (!parameters.colDef.suppressKeyboardEvent) {\n // eslint-disable-next-line no-param-reassign\n parameters.colDef.suppressKeyboardEvent = (suppressParameters) =>\n AutocompleteSelectCellEditor.suppressKeyboardEvent(\n suppressParameters,\n this.required,\n this.backspaceTriggersEdit,\n this.gridOptionsAdapter.version >= 28,\n )\n }\n }\n\n public afterGuiAttached(): void {\n if (this.focusAfterAttached) {\n this.autocompleteInput.focusAndSelect()\n this.autocompleteInput.setCaretAtEnd()\n }\n\n // When started by Enter key, trigger the autocomplete dropdown\n if (this.startedByEnter) {\n setTimeout(() => {\n this.autocompleteInput.triggerAutocomplete()\n })\n }\n }\n\n public focusIn(): void {\n this.autocompleteInput.focusAndSelect()\n }\n\n public focusOut(): void {\n this.autocompleteInput.blur()\n this.autocompleteInput.destroy()\n }\n\n public getValue(): DataFormat | undefined {\n return this.autocompleteInput.getValue()\n }\n\n public isCancelAfterEnd(): boolean {\n return this.required && !this.autocompleteInput.getValue()\n }\n\n // For backward compatibility - expose currentItem\n public get currentItem(): DataFormat | undefined {\n return this.autocompleteInput?.currentItem\n }\n\n public set currentItem(value: DataFormat | undefined) {\n if (this.autocompleteInput) {\n this.autocompleteInput.currentItem = value\n }\n }\n\n // Private methods\n\n private handleSelection(item: DataFormat | undefined, event: KeyboardEvent | MouseEvent): void {\n // Check if this was a keyboard event (Enter/Tab) vs mouse click\n // Need the second check because of cypress testing changing the view context\n const isKeyboardEvent =\n event instanceof KeyboardEvent || event instanceof event.view!.document.defaultView!.KeyboardEvent\n\n if (isKeyboardEvent) {\n this.handleKeyboardSelection(event as KeyboardEvent)\n } else if (item) {\n this.selectAndClose()\n }\n }\n\n private handleKeyboardSelection(event: KeyboardEvent): void {\n // eslint-disable-next-line sonarjs/deprecation\n const keyCode = event.which || event.keyCode || 0\n\n if (keyCode === KEY_TAB && this.gridApi) {\n // Tab key - navigate to next/previous cell\n if (event.shiftKey) {\n this.gridApi.tabToPreviousCell()\n } else {\n this.gridApi.tabToNextCell()\n }\n } else {\n // Enter key or other - just close\n this.selectAndClose()\n }\n }\n\n private selectAndClose(): void {\n this.focusOut()\n if (this.stopEditing) {\n this.stopEditing()\n }\n }\n\n /**\n * Wraps a user-provided callback to inject the cell editor as the first parameter.\n *\n * This enables backward compatibility: users expect callbacks like `render(cellEditor, item, value)`,\n * but internally AutocompleteInput uses simpler signatures like `render(item, value)`.\n *\n * @param callback - User's callback that expects the cell editor as first parameter\n * @returns A wrapped function that injects `this` (the cell editor) as the first argument\n *\n * @example\n * // User provides: (cellEditor, item, value) => HTMLElement\n * // We transform to: (item, value) => userCallback(this, item, value)\n * transformed.render = this.wrapCallback(userSettings.render)\n */\n private wrapCallback<Arguments extends any[], Return>(\n callback: (context: this, ...arguments_: Arguments) => Return,\n ): (...arguments_: Arguments) => Return {\n // Capture `this` (the cell editor) via closure and prepend it to all calls\n return (...arguments_: Arguments) => {\n return callback(this, ...arguments_)\n }\n }\n\n private transformAutocompleteSettings(\n parameters: AutocompleteParameters,\n ): AutocompleteInputConfig['autocompleteSettings'] {\n const userSettings = parameters.autocomplete\n if (!userSettings) {\n return {}\n }\n\n // Transform the settings to add AutocompleteInput as context to the callback functions\n const transformed: AutocompleteInputConfig['autocompleteSettings'] = {}\n\n if (userSettings.render) {\n transformed.render = this.wrapCallback(userSettings.render)\n }\n\n if (userSettings.renderGroup) {\n transformed.renderGroup = this.wrapCallback(userSettings.renderGroup)\n }\n\n if (userSettings.onFreeTextSelect) {\n transformed.onFreeTextSelect = this.wrapCallback(userSettings.onFreeTextSelect)\n }\n\n if (userSettings.onSelect) {\n transformed.onSelect = this.wrapCallback(userSettings.onSelect)\n }\n\n if (userSettings.fetch) {\n transformed.fetch = this.wrapCallback(userSettings.fetch)\n }\n\n if (userSettings.customize) {\n transformed.customize = this.wrapCallback(userSettings.customize)\n }\n\n // Copy non-function settings directly\n if (userSettings.className !== undefined) transformed.className = userSettings.className\n if (userSettings.minLength !== undefined) transformed.minLength = userSettings.minLength\n if (userSettings.emptyMsg !== undefined) transformed.emptyMsg = userSettings.emptyMsg\n if (userSettings.strict !== undefined) transformed.strict = userSettings.strict\n if (userSettings.autoselectfirst !== undefined) transformed.autoselectfirst = userSettings.autoselectfirst\n if (userSettings.showOnFocus !== undefined) transformed.showOnFocus = userSettings.showOnFocus\n if (userSettings.debounceWaitMs !== undefined) transformed.debounceWaitMs = userSettings.debounceWaitMs\n\n return transformed\n }\n\n // Static helper methods\n\n private static getSelectData(parameters: AutocompleteParameters): Array<DataFormat> {\n if (typeof parameters.selectData === 'function') {\n return parameters.selectData(parameters)\n }\n if (Array.isArray(parameters.selectData)) {\n return parameters.selectData\n }\n return []\n }\n\n private static getStartValue(parameters: AutocompleteParameters): string {\n // Check for new eventKey (v27+) or fall back to keyPress for backward compatibility\n const eventKey = (parameters as any).eventKey as string\n const keyPress = (parameters as any).keyPress as number\n\n // Check for backspace or delete using either the string eventKey or numeric keyPress\n const isBackspace = eventKey ? eventKey === KEY_BACKSPACE_STRING : keyPress === KEY_BACKSPACE\n const isDelete = eventKey ? eventKey === KEY_DELETE_STRING : keyPress === KEY_DELETE\n\n if (isBackspace || isDelete) {\n return ''\n }\n\n // Detecting if the pressed key is a character\n if (parameters.eventKey?.length === 1) {\n return parameters.eventKey\n }\n\n return parameters.formatValue(parameters.value) ?? ''\n }\n\n /**\n * Determines whether a keyboard event should be suppressed in a grid cell.\n * Supports both modern (key-based) and legacy (keyCode-based) keyboard event handling.\n */\n private static suppressKeyboardEvent(\n suppressParameters: SuppressKeyboardEventParams,\n isRequired = false,\n backspaceTriggersEdit = true,\n isVersionGte28 = false,\n ): boolean {\n // eslint-disable-next-line sonarjs/deprecation\n const { keyCode } = suppressParameters.event\n const { key } = suppressParameters.event\n\n // Handle both numeric keyCode and string key approaches\n if (suppressParameters.editing && (key ? KeysHandledStrings.has(key) : KeysHandled.has(keyCode))) {\n return true\n }\n\n // Logic below this point is required only if we are using ag-grid>=28, field is required, and is not in edit mode\n if (!isVersionGte28 || !isRequired || suppressParameters.editing) {\n return false\n }\n\n // If the user hits delete, prevent it as it doesn't trigger a cell edit anymore\n if (key ? key === KEY_DELETE_STRING : keyCode === KEY_DELETE) {\n return true\n }\n\n // If the user hits backspace and cell editing is not enabled, prevent it\n return !backspaceTriggersEdit && (key ? key === KEY_BACKSPACE_STRING : keyCode === KEY_BACKSPACE)\n }\n}\n","import GridOptionsV24Adapter from './grid-options-v24-adapter'\nimport GridOptionsV25Adapter from './grid-options-v25-adapter'\nimport GridOptionsV29Adapter from './grid-options-v29-adapter'\nimport GridOptionsV30Adapter from './grid-options-v30-adapter'\nimport GridOptionsV32Adapter from './grid-options-v32-adapter'\nimport { IGridOptionsAdapter } from './grid-options-interfaces'\n\n/**\n * Factory function to create the appropriate adapter based on the available properties\n */\nexport default function createGridOptionsAdapter(gridInstance: any): IGridOptionsAdapter {\n if (!('context' in gridInstance)) {\n return new GridOptionsV32Adapter(gridInstance)\n }\n if ('gos' in gridInstance) {\n // gos (gridOptionsService shorthand) exists on gridApi in v30-v31\n return new GridOptionsV30Adapter(gridInstance.gos)\n }\n if ('gridOptionsService' in gridInstance) {\n // gridOptionsService exists on gridApi only in v29 (v30+ replaced it with gos)\n return new GridOptionsV29Adapter(gridInstance.gridOptionsService)\n }\n if ('setGridAriaProperty' in gridInstance) {\n // setGridAriaProperty was introduced on v25\n return new GridOptionsV25Adapter(gridInstance.gridOptionsWrapper)\n }\n return new GridOptionsV24Adapter()\n}\n","import AutocompleteSelectCellEditor from './ag-grid-autocomplete'\n\nexport { DataFormat, IAutocompleteSelectCellEditorParameters } from './types'\nexport { default as AutocompleteSelectCellEditor } from './ag-grid-autocomplete'\nexport { AutocompleteInput, AutocompleteInputConfig } from './src/autocomplete-input'\n// eslint-disable-next-line unicorn/prefer-export-from\nexport default AutocompleteSelectCellEditor\n"],"names":["root","factory","exports","module","require","define","amd","a","i","self","__WEBPACK_EXTERNAL_MODULE__743__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","GridOptionsV24Adapter","version","isEnableCellEditingOnBackspace","GridOptionsV25Adapter","constructor","gridOptionsWrapper","this","GridOptionsV29Adapter","gridOptionsService","is","GridOptionsV30Adapter","GridOptionsV32Adapter","gridApi","getGridOption","defaultRenderGroup","groupName","groupDiv","document","createElement","textContent","className","defaultRender","item","itemElement","label","renderItems","items","selected","inputValue","clickHandler","render","renderGroup","fragment","createDocumentFragment","elements","previousGroup","group","push","div","addEventListener","event","classList","add","append","singleton","initialValue","newValue","KEYUP_EVENT_NAME","KEYS_TO_IGNORE","Set","DEFAULT_MIN_LENGTH","autocomplete","settings","getDocument","setDocument","input","ownerDocument","globalThis","getItems","setItems","getInputValue","setInputValue","getSelected","setSelected","getKeypressCounter","setKeypressCounter","getDebounceTimer","setDebounceTimer","strict","autoselectfirst","onFreeTextSelect","minLength","showOnFocus","customize","emptyMsg","debounceWaitMs","minimumInputLength","container","containerStyle","style","position","incrementKeypressCounter","clearDebounceTimer","debounceTimer","clearTimeout","containerDisplayed","parentNode","clear","remove","itemClickHandler","preventDefault","stopPropagation","onSelect","update","firstChild","removeChildren","length","empty","body","height","width","offsetWidth","inputRect","getBoundingClientRect","top","offsetHeight","maxHeight","defaultView","innerHeight","bottom","left","updatePosition","element","querySelector","previous","previousElementSibling","includes","offsetTop","scrollTop","selectBottom","containerBottom","updateScroll","updateIfDisplayed","resizeEventHandler","scrollEventHandler","target","startFetch","trigger","savedKeypressCounter","debouncingTime","handleFetchResult","setTimeout","fetch","debouncedFetch","keyupEventHandler","keyCode","which","has","keydownEventHandler","arrowKey","index","at","selectPreviousItem","selectNextItem","handleArrowKeysDown","freeTextSelect","handleSelectKeysDown","focusEventHandler","focusOutEventHandler","activeElement","addEventListeners","destroy","removeEventListener","removeEventListeners","AutocompleteInput","currentItem","selectedItem","config","inputElement","eInput","template","innerHTML","trim","content","placeholder","setupAutocomplete","getGui","getInputElement","getValue","setValue","focus","select","blur","focusAndSelect","setCaretAtEnd","setSelectionRange","triggerAutocomplete","dispatchEvent","Event","bubbles","autocompleter","getSelectData","selectData","Array","isArray","mergedSettings","getDefaultAutocompleteSettings","autocompleteSettings","escapedValue","replaceAll","String","raw","regex","RegExp","fieldItem","replace","match","onItemMousedown","name","_currentValue","text","callback","toLowerCase","filter","n","dropdownContainer","window","KEY_BACKSPACE_STRING","KEY_DELETE_STRING","KEY_ENTER_STRING","KeysHandled","KeysHandledStrings","AutocompleteSelectCellEditor","Component","super","focusAfterAttached","startedByEnter","required","backspaceTriggersEdit","init","parameters","gridInstance","api","stopEditing","cellStartedEdit","eventKey","gridOptionsAdapter","gos","autocompleteInput","getStartValue","transformAutocompleteSettings","handleSelection","colDef","suppressKeyboardEvent","suppressParameters","afterGuiAttached","focusIn","focusOut","isCancelAfterEnd","KeyboardEvent","view","handleKeyboardSelection","selectAndClose","shiftKey","tabToPreviousCell","tabToNextCell","wrapCallback","arguments_","userSettings","transformed","keyPress","formatValue","isRequired","isVersionGte28","editing"],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-grid-autocomplete",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
4
4
|
"description": "Quick implementation of autocompletion into ag-Grid cell using autocompleter package.",
|
|
5
5
|
"deprecated": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"types/types.d.ts",
|
|
10
10
|
"types/index.d.ts",
|
|
11
11
|
"types/autocompleter/types.d.ts",
|
|
12
|
+
"types/src/autocomplete-input.d.ts",
|
|
12
13
|
"dist/index.js",
|
|
13
14
|
"dist/index.js.map",
|
|
14
15
|
"dist/main.css",
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
"clean": "rm -rf **/*.map **/*.d.ts *.d.ts *.map ag-grid-autocomplete.js dist/",
|
|
26
27
|
"pretest": "npm run clean && npm run build",
|
|
27
28
|
"test": "npx cypress run",
|
|
28
|
-
"test:matrix": "./test-helpers/
|
|
29
|
+
"test:matrix": "./test-helpers/test-matrix.sh",
|
|
29
30
|
"format": "prettier --write .",
|
|
30
31
|
"lint": "eslint .",
|
|
31
32
|
"lint:fix": "eslint --fix .",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"ag-grid-autocomplete-editor"
|
|
56
57
|
],
|
|
57
58
|
"peerDependencies": {
|
|
58
|
-
"
|
|
59
|
+
"ag-grid-community": ">= 23"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@commitlint/cli": "^19.8.0",
|
|
@@ -65,10 +66,10 @@
|
|
|
65
66
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
66
67
|
"@typescript-eslint/parser": "^7.18.0",
|
|
67
68
|
"ag-grid-autocomplete": "file:./",
|
|
68
|
-
"ag-grid-community": "^
|
|
69
|
+
"ag-grid-community": "^35.0.0",
|
|
69
70
|
"autoprefixer": "10.2.5",
|
|
70
71
|
"css-loader": "5.2.2",
|
|
71
|
-
"cypress": "^
|
|
72
|
+
"cypress": "^15.0.0",
|
|
72
73
|
"cypress-real-events": "^1.14.0",
|
|
73
74
|
"eslint": "^8.57.1",
|
|
74
75
|
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
"sass-loader": "11.0.1",
|
|
91
92
|
"semantic-release": "^24.2.3",
|
|
92
93
|
"ts-loader": "9.5.2",
|
|
93
|
-
"typescript": "
|
|
94
|
+
"typescript": "~5.4.5",
|
|
94
95
|
"webpack": "5.98.0",
|
|
95
96
|
"webpack-cli": "6.0.1"
|
|
96
97
|
},
|
|
@@ -109,7 +110,12 @@
|
|
|
109
110
|
},
|
|
110
111
|
"release": {
|
|
111
112
|
"branches": [
|
|
112
|
-
"main"
|
|
113
|
+
"main",
|
|
114
|
+
{
|
|
115
|
+
"name": "v2",
|
|
116
|
+
"channel": "next",
|
|
117
|
+
"prerelease": "rc"
|
|
118
|
+
}
|
|
113
119
|
]
|
|
114
120
|
},
|
|
115
121
|
"types": "types/index.d.ts"
|
|
@@ -1,41 +1,60 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component, ICellEditorComp } from 'ag-grid-community';
|
|
2
2
|
import { IAutocompleteSelectCellEditorParameters, DataFormat } from './types';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type AutocompleteParameters = IAutocompleteSelectCellEditorParameters<AutocompleteSelectCellEditor>;
|
|
4
|
+
/**
|
|
5
|
+
* Autocomplete cell editor for AG Grid.
|
|
6
|
+
* This is a thin wrapper around AutocompleteInput that handles AG Grid integration.
|
|
7
|
+
*/
|
|
8
|
+
export default class AutocompleteSelectCellEditor extends Component implements ICellEditorComp {
|
|
9
|
+
private autocompleteInput;
|
|
5
10
|
private focusAfterAttached;
|
|
6
|
-
private
|
|
7
|
-
private autocompleter?;
|
|
11
|
+
private startedByEnter;
|
|
8
12
|
private required;
|
|
13
|
+
private gridApi?;
|
|
14
|
+
private gridOptionsAdapter;
|
|
9
15
|
private stopEditing?;
|
|
10
16
|
/**
|
|
11
17
|
* Originally AgGrid would always trigger cell editing when backspace was hit
|
|
12
18
|
*/
|
|
13
19
|
private backspaceTriggersEdit;
|
|
14
|
-
|
|
15
|
-
private gridOptionsAdapter;
|
|
16
|
-
private static getSelectData;
|
|
17
|
-
private static getDefaultAutocompleteSettings;
|
|
20
|
+
constructor();
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param parameters - Event parameters from ag-grid
|
|
23
|
-
* @param isRequired - Whether the cell represents a required field
|
|
24
|
-
* @param backspaceTriggersEdit - Whether pressing backspace should trigger cell editing
|
|
25
|
-
* @param isVersionGte28 - Whether using ag-grid version 28 or greater (which changed edit behavior)
|
|
26
|
-
* @returns True if the event should be suppressed, false otherwise
|
|
22
|
+
* Initialize the cell editor
|
|
23
|
+
* @param parameters - Cell editor parameters from AG Grid
|
|
27
24
|
*/
|
|
28
|
-
|
|
29
|
-
private static getStartValue;
|
|
30
|
-
constructor();
|
|
31
|
-
init(parameters: IAutocompleteSelectCellEditorParameters<AutocompleteSelectCellEditor>): void;
|
|
32
|
-
handleTabEvent(event: KeyboardEvent): void;
|
|
25
|
+
init(parameters: AutocompleteParameters): void;
|
|
33
26
|
afterGuiAttached(): void;
|
|
34
27
|
focusIn(): void;
|
|
35
28
|
focusOut(): void;
|
|
36
|
-
destroy(): void;
|
|
37
29
|
getValue(): DataFormat | undefined;
|
|
38
30
|
isCancelAfterEnd(): boolean;
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
get currentItem(): DataFormat | undefined;
|
|
32
|
+
set currentItem(value: DataFormat | undefined);
|
|
33
|
+
private handleSelection;
|
|
34
|
+
private handleKeyboardSelection;
|
|
35
|
+
private selectAndClose;
|
|
36
|
+
/**
|
|
37
|
+
* Wraps a user-provided callback to inject the cell editor as the first parameter.
|
|
38
|
+
*
|
|
39
|
+
* This enables backward compatibility: users expect callbacks like `render(cellEditor, item, value)`,
|
|
40
|
+
* but internally AutocompleteInput uses simpler signatures like `render(item, value)`.
|
|
41
|
+
*
|
|
42
|
+
* @param callback - User's callback that expects the cell editor as first parameter
|
|
43
|
+
* @returns A wrapped function that injects `this` (the cell editor) as the first argument
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // User provides: (cellEditor, item, value) => HTMLElement
|
|
47
|
+
* // We transform to: (item, value) => userCallback(this, item, value)
|
|
48
|
+
* transformed.render = this.wrapCallback(userSettings.render)
|
|
49
|
+
*/
|
|
50
|
+
private wrapCallback;
|
|
51
|
+
private transformAutocompleteSettings;
|
|
52
|
+
private static getSelectData;
|
|
53
|
+
private static getStartValue;
|
|
54
|
+
/**
|
|
55
|
+
* Determines whether a keyboard event should be suppressed in a grid cell.
|
|
56
|
+
* Supports both modern (key-based) and legacy (keyCode-based) keyboard event handling.
|
|
57
|
+
*/
|
|
58
|
+
private static suppressKeyboardEvent;
|
|
41
59
|
}
|
|
60
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AutocompleteSelectCellEditor from './ag-grid-autocomplete';
|
|
2
2
|
export { DataFormat, IAutocompleteSelectCellEditorParameters } from './types';
|
|
3
3
|
export { default as AutocompleteSelectCellEditor } from './ag-grid-autocomplete';
|
|
4
|
+
export { AutocompleteInput, AutocompleteInputConfig } from './src/autocomplete-input';
|
|
4
5
|
export default AutocompleteSelectCellEditor;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AutocompleteSettings } from '../autocompleter/types';
|
|
2
|
+
import { DataFormat } from '../types';
|
|
3
|
+
export interface AutocompleteInputConfig {
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
initialValue?: string;
|
|
6
|
+
selectData: DataFormat[] | (() => DataFormat[]);
|
|
7
|
+
autocompleteSettings?: Partial<AutocompleteSettings<DataFormat>>;
|
|
8
|
+
onSelect?: (item: DataFormat | undefined, event: KeyboardEvent | MouseEvent) => void;
|
|
9
|
+
onItemMousedown?: (item: DataFormat, event: MouseEvent) => void;
|
|
10
|
+
/** Optional existing input element to use instead of creating one */
|
|
11
|
+
inputElement?: HTMLInputElement;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Autocomplete input component - handles autocomplete UI and selection logic.
|
|
15
|
+
* This is separated from the cell editor to allow for cleaner AG Grid version compatibility.
|
|
16
|
+
*/
|
|
17
|
+
export declare class AutocompleteInput {
|
|
18
|
+
private readonly container?;
|
|
19
|
+
private readonly eInput;
|
|
20
|
+
private autocompleter?;
|
|
21
|
+
private config;
|
|
22
|
+
private selectedItem?;
|
|
23
|
+
get currentItem(): DataFormat | undefined;
|
|
24
|
+
set currentItem(value: DataFormat | undefined);
|
|
25
|
+
constructor(config: AutocompleteInputConfig);
|
|
26
|
+
getGui(): HTMLElement | undefined;
|
|
27
|
+
getInputElement(): HTMLInputElement;
|
|
28
|
+
getValue(): DataFormat | undefined;
|
|
29
|
+
setValue(value: string): void;
|
|
30
|
+
focus(): void;
|
|
31
|
+
select(): void;
|
|
32
|
+
blur(): void;
|
|
33
|
+
focusAndSelect(): void;
|
|
34
|
+
setCaretAtEnd(): void;
|
|
35
|
+
triggerAutocomplete(): void;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
private getSelectData;
|
|
38
|
+
private setupAutocomplete;
|
|
39
|
+
private getDefaultAutocompleteSettings;
|
|
40
|
+
}
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component, ICellEditorParams } from 'ag-grid-community';
|
|
2
2
|
import { AutocompleteItem, EventTrigger } from './autocompleter/types';
|
|
3
3
|
export interface DataFormat extends AutocompleteItem {
|
|
4
4
|
value: number | string;
|
|
@@ -6,22 +6,31 @@ export interface DataFormat extends AutocompleteItem {
|
|
|
6
6
|
group?: string;
|
|
7
7
|
}
|
|
8
8
|
export type AutocompleteClient = DataFormat & AutocompleteItem;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Settings for the autocompleter component.
|
|
11
|
+
* The generic U parameter represents the component context passed to callbacks.
|
|
12
|
+
*/
|
|
13
|
+
export interface IAutocompleterSettings<T extends AutocompleteItem, U = unknown> {
|
|
14
|
+
render?: (context: U, item: T, currentValue: string) => HTMLElement;
|
|
15
|
+
renderGroup?: (context: U, name: string, currentValue: string) => HTMLElement;
|
|
12
16
|
className?: string;
|
|
13
17
|
minLength?: number;
|
|
14
18
|
emptyMsg?: string;
|
|
15
19
|
strict?: boolean;
|
|
16
20
|
autoselectfirst?: boolean;
|
|
17
|
-
onFreeTextSelect?: (
|
|
18
|
-
onSelect?: (
|
|
19
|
-
fetch?: (
|
|
21
|
+
onFreeTextSelect?: (context: U, item: T, input: HTMLInputElement) => void;
|
|
22
|
+
onSelect?: (context: U, item: T | undefined, input: HTMLInputElement) => void;
|
|
23
|
+
fetch?: (context: U, text: string, update: (items: T[] | false) => void, trigger?: EventTrigger) => void;
|
|
20
24
|
debounceWaitMs?: number;
|
|
21
25
|
showOnFocus?: boolean;
|
|
22
|
-
customize?: (
|
|
26
|
+
customize?: (context: U, input: HTMLInputElement, inputRect: DOMRect, container: HTMLDivElement, maxHeight: number) => void;
|
|
23
27
|
}
|
|
24
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Parameters for the AutocompleteSelectCellEditor.
|
|
30
|
+
* Note: U extends PopupComponent for backward compatibility with existing user code
|
|
31
|
+
* that accesses cell editor methods in callbacks.
|
|
32
|
+
*/
|
|
33
|
+
export interface IAutocompleteSelectCellEditorParameters<U extends Component> extends ICellEditorParams {
|
|
25
34
|
autocomplete?: IAutocompleterSettings<DataFormat, U>;
|
|
26
35
|
selectData: Array<DataFormat> | ((parameters: IAutocompleteSelectCellEditorParameters<U>) => Array<DataFormat>);
|
|
27
36
|
placeholder?: string;
|