@peckadesign/pd-naja 3.1.1 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/PdNaja.esm.js +56 -100
  2. package/dist/PdNaja.esm.js.map +1 -1
  3. package/dist/classes/ControlManager.d.ts +1 -1
  4. package/dist/extensions/AjaxModalExtension.d.ts +6 -6
  5. package/dist/extensions/AjaxModalPreventRedrawExtension.d.ts +2 -2
  6. package/dist/extensions/AjaxOnceExtension.d.ts +2 -2
  7. package/dist/extensions/BtnSpinnerExtension.d.ts +2 -2
  8. package/dist/extensions/ConfirmExtension.d.ts +1 -1
  9. package/dist/extensions/FollowUpRequestExtension.d.ts +2 -2
  10. package/dist/extensions/ForceRedirectExtension.d.ts +2 -2
  11. package/dist/extensions/ForceReplaceExtension.d.ts +2 -2
  12. package/dist/extensions/ScrollToExtension.d.ts +2 -2
  13. package/dist/extensions/SingleSubmitExtension.d.ts +2 -2
  14. package/dist/extensions/SnippetFormPartExtension.d.ts +1 -1
  15. package/dist/extensions/SpinnerExtension.d.ts +2 -2
  16. package/dist/extensions/SuggestExtension.d.ts +2 -2
  17. package/dist/extensions/ToggleClassExtension.d.ts +2 -2
  18. package/dist/index.esm.js +56 -100
  19. package/dist/index.esm.js.map +1 -1
  20. package/eslint.config.mjs +28 -0
  21. package/package.json +15 -14
  22. package/src/classes/ControlManager.ts +2 -7
  23. package/src/extensions/AjaxModalExtension.ts +79 -110
  24. package/src/extensions/AjaxModalPreventRedrawExtension.ts +2 -3
  25. package/src/extensions/AjaxOnceExtension.ts +2 -3
  26. package/src/extensions/BtnSpinnerExtension.ts +2 -3
  27. package/src/extensions/ConfirmExtension.ts +1 -2
  28. package/src/extensions/FollowUpRequestExtension.ts +2 -2
  29. package/src/extensions/ForceRedirectExtension.ts +2 -2
  30. package/src/extensions/ForceReplaceExtension.ts +2 -4
  31. package/src/extensions/ScrollToExtension.ts +2 -3
  32. package/src/extensions/SingleSubmitExtension.ts +2 -3
  33. package/src/extensions/SnippetFormPartExtension.ts +1 -2
  34. package/src/extensions/SpinnerExtension.ts +2 -4
  35. package/src/extensions/SuggestExtension.ts +2 -4
  36. package/src/extensions/ToggleClassExtension.ts +2 -3
  37. package/tsconfig.json +2 -2
  38. package/.eslintrc.js +0 -13
@@ -1,9 +1,18 @@
1
- import { Naja, BeforeEvent, CompleteEvent, StartEvent, SuccessEvent, Options, Extension } from 'naja/dist/Naja'
2
- import { BuildStateEvent, HistoryState } from 'naja/dist/core/HistoryHandler'
3
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
4
- import { FetchEvent } from 'naja/dist/core/SnippetCache'
5
-
6
- declare module 'naja/dist/Naja' {
1
+ import {
2
+ BeforeEvent,
3
+ BuildStateEvent,
4
+ CompleteEvent,
5
+ Extension,
6
+ FetchEvent,
7
+ HistoryState,
8
+ InteractionEvent,
9
+ Naja,
10
+ Options,
11
+ StartEvent,
12
+ SuccessEvent
13
+ } from 'naja'
14
+
15
+ declare module 'naja' {
7
16
  interface Options {
8
17
  pdModal?: boolean
9
18
  modalOpener?: Element
@@ -21,6 +30,7 @@ interface OptionsWithPdModal extends Options {
21
30
  }
22
31
 
23
32
  interface PdModalHistoryState extends HistoryState {
33
+ title: string
24
34
  pdModal: PdModalState
25
35
  }
26
36
 
@@ -30,7 +40,7 @@ export interface AjaxModal {
30
40
  // main element of the modal
31
41
  element: Element
32
42
 
33
- // id's of snippets, that are necessary for modal function
43
+ // id's of snippets that are necessary for modal function
34
44
  reservedSnippetIds: string[]
35
45
 
36
46
  show(opener: Element, options: any, event: BeforeEvent | PopStateEvent): void
@@ -47,21 +57,14 @@ export interface AjaxModal {
47
57
  setOptions(options: any): void
48
58
  }
49
59
 
50
- interface HistoryStateWrapper extends Record<string, any> {
51
- location: string
52
- state: HistoryState
53
- title: string
54
- }
55
-
56
- type HistoryDirection = 'forwards' | 'backwards'
57
-
58
60
  interface PdModalState {
59
- historyDirection: HistoryDirection
60
61
  opener: string // stringified Element
61
62
  options: any
63
+ refreshed?: boolean
62
64
  }
63
65
 
64
66
  export class AjaxModalExtension implements Extension {
67
+ private naja: Naja | undefined
65
68
  private readonly modal: AjaxModal
66
69
  private readonly uniqueExtKey: string = 'modal'
67
70
 
@@ -69,14 +72,11 @@ export class AjaxModalExtension implements Extension {
69
72
  private hidePopstateFlag = false
70
73
 
71
74
  private historyEnabled = false // (dis)allows `pushState` after hiding the modal when going back in history (popstate), we don't want to push new state into history same is true also when the history is disabled for request altogether
72
- private historyDirection: HistoryDirection = 'backwards'
73
75
 
74
76
  private shouldPreventSnippetFetch = false
75
77
 
76
78
  private modalOptions: any = {}
77
79
 
78
- private original: HistoryStateWrapper[] = [] // stack of states under the modal after hiding the modal with `forwards` history mode, we need to push the previous state
79
- private lastState: HistoryStateWrapper | null = null
80
80
  private initialState: HistoryState | Record<string, never>
81
81
 
82
82
  private readonly abortControllers: Map<string, AbortController> = new Map()
@@ -88,12 +88,20 @@ export class AjaxModalExtension implements Extension {
88
88
 
89
89
  this.modal = modal
90
90
  this.initialState = history.state || {}
91
+
92
+ // If the initial state already contains pdModal property, it means that the page with modal has been refreshed.
93
+ // We take a note of this, so we can properly handle modal closing
94
+ if (this.initialState.pdModal !== undefined) {
95
+ ;(this.initialState.pdModal as PdModalState).refreshed = true
96
+ }
91
97
  }
92
98
 
93
99
  public initialize(naja: Naja): void {
100
+ this.naja = naja
101
+
94
102
  naja.uiHandler.addEventListener('interaction', this.checkExtensionEnabled.bind(this))
95
103
 
96
- naja.historyHandler.addEventListener('buildState', this.buildState.bind(this))
104
+ naja.historyHandler.addEventListener('buildState', this.buildStateHandler.bind(this))
97
105
 
98
106
  naja.snippetCache.addEventListener('fetch', this.onSnippetFetch.bind(this))
99
107
 
@@ -119,9 +127,18 @@ export class AjaxModalExtension implements Extension {
119
127
  return 'pdModal' in state
120
128
  }
121
129
 
130
+ private isCurrentStateInitial(state: PdModalHistoryState): boolean {
131
+ return (
132
+ state.source === 'naja' &&
133
+ this.initialState.source === 'naja' &&
134
+ state.href === this.initialState.href &&
135
+ state.title === this.initialState.title &&
136
+ JSON.stringify(state.pdModal) === JSON.stringify(this.initialState.pdModal)
137
+ )
138
+ }
139
+
122
140
  private restoreExtensionPropertiesFromState = (state: PdModalHistoryState): void => {
123
141
  this.historyEnabled = true // Called from popstateHandler means the history is enabled
124
- this.historyDirection = state.pdModal.historyDirection
125
142
  this.modalOptions = state.pdModal.options
126
143
  }
127
144
 
@@ -144,12 +161,6 @@ export class AjaxModalExtension implements Extension {
144
161
 
145
162
  options.modalOptions = this.modalOptions
146
163
  options.modalOpener = element
147
-
148
- // If the extension is enabled and the modal is not opened, we detect and store history mode. History mode
149
- // cannot change when traversing an ajax link inside modal, it stays the same until modal is hidden.
150
- if (!this.modal.isShown()) {
151
- this.historyDirection = element.getAttribute('data-naja-modal-history') === 'forwards' ? 'forwards' : 'backwards'
152
- }
153
164
  }
154
165
 
155
166
  private onSnippetFetch(event: FetchEvent): void {
@@ -198,8 +209,8 @@ export class AjaxModalExtension implements Extension {
198
209
  }
199
210
  }
200
211
 
201
- private buildState(event: BuildStateEvent): void {
202
- const { operation, options, state } = event.detail
212
+ private buildStateHandler(event: BuildStateEvent): void {
213
+ const { isInitial, options, state } = event.detail
203
214
 
204
215
  // Always add a `title` into the state, so we can retrieve it when needed after closing the modal. See
205
216
  // `popstateHandler` below.
@@ -207,14 +218,9 @@ export class AjaxModalExtension implements Extension {
207
218
  state.title = document.title
208
219
  }
209
220
 
210
- // If this is called from Naja's `replaceInitialState`, we don't change the state.
211
- //
212
- // This is a possible weakness because this condition could be true even with actual user interaction, if
213
- // Naja's first interaction is with an element with `data-naja-history="replace"`. In this case the condition
214
- // will also be true, but it is probably the desired behaviour to save this state as non-modal anyway, since
215
- // the initial state should (or could) never be opened in a modal.
216
- if (operation === 'replaceState' && state.cursor === 0) {
217
- // If there already is `pdModal` configuration in history state, we need to preserve that configuration.
221
+ // If this is called from Naja's `replaceInitialState`, we don't change the state. Only if there already is a
222
+ // `pdModal` in the current history state, we need to preserve that configuration.
223
+ if (isInitial) {
218
224
  if (window.history.state?.pdModal) {
219
225
  state.pdModal = window.history.state.pdModal
220
226
  }
@@ -229,7 +235,6 @@ export class AjaxModalExtension implements Extension {
229
235
 
230
236
  if (isShown) {
231
237
  state.pdModal = {
232
- historyDirection: this.historyDirection,
233
238
  opener: (options.modalOpener as Element).outerHTML, // if `this.modal.isShown()` is true, the `modalOpener` has been stored
234
239
  options: this.modalOptions
235
240
  }
@@ -261,11 +266,6 @@ export class AjaxModalExtension implements Extension {
261
266
  const { options, payload } = event.detail
262
267
 
263
268
  this.popstateFlag = false
264
- this.lastState = {
265
- location: location.href,
266
- state: history.state,
267
- title: document.title
268
- }
269
269
 
270
270
  if (!this.isPdModalRequest(options)) {
271
271
  return
@@ -296,21 +296,6 @@ export class AjaxModalExtension implements Extension {
296
296
 
297
297
  private showHandler(): void {
298
298
  this.modal.setOptions(this.modalOptions)
299
-
300
- // If the modal history mode is `forwards`, we store the state under the modal, so we can push it as a new state
301
- // after hiding the modal.
302
- if (this.historyDirection === 'forwards') {
303
- if (this.popstateFlag && this.lastState) {
304
- this.original.push(this.lastState)
305
- } else {
306
- const state: HistoryStateWrapper = {
307
- location: location.href,
308
- state: history.state,
309
- title: document.title
310
- }
311
- this.original.push(state)
312
- }
313
- }
314
299
  }
315
300
 
316
301
  private hideHandler(event: Event): void {
@@ -328,48 +313,21 @@ export class AjaxModalExtension implements Extension {
328
313
  }
329
314
 
330
315
  private hiddenHandler(): void {
331
- // This method is called after the modal has been hidden. It either pushes a new state into history (mode
332
- // `forwards`) or calls `history.back()` to start go-back procedure.
333
- //
334
- // A new state is pushed only if we are able to retrieve the state under the modal (which should have been
335
- // stored previously), and the modal is not being closed using forward / back buttons in the browser.
316
+ // This method is called after the modal has been hidden. It calls `history.back()` to start go-back procedure
317
+ // to eventually return to the state leading to opening the modal.
336
318
  if (!this.historyEnabled) {
337
319
  return
338
320
  }
339
321
 
340
- if (this.historyDirection === 'backwards') {
341
- // We don't know how many states we need to return. We go one by one, see popstate handler. This go-back
342
- // procedure is detected using `hidePopstateFlag`.
343
- this.hidePopstateFlag = true
344
- this.cleanData()
345
- window.history.back()
346
- } else if (this.historyDirection === 'forwards') {
347
- const state = this.original.pop()
348
- this.original = []
349
-
350
- if (state) {
351
- // When closing the modal using forward / back buttons in the browser, the current state is the same as
352
- // the one stored in `this.original`. If that's the case, we don't push anything as it would duplicate
353
- // the state in history.
354
- if (history.state === undefined || history.state.href !== state.location) {
355
- history.pushState(state.state, state.title, state.location)
356
- document.title = state.title
357
-
358
- this.popstateFlag = false
359
- this.lastState = {
360
- location: state.location,
361
- state: state.state,
362
- title: state.title
363
- }
364
- }
365
- }
366
-
367
- this.cleanData()
368
- }
322
+ // We don't know how many states we need to return. We go one by one, see popstate handler. This go-back
323
+ // procedure is detected using `hidePopstateFlag`.
324
+ this.hidePopstateFlag = true
325
+ this.cleanData()
326
+ window.history.back()
369
327
  }
370
328
 
371
329
  private popstateHandler(event: PopStateEvent): void {
372
- const state: HistoryState = event.state || this.initialState
330
+ const state: HistoryState = (event.state || this.initialState) as HistoryState
373
331
 
374
332
  if (typeof state === 'undefined' || !this.modal) {
375
333
  return
@@ -379,28 +337,38 @@ export class AjaxModalExtension implements Extension {
379
337
  this.popstateFlag = true
380
338
  this.shouldPreventSnippetFetch = false
381
339
 
340
+ // This part handles the history back procedure.
341
+ //
382
342
  // We don't know how many states we go back. So we go one by one until the new state is not a modal state
383
343
  // (`isPdModalState` is `false`).
384
344
  if (this.hidePopstateFlag) {
385
- // We don't want the naja popstate callback to be executed (or any other popstate handler).
345
+ // We don't want the naja popstate callback to be executed (or any other popstate handler). Naja would
346
+ // update snippets which are not desired - we either continue going back in history, or we just closed the
347
+ // modal, so no restoration is needed.
386
348
  event.stopImmediatePropagation()
387
349
 
388
- // If the `state.cursor` is 0, the page has been refreshed, and we don't want to go back in history any
389
- // more.
390
- if (isCurrentStatePdModal && state.cursor !== 0) {
350
+ // Going back in history is undesirable even when the state is `pdModal` state, but the page has been
351
+ // refreshed. We can check this by checking if the `pdModal.refreshed` property is set to `true`. Because a
352
+ // user can skip multiple states using the browser back button, we also compare `this.initialState` with the
353
+ // current `state`. If the (refreshed) `pdModal` state is the same as the initial state, we don't want to go
354
+ // back in history.
355
+ //
356
+ // We should reevaluate this code when the issue is resolved: https://github.com/naja-js/naja/issues/418. We
357
+ // may, possibly, use `state.cursor > 0` to check if the state is not the initial state.
358
+ if (isCurrentStatePdModal && (state.pdModal.refreshed !== true || !this.isCurrentStateInitial(state))) {
391
359
  window.history.back()
392
360
 
393
361
  return
394
- } else {
395
- if (state.title) {
396
- document.title = state.title
397
- }
362
+ } else if (state.title) {
363
+ document.title = state.title
398
364
  }
399
365
 
400
366
  this.hidePopstateFlag = false
401
367
  }
402
368
 
403
- // We check if the state has a ` pdModal ` object present on popstate. If so, we proceed to open the modal.
369
+ // This part handles the history forward procedure.
370
+ //
371
+ // This We check if the state has a ` pdModal ` object present on popstate. If so, we proceed to open the modal.
404
372
  // Naja itself restores the content of the modal (either from cache or by new request).
405
373
  //
406
374
  // If the initial state is also detected as a pdModal state, we returned to some pdModal state using reload. In
@@ -410,6 +378,10 @@ export class AjaxModalExtension implements Extension {
410
378
  if (isCurrentStatePdModal && !this.isPdModalState(this.initialState)) {
411
379
  this.restoreExtensionPropertiesFromState(state)
412
380
 
381
+ if (state.pdModal.refreshed === true) {
382
+ this.resetPdModalRefreshed(state)
383
+ }
384
+
413
385
  this.modal.show(this.getElementFromString(state.pdModal.opener), state.pdModal.options, event)
414
386
 
415
387
  // If there is some snippet cache, we might restore modal options. If not, options will be restored based on
@@ -444,19 +416,16 @@ export class AjaxModalExtension implements Extension {
444
416
  this.shouldPreventSnippetFetch = true
445
417
  }
446
418
  }
419
+ }
447
420
 
448
- // Keep track of the current state. When the ` backwards ` history mode is used, we eventually push this state into
449
- // `this.original`.
450
- this.lastState = {
451
- location: location.href,
452
- state: state,
453
- title: document.title
454
- }
421
+ private resetPdModalRefreshed(state: PdModalHistoryState): void {
422
+ state.pdModal.refreshed = false
423
+
424
+ this.naja?.historyHandler.historyAdapter.replaceState(state, document.title, state.href)
455
425
  }
456
426
 
457
427
  private cleanData(): void {
458
428
  this.historyEnabled = false
459
- this.historyDirection = 'backwards'
460
429
  this.modalOptions = null
461
430
  }
462
431
 
@@ -1,7 +1,6 @@
1
- import { BeforeEvent, Extension, Naja } from 'naja/dist/Naja'
2
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
1
+ import { BeforeEvent, Extension, InteractionEvent, Naja } from 'naja'
3
2
 
4
- declare module 'naja/dist/Naja' {
3
+ declare module 'naja' {
5
4
  interface Options {
6
5
  pdModalPreventRedraw?: boolean
7
6
  }
@@ -1,8 +1,7 @@
1
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
2
- import { Extension, Naja, SuccessEvent } from 'naja/dist/Naja'
1
+ import { Extension, InteractionEvent, Naja, SuccessEvent } from 'naja'
3
2
  import { isDatasetTruthy } from '../utils'
4
3
 
5
- declare module 'naja/dist/Naja' {
4
+ declare module 'naja' {
6
5
  interface Options {
7
6
  ajaxOnceInitiator?: HTMLElement | SVGElement
8
7
  }
@@ -1,9 +1,8 @@
1
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
2
- import { CompleteEvent, Extension, Naja, StartEvent } from 'naja/dist/Naja'
1
+ import { CompleteEvent, Extension, InteractionEvent, Naja, StartEvent } from 'naja'
3
2
  import { SpinnerPropsFn, SpinnerType, WithSpinner } from '../types'
4
3
  import { hideSpinner, isDatasetTruthy, showSpinner } from '../utils'
5
4
 
6
- declare module 'naja/dist/Naja' {
5
+ declare module 'naja' {
7
6
  interface Options {
8
7
  btnSpinnerInitiator?: Element
9
8
  btnSpinner?: Element
@@ -1,5 +1,4 @@
1
- import { Extension, Naja } from 'naja/dist/Naja'
2
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
1
+ import { Extension, InteractionEvent, Naja } from 'naja'
3
2
 
4
3
  export class ConfirmExtension implements Extension {
5
4
  public initialize(naja: Naja): void {
@@ -1,6 +1,6 @@
1
- import { Extension, Naja, SuccessEvent } from 'naja/dist/Naja'
1
+ import { Extension, Naja, SuccessEvent } from 'naja'
2
2
 
3
- declare module 'naja/dist/Naja' {
3
+ declare module 'naja' {
4
4
  interface Payload {
5
5
  followUpUrl?: string
6
6
  }
@@ -1,6 +1,6 @@
1
- import { Extension, Naja, PayloadEvent, SuccessEvent } from 'naja/dist/Naja'
1
+ import { Extension, Naja, PayloadEvent, SuccessEvent } from 'naja'
2
2
 
3
- declare module 'naja/dist/Naja' {
3
+ declare module 'naja' {
4
4
  interface Payload {
5
5
  forceRedirect?: string
6
6
  }
@@ -1,9 +1,7 @@
1
- import { Extension, Naja } from 'naja/dist/Naja'
2
- import { BeforeUpdateEvent } from 'naja/dist/core/SnippetHandler'
3
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
1
+ import { BeforeUpdateEvent, Extension, InteractionEvent, Naja } from 'naja'
4
2
  import { isDatasetTruthy } from '../utils'
5
3
 
6
- declare module 'naja/dist/Naja' {
4
+ declare module 'naja' {
7
5
  interface Options {
8
6
  forceReplace?: boolean
9
7
  }
@@ -1,9 +1,8 @@
1
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
2
- import { BeforeEvent, Extension, Naja, SuccessEvent } from 'naja/dist/Naja'
1
+ import { BeforeEvent, Extension, InteractionEvent, Naja, SuccessEvent } from 'naja'
3
2
 
4
3
  type NajaScrollToEvent = 'before' | 'success'
5
4
 
6
- declare module 'naja/dist/Naja' {
5
+ declare module 'naja' {
7
6
  interface Options {
8
7
  scrollToEvent?: NajaScrollToEvent
9
8
  scrollToOptions?: ScrollIntoViewOptions
@@ -1,10 +1,9 @@
1
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
2
- import { CompleteEvent, Extension, Naja, StartEvent } from 'naja/dist/Naja'
1
+ import { CompleteEvent, Extension, InteractionEvent, Naja, StartEvent } from 'naja'
3
2
  import { isDatasetFalsy } from '../utils'
4
3
 
5
4
  type HTMLSubmitElement = HTMLButtonElement | HTMLInputElement
6
5
 
7
- declare module 'naja/dist/Naja' {
6
+ declare module 'naja' {
8
7
  interface Options {
9
8
  singleSubmitForm?: HTMLFormElement
10
9
  }
@@ -1,5 +1,4 @@
1
- import { AfterUpdateEvent } from 'naja/dist/core/SnippetHandler'
2
- import { Extension, Naja } from 'naja/dist/Naja'
1
+ import { AfterUpdateEvent, Extension, Naja } from 'naja'
3
2
 
4
3
  export class SnippetFormPartExtension implements Extension {
5
4
  private netteForms: any
@@ -1,5 +1,4 @@
1
- import { CompleteEvent, Extension, Naja, StartEvent } from 'naja/dist/Naja'
2
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
1
+ import { CompleteEvent, Extension, InteractionEvent, Naja, StartEvent } from 'naja'
3
2
  import { SpinnerPropsFn, SpinnerType, WithSpinner } from '../types'
4
3
  import { hideSpinner, showSpinner } from '../utils'
5
4
 
@@ -17,7 +16,7 @@ import { hideSpinner, showSpinner } from '../utils'
17
16
  * ii. If not, the spinner element is appended into `ajaxSpinnerWrapSelector` itself.
18
17
  */
19
18
 
20
- declare module 'naja/dist/Naja' {
19
+ declare module 'naja' {
21
20
  interface Options {
22
21
  spinnerInitiator?: Element
23
22
  spinnerQueue?: Element[]
@@ -75,7 +74,6 @@ export class SpinnerExtension implements Extension, WithSpinner {
75
74
  options.spinnerQueue = options.spinnerQueue || []
76
75
 
77
76
  placeholders.forEach((placeholder) => {
78
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
79
77
  options.spinnerQueue!.push(showSpinner.call(this, placeholder, spinnerInitiator))
80
78
  })
81
79
  }
@@ -1,11 +1,9 @@
1
- import { AfterUpdateEvent } from 'naja/dist/core/SnippetHandler'
2
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
3
- import { CompleteEvent, Extension, Naja, StartEvent } from 'naja/dist/Naja'
1
+ import { AfterUpdateEvent, CompleteEvent, Extension, InteractionEvent, Naja, StartEvent } from 'naja'
4
2
  import { Suggest, SuggestOptions } from '../classes/Suggest'
5
3
  import { SpinnerPropsFn, SpinnerType } from '../types'
6
4
  import { SpinnerExtension } from './SpinnerExtension'
7
5
 
8
- declare module 'naja/dist/Naja' {
6
+ declare module 'naja' {
9
7
  interface Options {
10
8
  suggest?: Suggest
11
9
  }
@@ -1,5 +1,4 @@
1
- import { InteractionEvent } from 'naja/dist/core/UIHandler'
2
- import { CompleteEvent, Extension, Naja, StartEvent } from 'naja/dist/Naja'
1
+ import { CompleteEvent, Extension, InteractionEvent, Naja, StartEvent } from 'naja'
3
2
 
4
3
  type ToggleClassRecord = Record<string, string>
5
4
 
@@ -8,7 +7,7 @@ type ToggleClassOptions = {
8
7
  toggleClass: ToggleClassRecord
9
8
  }
10
9
 
11
- declare module 'naja/dist/Naja' {
10
+ declare module 'naja' {
12
11
  interface Options {
13
12
  toggleClassOptions?: ToggleClassOptions
14
13
  }
package/tsconfig.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2021",
4
- "module": "ES2015",
5
- "moduleResolution": "node",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
6
  "esModuleInterop": true,
7
7
 
8
8
  "strict": true,
package/.eslintrc.js DELETED
@@ -1,13 +0,0 @@
1
- require('@rushstack/eslint-patch/modern-module-resolution')
2
-
3
- module.exports = {
4
- root: true,
5
- extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', 'prettier'],
6
- rules: {
7
- '@typescript-eslint/ban-ts-comment': 'off',
8
- '@typescript-eslint/no-explicit-any': 'off',
9
- '@typescript-eslint/no-inferrable-types': 'off',
10
- 'prettier/prettier': 1
11
- },
12
- ignorePatterns: ['*.js']
13
- }