@keenthemes/ktui 1.1.5 → 1.1.6
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/dist/ktui.js +11232 -11095
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.js.map +1 -1
- package/dist/styles.css +33 -27
- package/lib/cjs/components/collapse/collapse.js +0 -2
- package/lib/cjs/components/collapse/collapse.js.map +1 -1
- package/lib/cjs/components/component.js +3 -1
- package/lib/cjs/components/component.js.map +1 -1
- package/lib/cjs/components/datatable/datatable-sort.js +1 -2
- package/lib/cjs/components/datatable/datatable-sort.js.map +1 -1
- package/lib/cjs/components/datatable/datatable.js +45 -23
- package/lib/cjs/components/datatable/datatable.js.map +1 -1
- package/lib/cjs/components/drawer/drawer.js +21 -9
- package/lib/cjs/components/drawer/drawer.js.map +1 -1
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/scrollto/scrollto.js +0 -2
- package/lib/cjs/components/scrollto/scrollto.js.map +1 -1
- package/lib/cjs/components/select/combobox.js.map +1 -1
- package/lib/cjs/components/select/dropdown.js.map +1 -1
- package/lib/cjs/components/select/remote.js.map +1 -1
- package/lib/cjs/components/select/search.js +9 -5
- package/lib/cjs/components/select/search.js.map +1 -1
- package/lib/cjs/components/select/select.js +22 -5
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/cjs/components/select/tags.js.map +1 -1
- package/lib/cjs/components/select/templates.js.map +1 -1
- package/lib/cjs/components/select/utils.js +10 -0
- package/lib/cjs/components/select/utils.js.map +1 -1
- package/lib/cjs/components/sticky/sticky.js +104 -24
- package/lib/cjs/components/sticky/sticky.js.map +1 -1
- package/lib/cjs/components/theme-switch/theme-switch.js +0 -2
- package/lib/cjs/components/theme-switch/theme-switch.js.map +1 -1
- package/lib/cjs/components/toast/toast.js +1 -2
- package/lib/cjs/components/toast/toast.js.map +1 -1
- package/lib/cjs/helpers/dom.js +0 -2
- package/lib/cjs/helpers/dom.js.map +1 -1
- package/lib/esm/components/collapse/collapse.js +0 -2
- package/lib/esm/components/collapse/collapse.js.map +1 -1
- package/lib/esm/components/component.js +3 -1
- package/lib/esm/components/component.js.map +1 -1
- package/lib/esm/components/datatable/datatable-sort.js +1 -2
- package/lib/esm/components/datatable/datatable-sort.js.map +1 -1
- package/lib/esm/components/datatable/datatable.js +45 -23
- package/lib/esm/components/datatable/datatable.js.map +1 -1
- package/lib/esm/components/drawer/drawer.js +21 -9
- package/lib/esm/components/drawer/drawer.js.map +1 -1
- package/lib/esm/components/dropdown/dropdown.js.map +1 -1
- package/lib/esm/components/scrollto/scrollto.js +0 -2
- package/lib/esm/components/scrollto/scrollto.js.map +1 -1
- package/lib/esm/components/select/combobox.js.map +1 -1
- package/lib/esm/components/select/dropdown.js.map +1 -1
- package/lib/esm/components/select/remote.js.map +1 -1
- package/lib/esm/components/select/search.js +9 -5
- package/lib/esm/components/select/search.js.map +1 -1
- package/lib/esm/components/select/select.js +22 -5
- package/lib/esm/components/select/select.js.map +1 -1
- package/lib/esm/components/select/tags.js.map +1 -1
- package/lib/esm/components/select/templates.js.map +1 -1
- package/lib/esm/components/select/utils.js +10 -0
- package/lib/esm/components/select/utils.js.map +1 -1
- package/lib/esm/components/sticky/sticky.js +104 -24
- package/lib/esm/components/sticky/sticky.js.map +1 -1
- package/lib/esm/components/theme-switch/theme-switch.js +0 -2
- package/lib/esm/components/theme-switch/theme-switch.js.map +1 -1
- package/lib/esm/components/toast/toast.js +1 -2
- package/lib/esm/components/toast/toast.js.map +1 -1
- package/lib/esm/helpers/dom.js +0 -2
- package/lib/esm/helpers/dom.js.map +1 -1
- package/package.json +14 -7
- package/src/components/collapse/collapse.ts +0 -3
- package/src/components/component.ts +5 -5
- package/src/components/datatable/__tests__/currency-sort.test.ts +108 -0
- package/src/components/datatable/__tests__/multi-row-headers.test.ts +121 -0
- package/src/components/datatable/__tests__/pagination-reset.test.ts +13 -5
- package/src/components/datatable/__tests__/race-conditions.test.ts +138 -78
- package/src/components/datatable/__tests__/setup.ts +9 -4
- package/src/components/datatable/datatable-sort.ts +12 -16
- package/src/components/datatable/datatable.css +4 -4
- package/src/components/datatable/datatable.ts +56 -26
- package/src/components/datatable/types.ts +3 -1
- package/src/components/drawer/drawer.ts +61 -24
- package/src/components/dropdown/dropdown.ts +3 -1
- package/src/components/scrollto/scrollto.ts +0 -3
- package/src/components/select/__tests__/ux-behaviors.test.ts +274 -8
- package/src/components/select/combobox.ts +0 -1
- package/src/components/select/dropdown.ts +0 -2
- package/src/components/select/remote.ts +1 -6
- package/src/components/select/search.ts +14 -7
- package/src/components/select/select.ts +29 -29
- package/src/components/select/tags.ts +0 -1
- package/src/components/select/templates.ts +8 -8
- package/src/components/select/utils.ts +15 -2
- package/src/components/sticky/__tests__/sticky.test.ts +205 -0
- package/src/components/sticky/sticky.ts +119 -21
- package/src/components/sticky/types.ts +3 -0
- package/src/components/theme-switch/theme-switch.ts +0 -3
- package/src/components/toast/toast.ts +3 -2
- package/src/helpers/dom.ts +0 -3
|
@@ -34,11 +34,17 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
34
34
|
reverse: false,
|
|
35
35
|
release: '',
|
|
36
36
|
activate: '',
|
|
37
|
+
releaseDelay: 0,
|
|
38
|
+
activeClass: '',
|
|
39
|
+
releaseClass: '',
|
|
37
40
|
};
|
|
38
41
|
protected override _config: KTStickyConfigInterface = this._defaultConfig;
|
|
39
42
|
protected _targetElement: HTMLElement | Document | null = null;
|
|
40
43
|
|
|
41
44
|
protected _attributeRoot: string;
|
|
45
|
+
protected _isScrolling: boolean;
|
|
46
|
+
protected _timeoutState: ReturnType<typeof setTimeout> | null = null;
|
|
47
|
+
protected _scrollTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
42
48
|
protected _eventTriggerState: boolean;
|
|
43
49
|
protected _lastScrollTop: number;
|
|
44
50
|
protected _releaseElement: HTMLElement;
|
|
@@ -69,6 +75,9 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
69
75
|
);
|
|
70
76
|
this._wrapperElement = this._element.closest('[data-kt-sticky-wrapper]');
|
|
71
77
|
this._attributeRoot = `data-kt-sticky-${this._getOption('name')}`;
|
|
78
|
+
this._isScrolling = false;
|
|
79
|
+
this._timeoutState = null;
|
|
80
|
+
this._scrollTimeout = null;
|
|
72
81
|
this._eventTriggerState = true;
|
|
73
82
|
this._lastScrollTop = 0;
|
|
74
83
|
|
|
@@ -110,26 +119,57 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
110
119
|
|
|
111
120
|
// Store scroll handler reference for cleanup
|
|
112
121
|
this._scrollHandler = () => {
|
|
113
|
-
|
|
122
|
+
|
|
123
|
+
this._isScrolling = true;
|
|
124
|
+
|
|
125
|
+
if(this._isActive() === true){
|
|
126
|
+
|
|
127
|
+
this._debounceScroll(() => {
|
|
128
|
+
|
|
129
|
+
this._isScrolling = false;
|
|
130
|
+
this._process();
|
|
131
|
+
|
|
132
|
+
}, 200);
|
|
133
|
+
|
|
134
|
+
}else{
|
|
135
|
+
|
|
136
|
+
this._isScrolling = false;
|
|
137
|
+
this._process();
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
114
141
|
};
|
|
115
142
|
|
|
116
143
|
if (this._targetElement) {
|
|
117
144
|
if (this._targetElement === document) {
|
|
118
|
-
window.addEventListener('scroll', this._scrollHandler);
|
|
145
|
+
window.addEventListener('scroll', this._scrollHandler, { passive: true });
|
|
119
146
|
} else {
|
|
120
147
|
(this._targetElement as HTMLElement).addEventListener(
|
|
121
148
|
'scroll',
|
|
122
149
|
this._scrollHandler,
|
|
150
|
+
{ passive: true }
|
|
123
151
|
);
|
|
124
152
|
}
|
|
125
153
|
}
|
|
126
154
|
}
|
|
127
155
|
|
|
156
|
+
protected _debounceScroll(callback: () => void, delay: number = 200): void {
|
|
157
|
+
|
|
158
|
+
if (this._scrollTimeout) {
|
|
159
|
+
clearTimeout(this._scrollTimeout);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
this._scrollTimeout = setTimeout(() => {
|
|
163
|
+
callback();
|
|
164
|
+
}, delay);
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
128
168
|
protected _process(): void {
|
|
129
169
|
const reverse = this._getOption('reverse');
|
|
130
170
|
const offset = this._getOffset();
|
|
131
171
|
|
|
132
|
-
if (offset
|
|
172
|
+
if (offset <= 0) {
|
|
133
173
|
this._disable();
|
|
134
174
|
return;
|
|
135
175
|
}
|
|
@@ -242,7 +282,6 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
242
282
|
const end = this._getOption('end') as string;
|
|
243
283
|
const height = this._calculateHeight();
|
|
244
284
|
const zindex = this._getOption('zindex') as string;
|
|
245
|
-
const classList = this._getOption('class') as string;
|
|
246
285
|
|
|
247
286
|
if (height + parseInt(top) > KTDom.getViewPort().height) {
|
|
248
287
|
return false;
|
|
@@ -310,16 +349,27 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
310
349
|
this._element.style.position = 'fixed';
|
|
311
350
|
}
|
|
312
351
|
|
|
313
|
-
|
|
314
|
-
|
|
352
|
+
const activeClassList = this._getOption('activeClass') as string;
|
|
353
|
+
if (activeClassList) {
|
|
354
|
+
KTDom.addClass(this._element, activeClassList);
|
|
355
|
+
}else{
|
|
356
|
+
const classList = this._getOption('class') as string;
|
|
357
|
+
if (classList) {
|
|
358
|
+
KTDom.addClass(this._element, classList);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const releaseClassList = this._getOption('releaseClass') as string;
|
|
363
|
+
if (releaseClassList) {
|
|
364
|
+
KTDom.removeClass(this._element, releaseClassList);
|
|
315
365
|
}
|
|
316
366
|
|
|
317
367
|
if (this._wrapperElement) {
|
|
318
368
|
this._wrapperElement.style.height = `${height}px`;
|
|
319
369
|
}
|
|
320
370
|
|
|
321
|
-
this._element.classList.add('active');
|
|
322
371
|
this._element.classList.remove('release');
|
|
372
|
+
this._element.classList.add('active');
|
|
323
373
|
|
|
324
374
|
return true;
|
|
325
375
|
}
|
|
@@ -327,6 +377,53 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
327
377
|
protected _disable(): void {
|
|
328
378
|
if (!this._element) return;
|
|
329
379
|
|
|
380
|
+
if (this._wrapperElement) {
|
|
381
|
+
this._wrapperElement.style.height = '';
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
this._element.classList.remove('active');
|
|
385
|
+
this._element.classList.add('release');
|
|
386
|
+
|
|
387
|
+
const activeClassList = this._getOption('activeClass') as string;
|
|
388
|
+
if (activeClassList) {
|
|
389
|
+
KTDom.removeClass(this._element, activeClassList);
|
|
390
|
+
}else{
|
|
391
|
+
const classList = this._getOption('class') as string;
|
|
392
|
+
if (classList) {
|
|
393
|
+
KTDom.removeClass(this._element, classList);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const releaseClassList = this._getOption('releaseClass') as string;
|
|
398
|
+
if (releaseClassList) {
|
|
399
|
+
KTDom.addClass(this._element, releaseClassList);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if(this._eventTriggerState === false){
|
|
403
|
+
const releaseDelay = this._getOption('releaseDelay') as number;
|
|
404
|
+
if(releaseDelay && this._timeoutState === null){
|
|
405
|
+
this._timeoutState = setTimeout(() => {
|
|
406
|
+
|
|
407
|
+
if (!this._element){
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (this._isRelease() === true) {
|
|
412
|
+
this._resetStyles();
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
this._timeoutState = null;
|
|
416
|
+
|
|
417
|
+
}, releaseDelay);
|
|
418
|
+
}else{
|
|
419
|
+
this._resetStyles();
|
|
420
|
+
}
|
|
421
|
+
}else{
|
|
422
|
+
this._timeoutState = null;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
protected _resetStyles = function () {
|
|
330
427
|
this._element.style.top = '';
|
|
331
428
|
this._element.style.bottom = '';
|
|
332
429
|
this._element.style.insetInlineStart = '';
|
|
@@ -338,21 +435,11 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
338
435
|
this._element.style.right = '';
|
|
339
436
|
this._element.style.zIndex = '';
|
|
340
437
|
this._element.style.position = '';
|
|
341
|
-
|
|
342
|
-
const classList = this._getOption('class') as string;
|
|
343
|
-
|
|
344
|
-
if (this._wrapperElement) {
|
|
345
|
-
this._wrapperElement.style.height = '';
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
if (classList) {
|
|
349
|
-
KTDom.removeClass(this._element, classList);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
this._element.classList.remove('active');
|
|
353
|
-
}
|
|
438
|
+
};
|
|
354
439
|
|
|
355
440
|
protected _update(): void {
|
|
441
|
+
this._timeoutState = null;
|
|
442
|
+
this._eventTriggerState = true;
|
|
356
443
|
if (this._isActive()) {
|
|
357
444
|
this._disable();
|
|
358
445
|
this._enable();
|
|
@@ -385,6 +472,10 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
385
472
|
return this._element.classList.contains('active');
|
|
386
473
|
}
|
|
387
474
|
|
|
475
|
+
protected _isRelease(): boolean {
|
|
476
|
+
return this._element.classList.contains('release');
|
|
477
|
+
}
|
|
478
|
+
|
|
388
479
|
public update(): void {
|
|
389
480
|
this._update();
|
|
390
481
|
}
|
|
@@ -393,6 +484,10 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
393
484
|
return this._isActive();
|
|
394
485
|
}
|
|
395
486
|
|
|
487
|
+
public isRelease(): boolean {
|
|
488
|
+
return this._isRelease();
|
|
489
|
+
}
|
|
490
|
+
|
|
396
491
|
public override dispose(): void {
|
|
397
492
|
// Remove resize event listener
|
|
398
493
|
if (this._resizeHandler) {
|
|
@@ -415,7 +510,10 @@ export class KTSticky extends KTComponent implements KTStickyInterface {
|
|
|
415
510
|
|
|
416
511
|
// Clean up state
|
|
417
512
|
this._disable();
|
|
418
|
-
if (
|
|
513
|
+
if (
|
|
514
|
+
this._attributeRoot &&
|
|
515
|
+
document.body.hasAttribute(this._attributeRoot)
|
|
516
|
+
) {
|
|
419
517
|
document.body.removeAttribute(this._attributeRoot);
|
|
420
518
|
}
|
|
421
519
|
|
|
@@ -415,8 +415,9 @@ export class KTToast extends KTComponent implements KTToastInterface {
|
|
|
415
415
|
if (options.beep) {
|
|
416
416
|
try {
|
|
417
417
|
// Use Web Audio API for a short beep
|
|
418
|
-
const ctx = new (
|
|
419
|
-
(window as any).webkitAudioContext
|
|
418
|
+
const ctx = new (
|
|
419
|
+
window.AudioContext || (window as any).webkitAudioContext
|
|
420
|
+
)();
|
|
420
421
|
const o = ctx.createOscillator();
|
|
421
422
|
const g = ctx.createGain();
|
|
422
423
|
o.type = 'sine';
|
package/src/helpers/dom.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright 2025 by Keenthemes Inc
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/* eslint-disable max-len */
|
|
7
6
|
import KTUtils from './utils';
|
|
8
7
|
import { KTOffsetType, KTOptionType, KTViewPortType } from '../types';
|
|
9
8
|
|
|
@@ -130,7 +129,6 @@ const KTDom = {
|
|
|
130
129
|
for (
|
|
131
130
|
element && element !== document.documentElement;
|
|
132
131
|
(element = element.parentElement as HTMLElement);
|
|
133
|
-
|
|
134
132
|
) {
|
|
135
133
|
if (selector) {
|
|
136
134
|
if (element.matches(selector)) {
|
|
@@ -183,7 +181,6 @@ const KTDom = {
|
|
|
183
181
|
return false;
|
|
184
182
|
}
|
|
185
183
|
|
|
186
|
-
// eslint-disable-next-line max-len
|
|
187
184
|
return (
|
|
188
185
|
getComputedStyle(element).getPropertyValue('visibility') === 'visible'
|
|
189
186
|
);
|